コード例 #1
0
		public ContextMenuProvider(MenuService menuService, FrameworkElement elem, Guid guid, IGuidObjectsProvider provider, IContextMenuInitializer initCtxMenu, Guid? ctxMenuGuid) {
			this.menuService = menuService;
			element = elem;
			this.guid = guid;
			this.provider = provider;
			this.initCtxMenu = initCtxMenu;
			this.ctxMenuGuid = ctxMenuGuid ?? new Guid(MenuConstants.CTX_MENU_GUID);
			elem.ContextMenu = new ContextMenu();
			elem.ContextMenuOpening += FrameworkElement_ContextMenuOpening;
		}
コード例 #2
0
ファイル: ContextMenuProvider.cs プロジェクト: zz110/dnSpy
 public ContextMenuProvider(MenuService menuService, FrameworkElement elem, Guid guid, IGuidObjectsProvider provider, IContextMenuInitializer initCtxMenu, Guid?ctxMenuGuid)
 {
     this.menuService         = menuService;
     element                  = elem;
     this.guid                = guid;
     this.provider            = provider;
     this.initCtxMenu         = initCtxMenu;
     this.ctxMenuGuid         = ctxMenuGuid ?? new Guid(MenuConstants.CTX_MENU_GUID);
     elem.ContextMenu         = new ContextMenu();
     elem.ContextMenuOpening += FrameworkElement_ContextMenuOpening;
 }
コード例 #3
0
ファイル: ContextMenuCreator.cs プロジェクト: lovebanyi/dnSpy
 public ContextMenuCreator(MenuManager menuManager, FrameworkElement elem, Guid guid, IGuidObjectsCreator creator, IContextMenuInitializer initCtxMenu, Guid? ctxMenuGuid)
 {
     this.menuManager = menuManager;
     this.element = elem;
     this.guid = guid;
     this.creator = creator;
     this.initCtxMenu = initCtxMenu;
     this.ctxMenuGuid = ctxMenuGuid ?? new Guid(MenuConstants.CTX_MENU_GUID);
     elem.ContextMenu = new ContextMenu();
     elem.ContextMenuOpening += FrameworkElement_ContextMenuOpening;
 }
コード例 #4
0
 public ContextMenuCreator(MenuManager menuManager, FrameworkElement elem, Guid guid, IGuidObjectsCreator creator, IContextMenuInitializer initCtxMenu, Guid?ctxMenuGuid)
 {
     this.menuManager         = menuManager;
     this.element             = elem;
     this.guid                = guid;
     this.creator             = creator;
     this.initCtxMenu         = initCtxMenu;
     this.ctxMenuGuid         = ctxMenuGuid ?? new Guid(MenuConstants.CTX_MENU_GUID);
     elem.ContextMenu         = new ContextMenu();
     elem.ContextMenuOpening += FrameworkElement_ContextMenuOpening;
 }
コード例 #5
0
 public IContextMenuProvider InitializeContextMenu(FrameworkElement elem, string guid, IGuidObjectsProvider provider, IContextMenuInitializer initCtxMenu, string ctxMenuGuid) => InitializeContextMenu(elem, new Guid(guid), provider, initCtxMenu, ctxMenuGuid == null ? (Guid?)null : new Guid(ctxMenuGuid));
コード例 #6
0
 public IContextMenuProvider InitializeContextMenu(FrameworkElement elem, Guid guid, IGuidObjectsProvider provider, IContextMenuInitializer initCtxMenu, Guid?ctxMenuGuid)
 {
     Debug.Assert(guid != Guid.Empty);
     return(new ContextMenuProvider(this, elem, guid, provider, initCtxMenu, ctxMenuGuid));
 }
