コード例 #1
0
            public ConnectStatus(MainWindow window)
            {
                this.window  = window;
                icon         = new NotifyIcon();
                icon.Visible = true;

                icon.DoubleClick += (sender, e) => {
                    window.WindowState = System.Windows.WindowState.Normal;
                    window.Activate();
                };

                var menu = new ContextMenu();

                menu.MenuItems.Add(resources["AddRules"] as string, (sender, e) => {
                    Rules.OpenEditor(false);
                });

                menu.MenuItems.Add(resources["Exit"] as string, (sender, e) => {
                    System.Windows.Application.Current.Shutdown();
                });

                icon.ContextMenu = menu;

                SetStatus(Status.Stopped, resources["NotConnected"] as string);
                System.Windows.Application.Current.Exit += (sender, e) => {
                    icon.Dispose();
                };
            }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: coolinc/XWall
 private void onCustomRulesEditButtonClick(object sender, RoutedEventArgs e)
 {
     Rules.OpenEditor();
 }
コード例 #3
0
            public NotificationController(MainWindow window)
            {
                this.window  = window;
                icon         = new NotifyIcon();
                icon.Visible = true;

                icon.DoubleClick += (sender, e) => {
                    window.WindowState = System.Windows.WindowState.Normal;
                    window.Activate();
                };

                icon.BalloonTipClicked += (sender, e) => {
                    window.WindowState = System.Windows.WindowState.Normal;
                    window.Activate();
                };

                var menu = new ContextMenu();

                // Add Rules

                menu.MenuItems.Add(resources["AddRules"] as string, (sender, e) => {
                    Rules.OpenEditor(false);
                });

                // Proxy Type

                menu.MenuItems.Add(window.proxyTypeContextMenu);

                // Proxy Mode

                var proxyModeNormalItem     = new MenuItem(resources["Normal"] as string);
                var proxyModeForwardAllItem = new MenuItem(resources["ForwardAll"] as string);

                var proxyModeCheckSwitcher = new Action(() => {
                    proxyModeNormalItem.Checked     = !settings.ForwardAll;
                    proxyModeForwardAllItem.Checked = settings.ForwardAll;
                });

                proxyModeCheckSwitcher();

                settings.PropertyChanged += (sender, e) => {
                    if (e.PropertyName == "ForwardAll")
                    {
                        proxyModeCheckSwitcher();
                    }
                };

                proxyModeNormalItem.Click += (sender, e) => {
                    if (settings.ForwardAll)
                    {
                        settings.ForwardAll = false;
                    }
                };

                proxyModeForwardAllItem.Click += (sender, e) => {
                    if (!settings.ForwardAll)
                    {
                        settings.ForwardAll = true;
                    }
                };

                proxyModeNormalItem.RadioCheck     = true;
                proxyModeForwardAllItem.RadioCheck = true;

                var proxyModeMenuItem = new MenuItem(resources["ProxyMode"] as string, new MenuItem[] { proxyModeNormalItem, proxyModeForwardAllItem });

                menu.MenuItems.Add(proxyModeMenuItem);

                // Profiles

                menu.MenuItems.Add(window.profileContextMenu);

                // Restart Application
                menu.MenuItems.Add(resources["Restart_Text"] as string, (sender, e) =>
                {
                    Process.Start(System.Windows.Forms.Application.ExecutablePath, "restart");
                    App.Current.Shutdown();
                });

                // Exit

                menu.MenuItems.Add(resources["Exit"] as string, (sender, e) => {
                    System.Windows.Application.Current.Shutdown();
                });


                // End

                icon.ContextMenu = menu;

                SetStatus(settings.ProxyType, Status.Stopped, resources["NotConnected"] as string);
                System.Windows.Application.Current.Exit += (sender, e) => {
                    icon.Dispose();
                };
            }