Esempio n. 1
0
        void BuildContextMenu()
        {
            System.Windows.Forms.ContextMenu _menu = new System.Windows.Forms.ContextMenu();

            //Received image list contextmenu
            System.Windows.Forms.MenuItem _imgmenu = new System.Windows.Forms.MenuItem();
            _imgmenu.Text = "Saved Images";
            foreach (Packet_ImageFromClient i in ReceivedImagesList)
            {
                System.Windows.Forms.MenuItem z = new System.Windows.Forms.MenuItem();
                z.Tag    = "image:" + i.ImageName;
                z.Text   = i.ImageName;
                z.Click += ContextMenuScreenshot_click;
                _imgmenu.MenuItems.Add(z);
            }

            _menu.MenuItems.Add(_imgmenu);

            //Exit button
            System.Windows.Forms.MenuItem _exit = new System.Windows.Forms.MenuItem();
            _exit.Text   = "Exit";
            _exit.Click += ContextMenuExit_Click;
            _menu.MenuItems.Add(_exit);

            //Disconnect button
            if (!object.ReferenceEquals(_server, null))
            {
                System.Windows.Forms.MenuItem _disconnect = new System.Windows.Forms.MenuItem();
                _disconnect.Text   = "Disconnect from " + _server.ConnectedAddress.ToString();
                _disconnect.Click += _disconnect_Click;
                _menu.MenuItems.Add(_disconnect);
            }
            Notifications.ContextMenu = _menu;
        }
Esempio n. 2
0
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            notifyIcon        = new System.Windows.Forms.NotifyIcon();
            notifyIcon.Click += notifyIcon_Click;
            var mI = new System.Windows.Forms.MenuItem("Exit Infinitton WPF");

            mI.Click += MenuItem_OnClick;
            notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(new[] { mI });
            notifyIcon.Icon        = new System.Drawing.Icon("Icon16.ico");
            notifyIcon.Visible     = true;
            brightnessSlider.Value = Properties.Settings.Default.Brightness;
            controller             = new MainController(this);
            tbNewProcessAction.Items.Add(LaunchAction.ProcessRunningAction.NewProcess.ToString());
            tbNewProcessAction.Items.Add(LaunchAction.ProcessRunningAction.FocusOldProcess.ToString());
            tbNewProcessAction.Items.Add(LaunchAction.ProcessRunningAction.KillOldProcess.ToString());
        }
Esempio n. 3
0
        private System.Windows.Forms.MenuItem ContextMenuItemToFormsItem(object @object)
        {
            var menuItem = @object as MenuItem;

            if (menuItem != null)
            {
                var formsMenuItem = new System.Windows.Forms.MenuItem(menuItem.Header?.ToString(), (sender, args) =>
                {
                    menuItem.Command.Execute(null);
                });

                formsMenuItem.Visible = menuItem.Visibility == Visibility.Visible;
                formsMenuItem.Enabled = menuItem.IsEnabled;

                var menuItemHeaderPropertyDescriptor =
                    DependencyPropertyDescriptor.FromProperty(HeaderedItemsControl.HeaderProperty, typeof(MenuItem));

                menuItemHeaderPropertyDescriptor.AddValueChanged(menuItem, (sender, args) =>
                {
                    var desciptorMenuItem = (MenuItem)sender;
                    _menuItemsMap[desciptorMenuItem].Text = desciptorMenuItem.Header.ToString();
                });

                var menuItemIsEnabledPropertyDescriptor =
                    DependencyPropertyDescriptor.FromProperty(IsEnabledProperty, typeof(MenuItem));

                menuItemIsEnabledPropertyDescriptor.AddValueChanged(menuItem, (sender, args) =>
                {
                    var desciptorMenuItem = (MenuItem)sender;
                    _menuItemsMap[desciptorMenuItem].Enabled = desciptorMenuItem.IsEnabled;
                });

                return(formsMenuItem);
            }

            if (@object is Separator)
            {
                return(new System.Windows.Forms.MenuItem("-"));
            }

            throw new InvalidCastException("Can't cast " + @object?.GetType() + " to " + typeof(System.Windows.Forms.MenuItem));
        }
Esempio n. 4
0
        private void ContextMenuScreenshot_click(object sender, EventArgs e)
        {
            System.Windows.Forms.MenuItem s = sender as System.Windows.Forms.MenuItem;

            string _type    = s.Tag.ToString().Split(':')[0];
            string _imgname = s.Tag.ToString().Split(':')[1];

            if (_type == "image")
            {
                foreach (Packet_ImageFromClient _img in ReceivedImagesList)
                {
                    if (_img.ImageName == _imgname)
                    {
                        Output("Displaying " + _img.ImageName + " from " + _img.Sender);
                        Bitmap _deserialized = (Bitmap)Serializer.DeserializeObject(_img.Image);
                        DisplayImage(_deserialized);
                    }
                }
            }
        }
Esempio n. 5
0
        private void InitializeNotifyIcon()
        {
            Stream newMessageIconStream = System.Windows.Application.GetResourceStream(new Uri("pack://application:,,,/Toxy;component/Resources/Icons/icon2.ico")).Stream;
            Stream iconStream = System.Windows.Application.GetResourceStream(new Uri("pack://application:,,,/Toxy;component/Resources/Icons/icon.ico")).Stream;

            notifyIcon = new Icon(iconStream);
            newMessageNotifyIcon = new Icon(newMessageIconStream);

            this.nIcon.Icon = notifyIcon;
            nIcon.Click += nIcon_Click;

            var trayIconContextMenu = new System.Windows.Forms.ContextMenu();
            var closeMenuItem = new System.Windows.Forms.MenuItem("Exit", closeMenuItem_Click);
            var openMenuItem = new System.Windows.Forms.MenuItem("Open", openMenuItem_Click);

            var statusMenuItem = new System.Windows.Forms.MenuItem("Status");
            var setOnlineMenuItem = new System.Windows.Forms.MenuItem("Online", setStatusMenuItem_Click);
            var setAwayMenuItem = new System.Windows.Forms.MenuItem("Away", setStatusMenuItem_Click);
            var setBusyMenuItem = new System.Windows.Forms.MenuItem("Busy", setStatusMenuItem_Click);

            setOnlineMenuItem.Tag = 0; // Online
            setAwayMenuItem.Tag = 1; // Away
            setBusyMenuItem.Tag = 2; // Busy

            statusMenuItem.MenuItems.Add(setOnlineMenuItem);
            statusMenuItem.MenuItems.Add(setAwayMenuItem);
            statusMenuItem.MenuItems.Add(setBusyMenuItem);

            trayIconContextMenu.MenuItems.Add(openMenuItem);
            trayIconContextMenu.MenuItems.Add(statusMenuItem);
            trayIconContextMenu.MenuItems.Add(closeMenuItem);
            nIcon.ContextMenu = trayIconContextMenu;
        }