Beispiel #1
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     ConfigHandler.LoadConfig(ref config);
     v2rayHandler = new V2rayHandler();
     v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;
     InitSubItemAutoUpdate();
 }
Beispiel #2
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     ConfigHandler.LoadConfig(ref config);
     v2rayHandler = new V2rayHandler();
     v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;
     statistics = new StatisticsHandler(config, UpdateHandler);
 }
Beispiel #3
0
        public static void Init(V2rayHandler v2rayHandler)
        {
            _hotKeyManager             = new HotKeyManager();
            _hotKeyManager.KeyPressed += HotKeyManagerPressed;

            HotkeyCallbacks.InitInstance(v2rayHandler);
        }
Beispiel #4
0
        public static void InitInstance(V2rayHandler v2rayHandler)
        {
            if (Instance != null)
            {
                return;
            }

            Instance = new HotkeyCallbacks(v2rayHandler);
        }
Beispiel #5
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     //隐藏窗体不应在构造时期
     this.ShowInTaskbar = false;
     this.WindowState   = FormWindowState.Minimized;
     HideForm();
     ConfigHandler.LoadConfig(ref config);
     v2rayHandler = new V2rayHandler();
     v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;
 }
Beispiel #6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ConfigHandler.LoadConfig(ref config);
            ConfigHandler.InitBuiltinRouting(ref config);
            v2rayHandler = new V2rayHandler();
            v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;

            if (config.enableStatistics)
            {
                statistics = new StatisticsHandler(config, UpdateStatisticsHandler);
            }
        }
Beispiel #7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ConfigHandler.LoadConfig(ref config);
            v2rayHandler = new V2rayHandler();
            v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;

            this.tsbSubUpdate_Click(sender, e);

            if (!v2rayHandler.CheckHasV2rayCore())
            {
                AppendText(true, UIRes.I18N("NotFoundV2rayCore"));
                tsbCheckUpdateCore_Click(sender, e);
            }

            //FIXME 修改时间失败
            //Console.WriteLine(UpdateLocalTime.SetDate(NetTime.GetBeijingTime()));
        }
Beispiel #8
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (ConfigHandler.LoadConfig(ref config) != 0)
            {
                UI.ShowWarning($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用");
                Environment.Exit(0);
                return;
            }
            ConfigHandler.InitBuiltinRouting(ref config);
            MainFormHandler.Instance.BackupGuiNConfig(config, true);
            v2rayHandler = new V2rayHandler();
            v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;

            if (config.enableStatistics)
            {
                statistics = new StatisticsHandler(config, UpdateStatisticsHandler);
            }
        }
Beispiel #9
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            splitContainer1.Panel2Collapsed = true;

            ConfigHandler.LoadConfig(ref config);
            v2rayHandler = new V2rayHandler();
            v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;

            if (!config.formMainSize.IsEmpty)
            {
                this.Left   = config.formMainSize.X;
                this.Top    = config.formMainSize.Y;
                this.Width  = config.formMainSize.Width;
                this.Height = config.formMainSize.Height;
            }
            this.WindowState = config.windowState;

            if (config.enableStatistics)
            {
                statistics = new StatisticsHandler(config, UpdateStatisticsHandler);
            }
        }
Beispiel #10
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ConfigHandler.LoadConfig(ref config);
            v2rayHandler = new V2rayHandler();
            v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;

            pacListHandle = new PACListHandle();
            pacListHandle.UpdateCompleted += (sender2, args) =>
            {
                if (args.Success)
                {
                    v2rayHandler_ProcessEvent(false, "PAC更新成功!");
                }
                else
                {
                    v2rayHandler_ProcessEvent(false, "PAC更新失败!");
                }
            };
            pacListHandle.Error += (sender2, args) =>
            {
                v2rayHandler_ProcessEvent(true, args.GetException().Message);
            };
        }
Beispiel #11
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     if (config == null)
     {
         ConfigHandler.LoadConfig(ref config);
     }
     v2rayHandler = new V2rayHandler();
     v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;
     HttpProxyHandler.ActionServer.Start((tobe) => {
         if (tobe.listenerType == -1)
         {
             if (previousListenerType != null)
             {
                 config.listenerType = (int)previousListenerType;
             }
         }
         else
         {
             previousListenerType = config.listenerType;
             config.listenerType  = tobe.listenerType;
         }
         ChangePACButtonStatus(config.listenerType);
     });
 }
Beispiel #12
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ConfigHandler.LoadConfig(ref config);
            v2rayHandler = new V2rayHandler();
            v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent;
            statistics = new StatisticsHandler(config,
                                               (ulong totalUp, ulong totalDown, ulong up, ulong down, List <Mode.ServerStatistics> statistics) =>
            {
                double up_amount = 0.0, down_amount;
                string up_unit   = "", down_unit;

                up   /= (ulong)(config.statisticsFreshRate / 1000f);
                down /= (ulong)(config.statisticsFreshRate / 1000f);

                Utils.ToHumanReadable(up, out up_amount, out up_unit);
                Utils.ToHumanReadable(down, out down_amount, out down_unit);
                up_unit   += "/s";
                down_unit += "/s";

                toolSslBlank4.Text = string.Format(
                    "{4}: {0:f2} {1} | {5}: {2:f2} {3}",
                    up_amount,
                    up_unit,
                    down_amount,
                    down_unit,
                    UIRes.I18N("uploadSpeed"),
                    UIRes.I18N("downloadSpeed")
                    );


                List <string[]> datas = new List <string[]>();
                for (int i = 0; i < config.vmess.Count; i++)
                {
                    string totalUp_ = string.Empty,
                    totalDown_      = string.Empty,
                    todayUp_        = string.Empty,
                    todayDown_      = string.Empty;
                    var index       = statistics.FindIndex(item_ => (config.vmess[i].address == item_.address && config.vmess[i].port == item_.port));
                    if (index != -1)
                    {
                        Func <ulong, string> human_fy = (amount) =>
                        {
                            double result;
                            string unit;
                            Utils.ToHumanReadable(amount, out result, out unit);
                            return($"{string.Format("{0:f2}", result)}{unit}");
                        };
                        totalUp_   = human_fy(statistics[index].totalUp);
                        totalDown_ = human_fy(statistics[index].totalDown);
                        todayUp_   = human_fy(statistics[index].todayUp);
                        todayDown_ = human_fy(statistics[index].todayDown);
                    }

                    datas.Add(new string[] { totalUp_, totalDown_, todayUp_, todayDown_ });
                }

                lvServers.Invoke((MethodInvoker) delegate
                {
                    lvServers.SuspendLayout();
                    for (int i = 0; i < datas.Count; i++)
                    {
                        lvServers.Items[i].SubItems[7].Text  = datas[i][0];
                        lvServers.Items[i].SubItems[8].Text  = datas[i][1];
                        lvServers.Items[i].SubItems[9].Text  = datas[i][2];
                        lvServers.Items[i].SubItems[10].Text = datas[i][3];
                    }
                    lvServers.ResumeLayout();
                });
            });
        }
Beispiel #13
0
 private HotkeyCallbacks(V2rayHandler v2rayHandler)
 {
     _v2rayHandler = v2rayHandler;
 }