예제 #1
0
        object Create(ToolBarButtonMD md, IToolBarItemContext ctx, IInputElement commandTarget)
        {
            var item = (IToolBarButton)md.ToolBarItem;
            var md2  = (IToolBarButtonMetadata)md.Metadata;

            var cmdHolder = item as ICommandHolder;
            var cmd       = cmdHolder != null ? cmdHolder.Command : new RelayCommand(a => item.Execute(ctx), a => item.IsEnabled(ctx));

            string header  = ResourceHelper.GetString(item, md2.Header);
            string icon    = md2.Icon;
            string toolTip = ResourceHelper.GetString(item, md2.ToolTip);

            header  = item.GetHeader(ctx) ?? header;
            toolTip = item.GetToolTip(ctx) ?? toolTip;

            var imgRef          = item.GetIcon(ctx) ?? ImageReferenceHelper.GetImageReference(item, icon) ?? default(ImageReference);
            var toggleButtonCmd = item as IToolBarToggleButton;

            Debug.Assert(md2.IsToggleButton == (toggleButtonCmd != null), "Implement IToolBarToggleButton if IsToggleButton is true");
            if (toggleButtonCmd != null)
            {
                return(CreateToggleButton(toggleButtonCmd.GetBinding(ctx), cmd, commandTarget, header, toolTip, imgRef));
            }
            return(new ToolBarButtonVM(cmd, commandTarget, header, toolTip, imgRef));
        }
예제 #2
0
 public override void Execute(IToolBarItemContext context)
 {
     Parallel.Invoke(() =>
     {
         new Myform(CurrentThemeService.Theme.IsDark).Show();
     });
 }
예제 #3
0
 public Binding GetBinding(IToolBarItemContext context)
 {
     Debug.Assert(appWindow != null && appWindow.MainWindow != null);
     return new Binding("IsFullScreen") {
         Source = appWindow.MainWindow,
     };
 }
예제 #4
0
 public Binding GetBinding(IToolBarItemContext context)
 {
     Debug.Assert(appWindow != null && appWindow.MainWindow != null);
     return(new Binding(nameof(appWindow.MainWindow.IsFullScreen))
     {
         Source = appWindow.MainWindow,
     });
 }
예제 #5
0
 public override object GetUIObject(IToolBarItemContext context, IInputElement commandTarget)
 {
     if (menu == null)
     {
         menu = menuManager.CreateMenu(new Guid(MenuConstants.APP_MENU_GUID), commandTarget);
     }
     return(menu);
 }
예제 #6
0
 public override bool IsVisible(IToolBarItemContext context)
 {
     Debug.Assert(appWindow != null && appWindow.MainWindow != null);
     if (!initd) {
         appWindow.MainWindow.IsFullScreenChanged += (s, e) => appWindow.RefreshToolBar();
         initd = true;
     }
     return appWindow.MainWindow.IsFullScreen;
 }
예제 #7
0
        public override void Execute(IToolBarItemContext context)
        {
            var res = messageBoxManager.ShowIgnorableMessage(new Guid("FC8FC68F-4285-4CDF-BEC0-FF6498EEC4AA"), dnSpy_AsmEditor_Resources.AskClearUndoHistory, MsgBoxButton.Yes | MsgBoxButton.No);

            if (res == null || res == MsgBoxButton.Yes)
            {
                undoCommandManager.Value.Clear();
            }
        }
예제 #8
0
 public override bool IsVisible(IToolBarItemContext context)
 {
     Debug.Assert(appWindow != null && appWindow.MainWindow != null);
     if (!initd)
     {
         appWindow.MainWindow.IsFullScreenChanged += (s, e) => appWindow.RefreshToolBar();
         initd = true;
     }
     return(appWindow.MainWindow.IsFullScreen);
 }
예제 #9
0
        object?Create(ToolBarItemMD md, IToolBarItemContext ctx, IInputElement?commandTarget)
        {
            if (md is ToolBarButtonMD mdButton)
            {
                return(Create(mdButton, ctx, commandTarget));
            }

            if (md is ToolBarObjectMD mdObj)
            {
                return(Create(mdObj, ctx, commandTarget));
            }

            Debug.Fail("Unknown TB MD");
            return(null);
        }
