示例#1
0
        private App()
        {
            icon = new NotifyIcon()
            {
                Text        = "Sentinel",
                Icon        = sentinel_icon,
                Visible     = true,
                ContextMenu = new ContextMenu(new MenuItem[]
                {
                    new MenuItem("Sentinel v1.0.0")
                    {
                        Enabled = false
                    },
                    new MenuItem("Settings", (sender, ev) =>
                    {
                        new AboutWindow(sentinel.settings).Show();
                    }),
                    new MenuItem("Quit", (a, b) => Shutdown())
                })
            };
            icon.Click += (a, b) => new AboutWindow(sentinel.settings).Show();

            if (!StartMenuHelpers.IsInstalled())
            {
                // We're not yet installed, show the wizard first.
                var wizard = new SetupWizard();
                wizard.Closed += (a, b) => sentinel = new Sentinel();
                wizard.Show();
            }
            else
            {
                // We're already installed, construct immediately.
                sentinel = new Sentinel();
            }
        }
示例#2
0
        private App()
        {
            icon = new NotifyIcon()
            {
                Text        = "Sentinel",
                Icon        = sentinel_icon,
                Visible     = true,
                ContextMenu = new ContextMenu(new MenuItem[]
                {
                    new MenuItem("Sentinel v1.0.1")
                    {
                        Enabled = false
                    },
                    new MenuItem("Settings", (sender, ev) =>
                    {
                        new AboutWindow(sentinel.settings).Show();
                    }),
                    new MenuItem("Quit", (a, b) => Shutdown())
                })
            };
            icon.Click += (a, b) =>
            {
                // Only open about if left mouse is used (otherwise right clicking opens both context menu and about).
                if (b is MouseEventArgs args && args.Button == MouseButtons.Left)
                {
                    new AboutWindow(sentinel.settings).Show();
                }
            };

            if (!StartMenuHelpers.IsInstalled())
            {
                // We're not yet installed, show the wizard first.
                var wizard = new SetupWizard();
                wizard.Closed += (a, b) => sentinel = new Sentinel();
                wizard.Show();
            }
            else
            {
                // We're already installed, construct immediately.
                sentinel = new Sentinel();
            }
        }
示例#3
0
        private void nextButton_Click(object sender, RoutedEventArgs e)
        {
            if (state == SetupWizardState.StartMenu)
            {
                // Install start menu and COM server.
                StartMenuHelpers.Install(App.AppId, typeof(ActivationHandler).GUID);
                COMServerHelpers.Register(typeof(ActivationHandler).GUID);

                state = SetupWizardState.Startup;
                Render();
            }
            else if (state == SetupWizardState.Startup)
            {
                var regKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                regKey.SetValue(App.AppId, Process.GetCurrentProcess().MainModule.FileName);

                state = SetupWizardState.Done;
                Render();
            }
            else if (state == SetupWizardState.Done)
            {
                Close();
            }
        }