From 904373afe228f7340d3136a24ac18fa419c55e82 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 3 Aug 2014 20:06:12 +0200 Subject: [PATCH] fix #234: Short cuts/toolbar actions do not always work in non-WPF view contents --- .../Project/Src/View/HexEditContainer.cs | 4 --- .../HexEditor/Project/Src/View/HexEditView.cs | 25 ++++++++++--------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.cs b/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.cs index 3d06983640..2f4b077f7b 100644 --- a/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.cs +++ b/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditContainer.cs @@ -34,10 +34,6 @@ namespace HexEditor.View get { return hexEditControl.HasSomethingSelected; } } - public bool EditorFocused { - get { return hexEditControl.Focused; } - } - public bool CanUndo { get { return hexEditControl.CanUndo; } } diff --git a/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditView.cs b/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditView.cs index 63e4e00b04..bfe4d78981 100644 --- a/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditView.cs +++ b/src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditView.cs @@ -18,10 +18,8 @@ using System; using System.IO; -using ICSharpCode.Core; -using ICSharpCode.Core.WinForms; +using System.Windows.Input; using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.WinForms; using ICSharpCode.SharpDevelop.Workbench; @@ -34,7 +32,8 @@ namespace HexEditor.View public HexEditView(OpenedFile file) { hexEditContainer = new HexEditContainer(); - hexEditContainer.hexEditControl.DocumentChanged += new EventHandler(DocumentChanged); + hexEditContainer.hexEditControl.DocumentChanged += DocumentChanged; + hexEditContainer.hexEditControl.Selection.SelectionChanged += SelectionChanged; this.Files.Add(file); @@ -67,23 +66,23 @@ namespace HexEditor.View #region IClipboardHandler public bool EnableCut { - get { return hexEditContainer.HasSomethingSelected & hexEditContainer.EditorFocused; } + get { return hexEditContainer.HasSomethingSelected; } } public bool EnableCopy { - get { return hexEditContainer.HasSomethingSelected & hexEditContainer.EditorFocused; } + get { return hexEditContainer.HasSomethingSelected; } } public bool EnablePaste { - get { return hexEditContainer.EditorFocused; } + get { return true; } } public bool EnableDelete { - get { return hexEditContainer.HasSomethingSelected & hexEditContainer.EditorFocused; } + get { return hexEditContainer.HasSomethingSelected; } } public bool EnableSelectAll { - get { return hexEditContainer.EditorFocused; } + get { return true; } } public void Cut() @@ -137,10 +136,12 @@ namespace HexEditor.View void DocumentChanged(object sender, EventArgs e) { if (PrimaryFile != null) PrimaryFile.MakeDirty(); + CommandManager.InvalidateRequerySuggested(); } - - public override bool IsDirty { - get { return base.IsDirty; } + + void SelectionChanged(object sender, System.EventArgs e) + { + CommandManager.InvalidateRequerySuggested(); } } }