コード例 #7
0
        internal bool?ShowContextMenu(object evArgs, FrameworkElement ctxMenuElem, Guid topLevelMenuGuid, Guid ownerMenuGuid, GuidObject creatorObject, IGuidObjectsProvider provider, IContextMenuInitializer initCtxMenu, bool openedFromKeyboard)
        {
            InitializeMenuItemObjects();

            // There could be nested context menu handler calls, eg. first text editor followed by
            // the TabControl. We don't wan't the TabControl to disable the text editor's ctx menu.
            if (prevEventArgs.Target == evArgs)
            {
                return(null);
            }

            var ctx = new MenuItemContext(topLevelMenuGuid, openedFromKeyboard, creatorObject, provider?.GetGuidObjects(new GuidObjectsProviderArgs(creatorObject, openedFromKeyboard)));

            bool b = guidToGroups.TryGetValue(ownerMenuGuid, out var groups);

            if (!b)
            {
                return(false);
            }

            var menu = new ContextMenu();

            BindBackgroundBrush(menu, isCtxMenu: true);

            // The owner control could be zoomed (eg. text editor) but the context menu isn't, so make
            // sure we use 100% zoom here (same as the context menu).
            double defaultZoom = 1.0;

            DsImage.SetZoom(menu, defaultZoom);
            // Also make sure we use Display mode. Let MetroWindow handle it since it has some extra checks
            var window = Window.GetWindow(ctxMenuElem) as MetroWindow;

            window?.SetScaleTransform(menu, defaultZoom);

            var allItems = CreateMenuItems(ctx, groups, null, null, true);

            if (allItems.Count == 0)
            {
                return(false);
            }
            foreach (var i in allItems)
            {
                menu.Items.Add(i);
            }

            menu.Closed += (s, e) => {
                ctx.Dispose();
                ctxMenuElem.ContextMenu = new ContextMenu();
            };
            if (initCtxMenu != null)
            {
                initCtxMenu.Initialize(ctx, menu);
            }
            ctxMenuElem.ContextMenu = menu;
            prevEventArgs.Target    = evArgs;
            return(true);
        }
コード例 #8
0
ファイル: MenuManager.cs プロジェクト: haise0/reAtomizer
        internal bool?ShowContextMenu(object evArgs, FrameworkElement ctxMenuElem, Guid topLevelMenuGuid, Guid ownerMenuGuid, GuidObject creatorObject, IGuidObjectsCreator creator, IContextMenuInitializer initCtxMenu, bool openedFromKeyboard)
        {
            InitializeMenuItemObjects();

            // There could be nested contex menu handler calls, eg. first text editor followed by
            // the TabControl. We don't wan't the TabControl to disable the text editor's ctx menu.
            if (prevEventArgs.Target == evArgs)
            {
                return(null);
            }

            var ctx = new MenuItemContext(topLevelMenuGuid, openedFromKeyboard, creatorObject, creator == null ? null : creator.GetGuidObjects(creatorObject, openedFromKeyboard));

            List <MenuItemGroupMD> groups;
            bool b = guidToGroups.TryGetValue(ownerMenuGuid, out groups);

            if (!b)
            {
                return(false);
            }

            var menu     = new ContextMenu();
            var allItems = CreateMenuItems(ctx, groups, null, null, true);

            if (allItems.Count == 0)
            {
                return(false);
            }
            foreach (var i in allItems)
            {
                menu.Items.Add(i);
            }

            menu.Opened += (s, e) => openedContextMenus.Add(menu);
            menu.Closed += (s, e) => {
                openedContextMenus.Remove(menu);
                ctxMenuElem.ContextMenu = new ContextMenu();
            };
            if (initCtxMenu != null)
            {
                initCtxMenu.Initialize(ctx, menu);
            }
            ctxMenuElem.ContextMenu = menu;
            prevEventArgs.Target    = evArgs;
            return(true);
        }
コード例 #9
0
ファイル: MenuManager.cs プロジェクト: haise0/reAtomizer
 public IContextMenuCreator InitializeContextMenu(FrameworkElement elem, string guid, IGuidObjectsCreator creator, IContextMenuInitializer initCtxMenu, string ctxMenuGuid)
 {
     return(InitializeContextMenu(elem, new Guid(guid), creator, initCtxMenu, ctxMenuGuid == null ? (Guid?)null : new Guid(ctxMenuGuid)));
 }
コード例 #10
0
ファイル: MenuManager.cs プロジェクト: lovebanyi/dnSpy
        internal bool? ShowContextMenu(object evArgs, FrameworkElement ctxMenuElem, Guid topLevelMenuGuid, Guid ownerMenuGuid, GuidObject creatorObject, IGuidObjectsCreator creator, IContextMenuInitializer initCtxMenu, bool openedFromKeyboard)
        {
            InitializeMenuItemObjects();

            // There could be nested contex menu handler calls, eg. first text editor followed by
            // the TabControl. We don't wan't the TabControl to disable the text editor's ctx menu.
            if (prevEventArgs.Target == evArgs)
                return null;

            var ctx = new MenuItemContext(topLevelMenuGuid, openedFromKeyboard, creatorObject, creator == null ? null : creator.GetGuidObjects(creatorObject, openedFromKeyboard));

            List<MenuItemGroupMD> groups;
            bool b = guidToGroups.TryGetValue(ownerMenuGuid, out groups);
            if (!b)
                return false;

            var menu = new ContextMenu();
            var allItems = CreateMenuItems(ctx, groups, null, null, true);
            if (allItems.Count == 0)
                return false;
            foreach (var i in allItems)
                menu.Items.Add(i);

            menu.Opened += (s, e) => openedContextMenus.Add(menu);
            menu.Closed += (s, e) => {
                openedContextMenus.Remove(menu);
                ctxMenuElem.ContextMenu = new ContextMenu();
            };
            if (initCtxMenu != null)
                initCtxMenu.Initialize(ctx, menu);
            ctxMenuElem.ContextMenu = menu;
            prevEventArgs.Target = evArgs;
            return true;
        }