예제 #10
0
        object Create(ToolBarItemMD md, IToolBarItemContext ctx, IInputElement commandTarget)
        {
            var mdButton = md as ToolBarButtonMD;

            if (mdButton != null)
            {
                return(Create(mdButton, ctx, commandTarget));
            }

            var mdObj = md as ToolBarObjectMD;

            if (mdObj != null)
            {
                return(Create(mdObj, ctx, commandTarget));
            }

            Debug.Fail("Unknown TB MD");
            return(null);
        }
예제 #11
0
        object Create(ToolBarButtonMD md, IToolBarItemContext ctx, IInputElement commandTarget)
        {
            var item = (IToolBarButton)md.ToolBarItem;
            var md2  = (IToolBarButtonMetadata)md.Metadata;

            var cmdHolder = item as ICommandHolder;
            var cmd       = cmdHolder != null ? cmdHolder.Command : new RelayCommand(a => item.Execute(ctx), a => item.IsEnabled(ctx));

            string header  = ResourceHelper.GetString(item, md2.Header);
            string icon    = md2.Icon;
            string toolTip = ResourceHelper.GetString(item, md2.ToolTip);
            var    item2   = item as IToolBarButton2;

            if (item2 != null)
            {
                header  = item2.GetHeader(ctx) ?? header;
                icon    = item2.GetIcon(ctx) ?? icon;
                toolTip = item2.GetToolTip(ctx) ?? toolTip;
            }

            BitmapSource imageSource = null;

            if (!string.IsNullOrEmpty(icon))
            {
                imageSource = imageManager.GetImage(item.GetType().Assembly, icon, BackgroundType.ToolBar);
            }

            var toggleButtonCmd = item as IToolBarToggleButton;

            Debug.Assert(md2.IsToggleButton == (toggleButtonCmd != null), "Implement IToolBarToggleButton if IsToggleButton is true");
            if (toggleButtonCmd != null)
            {
                return(CreateToggleButton(toggleButtonCmd.GetBinding(ctx), cmd, commandTarget, header, toolTip, imageSource));
            }
            return(new ToolBarButtonVM(cmd, commandTarget, header, toolTip, imageSource));
        }
예제 #12
0
 public override void Execute(IToolBarItemContext context) => debugger.Value.DebugProgram(pauseAtEntryPoint: false);
예제 #13
0
 public override void Execute(IToolBarItemContext context) => debugger.Value.StepOut();
예제 #14
0
 public override bool IsEnabled(IToolBarItemContext context) => debugger.Value.CanShowNextStatement;
예제 #15
0
 public virtual string GetHeader(IToolBarItemContext context)
 {
     return null;
 }
예제 #16
0
 public virtual bool IsEnabled(IToolBarItemContext context)
 {
     return true;
 }
예제 #17
0
		public override void Execute(IToolBarItemContext context) => MsgBox.Instance.Show("Command #1");
예제 #18
0
        object Create(ToolBarButtonMD md, IToolBarItemContext ctx, IInputElement commandTarget)
        {
            var item = (IToolBarButton)md.ToolBarItem;
            var md2 = (IToolBarButtonMetadata)md.Metadata;

            var cmdHolder = item as ICommandHolder;
            var cmd = cmdHolder != null ? cmdHolder.Command : new RelayCommand(a => item.Execute(ctx), a => item.IsEnabled(ctx));

            string header = ResourceHelper.GetString(item, md2.Header);
            string icon = md2.Icon;
            string toolTip = ResourceHelper.GetString(item, md2.ToolTip);
            var item2 = item as IToolBarButton2;
            if (item2 != null) {
                header = item2.GetHeader(ctx) ?? header;
                icon = item2.GetIcon(ctx) ?? icon;
                toolTip = item2.GetToolTip(ctx) ?? toolTip;
            }

            BitmapSource imageSource = null;
            if (!string.IsNullOrEmpty(icon))
                imageSource = imageManager.GetImage(item.GetType().Assembly, icon, BackgroundType.ToolBar);

            var toggleButtonCmd = item as IToolBarToggleButton;
            Debug.Assert(md2.IsToggleButton == (toggleButtonCmd != null), "Implement IToolBarToggleButton if IsToggleButton is true");
            if (toggleButtonCmd != null)
                return CreateToggleButton(toggleButtonCmd.GetBinding(ctx), cmd, commandTarget, header, toolTip, imageSource);
            return new ToolBarButtonVM(cmd, commandTarget, header, toolTip, imageSource);
        }
