示例#1
0
        private void UpdateMenuItemSqlServerService()
        {
            if (gSqlServerService == null)
            {
                gmSqlServerService.Enabled = false;
            }
            else
            {
                gSqlServerService.Refresh();
                gLastStatusSqlServerService = gSqlServerService.Status;
                switch (gSqlServerService.Status)
                {
                case ServiceControllerStatus.Paused:
                case ServiceControllerStatus.Running:
                    gmSqlServerService.Text         = "Stop Sql server";
                    gmSqlServerService.Image        = gSqlServerServiceImageOn;
                    gmSqlServerService.ImageScaling = ToolStripItemImageScaling.None;
                    gmSqlServerService.Invalidate();
                    break;

                case ServiceControllerStatus.Stopped:
                    gmSqlServerService.Text         = "Start Sql server";
                    gmSqlServerService.Image        = gSqlServerServiceImageOff;
                    gmSqlServerService.ImageScaling = ToolStripItemImageScaling.None;
                    gmSqlServerService.Invalidate();
                    break;

                default:
                    gmSqlServerService.Enabled = false;
                    break;
                }
            }
        }
示例#2
0
        /*************************************/
        /**** Protected Methods           ****/
        /*************************************/

        protected void AppendMenuTree(Tree <object> tree, ToolStripDropDown menu)
        {
            if (tree.Children.Count > 0)
            {
                ToolStripMenuItem treeMenu = AppendMenuItem(menu, tree.Name);
                treeMenu.Paint += (s, e) =>
                {
                    if (treeMenu.DropDown.Items.Count == 0)
                    {
                        foreach (Tree <object> childTree in tree.Children.Values.OrderBy(x => x.Name))
                        {
                            AppendMenuTree(childTree, treeMenu.DropDown);
                        }
                        treeMenu.Invalidate();
                    }
                };
            }
            else
            {
                object            method     = tree.Value;
                ToolStripMenuItem methodItem = AppendMenuItem(menu, tree.Name, Item_Click);
                m_ItemLinks[methodItem] = tree.Value;
                methodItem.ToolTipText  = method.IDescription();
            }
        }
示例#3
0
        private void PrepareCaptureMenuAsync(ToolStripMenuItem tsmiWindow, EventHandler handlerWindow, ToolStripMenuItem tsmiMonitor, EventHandler handlerMonitor)
        {
            tsmiWindow.DropDownItems.Clear();

            WindowsList       windowsList = new WindowsList();
            List <WindowInfo> windows     = null;

            TaskEx.Run(() =>
            {
                windows = windowsList.GetVisibleWindowsList();
            },
                       () =>
            {
                if (windows != null)
                {
                    foreach (WindowInfo window in windows)
                    {
                        try
                        {
                            string title      = window.Text.Truncate(50);
                            ToolStripItem tsi = tsmiWindow.DropDownItems.Add(title);
                            tsi.Tag           = window;
                            tsi.Click        += handlerWindow;

                            using (Icon icon = window.Icon)
                            {
                                if (icon != null && icon.Width > 0 && icon.Height > 0)
                                {
                                    tsi.Image = icon.ToBitmap();
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            DebugHelper.WriteException(e);
                        }
                    }
                }

                tsmiMonitor.DropDownItems.Clear();

                Screen[] screens = Screen.AllScreens;

                for (int i = 0; i < screens.Length; i++)
                {
                    Screen screen     = screens[i];
                    string text       = string.Format("{0}. {1}x{2}", i + 1, screen.Bounds.Width, screen.Bounds.Height);
                    ToolStripItem tsi = tsmiMonitor.DropDownItems.Add(text);
                    tsi.Tag           = screen.Bounds;
                    tsi.Click        += handlerMonitor;
                }

                tsmiWindow.Invalidate();
                tsmiMonitor.Invalidate();
            });
        }
示例#4
0
        int OnMouseLLHook(int code, WM message, IntPtr state)
        {
            try
            {
                if (message == WM.LBUTTONDOWN)
                {
                    var clientPos = virtualContextMenu.PointToClient(Cursor.Position);
                    if (virtualContextMenu.Visible && virtualContextMenu.ClientRectangle.Contains(clientPos) == false)
                    {
                        virtualContextMenu.Hide();
                    }
                }
                if (message == WM.RBUTTONUP)
                {
                    // コンテキストメニューを表示
                    virtualContextMenu.Items.Clear();

                    for (int i = 0; i < appGraph.edges.Count; i++)
                    {
                        AppEdge appEdge = appGraph.edges[i];
                        if (!IsValidEdge(appEdge, TriggerType.ContextMenu))
                        {
                            continue;
                        }
                        var item = new ToolStripMenuItem(appEdge.ActionHandler.ContextMenuText);
                        item.Click += (s, ee) => ExecuteActionHandler(appEdge);
                        item.Invalidate();
                        virtualContextMenu.Items.Add(item);
                    }

                    if (virtualContextMenu.Items.Count >= 1)
                    {
                        ToolStripMenuItem[] itemList = new ToolStripMenuItem[virtualContextMenu.Items.Count];
                        for (int j = 0; j < virtualContextMenu.Items.Count; j++)
                        {
                            itemList[j] = virtualContextMenu.Items[j] as ToolStripMenuItem;
                        }
                        virtualContextMenu.Show(new Point(Cursor.Position.X, Cursor.Position.Y - 22 * virtualContextMenu.Items.Count));
                    }
                }
                return(CallNextHookEx(mouseHook, code, message, state));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(CallNextHookEx(mouseHook, code, message, state));
            }
        }