Exemple #1
0
        static void Main()
        {
            Util.Utils.ReleaseMemory();
            using (Mutex mutex = new Mutex(false, "Global\\ShadowsocksR_" + Application.StartupPath.GetHashCode()))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (!mutex.WaitOne(0, false))
                {
                    MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.") + "\n" +
                        I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."),
                        I18N.GetString("ShadowsocksR is already running."));
                    return;
                }
                Directory.SetCurrentDirectory(Application.StartupPath);
            //#if !DEBUG
                Logging.OpenLogFile();
            //#endif
                ShadowsocksController controller = new ShadowsocksController();

                MenuViewController viewController = new MenuViewController(controller);

                controller.Start();

                Application.Run();
            }
        }
        static void Main()
        {
            Util.Utils.ReleaseMemory();
            using (Mutex mutex = new Mutex(false, "Global\\" + "71981632-A427-497F-AB91-241CD227EC1F"))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (!mutex.WaitOne(0, false))
                {
                    Process[] oldProcesses = Process.GetProcessesByName("Shadowsocks");
                    if (oldProcesses.Length > 0)
                    {
                        Process oldProcess = oldProcesses[0];
                    }
                    MessageBox.Show("Shadowsocks is already running.\n\nFind Shadowsocks icon in your notify tray.");
                    return;
                }
                Directory.SetCurrentDirectory(Application.StartupPath);
#if !DEBUG
                Logging.OpenLogFile();
#endif
                ShadowsocksController controller = new ShadowsocksController();

                MenuViewController viewController = new MenuViewController(controller);

                controller.Start();

                Application.Run();
            }
        }
 public static MenuViewController one()
 {
     if (_one == null)
     {
         _one = new MenuViewController();
     }
     return(_one);
 }
 private void LoadCurrentConfiguration()
 {
     config = controller.GetCurrentConfiguration();
     LoadConfiguration(config);
     _lastSelectedIndex = config.index;
     if (0 <= _lastSelectedIndex && _lastSelectedIndex < ServersListBox.Items.Count)
     {
         ServersListBox.SelectedIndex = _lastSelectedIndex;
     }
     ModeSelectButton.Text = I18N.GetString(config.global ?  "Smart Mode" : "Global Mode");
     EnableButton.Text     = I18N.GetString((config.enabled ?  "Disable" : "Enable") + " System Proxy");
     StateLabel.Text       = I18N.GetString(config.enabled ? "Enable" :  "Disable") + " / " + I18N.GetString(config.global ?  "Global Mode" : "Smart Mode");
     TrafficLabel.Text     = MenuViewController.one().LeftTraffic;
     LoadSelectedServer();
 }
        static void Main()
        {
            // Check OS since we are using dual-mode socket
            if (!Utils.IsWinVistaOrHigher())
            {
                MessageBox.Show(I18N.GetString("Unsupported operating system, use Windows Vista at least."),
                "Shadowsocks Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Utils.ReleaseMemory(true);
            using (Mutex mutex = new Mutex(false, "Global\\Shadowsocks_" + Application.StartupPath.GetHashCode()))
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (!mutex.WaitOne(0, false))
                {
                    Process[] oldProcesses = Process.GetProcessesByName("Shadowsocks");
                    if (oldProcesses.Length > 0)
                    {
                        Process oldProcess = oldProcesses[0];
                    }
                    MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.") + "\n" +
                        I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."),
                        I18N.GetString("Shadowsocks is already running."));
                    return;
                }
                Directory.SetCurrentDirectory(Application.StartupPath);
#if DEBUG
                Logging.OpenLogFile();

                // truncate privoxy log file while debugging
                string privoxyLogFilename = Utils.GetTempPath("privoxy.log");
                if (File.Exists(privoxyLogFilename))
                    using (new FileStream(privoxyLogFilename, FileMode.Truncate)) { }
#else
                Logging.OpenLogFile();
#endif
                ShadowsocksController controller = new ShadowsocksController();
                MenuViewController viewController = new MenuViewController(controller);
                controller.Start();
                Application.Run();
            }
        }
        public ConfigForm(ShadowsocksController controller, MenuViewController menu)
        {
            ComputerInfo info = new ComputerInfo();

            MessageBox.Show("Availible Physical Memory" + Convert.ToDouble(info.AvailablePhysicalMemory)/(1024.0*1024.0*1024.0) + "GB");
            this.Font = System.Drawing.SystemFonts.MessageBoxFont;
            InitializeComponent();

            // a dirty hack
            this.ServersListBox.Dock = System.Windows.Forms.DockStyle.Fill;
            this.PerformLayout();

            UpdateTexts();
            this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon());
            this.menu = menu;
            this.controller = controller;
            controller.ConfigChanged += controller_ConfigChanged;

            LoadCurrentConfiguration();
        }
        static void Main()
        {
            Utils.ReleaseMemory(true);
            using (Mutex mutex = new Mutex(false, "Global\\Shadowsocks_" + Application.StartupPath.GetHashCode()))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (!mutex.WaitOne(0, false))
                {
                    Process[] oldProcesses = Process.GetProcessesByName("Shadowsocks");
                    if (oldProcesses.Length > 0)
                    {
                        Process oldProcess = oldProcesses[0];
                    }
                    MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.") + "\n" +
                        I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."),
                        I18N.GetString("Shadowsocks is already running."));
                    return;
                }
                Directory.SetCurrentDirectory(Application.StartupPath);