예제 #19
0
		public override void Execute(IToolBarItemContext context) {
			dnSpy.Shared.App.MsgBox.Instance.Show("Command #1");
		}
예제 #20
0
 public bool IsVisible(IToolBarItemContext context)
 {
     return true;
 }
예제 #21
0
		public override string GetToolTip(IToolBarItemContext context) =>
			string.Format(dnSpy_Resources.SearchAssembliesToolBarToolTip, dnSpy_Resources.ShortCutKeyCtrlShiftK);
예제 #22
0
 public override bool IsEnabled(IToolBarItemContext context)
 {
     return realCommand.CanExecute(context);
 }
예제 #23
0
 public override void Execute(IToolBarItemContext context)
 {
     realCommand.Execute(context);
 }
예제 #24
0
 object Create(ToolBarObjectMD md, IToolBarItemContext ctx, IInputElement commandTarget)
 {
     var item = (IToolBarObject)md.ToolBarItem;
     return item.GetUIObject(ctx, commandTarget);
 }
예제 #25
0
 public override void Execute(IToolBarItemContext context) => debugger.Value.Continue();
예제 #26
0
		public override bool IsEnabled(IToolBarItemContext context) {
			return undoCommandManager.Value.CanUndo ||
				undoCommandManager.Value.CanRedo;
		}
예제 #27
0
 public override bool IsEnabled(IToolBarItemContext context) => debugger.Value.CanBreakAll;
예제 #28
0
		public override void Execute(IToolBarItemContext context) {
			var res = messageBoxManager.ShowIgnorableMessage(new Guid("FC8FC68F-4285-4CDF-BEC0-FF6498EEC4AA"), dnSpy_AsmEditor_Resources.AskClearUndoHistory, MsgBoxButton.Yes | MsgBoxButton.No);
			if (res == null || res == MsgBoxButton.Yes)
				undoCommandManager.Value.Clear();
		}
예제 #29
0
		/// <inheritdoc/>
		public override bool IsEnabled(IToolBarItemContext context) => Command.CanExecute(context);
예제 #30
0
		public override void Execute(IToolBarItemContext context) {
		}
예제 #31
0
		public override object GetUIObject(IToolBarItemContext context, IInputElement commandTarget) => comboBox;
예제 #32
0
		public override object GetUIObject(IToolBarItemContext context, IInputElement commandTarget) {
			if (menu == null)
				menu = menuManager.CreateMenu(new Guid(MenuConstants.APP_MENU_GUID), commandTarget);
			return menu;
		}
예제 #33
0
 public virtual string GetToolTip(IToolBarItemContext context)
 {
     return null;
 }
예제 #34
0
 public override void Execute(IToolBarItemContext context) => debugger.Value.StopDebugging();
예제 #35
0
 public override void Execute(IToolBarItemContext context) => debugger.Value.ShowNextStatement();
예제 #36
0
 public override string GetToolTip(IToolBarItemContext context) => ToolTipHelper.AddKeyboardShortcut(dnSpy_Debugger_Resources.ToolBarStopDebuggingToolTip, dnSpy_Debugger_Resources.ShortCutKeyShiftF5);
예제 #37
0
 public override string GetToolTip(IToolBarItemContext context) => ToolTipHelper.AddKeyboardShortcut(dnSpy_Debugger_Resources.ToolBarShowNextStatementToolTip, dnSpy_Debugger_Resources.ShortCutAltAsterisk);
예제 #38
0
 public abstract object GetUIObject(IToolBarItemContext context, IInputElement commandTarget);
예제 #39
0
 public override bool IsVisible(IToolBarItemContext context) => !initd || !debugger.Value.IsDebugging;
예제 #40
0
 /// <inheritdoc/>
 public abstract object GetUIObject(IToolBarItemContext context, IInputElement commandTarget);
예제 #41
0
 public override string GetToolTip(IToolBarItemContext context) => ToolTipHelper.AddKeyboardShortcut(dnSpy_Debugger_Resources.ToolBarDebugAssemblyToolTip, dnSpy_Debugger_Resources.ShortCutKeyF5);
