public XsocksApplicationContext(XsocksController controller)
        {
            Application.ApplicationExit += OnApplicationExit;

            BuildMenu();

            _controller = controller;
            controller.EnableStatusChanged       += ControllerEnableStatusChanged;
            controller.ConfigChanged             += ControllerConfigChanged;
            controller.PacFileReadyToOpen        += ControllerFileReadyToOpen;
            controller.UserRuleFileReadyToOpen   += ControllerFileReadyToOpen;
            controller.ShareOverLanStatusChanged += ControllerShareOverLanStatusChanged;
            controller.EnableGlobalChanged       += ControllerEnableGlobalChanged;
            controller.Errored += ControllerErrored;
            controller.UpdatePacFromGfwListCompleted += ControllerUpdatePACFromGFWListCompleted;
            controller.UpdatePacFromGfwListError     += ControllerUpdatePACFromGFWListError;

            _trayIcon = new NotifyIcon
            {
                Visible = true
            };
            _trayIcon.MouseDoubleClick += TrayIconDoubleClick;
            _trayIcon.ContextMenu       = _trayIconContextMenu;
            UpdateTrayIcon();

            LoadCurrentConfiguration();

            if (controller.GetConfiguration().IsDefault)
            {
                _isFirstRun = true;
                ShowConfigForm();
            }
        }
Exemple #2
0
        public MainForm(XsocksController controller)
        {
            InitializeComponent();


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

            UpdateTexts();
            this.Icon = Icon.FromHandle(Resources.icon128.GetHicon());

            _controller = controller;
            controller.ConfigChanged += controller_ConfigChanged;

            LoadCurrentConfiguration();
        }
Exemple #3
0
        private static void Main()
        {
            Utils.ReleaseMemory();
            using (Mutex mutex = new Mutex(false, "Global\\" + "71904632-A427-497F-AB91-241CD477EC1F"))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (!mutex.WaitOne(0, false))
                {
                    MessageBox.Show("Xsocks is already running.\nFind Xsocks icon in notify tray.",
                                    "Xsocks", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                Directory.SetCurrentDirectory(Application.StartupPath);
#if !DEBUG
                Logging.OpenLogFile();
#endif
                XsocksController controller = new XsocksController();
                controller.Start();
                Application.Run(new XsocksApplicationContext(controller));
            }
        }