Beispiel #1
0
        public FormMain(
            Services.PsSettings setting,
            Services.PacServer pacServer,
            Services.ServerTracker servTracker)
        {
            this.setting     = setting;
            this.pacServer   = pacServer;
            this.servTracker = servTracker;

            this.FormClosing += (s, a) =>
            {
                var confirm = true;
                if (!setting.isCleaning && !this.formVGCPluginCtrl.IsOptionsSaved())
                {
                    confirm = VgcApis.Libs.UI.Confirm(I18N.ConfirmCloseWinWithoutSave);
                }

                if (confirm)
                {
                    ReleaseUpdateTimer();
                    formVGCPluginCtrl.Cleanup();
                }
                else
                {
                    a.Cancel = true;
                }
            };

            InitializeComponent();
        }
Beispiel #2
0
        private void BindEvents(
            Services.PacServer pacServer,
            Button btnRestart,
            Button btnStop,
            Button btnDebug,
            Button btnCopy,
            Button btnClearSysProxy)
        {
            btnClearSysProxy.Click += (s, a) =>
                                      Lib.Sys.ProxySetter.ClearSysProxy();

            btnRestart.Click += (s, a) => pacServer.StartPacServer();

            btnStop.Click += (s, a) => pacServer.StopPacServer();

            btnDebug.Click +=
                (s, a) => vgcUtils.VisitUrl(
                    I18N.VisitPacDebugger, GetDebugUrl());

            btnCopy.Click += (s, a) =>
            {
                MessageBox.Show(
                    vgcUtils.CopyToClipboard(this.lbPacUrl.Text) ?
                    I18N.CopySuccess : I18N.CopyFail);
            };
        }
Beispiel #3
0
        public TabStatus(
            Services.PacServer pacServer,

            Label lbPacServerStatus,
            Label lbPacUrl,
            Button btnRestart,
            Button btnStop,
            Button btnViewInNotepad,
            Button btnDebug,
            Button btnCopy)
        {
            this.pacServer = pacServer;

            BindControls(lbPacServerStatus, lbPacUrl);
            BindEvents(
                pacServer,
                btnRestart,
                btnStop,
                btnViewInNotepad,
                btnDebug,
                btnCopy);

            OnPacServerStateChangedHandler(null, EventArgs.Empty);

            pacServer.OnPACServerStateChanged += OnPacServerStateChangedHandler;
        }
Beispiel #4
0
        public TabStatus(
            VgcApis.Models.IUtils vgcUtils,
            Services.PsSettings setting,
            Services.PacServer pacServer,

            Label lbPacServerStatus,
            Label lbPacUrl,
            Button btnRestart,
            Button btnStop,
            Button btnDebug,
            Button btnCopy,
            Button btnClearSysProxy)
        {
            this.vgcUtils  = vgcUtils;
            this.setting   = setting;
            this.pacServer = pacServer;

            BindControls(lbPacServerStatus, lbPacUrl);
            BindEvents(
                pacServer,
                btnRestart,
                btnStop,
                btnDebug,
                btnCopy,
                btnClearSysProxy);

            OnPacServerStateChangedHandler(null, EventArgs.Empty);

            pacServer.OnPACServerStateChanged += OnPacServerStateChangedHandler;
        }
Beispiel #5
0
        private void BindEvents(
            Services.PacServer pacServer,
            Button btnRestart,
            Button btnStop,
            Button btnSaveAs,
            Button btnDebug,
            Button btnCopy,
            Button btnClearSysProxy)
        {
            btnSaveAs.Click += (s, a) =>
            {
                VgcApis.Libs.UI.SaveToFile(
                    VgcApis.Models.Consts.Files.PacExt,
                    pacServer.GetCurPacFileContent());
            };

            btnClearSysProxy.Click += (s, a) =>
                                      Lib.Sys.ProxySetter.ClearSysProxy();

            btnRestart.Click += (s, a) => pacServer.StartPacServer();

            btnStop.Click += (s, a) => pacServer.StopPacServer();

            btnDebug.Click +=
                (s, a) => VgcApis.Libs.UI.VisitUrl(
                    I18N.VisitPacDebugger, GetDebugUrl());

            btnCopy.Click += (s, a) =>
            {
                MessageBox.Show(
                    VgcApis.Libs.Utils.CopyToClipboard(this.lbPacUrl.Text) ?
                    I18N.CopySuccess : I18N.CopyFail);
            };
        }
Beispiel #6
0
        public static FormMain CreateForm(
            Services.PsSettings setting,
            Services.PacServer pacServer,
            Services.ServerTracker servTracker)
        {
            FormMain r = null;

            VgcApis.Misc.UI.Invoke(() =>
            {
                r = new FormMain(setting, pacServer, servTracker);
            });
            return(r);
        }
Beispiel #7
0
        private void BindEvents(
            Services.PacServer pacServer,
            Button btnRestart,
            Button btnStop,
            Button btnViewInNotepad,
            Button btnDebug,
            Button btnCopy,
            Button btnClearSysProxy)
        {
            btnViewInNotepad.Click += (s, a) =>
            {
                try
                {
                    var content = pacServer.GetCurPacFileContent();
                    VgcApis.Libs.Sys.NotepadHelper.ShowMessage(
                        content, @"PAC.js");
                }
                catch
                {
                    VgcApis.Libs.UI.MsgBoxAsync(I18N.LaunchNotepadFail);
                }
            };

            btnClearSysProxy.Click += (s, a) =>
                                      Lib.Sys.ProxySetter.ClearSysProxy();

            btnRestart.Click += (s, a) => pacServer.StartPacServer();

            btnStop.Click += (s, a) => pacServer.StopPacServer();

            btnDebug.Click +=
                (s, a) => VgcApis.Libs.UI.VisitUrl(
                    I18N.VisitPacDebugger, GetDebugUrl());

            btnCopy.Click += (s, a) =>
            {
                MessageBox.Show(
                    VgcApis.Libs.Utils.CopyToClipboard(this.lbPacUrl.Text) ?
                    I18N.CopySuccess : I18N.CopyFail);
            };
        }
Beispiel #8
0
        public FormMain(
            VgcApis.Models.IUtils vgcUtils,
            Services.PsSettings setting,
            Services.PacServer pacServer,
            Services.ServerTracker servTracker)
        {
            this.vgcUtils    = vgcUtils;
            this.setting     = setting;
            this.pacServer   = pacServer;
            this.servTracker = servTracker;

            this.FormClosing += (s, a) =>
            {
                var confirm = true;
                if (!setting.isCleaning && !this.formVGCPluginCtrl.IsOptionsSaved())
                {
                    confirm = vgcUtils.Confirm(I18N.ConfirmCloseWinWithoutSave);
                }

                if (confirm)
                {
                    ReleaseUpdateTimer();
                    formVGCPluginCtrl.Cleanup();
                }
                else
                {
                    a.Cancel = true;
                }
            };

            InitializeComponent();

#if DEBUG
            this.Icon = Properties.Resources.icon_light;
#else
            this.Icon = Properties.Resources.icon_dark;
#endif
            this.Show();
        }