#if DEBUG
                Logging.OpenLogFile();

                // truncate privoxy log file while debugging
                string privoxyLogFilename = Utils.GetTempPath("privoxy.log");
                if (File.Exists(privoxyLogFilename))
                    using (new FileStream(privoxyLogFilename, FileMode.Truncate)) { }
#else
                Logging.OpenLogFile();
#endif
                ShadowsocksController controller = new ShadowsocksController();
                MenuViewController viewController = new MenuViewController(controller);
                controller.Start();
                Application.Run();
            }
        }
        public static MenuViewController StaticMenuView = null;//为毛MenuView不设计为单例模式。。。怨念。。。

        private void _SetStaticMenuView()
        {
            StaticMenuView = this;
        }
        static void Main()
        {
            // Check OS since we are using dual-mode socket
            if (!Utils.IsWinVistaOrHigher())
            {
                MessageBox.Show(I18N.GetString("Unsupported operating system, use Windows Vista at least."),
                "Shadowsocks Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check .NET Framework version
            if (!Utils.IsSupportedRuntimeVersion())
            {
                MessageBox.Show(I18N.GetString("Unsupported .NET Framework, please update to 4.6.2 or later."),
                "Shadowsocks Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Process.Start(
                    "http://dotnetsocial.cloudapp.net/GetDotnet?tfm=.NETFramework,Version=v4.6.2");
                return;
            }

            Utils.ReleaseMemory(true);
            using (Mutex mutex = new Mutex(false, $"Global\\Shadowsocks_{Application.StartupPath.GetHashCode()}"))
            {
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                // handle UI exceptions
                Application.ThreadException += Application_ThreadException;
                // handle non-UI exceptions
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                Application.ApplicationExit += Application_ApplicationExit;
                SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (!mutex.WaitOne(0, false))
                {
                    Process[] oldProcesses = Process.GetProcessesByName("Shadowsocks");
                    if (oldProcesses.Length > 0)
                    {
                        Process oldProcess = oldProcesses[0];
                    }
                    MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.")
                        + Environment.NewLine
                        + I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."),
                        I18N.GetString("Shadowsocks is already running."));
                    return;
                }
                Directory.SetCurrentDirectory(Application.StartupPath);
            #if DEBUG
                Logging.OpenLogFile();

                // truncate privoxy log file while debugging
                string privoxyLogFilename = Utils.GetTempPath("privoxy.log");
                if (File.Exists(privoxyLogFilename))
                    using (new FileStream(privoxyLogFilename, FileMode.Truncate)) { }
            #else
                Logging.OpenLogFile();
            #endif
                _controller = new ShadowsocksController();
                _viewController = new MenuViewController(_controller);
                HotKeys.Init();
                _controller.Start();
                Application.Run();
            }
        }
Exemple #10
0
        private Boolean validateAndLogin()
        {
            Boolean autologin   = false;
            Boolean input_error = judgeInputErrorAsync();

            if (input_error)
            {
                if (_loginErrorTimes < MAXLOGININPUTTIMES)
                {
                    linkLabel3.Text         = "密码或账号错误,您还有" + (MAXLOGININPUTTIMES - (_loginErrorTimes)) + "次机会";
                    linkLabel3.Visible      = true;
                    linkLabel3.LinkBehavior = LinkBehavior.NeverUnderline;
                    _loginErrorTimes++;
                }
                else
                {
                    linkLabel3.Text = "您输入错了" + MAXLOGININPUTTIMES + "次,请找回密码";
                    Console.WriteLine(linkLabel3.Width);
                    linkLabel3.Visible     = true;
                    linkLabel3.LinkVisited = true;
                    Console.WriteLine(linkLabel3.Text);
                    Console.WriteLine(linkLabel3.Text.IndexOf("请"));
                    int infolen = linkLabel3.Text.IndexOf("码") - linkLabel3.Text.IndexOf("请");
                    linkLabel3.LinkArea = new LinkArea(linkLabel3.Text.IndexOf("请") + 1, infolen);
                    button1.Enabled     = false;
                }
            }
            else
            {
                if (checkBox1.Checked || checkBox2.Checked)
                {
                    //记住密码,checkBox1 checked,将账号密码保存到本地
                    //自动登陆,checkBox2 checked,自动登陆标记为至true
                    string logininfo = "";
                    if (checkBox1.Checked)
                    {
                        logininfo += "true";
                    }
                    else
                    {
                        logininfo += "false";
                    }
                    if (checkBox2.Checked)
                    {
                        logininfo += "|true";
                    }
                    else
                    {
                        logininfo += "|false";
                    }
                    if (checkBox1.Checked)
                    {
                        logininfo += "|" + skinTextBox1.SkinTxt.Text + "|" + skinTextBox2.SkinTxt.Text;
                    }
                    TouchUserLoginFile(logininfo);
                }
                ShadowsocksController controller = new ShadowsocksController();

                MenuViewController viewController = new MenuViewController(controller);

                controller.Start();

                //this.Hide();

                //FunctionForm funcForm = new FunctionForm();
                //funcForm.Show();
                autologin = true;
            }

            return(autologin);
        }
 public void initialize(MenuViewController menu)
 {
     configForm = new ConfigForm(controller, menu);
     configForm.Show();
     configForm.Hide();
 }
Exemple #12
-1
        static void Main()
        {
            Util.Utils.ReleaseMemory();
            using (Mutex mutex = new Mutex(false, "Global\\" + "71981632-A427-497F-AB91-241CD227EC1F"))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (!mutex.WaitOne(0, false))
                {
                    Process[] oldProcesses = Process.GetProcessesByName("Shadowsocks");
                    if (oldProcesses.Length > 0)
                    {
                        Process oldProcess = oldProcesses[0];
                    }
                    MessageBox.Show("已经存在运行的I-WALL,请检查系统托盘。");
                    return;
                }
                Directory.SetCurrentDirectory(Application.StartupPath);
            #if !DEBUG
                Logging.OpenLogFile();
            #endif
                ShadowsocksController controller = new ShadowsocksController();

                MenuViewController viewController = new MenuViewController(controller);

                controller.Start();
               /* if (System.IO.File.Exists(@"C:\test.txt"))
                          System.IO.File.Delete(@"C:\test.txt");*/
                Application.Run();
            }
        }