Browse Source

Fix compiler errors in ICSharpCode.TreeView.Demo.

newNR
Daniel Grunwald 12 years ago
parent
commit
c928f88b5c
  1. 10
      src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/FileNode.cs
  2. 68
      src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/FileSystemNode.cs
  3. 16
      src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/FolderNode.cs
  4. 19
      src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/ICSharpCode.TreeView.Demo.csproj
  5. 2
      src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/Window1.xaml
  6. 13
      src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeViewItem.cs

10
src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/FileNode.cs

@ -84,10 +84,10 @@ namespace ICSharpCode.TreeView.Demo
{ {
get { return info.FullName; } get { return info.FullName; }
} }
//
public override void Paste(IDataObject data) // public override void Paste(IDataObject data)
{ // {
Parent.Paste(data); // Parent.Paste(data);
} // }
} }
} }

68
src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/FileSystemNode.cs

@ -29,42 +29,40 @@ namespace ICSharpCode.TreeView.Demo
{ {
return FullPath; return FullPath;
} }
//
public override bool CanCopy(SharpTreeNode[] nodes) // public override bool CanCopy(SharpTreeNode[] nodes)
{ // {
return true; // return true;
} // }
public override IDataObject Copy(SharpTreeNode[] nodes) public override IDataObject Copy(SharpTreeNode[] nodes)
{ {
var data = new DataObject(); var data = new DataObject();
var paths = SharpTreeNode.ActiveNodes.Cast<FileSystemNode>().Select(n => n.FullPath).ToArray(); var paths = nodes.OfType<FileSystemNode>().Select(n => n.FullPath).ToArray();
data.SetData(typeof(string[]), paths); data.SetData(typeof(string[]), paths);
return data; return data;
} }
//
public override bool CanPaste(IDataObject data) // public override bool CanPaste(IDataObject data)
// {
// return true;
// }
//
public override bool CanDelete()
{ {
return true; return true;
} }
public override bool CanDelete(SharpTreeNode[] nodes) public override void Delete()
{
return nodes.All(n => n.Parent != null);
}
public override void Delete(SharpTreeNode[] nodes)
{ {
if (MessageBox.Show("Sure?", "Delete", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { if (MessageBox.Show("Sure?", "Delete", MessageBoxButton.OKCancel) == MessageBoxResult.OK) {
DeleteCore(nodes); DeleteCore();
} }
} }
public override void DeleteCore(SharpTreeNode[] nodes) public override void DeleteCore()
{ {
foreach (var node in nodes.ToArray()) { this.Parent.Children.Remove(this);
node.Parent.Children.Remove(node);
}
} }
public override bool CanDrag(SharpTreeNode[] nodes) public override bool CanDrag(SharpTreeNode[] nodes)
@ -72,19 +70,19 @@ namespace ICSharpCode.TreeView.Demo
return true; return true;
} }
ContextMenu menu; // ContextMenu menu;
//
public override ContextMenu GetContextMenu() // public override ContextMenu GetContextMenu()
{ // {
if (menu == null) { // if (menu == null) {
menu = new ContextMenu(); // menu = new ContextMenu();
menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Cut }); // menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Cut });
menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Copy }); // menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Copy });
menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Paste }); // menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Paste });
menu.Items.Add(new Separator()); // menu.Items.Add(new Separator());
menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Delete }); // menu.Items.Add(new MenuItem() { Command = ApplicationCommands.Delete });
} // }
return menu; // return menu;
} // }
} }
} }

16
src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/FolderNode.cs

@ -59,7 +59,7 @@ namespace ICSharpCode.TreeView.Demo
get { return path; } get { return path; }
} }
public override void LoadChildren() protected override void LoadChildren()
{ {
try { try {
foreach (var p in Directory.GetDirectories(path) foreach (var p in Directory.GetDirectories(path)
@ -75,18 +75,14 @@ namespace ICSharpCode.TreeView.Demo
} }
} }
public override DropEffect CanDrop(IDataObject data, DropEffect requestedEffect) public override bool CanDrop(DragEventArgs e, int index)
{ {
var paths = data.GetData(typeof(string[])) as string[]; return e.Data.GetDataPresent(typeof(string[]));
if (paths != null) {
return requestedEffect == DropEffect.Link ? DropEffect.Move : requestedEffect;
}
return DropEffect.None;
} }
public override void Drop(IDataObject data, int index, DropEffect finalEffect) public override void Drop(DragEventArgs e, int index)
{ {
var paths = data.GetData(typeof(string[])) as string[]; var paths = e.Data.GetData(typeof(string[])) as string[];
if (paths != null) { if (paths != null) {
for (int i = 0; i < paths.Length; i++) { for (int i = 0; i < paths.Length; i++) {
var p = paths[i]; var p = paths[i];

19
src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/ICSharpCode.TreeView.Demo.csproj

@ -14,11 +14,16 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWin32Manifest>False</NoWin32Manifest>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>Full</DebugType>
<Optimize>false</Optimize> <Optimize>False</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
@ -32,6 +37,16 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>x86</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core"> <Reference Include="System.Core">

2
src/Libraries/SharpTreeView/ICSharpCode.TreeView.Demo/Window1.xaml

@ -10,7 +10,7 @@
<TextBlock DockPanel.Dock="Top" <TextBlock DockPanel.Dock="Top"
Height="70"> Height="70">
Features: MVVM (POCO variant), Multiselect, Drag and Drop (with or without order), Cut / Copy / Paste / Delete, Rename (try rename file to '?'),<LineBreak /> Features: MVVM (VM must derive from SharpTreeNode), Multiselect, Drag and Drop (with or without order), Cut / Copy / Paste / Delete, Rename (try rename file to '?'),<LineBreak />
VirtualizationMode.Recycling (by default), Root Lines, Columns (using ListView), Icon, Checkbox, ContextMenu, Lazy Loading.<LineBreak /> VirtualizationMode.Recycling (by default), Root Lines, Columns (using ListView), Icon, Checkbox, ContextMenu, Lazy Loading.<LineBreak />
<LineBreak /> <LineBreak />
<Run FontWeight="Bold">Changes does not affect real file system.</Run> <Run FontWeight="Bold">Changes does not affect real file system.</Run>

13
src/Libraries/SharpTreeView/ICSharpCode.TreeView/SharpTreeViewItem.cs

@ -33,13 +33,16 @@ namespace ICSharpCode.TreeView
{ {
switch (e.Key) { switch (e.Key) {
case Key.F2: case Key.F2:
// if (SharpTreeNode.ActiveNodes.Count == 1 && Node.IsEditable) { if (Node.IsEditable && ParentTreeView != null && ParentTreeView.SelectedItems.Count == 1 && ParentTreeView.SelectedItems[0] == Node) {
// Node.IsEditing = true; Node.IsEditing = true;
// e.Handled = true; e.Handled = true;
// } }
break; break;
case Key.Escape: case Key.Escape:
Node.IsEditing = false; if (Node.IsEditing) {
Node.IsEditing = false;
e.Handled = true;
}
break; break;
} }
} }

Loading…
Cancel
Save