예제 #1
0
        public ServerMenuItems(
            ToolStripMenuItem stopSelected,
            ToolStripMenuItem restartSelected,
            ToolStripMenuItem clearSysProxy,
            ToolStripMenuItem refreshSummary,
            ToolStripMenuItem selectAllAutorun,
            ToolStripMenuItem selectAll,
            ToolStripMenuItem selectNone,
            ToolStripMenuItem selectInvert,
            ToolStripMenuItem speedTestOnSelected,
            ToolStripMenuItem deleteSelected,
            ToolStripMenuItem copyAsV2rayLinks,
            ToolStripMenuItem copyAsVmessLinks,
            ToolStripMenuItem copyAsSubscriptions,
            ToolStripMenuItem deleteAllItems)
        {
            setting = Service.Setting.Instance;
            cache   = Service.Cache.Instance;

            deleteAllItems.Click += (s, a) =>
            {
                if (Lib.UI.Confirm(I18N("ConfirmDeleteAllServers")))
                {
                    setting.DeleteAllServer();
                }
            };

            copyAsSubscriptions.Click += (s, a) =>
            {
                if (!CheckSelectedServerCount())
                {
                    return;
                }
                CopySelectedAsSubscription();
            };

            copyAsV2rayLinks.Click += (s, a) =>
            {
                if (!CheckSelectedServerCount())
                {
                    return;
                }

                CopySelectedAsV2RayLinks();
            };

            copyAsVmessLinks.Click += (s, a) =>
            {
                if (!CheckSelectedServerCount())
                {
                    return;
                }

                CopySelectedAsVmessLinks();
            };

            deleteSelected.Click += (s, a) =>
            {
                if (!CheckSelectedServerCount())
                {
                    return;
                }

                if (!Lib.UI.Confirm(I18N("ConfirmDeleteSelectedServers")))
                {
                    return;
                }
                setting.DeleteSelectedServers();
            };

            speedTestOnSelected.Click += (s, a) =>
            {
                if (!CheckSelectedServerCount())
                {
                    return;
                }

                if (!Lib.UI.Confirm(I18N("TestWillTakeALongTime")))
                {
                    return;
                }

                if (!setting.DoSpeedTestOnSelectedServers())
                {
                    MessageBox.Show(I18N("LastTestNoFinishYet"));
                }
            };

            stopSelected.Click += (s, a) =>
            {
                if (!CheckSelectedServerCount())
                {
                    return;
                }

                if (Lib.UI.Confirm(I18N("ConfirmStopAllSelectedServers")))
                {
                    setting.StopAllSelectedThen();
                }
            };

            restartSelected.Click += (s, a) =>
            {
                if (!CheckSelectedServerCount())
                {
                    return;
                }

                if (Lib.UI.Confirm(I18N("ConfirmRestartAllSelectedServers")))
                {
                    setting.RestartAllSelected();
                }
            };

            selectAllAutorun.Click += (s, a) =>
            {
                var panel = GetFlyPanel();
                panel.SelectAutorun();
            };

            selectAll.Click += (s, a) =>
            {
                var panel = GetFlyPanel();
                panel.SelectAll();
            };

            selectNone.Click += (s, a) =>
            {
                var panel = GetFlyPanel();
                panel.SelectNone();
            };

            selectInvert.Click += (s, a) =>
            {
                var panel = GetFlyPanel();
                panel.SelectInvert();
            };


            clearSysProxy.Click += (s, a) =>
            {
                if (Lib.UI.Confirm(I18N("ConfirmClearSysProxy")))
                {
                    setting.ClearSystemProxy();
                }
            };

            refreshSummary.Click += (s, a) =>
            {
                cache.html.Clear();
                setting.UpdateAllServersSummary();
            };
        }