Example #1
0
        public MenuViewController(V2RayShellController controller)
        {
            this.controller = controller;

            LoadMenu();

            controller.EnableStatusChanged         += controller_EnableStatusChanged;
            controller.ConfigChanged               += controller_ConfigChanged;
            controller.PACFileReadyToOpen          += controller_FileReadyToOpen;
            controller.UserRuleFileReadyToOpen     += controller_FileReadyToOpen;
            controller.ShareOverLANStatusChanged   += controller_ShareOverLANStatusChanged;
            controller.VerboseLoggingStatusChanged += controller_VerboseLoggingStatusChanged;
            controller.EnableGlobalChanged         += controller_EnableGlobalChanged;
            controller.Errored += controller_Errored;
            controller.UpdatePACFromGFWListCompleted += controller_UpdatePACFromGFWListCompleted;
            controller.UpdatePACFromGFWListError     += controller_UpdatePACFromGFWListError;

            _notifyIcon = new NotifyIcon();
            UpdateTrayIcon();
            _notifyIcon.Visible            = true;
            _notifyIcon.ContextMenu        = contextMenu1;
            _notifyIcon.BalloonTipClicked += notifyIcon1_BalloonTipClicked;
            _notifyIcon.MouseClick        += notifyIcon1_Click;
            _notifyIcon.MouseDoubleClick  += notifyIcon1_DoubleClick;

            updateChecker = new UpdateChecker();

            LoadCurrentConfiguration();

            Configuration config = controller.GetConfigurationCopy();

            if (config.isDefault)
            {
                _isFirstRun = true;
                ShowConfigForm();
            }
            else if (config.autoCheckUpdate)
            {
                CheckUpdate(config);
            }
        }