Exemple #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            AddAddServerToolStripMenuItems();

            #region i18N Translations

            _mainFormText.Add(UninstallServiceToolStripMenuItem.Name, new[] { "Uninstall {0}", "NF Service" });
            _mainFormText.Add(UninstallTapDriverToolStripMenuItem.Name, new[] { "Uninstall {0}", "TUN/TAP driver" });

            #endregion

            OnlyInstance.Called += OnCalled;
            // 计算 ComboBox绘制 目标宽度
            _eWidth = ServerComboBox.Width / 10;

            ModeHelper.Load();
            InitMode();
            InitServer();
            _comboBoxInitialized = true;

            // 加载翻译
            InitText();

            // 隐藏 NatTypeStatusLabel
            NatTypeStatusText();

            _configurationGroupBoxHeight = ConfigurationGroupBox.Height;
            _profileConfigurationHeight  = ConfigurationGroupBox.Controls[0].Height / 3; // 因为 AutoSize, 所以得到的是Controls的总高度
            // 加载快速配置
            InitProfile();

            // 打开软件时启动加速,产生开始按钮点击事件
            if (Global.Settings.StartWhenOpened)
            {
                ControlButton.PerformClick();
            }

            Task.Run(() =>
            {
                // 检查更新
                if (Global.Settings.CheckUpdateWhenOpened)
                {
                    CheckUpdate();
                }
            });


            Task.Run(async() =>
            {
                // 检查订阅更新
                if (Global.Settings.UpdateSubscribeatWhenOpened)
                {
                    await UpdateServersFromSubscribe();
                }
            });
        }
Exemple #2
0
 private void ReloadModesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Enabled = false;
     try
     {
         ModeHelper.Load();
         InitMode();
         NotifyTip(i18N.Translate("Modes have been reload"));
     }
     catch (Exception)
     {
         // ignored
     }
     finally
     {
         Enabled = true;
     }
 }
Exemple #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            AddAddServerToolStripMenuItems();

            OnlyInstance.Called += OnCalled;
            // 计算 ComboBox绘制 目标宽度
            _eWidth = ServerComboBox.Width / 10;

            ModeHelper.Load();
            InitMode();
            InitServer();
            _comboBoxInitialized = true;

            // 加载翻译
            InitText();

            // 隐藏 NatTypeStatusLabel
            NatTypeStatusText();

            _sizeHeight = Size.Height;
            _configurationGroupBoxHeight = ConfigurationGroupBox.Height;
            _profileConfigurationHeight  = ConfigurationGroupBox.Controls[0].Height / 3; // 因为 AutoSize, 所以得到的是Controls的总高度
            _profileGroupboxHeight       = ProfileGroupBox.Height;
            // 加载快速配置
            InitProfile();

            // 打开软件时启动加速,产生开始按钮点击事件
            if (Global.Settings.StartWhenOpened)
            {
                ControlButton.PerformClick();
            }

            // 自动检测延迟
            Task.Run(() =>
            {
                while (true)
                {
                    if (State == State.Waiting || State == State.Stopped)
                    {
                        TestServer();

                        Thread.Sleep(10000);
                    }
                    else
                    {
                        Thread.Sleep(200);
                    }
                }
            });

            Task.Run(() =>
            {
                // 检查更新
                if (Global.Settings.CheckUpdateWhenOpened)
                {
                    CheckUpdate();
                }
            });


            Task.Run(async() =>
            {
                // 检查订阅更新
                if (Global.Settings.UpdateSubscribeatWhenOpened)
                {
                    await UpdateServersFromSubscribe();
                }
            });
        }