예제 #42
0
 public override string GetToolTip(IToolBarItemContext context) => ToolTipHelper.AddKeyboardShortcut(dnSpy_Resources.OpenToolBarToolTip, dnSpy_Resources.ShortCutKeyCtrlO);
예제 #43
0
 public override void Execute(IToolBarItemContext context) => debugger.Value.BreakAll();
예제 #44
0
 public override object GetUIObject(IToolBarItemContext context, IInputElement?commandTarget) => comboBox;
예제 #45
0
 public override string GetToolTip(IToolBarItemContext context) => ToolTipHelper.AddKeyboardShortcut(dnSpy_Debugger_Resources.ToolBarBreakAllToolTip, dnSpy_Debugger_Resources.ShortCutKeyCtrlAltBreak);
예제 #46
0
        object Create(ToolBarItemMD md, IToolBarItemContext ctx, IInputElement commandTarget)
        {
            var mdButton = md as ToolBarButtonMD;
            if (mdButton != null)
                return Create(mdButton, ctx, commandTarget);

            var mdObj = md as ToolBarObjectMD;
            if (mdObj != null)
                return Create(mdObj, ctx, commandTarget);

            Debug.Fail("Unknown TB MD");
            return null;
        }
예제 #47
0
 public override bool IsEnabled(IToolBarItemContext context) => debugger.Value.CanStopDebugging;
예제 #48
0
		/// <inheritdoc/>
		public abstract void Execute(IToolBarItemContext context);
예제 #49
0
		/// <inheritdoc/>
		public virtual bool IsEnabled(IToolBarItemContext context) => true;
예제 #50
0
		/// <inheritdoc/>
		public virtual bool IsVisible(IToolBarItemContext context) => true;
예제 #51
0
        object Create(ToolBarObjectMD md, IToolBarItemContext ctx, IInputElement commandTarget)
        {
            var item = (IToolBarObject)md.ToolBarItem;

            return(item.GetUIObject(ctx, commandTarget));
        }
예제 #52
0
		/// <inheritdoc/>
		public virtual string GetHeader(IToolBarItemContext context) => null;
예제 #53
0
 /// <inheritdoc/>
 public bool IsVisible(IToolBarItemContext context) => true;
예제 #54
0
		/// <inheritdoc/>
		public virtual ImageReference? GetIcon(IToolBarItemContext context) => null;
예제 #55
0
 public override void Execute(IToolBarItemContext context) => MsgBox.Instance.Show("Command #1");
예제 #56
0
		/// <inheritdoc/>
		public virtual string GetToolTip(IToolBarItemContext context) => null;
예제 #57
0
 public override string GetToolTip(IToolBarItemContext context) => ToolTipHelper.AddKeyboardShortcut(dnSpy_AsmEditor_Resources.RedoToolBarToolTip, dnSpy_AsmEditor_Resources.ShortCutKeyCtrlY);
예제 #58
0
		object Create(ToolBarButtonMD md, IToolBarItemContext ctx, IInputElement commandTarget) {
			var item = (IToolBarButton)md.ToolBarItem;
			var md2 = (IToolBarButtonMetadata)md.Metadata;

			var cmdHolder = item as ICommandHolder;
			var cmd = cmdHolder != null ? cmdHolder.Command : new RelayCommand(a => item.Execute(ctx), a => item.IsEnabled(ctx));

			string header = ResourceHelper.GetString(item, md2.Header);
			string icon = md2.Icon;
			string toolTip = ResourceHelper.GetString(item, md2.ToolTip);
			header = item.GetHeader(ctx) ?? header;
			toolTip = item.GetToolTip(ctx) ?? toolTip;

			var imgRef = item.GetIcon(ctx) ?? ImageReferenceHelper.GetImageReference(item, icon) ?? default(ImageReference);
			var toggleButtonCmd = item as IToolBarToggleButton;
			Debug.Assert(md2.IsToggleButton == (toggleButtonCmd != null), "Implement IToolBarToggleButton if IsToggleButton is true");
			if (toggleButtonCmd != null)
				return CreateToggleButton(toggleButtonCmd.GetBinding(ctx), cmd, commandTarget, header, toolTip, imgRef);
			return new ToolBarButtonVM(cmd, commandTarget, header, toolTip, imgRef);
		}