コード例 #11
0
ファイル: MenuManager.cs プロジェクト: lovebanyi/dnSpy
 public IContextMenuCreator InitializeContextMenu(FrameworkElement elem, string guid, IGuidObjectsCreator creator, IContextMenuInitializer initCtxMenu, string ctxMenuGuid)
 {
     return InitializeContextMenu(elem, new Guid(guid), creator, initCtxMenu, ctxMenuGuid == null ? (Guid?)null : new Guid(ctxMenuGuid));
 }
コード例 #12
0
ファイル: MenuManager.cs プロジェクト: lovebanyi/dnSpy
 public IContextMenuCreator InitializeContextMenu(FrameworkElement elem, Guid guid, IGuidObjectsCreator creator, IContextMenuInitializer initCtxMenu, Guid? ctxMenuGuid)
 {
     Debug.Assert(guid != Guid.Empty);
     return new ContextMenuCreator(this, elem, guid, creator, initCtxMenu, ctxMenuGuid);
 }
コード例 #13
0
ファイル: MenuService.cs プロジェクト: manojdjoshi/dnSpy
		public IContextMenuProvider InitializeContextMenu(FrameworkElement elem, string guid, IGuidObjectsProvider provider, IContextMenuInitializer initCtxMenu, string ctxMenuGuid) => InitializeContextMenu(elem, new Guid(guid), provider, initCtxMenu, ctxMenuGuid == null ? (Guid?)null : new Guid(ctxMenuGuid));
コード例 #14
0
ファイル: MenuService.cs プロジェクト: manojdjoshi/dnSpy
		internal bool? ShowContextMenu(object evArgs, FrameworkElement ctxMenuElem, Guid topLevelMenuGuid, Guid ownerMenuGuid, GuidObject creatorObject, IGuidObjectsProvider provider, IContextMenuInitializer initCtxMenu, bool openedFromKeyboard) {
			InitializeMenuItemObjects();

			// There could be nested contex menu handler calls, eg. first text editor followed by
			// the TabControl. We don't wan't the TabControl to disable the text editor's ctx menu.
			if (prevEventArgs.Target == evArgs)
				return null;

			var ctx = new MenuItemContext(topLevelMenuGuid, openedFromKeyboard, creatorObject, provider?.GetGuidObjects(new GuidObjectsProviderArgs(creatorObject, openedFromKeyboard)));

			List<MenuItemGroupMD> groups;
			bool b = guidToGroups.TryGetValue(ownerMenuGuid, out groups);
			if (!b)
				return false;

			var menu = new ContextMenu();
			BindBackgroundBrush(menu, isCtxMenu: true);

			// The owner control could be zoomed (eg. text editor) but the context menu isn't, so make
			// sure we use 100% zoom here (same as the context menu).
			double defaultZoom = 1.0;
			DsImage.SetZoom(menu, defaultZoom);
			// Also make sure we use Display mode. Let MetroWindow handle it since it has some extra checks
			var window = Window.GetWindow(ctxMenuElem) as MetroWindow;
			window?.SetScaleTransform(menu, defaultZoom);

			var allItems = CreateMenuItems(ctx, groups, null, null, true);
			if (allItems.Count == 0)
				return false;
			foreach (var i in allItems)
				menu.Items.Add(i);

			menu.Closed += (s, e) => {
				ctx.Dispose();
				ctxMenuElem.ContextMenu = new ContextMenu();
			};
			if (initCtxMenu != null)
				initCtxMenu.Initialize(ctx, menu);
			ctxMenuElem.ContextMenu = menu;
			prevEventArgs.Target = evArgs;
			return true;
		}