Skip to content

Commit d54ac41

Browse files
SharpTreeView: Split into ILSpyX.TreeView and ILSpy.Controls.TreeView (#3240)
* Changes necessary for making SharpTreeNode cross platform by proxying System.Windows dependencies * Add ITreeNodeImagesProvider for node icons * Move InternalsVisibleTo to csproj (possible since net50) * Move view models and other xplat class for SharpTreeView to ILSpyX, Windows-dependent classes to ILSpy/Controls/TreeView * Move GetDoubleClickTime to NativeMethods
1 parent 2e7991e commit d54ac41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+308
-240
lines changed

ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
<Nullable>enable</Nullable>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<WarningsAsErrors>nullable</WarningsAsErrors>
8-
8+
99
<SignAssembly>True</SignAssembly>
1010
<AssemblyOriginatorKeyFile>..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>
11-
11+
1212
<NeutralLanguage>en-US</NeutralLanguage>
1313
<GenerateAssemblyVersionAttribute>False</GenerateAssemblyVersionAttribute>
1414
<GenerateAssemblyFileVersionAttribute>False</GenerateAssemblyFileVersionAttribute>
1515
<GenerateAssemblyInformationalVersionAttribute>False</GenerateAssemblyInformationalVersionAttribute>
1616
</PropertyGroup>
17-
17+
1818
<PropertyGroup>
1919
<PackageId>ICSharpCode.ILSpyX</PackageId>
2020
<PackageVersion>8.0.0.0-noversion</PackageVersion>
@@ -32,22 +32,27 @@
3232
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
3333
<Copyright>Copyright 2022-$([System.DateTime]::Now.Year) AlphaSierraPapa</Copyright>
3434
<PackageTags>C# Decompiler ILSpy</PackageTags>
35-
35+
3636
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
3737
<DebugType>embedded</DebugType>
3838
<DebugSymbols>true</DebugSymbols>
3939
<EmbedUntrackedSources>true</EmbedUntrackedSources>
4040
<PublishRepositoryUrl>true</PublishRepositoryUrl>
4141
</PropertyGroup>
42-
42+
43+
<ItemGroup>
44+
<InternalsVisibleTo Include="ILSpy" Key="00240000048000009400000006020000002400005253413100040000010001004dcf3979c4e902efa4dd2163a039701ed5822e6f1134d77737296abbb97bf0803083cfb2117b4f5446a217782f5c7c634f9fe1fc60b4c11d62c5b3d33545036706296d31903ddcf750875db38a8ac379512f51620bb948c94d0831125fbc5fe63707cbb93f48c1459c4d1749eb7ac5e681a2f0d6d7c60fa527a3c0b8f92b02bf" />
45+
<InternalsVisibleTo Include="ILSpy.Tests" Key="00240000048000009400000006020000002400005253413100040000010001004dcf3979c4e902efa4dd2163a039701ed5822e6f1134d77737296abbb97bf0803083cfb2117b4f5446a217782f5c7c634f9fe1fc60b4c11d62c5b3d33545036706296d31903ddcf750875db38a8ac379512f51620bb948c94d0831125fbc5fe63707cbb93f48c1459c4d1749eb7ac5e681a2f0d6d7c60fa527a3c0b8f92b02bf" />
46+
</ItemGroup>
47+
4348
<ItemGroup>
4449
<None Include="PackageReadme.md" Pack="true" PackagePath="\" />
4550
</ItemGroup>
46-
51+
4752
<ItemGroup>
4853
<Compile Remove="Properties\AssemblyInfo.template.cs" />
4954
</ItemGroup>
50-
55+
5156
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
5257
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
5358
</PropertyGroup>
@@ -77,7 +82,7 @@
7782
<ItemGroup>
7883
<ProjectReference Include="..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.csproj" />
7984
</ItemGroup>
80-
85+
8186
<Target Name="ILSpyUpdateAssemblyInfo" AfterTargets="ResolveProjectReferences">
8287
<ReadLinesFromFile ContinueOnError="true" File="..\VERSION">
8388
<Output TaskParameter="Lines" PropertyName="PackageVersion" />

ICSharpCode.ILSpyX/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,3 @@
1919

2020
[assembly: SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
2121
Justification = "AssemblyInformationalVersion does not need to be a parsable version")]
22-
23-
[assembly: InternalsVisibleTo("ILSpy, PublicKey=00240000048000009400000006020000002400005253413100040000010001004dcf3979c4e902efa4dd2163a039701ed5822e6f1134d77737296abbb97bf0803083cfb2117b4f5446a217782f5c7c634f9fe1fc60b4c11d62c5b3d33545036706296d31903ddcf750875db38a8ac379512f51620bb948c94d0831125fbc5fe63707cbb93f48c1459c4d1749eb7ac5e681a2f0d6d7c60fa527a3c0b8f92b02bf")]
24-
[assembly: InternalsVisibleTo("ILSpy.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001004dcf3979c4e902efa4dd2163a039701ed5822e6f1134d77737296abbb97bf0803083cfb2117b4f5446a217782f5c7c634f9fe1fc60b4c11d62c5b3d33545036706296d31903ddcf750875db38a8ac379512f51620bb948c94d0831125fbc5fe63707cbb93f48c1459c4d1749eb7ac5e681a2f0d6d7c60fa527a3c0b8f92b02bf")]
25-

