Add UWT context menu scaffolding to FileSystemEditor
This commit is contained in:
parent
fa8f14ca6a
commit
00529ca593
@ -21,6 +21,7 @@
|
||||
using System;
|
||||
using UniversalWidgetToolkit;
|
||||
using UniversalWidgetToolkit.Controls;
|
||||
using UniversalWidgetToolkit.Input.Mouse;
|
||||
using UniversalWidgetToolkit.Layouts;
|
||||
|
||||
namespace UniversalEditor.Editors.FileSystem
|
||||
@ -30,6 +31,9 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
private ListView tv = null;
|
||||
private DefaultTreeModel tmTreeView = null;
|
||||
|
||||
private Menu contextMenuUnselected = new Menu();
|
||||
private Menu contextMenuSelected = new Menu();
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.Layout = new BoxLayout(Orientation.Vertical);
|
||||
@ -41,6 +45,67 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
this.tv.SelectionMode = SelectionMode.Multiple;
|
||||
this.tv.Model = this.tmTreeView;
|
||||
|
||||
contextMenuUnselected.Items.AddRange(new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("_View", new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("T_humbnails"),
|
||||
new CommandMenuItem("Tile_s"),
|
||||
new CommandMenuItem("Ico_ns"),
|
||||
new CommandMenuItem("_List"),
|
||||
new CommandMenuItem("_Details")
|
||||
}),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Arrange _Icons by", new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("_Name"),
|
||||
new CommandMenuItem("_Size"),
|
||||
new CommandMenuItem("_Type"),
|
||||
new CommandMenuItem("_Date modified"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Show in _groups"),
|
||||
new CommandMenuItem("_Auto arrange"),
|
||||
new CommandMenuItem("A_lign to grid")
|
||||
}),
|
||||
new CommandMenuItem("_Refresh"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("_Paste"),
|
||||
new CommandMenuItem("Paste _shortcut"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Ne_w", new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("_Folder"),
|
||||
new CommandMenuItem("_Shortcut"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Briefcase"),
|
||||
new CommandMenuItem("Bitmap image"),
|
||||
new CommandMenuItem("Formatted text document"),
|
||||
new CommandMenuItem("Plain text document"),
|
||||
new CommandMenuItem("Wave sound"),
|
||||
new CommandMenuItem("Compressed (zipped) folder")
|
||||
}),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("P_roperties")
|
||||
});
|
||||
|
||||
contextMenuSelected.Items.AddRange(new MenuItem[]
|
||||
{
|
||||
new CommandMenuItem("_Open"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Se_nd to"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Cu_t"),
|
||||
new CommandMenuItem("_Copy"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("Create _shortcut"),
|
||||
new CommandMenuItem("_Delete"),
|
||||
new CommandMenuItem("Rena_me"),
|
||||
new SeparatorMenuItem(),
|
||||
new CommandMenuItem("P_roperties")
|
||||
});
|
||||
|
||||
this.tv.BeforeContextMenu += tv_BeforeContextMenu;
|
||||
|
||||
this.tv.Columns.Add(new ListViewColumnText(tmTreeView.Columns[0], "Name"));
|
||||
this.tv.Columns.Add(new ListViewColumnText(tmTreeView.Columns[1], "Size"));
|
||||
this.tv.Columns.Add(new ListViewColumnText(tmTreeView.Columns[2], "Type"));
|
||||
@ -48,5 +113,27 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
|
||||
this.Controls.Add(this.tv, new BoxLayout.Constraints(true, true));
|
||||
}
|
||||
|
||||
void tv_BeforeContextMenu(object sender, EventArgs e)
|
||||
{
|
||||
TreeModelRow row = null;
|
||||
if (e is MouseEventArgs)
|
||||
{
|
||||
MouseEventArgs ee = (e as MouseEventArgs);
|
||||
ListViewHitTestInfo info = tv.HitTest(ee.X, ee.Y);
|
||||
if (info != null)
|
||||
row = info.Row;
|
||||
}
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
tv.ContextMenu = contextMenuSelected;
|
||||
}
|
||||
else
|
||||
{
|
||||
tv.ContextMenu = contextMenuUnselected;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user