Browse Source

SD2-689 - Resource editor copy/paste. The resource editor now checks that the list item is not being edited and that the list view has focus before overriding the standard copy/paste behaviour when using keyboard shortcuts.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1218 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 20 years ago
parent
commit
f936c1c1b9
  1. 15
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/DisplayDefinition.cs
  2. 50
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/ResourceEdit/ResourceList.cs

15
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/DisplayDefinition.cs

@ -110,6 +110,9 @@ namespace ResourceEditor
public bool EnableCut public bool EnableCut
{ {
get { get {
if (resourceEditor.ResourceList.IsEditing || !resourceEditor.ResourceList.Focused) {
return false;
}
return resourceEditor.ResourceList.SelectedItems.Count > 0; return resourceEditor.ResourceList.SelectedItems.Count > 0;
} }
} }
@ -117,6 +120,9 @@ namespace ResourceEditor
public bool EnableCopy public bool EnableCopy
{ {
get { get {
if (resourceEditor.ResourceList.IsEditing || !resourceEditor.ResourceList.Focused) {
return false;
}
return resourceEditor.ResourceList.SelectedItems.Count > 0; return resourceEditor.ResourceList.SelectedItems.Count > 0;
} }
} }
@ -124,6 +130,9 @@ namespace ResourceEditor
public bool EnablePaste public bool EnablePaste
{ {
get { get {
if (resourceEditor.ResourceList.IsEditing || !resourceEditor.ResourceList.Focused) {
return false;
}
return true; return true;
} }
} }
@ -131,6 +140,9 @@ namespace ResourceEditor
public bool EnableDelete public bool EnableDelete
{ {
get { get {
if (resourceEditor.ResourceList.IsEditing || !resourceEditor.ResourceList.Focused) {
return false;
}
return resourceEditor.ResourceList.SelectedItems.Count > 0; return resourceEditor.ResourceList.SelectedItems.Count > 0;
} }
} }
@ -138,6 +150,9 @@ namespace ResourceEditor
public bool EnableSelectAll public bool EnableSelectAll
{ {
get { get {
if (resourceEditor.ResourceList.IsEditing || !resourceEditor.ResourceList.Focused) {
return false;
}
return true; return true;
} }
} }

50
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/ResourceEdit/ResourceList.cs

@ -39,6 +39,7 @@ namespace ResourceEditor
UndoStack undoStack = null; UndoStack undoStack = null;
bool writeProtected = false; bool writeProtected = false;
int editListViewItemIndex = -1;
public event EventHandler Changed; public event EventHandler Changed;
@ -73,12 +74,16 @@ namespace ResourceEditor
} }
} }
public bool IsEditing {
get {
return editListViewItemIndex != -1;
}
}
public ResourceList(ResourceEditorControl editor) public ResourceList(ResourceEditorControl editor)
{ {
undoStack = new UndoStack(); undoStack = new UndoStack();
name.Text = ResourceService.GetString("Global.Name"); name.Text = ResourceService.GetString("Global.Name");
name.Width = 250; name.Width = 250;
@ -110,9 +115,6 @@ namespace ResourceEditor
images.Images.Add(ResourceService.GetIcon("Icons.16x16.ResourceEditor.obj")); images.Images.Add(ResourceService.GetIcon("Icons.16x16.ResourceEditor.obj"));
SmallImageList = images; SmallImageList = images;
AfterLabelEdit += new LabelEditEventHandler(afterLabelEdit);
ContextMenuStrip = MenuService.CreateContextMenu(editor, "/SharpDevelop/ResourceEditor/ResourceList/ContextMenu"); ContextMenuStrip = MenuService.CreateContextMenu(editor, "/SharpDevelop/ResourceEditor/ResourceList/ContextMenu");
} }
@ -197,8 +199,27 @@ namespace ResourceEditor
} }
} }
void afterLabelEdit(object sender, LabelEditEventArgs e) public void InitializeListView()
{ {
BeginUpdate();
Items.Clear();
foreach (KeyValuePair<string, ResourceItem> entry in resources) {
ResourceItem item = entry.Value;
string tmp = item.ToString();
string type = item.ResourceValue.GetType().FullName;
ListViewItem lv = new ListViewItem(new String[] {item.Name, type, tmp}, item.ImageIndex);
Items.Add(lv);
}
EndUpdate();
}
protected override void OnAfterLabelEdit(LabelEditEventArgs e)
{
editListViewItemIndex = -1;
if (writeProtected) { if (writeProtected) {
e.CancelEdit = true; e.CancelEdit = true;
return; return;
@ -226,21 +247,12 @@ namespace ResourceEditor
OnChanged(); OnChanged();
} }
public void InitializeListView() protected override void OnBeforeLabelEdit(LabelEditEventArgs e)
{ {
BeginUpdate(); base.OnBeforeLabelEdit(e);
Items.Clear(); if (!e.CancelEdit) {
editListViewItemIndex = e.Item;
foreach (KeyValuePair<string, ResourceItem> entry in resources) {
ResourceItem item = entry.Value;
string tmp = item.ToString();
string type = item.ResourceValue.GetType().FullName;
ListViewItem lv = new ListViewItem(new String[] {item.Name, type, tmp}, item.ImageIndex);
Items.Add(lv);
} }
EndUpdate();
} }
} }
} }

Loading…
Cancel
Save