SharpTreeView/FlatListTreeNode.cs renamed to ICSharpCode.ILSpyX/TreeView/FlatListTreeNode.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
using System.Collections.Generic;
2121
using System.Diagnostics;
2222

23-
namespace ICSharpCode.TreeView
23+
#nullable disable
24+
25+
namespace ICSharpCode.ILSpyX.TreeView
2426
{
2527
// This part of SharpTreeNode controls the 'flat list' data structure, which emulates
2628
// a big flat list containing the whole tree; allowing access by visible index.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
2+
{
3+
public interface IPlatformDataObject
4+
{
5+
bool GetDataPresent(string format);
6+
object GetData(string format);
7+
8+
void SetData(string format, object data);
9+
}
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
2+
{
3+
public interface IPlatformDragDrop
4+
{
5+
XPlatDragDropEffects DoDragDrop(object dragSource, object data, XPlatDragDropEffects allowedEffects);
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
2+
{
3+
public interface IPlatformDragEventArgs
4+
{
5+
XPlatDragDropEffects Effects { get; set; }
6+
IPlatformDataObject Data { get; }
7+
}
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
2+
{
3+
public interface IPlatformRoutedEventArgs
4+
{
5+
bool Handled { get; set; }
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
2+
{
3+
public interface ITreeNodeImagesProvider
4+
{
5+
object Assembly { get; }
6+
}
7+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
3+
namespace ICSharpCode.ILSpyX.TreeView.PlatformAbstractions
4+
{
5+
//
6+
// Summary:
7+
// Specifies the effects of a drag-and-drop operation.
8+
[Flags]
9+
public enum XPlatDragDropEffects
10+
{
11+
//
12+
// Summary:
13+
// Scrolling is about to start or is currently occurring in the drop target.
14+
Scroll = int.MinValue,
15+
//
16+
// Summary:
17+
// The data is copied, removed from the drag source, and scrolled in the drop target.
18+
All = -2147483645,
19+
//
20+
// Summary:
21+
// The drop target does not accept the data.
22+
None = 0,
23+
//
24+
// Summary:
25+
// The data is copied to the drop target.
26+
Copy = 1,
27+
//
28+
// Summary:
29+
// The data from the drag source is moved to the drop target.
30+
Move = 2,
31+
//
32+
// Summary:
33+
// The data from the drag source is linked to the drop target.
34+
Link = 4
35+
}
36+
}

SharpTreeView/SharpTreeNode.cs renamed to ICSharpCode.ILSpyX/TreeView/SharpTreeNode.cs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@
2222
using System.ComponentModel;
2323
using System.Diagnostics;
2424
using System.Linq;
25-
using System.Windows;
26-
using System.Windows.Input;
27-
using System.Windows.Media;
2825

29-
namespace ICSharpCode.TreeView
26+
#nullable disable
27+
28+
using ICSharpCode.ILSpyX.TreeView.PlatformAbstractions;
29+
30+
namespace ICSharpCode.ILSpyX.TreeView
3031
{
3132
public partial class SharpTreeNode : INotifyPropertyChanged
3233
{
34+
protected static ITreeNodeImagesProvider ImagesProvider { get; private set; }
35+
public static void SetImagesProvider(ITreeNodeImagesProvider provider) => ImagesProvider = provider;
36+
3337
SharpTreeNodeCollection modelChildren;
3438
internal SharpTreeNode modelParent;
3539
bool isVisible = true;
@@ -584,7 +588,7 @@ public virtual void DeleteCore()
584588
throw new NotSupportedException(GetType().Name + " does not support deletion");
585589
}
586590

587-
public virtual IDataObject Copy(SharpTreeNode[] nodes)
591+
public virtual IPlatformDataObject Copy(SharpTreeNode[] nodes)
588592
{
589593
throw new NotSupportedException(GetType().Name + " does not support copy/paste or drag'n'drop");
590594
}
@@ -614,25 +618,26 @@ public virtual bool CanDrag(SharpTreeNode[] nodes)
614618
return false;
615619
}
616620

617-
public virtual void StartDrag(DependencyObject dragSource, SharpTreeNode[] nodes)
621+
public virtual void StartDrag(object dragSource, SharpTreeNode[] nodes, IPlatformDragDrop dragdropManager)
618622
{
619-
DragDropEffects effects = DragDropEffects.All;
623+
XPlatDragDropEffects effects = XPlatDragDropEffects.All;
620624
if (!nodes.All(n => n.CanDelete()))
621-
effects &= ~DragDropEffects.Move;
622-
DragDropEffects result = DragDrop.DoDragDrop(dragSource, Copy(nodes), effects);
623-
if (result == DragDropEffects.Move)
625+
effects &= ~XPlatDragDropEffects.Move;
626+
627+
XPlatDragDropEffects result = dragdropManager.DoDragDrop(dragSource, Copy(nodes), effects);
628+
if (result == XPlatDragDropEffects.Move)
624629
{
625630
foreach (SharpTreeNode node in nodes)
626631
node.DeleteCore();
627632
}
628633
}
629634

630-
public virtual bool CanDrop(DragEventArgs e, int index)
635+
public virtual bool CanDrop(IPlatformDragEventArgs e, int index)
631636
{
632637
return false;
633638
}
634639

635-
internal void InternalDrop(DragEventArgs e, int index)
640+
internal void InternalDrop(IPlatformDragEventArgs e, int index)
636641
{
637642
if (LazyLoading)
638643
{
@@ -643,7 +648,7 @@ internal void InternalDrop(DragEventArgs e, int index)
643648
Drop(e, index);
644649
}
645650

646-
public virtual void Drop(DragEventArgs e, int index)
651+
public virtual void Drop(IPlatformDragEventArgs e, int index)
647652
{
648653
throw new NotSupportedException(GetType().Name + " does not support Drop()");
649654
}
@@ -703,14 +708,14 @@ public void RaisePropertyChanged(string name)
703708
/// <summary>
704709
/// Gets called when the item is double-clicked.
705710
/// </summary>
706-
public virtual void ActivateItem(RoutedEventArgs e)
711+
public virtual void ActivateItem(IPlatformRoutedEventArgs e)
707712
{
708713
}
709714

710715
/// <summary>
711716
/// Gets called when the item is clicked with the middle mouse button.
712717
/// </summary>
713-
public virtual void ActivateItemSecondary(RoutedEventArgs e)
718+
public virtual void ActivateItemSecondary(IPlatformRoutedEventArgs e)
714719
{
715720
}
716721

0 commit comments

Comments
 (0)