Exemplo n.º 1
0
 public SubMenu(string MenuText, MenuFlags Flags, NativeMenu Owner)
 {
     this.Owner    = Owner;
     this.Flags    = Flags;
     this.MenuText = MenuText;
     CreateHandle();
 }
Exemplo n.º 2
0
        public static void MainWindowAppendMenu(MenuFlags menuFlag, string menuTitle, Action action)
        {
            var wih = new WindowInteropHelper(Application.Current.MainWindow);
            var myHWnd = wih.Handle;

            var hMenu = GetSystemMenu(myHWnd, false);

            var uIDNewItem = (uint) _menuActionDictionary.Count + 1001;
            _menuActionDictionary.Add(uIDNewItem, action);

            AppendMenu(hMenu, menuFlag, uIDNewItem, menuTitle);

            var source = HwndSource.FromHwnd(myHWnd);
            // NOTE: hookしなおす必要があるのか分からん
            if (_hook != null)
            {
                source?.RemoveHook(_hook);
            }

            _hook = (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
            {
                if (msg == WM_SYSCOMMAND && _menuActionDictionary.ContainsKey((uint) wParam))
                {
                    _menuActionDictionary[(uint) wParam]();
                    handled = true;
                }
                return IntPtr.Zero;
            };
            source?.AddHook(_hook);
        }
Exemplo n.º 3
0
 public MenuItem(CompositeWidget menu, string caption, Image image, MenuFlags flags)
 {
     if (menu != null && !(menu is PopupMenu) && !(menu is MenuItem))
     {
         throw new Exception("MenuItem:s can only have menus/popup and other menuitems as parent");
     }
     AttachDriverObject(menu, Guppy.Driver.CreateMenuItem(this, caption, image, flags));
 }
        public void UnlockMenu(MenuFlags menuFlags)
        {
            MenuFlags menuStatus = GetMenuStatus();

            menuStatus ^= menuFlags;

            byte[] bytes = BitConverter.GetBytes((int)menuStatus);

            _memoryAccessor.WriteMem(ProcessName, Addresses.MenuLock.Address, bytes);
        }
Exemplo n.º 5
0
        public unsafe static void AppendMenu(MenuHandle menu, string text, int id, bool disabled = false, bool @checked = false)
        {
            MenuFlags flags = MenuFlags.String;
            if (disabled) flags |= MenuFlags.Grayed;
            if (@checked) flags |= MenuFlags.Checked;

            fixed (char* c = text)
            {
                Error.ThrowLastErrorIfFalse(
                    Imports.AppendMenuW(menu, flags, (IntPtr)id, (IntPtr)c));
            }
        }
Exemplo n.º 6
0
 public MenuItem(string MenuText, MenuFlags Flags, int ItemId = 0, MenuItem_Handler Handler = null)
 {
     this.MenuText = MenuText;
     this.Flags    = Flags;
     if (ItemId == 0)
     {
         ItemId = ("SFS" + MenuText).GetHashCode();
     }
     this.ItemInfo = new MENUITEMINFO
     {
         wID        = ItemId,
         dwTypeData = Marshal.StringToHGlobalAnsi(MenuText),
         dwItemData = new IntPtr(ItemId),
         cch        = MenuText.Length + 1,
         fState     = MenuItemInfofState.MFS_ENABLED,
         fType      = MenuItemInfofType.MFT_STRING
     };
     this.Handler = Handler;
 }
Exemplo n.º 7
0
        public unsafe static void AppendMenu(MenuHandle menu, string text, int id, bool disabled = false, bool @checked = false)
        {
            MenuFlags flags = MenuFlags.String;

            if (disabled)
            {
                flags |= MenuFlags.Grayed;
            }
            if (@checked)
                flags |= MenuFlags.Checked;

            fixed(char *c = text)
            {
                if (!Imports.AppendMenuW(menu, flags, (IntPtr)id, (IntPtr)c))
                {
                    throw Errors.GetIoExceptionForLastError();
                }
            }
        }
Exemplo n.º 8
0
        public WinFormsMenuItem(Widget shellobject, string caption, Image image, MenuFlags flags)
            : base(shellobject)
        {
            if ((flags & MenuFlags.Separator) != 0)
            {
                item     = new System.Windows.Forms.ToolStripSeparator();
                item.Tag = shellobject; //map-back from native control to guppy object

                return;                 //no events for separator
            }
            else
            {
                System.Windows.Forms.ToolStripMenuItem mi = new System.Windows.Forms.ToolStripMenuItem();
                mi.Tag = shellobject; //map-back from native control to guppy object

                item            = mi;
                mi.Image        = WinFormsDriver.ImageToWinFormsImage(image);
                mi.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;

                //parse shortkey text
                if (caption == null)
                {
                    caption = "";
                }
                string[] capts = caption.Split('\t');
                if (capts.Length > 0)
                {
                    mi.Text = capts[0];
                }
                if (capts.Length > 1)
                {
                    mi.ShortcutKeyDisplayString = capts[1];
                }

                if ((flags & MenuFlags.Checkable) != 0)
                {
                    mi.CheckOnClick = true;
                    mi.CheckState   = (((flags & MenuFlags.Checked) != 0) ? System.Windows.Forms.CheckState.Checked : System.Windows.Forms.CheckState.Unchecked);
                }
            }

            item.Click += delegate { ((MenuItem)ShellObject).OnClicked(); };
        }
Exemplo n.º 9
0
        public MenuItem(string MenuText, Bitmap BitMap, MenuFlags Flags, int ItemId = 0, MenuItem_Handler Handler = null)
        {
            this.MenuText = MenuText;
            int MenuPictureWidth = GetSystemMetrics(71);

            this.BitMap = new Bitmap(BitMap, new Size(MenuPictureWidth, MenuPictureWidth));

            this.Flags = Flags;
            if (ItemId == 0)
            {
                ItemId = ("SFS" + MenuText).GetHashCode();
            }
            this.ItemInfo = new MENUITEMINFO
            {
                wID         = ItemId,
                dwTypeData  = Marshal.StringToHGlobalAnsi(MenuText),
                dwItemData  = new IntPtr(ItemId),
                cch         = MenuText.Length + 1,
                fState      = MenuItemInfofState.MFS_CHECKED,
                fType       = MenuItemInfofType.MFT_STRING,
                hbmpChecked = this.BitMap.GetHbitmap()
            };
            this.Handler = Handler;
        }
Exemplo n.º 10
0
 public override DriverMenuItem CreateMenuItem(Widget shellobject, string caption, Image image, MenuFlags flags)
 {
     return(new WinFormsMenuItem(shellobject, caption, image, flags));
 }
Exemplo n.º 11
0
 public abstract DriverMenuItem CreateMenuItem(Widget shellobject, string Caption, Image image, MenuFlags flags);
Exemplo n.º 12
0
 public static extern uint EnableMenuItem(IntPtr hMenu, int itemId, MenuFlags uEnable);
Exemplo n.º 13
0
 public override DriverMenuItem CreateMenuItem(Widget shellobject, string Caption, Image image, MenuFlags flags)
 {
     throw new NotImplementedException("menuitem not implemented in gtk driver");
 }
Exemplo n.º 14
0
 public static extern bool InsertMenu(IntPtr hMenu, int position, MenuFlags flags, IntPtr uIDNewItem, [MarshalAs(UnmanagedType.LPTStr)] string lpNewItem);
Exemplo n.º 15
0
 public static extern bool InsertMenu(IntPtr hMenu, Int32 wPosition, MenuFlags wFlags, Int32 wIDNewItem, string lpNewItem);
Exemplo n.º 16
0
 private static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, IntPtr uIDNewItem, string lpNewItem);
Exemplo n.º 17
0
 public static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, MenuFlags uEnable);
Exemplo n.º 18
0
 private static extern bool RemoveMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags);
Exemplo n.º 19
0
 public static extern bool DeleteMenu(IntPtr hMenu, int uPosition, MenuFlags uFlags);
Exemplo n.º 20
0
 private static extern long InsertMenu(IntPtr hMenu, int nPosition, MenuFlags wFlags, int wIDNewItem, [MarshalAs(UnmanagedType.VBByRefStr)] ref string lpNewItem);
Exemplo n.º 21
0
 private static extern int RemoveMenu(IntPtr hMenu,
                                      int Position, MenuFlags uFlags);
Exemplo n.º 22
0
 public static extern bool RemoveMenu(IntPtr hMenu, UInt32 uPosition, MenuFlags uFlags);
Exemplo n.º 23
0
 public static extern bool InsertMenu(
     IntPtr hmenu,
     uint position,
     MenuFlags flags,
     uint item_id,
     [MarshalAs(UnmanagedType.LPTStr)]string item_text);
Exemplo n.º 24
0
 private static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags,
                                       uint wIDNewItem, String lpNewItem);
Exemplo n.º 25
0
 public static extern bool EnableMenuItem([In] IntPtr hMenu, [In, MarshalAs(UnmanagedType.U4)] SystemMenuCommands uIDEnableItem, [In, MarshalAs(UnmanagedType.U4)] MenuFlags uEnable);
Exemplo n.º 26
0
 private static extern bool InsertMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
Exemplo n.º 27
0
 internal static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, UIntPtr uIDNewItem, string lpNewItem);
Exemplo n.º 28
0
 private static extern bool SetMenuItemBitmaps(IntPtr hMenu, uint uPosition, MenuFlags uFlags, IntPtr hBitmapUnchecked, IntPtr hBitmapChecked);
Exemplo n.º 29
0
 public static extern bool EnableMenuItem(IntPtr hMenu, SystemCommands uIDEnableItem, MenuFlags uEnable);
Exemplo n.º 30
0
 public static extern bool EnableMenuItem(IntPtr hMenu, SysCommands uIDEnableItem, MenuFlags uEnable);
 internal static extern bool InsertMenu(IntPtr hmenu, uint position, MenuFlags flags,
                                        uint item_id, [MarshalAs(UnmanagedType.LPTStr)] string item_text);
 static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
Exemplo n.º 33
0
 public static extern bool AppendMenu(IntPtr hMenu, [MarshalAs(UnmanagedType.U4)] MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
Exemplo n.º 34
0
 public static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
Exemplo n.º 35
0
 public static extern bool InsertMenu(IntPtr hMenu, uint uPosition, [MarshalAs(UnmanagedType.U4)] MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
Exemplo n.º 36
0
 public static extern bool RemoveMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags);
Exemplo n.º 37
0
 public static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, IntPtr MenuBitMAp, [MarshalAs(UnmanagedType.LPTStr)] string lpNewItem);