├── test
├── bin
│ ├── Debug
│ │ ├── test.exe
│ │ ├── test.pdb
│ │ ├── test.vshost.exe
│ │ ├── ControlTreeView.dll
│ │ └── ControlTreeView.pdb
│ └── Release
│ │ ├── test.exe
│ │ ├── test.pdb
│ │ ├── test.vshost.exe
│ │ ├── ControlTreeView.dll
│ │ ├── ControlTreeView.pdb
│ │ └── test.vshost.exe.manifest
├── obj
│ ├── Debug
│ │ ├── test.exe
│ │ ├── test.pdb
│ │ ├── test.Form1.resources
│ │ ├── test.Class1.resources
│ │ ├── test.Class2.resources
│ │ ├── test.Class3.resources
│ │ ├── test.Class4.resources
│ │ ├── ResolveAssemblyReference.cache
│ │ ├── TempPE
│ │ │ └── Class1.Designer.cs.dll
│ │ ├── test.Properties.Resources.resources
│ │ ├── test.csproj.GenerateResource.Cache
│ │ └── test.csproj.FileListAbsolute.txt
│ └── Release
│ │ ├── test.exe
│ │ ├── test.pdb
│ │ ├── test.Form1.resources
│ │ ├── test.Class1.resources
│ │ ├── test.Class2.resources
│ │ ├── test.Class3.resources
│ │ ├── test.Class4.resources
│ │ ├── test.Properties.Resources.resources
│ │ ├── test.csproj.GenerateResource.Cache
│ │ └── test.csproj.FileListAbsolute.txt
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Program.cs
├── Class2.cs
├── Class4.cs
├── Class1.cs
├── test.csproj
├── Class3.cs
├── Class1.resx
├── Class2.resx
├── Class3.resx
├── Class4.resx
├── Form1.resx
└── Form1.cs
├── ControlTreeViewLibrary.suo
├── ControlTreeView
├── Resources
│ ├── minus.bmp
│ ├── plus.bmp
│ └── TranspControl.dll
├── bin
│ ├── Debug
│ │ ├── ControlTreeView.dll
│ │ └── ControlTreeView.pdb
│ └── Release
│ │ ├── ControlTreeView.dll
│ │ └── ControlTreeView.pdb
├── obj
│ ├── Debug
│ │ ├── ControlTreeView.dll
│ │ ├── ControlTreeView.pdb
│ │ ├── CTreeView.CTreeView.resources
│ │ ├── CTreeView.NodeControl.resources
│ │ ├── TempPE
│ │ │ └── Resource.Designer.cs.dll
│ │ ├── ControlTreeView.CTreeView.resources
│ │ ├── CTreeView.csproj.GenerateResource.Cache
│ │ ├── ControlTreeView.NodeControl.resources
│ │ ├── CTreeViewLibrary.csproj.GenerateResource.Cache
│ │ ├── ControlTreeView.csproj.GenerateResource.Cache
│ │ ├── CTreeViewLibrary.csproj.FileListAbsolute.txt
│ │ ├── CTreeView.csproj.FileListAbsolute.txt
│ │ └── ControlTreeView.csproj.FileListAbsolute.txt
│ └── Release
│ │ ├── ControlTreeView.dll
│ │ ├── ControlTreeView.pdb
│ │ ├── ControlTreeView.CTreeView.resources
│ │ ├── ControlTreeView.NodeControl.resources
│ │ ├── ControlTreeView.csproj.GenerateResource.Cache
│ │ └── ControlTreeView.csproj.FileListAbsolute.txt
├── ControlTreeView.csproj.user
├── INodeControl.cs
├── CTreeViewEventArgs.cs
├── DragNodeEventArgs.cs
├── Properties
│ └── AssemblyInfo.cs
├── Other Declarations.cs
├── INodeContainer.cs
├── NodeControl.cs
├── ControlTreeView.csproj
├── ClassDiagram1.cd
├── NodeControl.resx
├── CTreeView
│ ├── CTreeView.Internal.resx
│ ├── CTreeView(T).Internal.resx
│ ├── CTreeView.Internal.cs
│ ├── CTreeView(T).Internal.cs
│ ├── CTreeView.Protected.cs
│ └── CTreeView(T).Protected.cs
├── CTreeNodeCollection
│ ├── CTreeNodeCollection.Public.cs
│ └── CTreeNodeCollection.cs
├── ClassDiagram2.cd
└── CTreeNode
│ └── CTreeNode.Internal.cs
├── README.md
├── .gitattributes
├── .gitignore
└── ControlTreeViewLibrary.sln
/test/bin/Debug/test.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Debug/test.exe
--------------------------------------------------------------------------------
/test/bin/Debug/test.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Debug/test.pdb
--------------------------------------------------------------------------------
/test/bin/Release/test.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Release/test.exe
--------------------------------------------------------------------------------
/test/bin/Release/test.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Release/test.pdb
--------------------------------------------------------------------------------
/test/obj/Debug/test.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/test.exe
--------------------------------------------------------------------------------
/test/obj/Debug/test.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/test.pdb
--------------------------------------------------------------------------------
/test/obj/Release/test.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Release/test.exe
--------------------------------------------------------------------------------
/test/obj/Release/test.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Release/test.pdb
--------------------------------------------------------------------------------
/ControlTreeViewLibrary.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeViewLibrary.suo
--------------------------------------------------------------------------------
/test/bin/Debug/test.vshost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Debug/test.vshost.exe
--------------------------------------------------------------------------------
/test/bin/Release/test.vshost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Release/test.vshost.exe
--------------------------------------------------------------------------------
/ControlTreeView/Resources/minus.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/Resources/minus.bmp
--------------------------------------------------------------------------------
/ControlTreeView/Resources/plus.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/Resources/plus.bmp
--------------------------------------------------------------------------------
/test/bin/Debug/ControlTreeView.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Debug/ControlTreeView.dll
--------------------------------------------------------------------------------
/test/bin/Debug/ControlTreeView.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Debug/ControlTreeView.pdb
--------------------------------------------------------------------------------
/test/obj/Debug/test.Form1.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/test.Form1.resources
--------------------------------------------------------------------------------
/test/bin/Release/ControlTreeView.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Release/ControlTreeView.dll
--------------------------------------------------------------------------------
/test/bin/Release/ControlTreeView.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/bin/Release/ControlTreeView.pdb
--------------------------------------------------------------------------------
/test/obj/Debug/test.Class1.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/test.Class1.resources
--------------------------------------------------------------------------------
/test/obj/Debug/test.Class2.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/test.Class2.resources
--------------------------------------------------------------------------------
/test/obj/Debug/test.Class3.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/test.Class3.resources
--------------------------------------------------------------------------------
/test/obj/Debug/test.Class4.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/test.Class4.resources
--------------------------------------------------------------------------------
/test/obj/Release/test.Form1.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Release/test.Form1.resources
--------------------------------------------------------------------------------
/test/obj/Release/test.Class1.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Release/test.Class1.resources
--------------------------------------------------------------------------------
/test/obj/Release/test.Class2.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Release/test.Class2.resources
--------------------------------------------------------------------------------
/test/obj/Release/test.Class3.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Release/test.Class3.resources
--------------------------------------------------------------------------------
/test/obj/Release/test.Class4.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Release/test.Class4.resources
--------------------------------------------------------------------------------
/ControlTreeView/Resources/TranspControl.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/Resources/TranspControl.dll
--------------------------------------------------------------------------------
/ControlTreeView/bin/Debug/ControlTreeView.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/bin/Debug/ControlTreeView.dll
--------------------------------------------------------------------------------
/ControlTreeView/bin/Debug/ControlTreeView.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/bin/Debug/ControlTreeView.pdb
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/ControlTreeView.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/ControlTreeView.dll
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/ControlTreeView.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/ControlTreeView.pdb
--------------------------------------------------------------------------------
/test/obj/Debug/ResolveAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/ResolveAssemblyReference.cache
--------------------------------------------------------------------------------
/test/obj/Debug/TempPE/Class1.Designer.cs.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/TempPE/Class1.Designer.cs.dll
--------------------------------------------------------------------------------
/ControlTreeView/bin/Release/ControlTreeView.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/bin/Release/ControlTreeView.dll
--------------------------------------------------------------------------------
/ControlTreeView/bin/Release/ControlTreeView.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/bin/Release/ControlTreeView.pdb
--------------------------------------------------------------------------------
/ControlTreeView/obj/Release/ControlTreeView.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Release/ControlTreeView.dll
--------------------------------------------------------------------------------
/ControlTreeView/obj/Release/ControlTreeView.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Release/ControlTreeView.pdb
--------------------------------------------------------------------------------
/test/obj/Debug/test.Properties.Resources.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/test.Properties.Resources.resources
--------------------------------------------------------------------------------
/test/obj/Debug/test.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Debug/test.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/test/obj/Release/test.Properties.Resources.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Release/test.Properties.Resources.resources
--------------------------------------------------------------------------------
/test/obj/Release/test.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/test/obj/Release/test.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/CTreeView.CTreeView.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/CTreeView.CTreeView.resources
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/CTreeView.NodeControl.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/CTreeView.NodeControl.resources
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/TempPE/Resource.Designer.cs.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/TempPE/Resource.Designer.cs.dll
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/ControlTreeView.CTreeView.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/ControlTreeView.CTreeView.resources
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/CTreeView.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/CTreeView.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/ControlTreeView.NodeControl.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/ControlTreeView.NodeControl.resources
--------------------------------------------------------------------------------
/ControlTreeView/obj/Release/ControlTreeView.CTreeView.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Release/ControlTreeView.CTreeView.resources
--------------------------------------------------------------------------------
/ControlTreeView/obj/Release/ControlTreeView.NodeControl.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Release/ControlTreeView.NodeControl.resources
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/CTreeViewLibrary.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/CTreeViewLibrary.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/ControlTreeView.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Debug/ControlTreeView.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/ControlTreeView/obj/Release/ControlTreeView.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Feofilakt/ControlTreeViewLibrary/HEAD/ControlTreeView/obj/Release/ControlTreeView.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/test/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ControlTreeView/ControlTreeView.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 | Program
4 | C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ControlTreeViewLibrary
2 | CTreeView is the advanced TreeView control for .NET WinForms that supports more features, different layouts and any controls in the nodes.
3 | You can see the samples, full description and instructions for use in the CodeProject article: http://www.codeproject.com/Tips/877018/TreeView-with-Controls-Supported-Org-Chart-Style.
4 | This project is published under The Code Project Open License (CPOL).
5 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/ControlTreeView/INodeControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | namespace ControlTreeView
8 | {
9 | ///
10 | /// Provides selection logic and DragAndDrop logic for the CTreeNode.Control.
11 | ///
12 | public interface INodeControl
13 | {
14 | ///
15 | /// The owner node of this control.
16 | ///
17 | CTreeNode OwnerNode { set; }
18 | }
19 | }
--------------------------------------------------------------------------------
/test/bin/Release/test.vshost.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/test/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace test
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// The main entry point for the application.
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new Form1());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear on external disk
35 | .Spotlight-V100
36 | .Trashes
37 |
38 | # Directories potentially created on remote AFP share
39 | .AppleDB
40 | .AppleDesktop
41 | Network Trash Folder
42 | Temporary Items
43 | .apdisk
44 |
--------------------------------------------------------------------------------
/ControlTreeView/CTreeViewEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ControlTreeView
7 | {
8 | public class CTreeViewEventArgs : EventArgs
9 | {
10 | ///
11 | /// Initializes a new instance of the CTreeViewEventArgs class for the specified tree node.
12 | ///
13 | /// The CTreeNode that the event is responding to.
14 | public CTreeViewEventArgs(CTreeNode node)
15 | {
16 | Node = node;
17 | }
18 |
19 | ///
20 | /// Gets the tree node that has been expanded, collapsed, or selected.
21 | ///
22 | public CTreeNode Node { get; private set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ControlTreeView/DragNodeEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 | using System.Windows.Forms;
7 |
8 | namespace ControlTreeView
9 | {
10 | public class DragNodesEventArgs : EventArgs
11 | {
12 | ///
13 | /// Initializes a new instance of the DragNodeEventArgs class.
14 | ///
15 | /// The tree nodes that the event is responding to.
16 | public DragNodesEventArgs(List nodes)
17 | {
18 | Nodes=nodes;
19 | }
20 |
21 | ///
22 | /// Gets the tree nodes that have been dragged.
23 | ///
24 | public List Nodes { get; private set; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/CTreeViewLibrary.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.dll
2 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.pdb
3 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ResolveAssemblyReference.cache
4 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\CTreeView.CTreeView.resources
5 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\CTreeView.NodeControl.resources
6 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\CTreeViewLibrary.csproj.GenerateResource.Cache
7 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.dll
8 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.pdb
9 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.XML
10 |
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/CTreeView.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | D:\IT\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.dll
2 | D:\IT\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.pdb
3 | D:\IT\ControlTreeView\ControlTreeView\obj\Debug\ResolveAssemblyReference.cache
4 | D:\IT\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.dll
5 | D:\IT\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.pdb
6 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.dll
7 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.pdb
8 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ResolveAssemblyReference.cache
9 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\CTreeView.CTreeView.resources
10 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\CTreeView.csproj.GenerateResource.Cache
11 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.dll
12 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.pdb
13 |
--------------------------------------------------------------------------------
/test/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:2.0.50727.5420
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace test.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ControlTreeViewLibrary.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlTreeView", "ControlTreeView\ControlTreeView.csproj", "{CDC9BDBF-6F7C-4F08-B9D5-396F39E85DC1}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{EBF0A50C-086A-4E46-9911-91F90B736923}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {CDC9BDBF-6F7C-4F08-B9D5-396F39E85DC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {CDC9BDBF-6F7C-4F08-B9D5-396F39E85DC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {CDC9BDBF-6F7C-4F08-B9D5-396F39E85DC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {CDC9BDBF-6F7C-4F08-B9D5-396F39E85DC1}.Release|Any CPU.Build.0 = Release|Any CPU
18 | {EBF0A50C-086A-4E46-9911-91F90B736923}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {EBF0A50C-086A-4E46-9911-91F90B736923}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {EBF0A50C-086A-4E46-9911-91F90B736923}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {EBF0A50C-086A-4E46-9911-91F90B736923}.Release|Any CPU.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("test")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("test")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("aa26f22e-2b69-4ddf-abec-d3ce1f6a2472")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ControlTreeView/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ControlTreeView")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ControlTreeView")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("387c8b48-fa0a-433f-a165-aea1018c5896")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ControlTreeView/Other Declarations.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 |
4 | namespace ControlTreeView
5 | {
6 | ///
7 | /// The draw style of CTreeView.
8 | ///
9 | public enum CTreeViewDrawStyle
10 | {
11 | LinearTree, HorizontalDiagram, VerticalDiagram
12 | }
13 |
14 | ///
15 | /// The selection mode of CTreeView.
16 | ///
17 | public enum CTreeViewSelectionMode
18 | {
19 | Multi, MultiSameParent, Single, None
20 | }
21 |
22 | ///
23 | /// The DragAndDrop mode of CTreeView.
24 | ///
25 | public enum CTreeViewDragAndDropMode
26 | {
27 | /*CopyReplaceReorder,*/ ReplaceReorder, Reorder, Nothing
28 | }
29 |
30 | ///
31 | /// The bitmaps for plus and minus buttons of nodes.
32 | ///
33 | public struct CTreeViewPlusMinus
34 | {
35 | private Bitmap _Plus;
36 | public Bitmap Plus
37 | {
38 | get { return _Plus; }
39 | }
40 |
41 | private Bitmap _Minus;
42 | public Bitmap Minus
43 | {
44 | get { return _Minus; }
45 | }
46 |
47 | private Size _Size;
48 | internal Size Size
49 | {
50 | get { return _Size; }
51 | }
52 |
53 | public CTreeViewPlusMinus(Bitmap plus, Bitmap minus)
54 | {
55 | _Size = plus.Size;
56 | if (_Size != minus.Size) throw new ArgumentException("Images are of different sizes");
57 | _Plus = plus;
58 | _Minus = minus;
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/test/Class2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using ControlTreeView;
6 | using System.Drawing;
7 |
8 | namespace test
9 | {
10 | class Class2 : NodeControl
11 | {
12 | private System.Windows.Forms.TextBox textBox2;
13 | private System.Windows.Forms.TextBox textBox1;
14 |
15 | public Class2(string text)
16 | : base()
17 | {
18 | InitializeComponent();
19 | textBox1.Text = Name = text;
20 | }
21 |
22 | private void InitializeComponent()
23 | {
24 | this.textBox1 = new System.Windows.Forms.TextBox();
25 | this.textBox2 = new System.Windows.Forms.TextBox();
26 | this.SuspendLayout();
27 | //
28 | // textBox1
29 | //
30 | this.textBox1.Location = new System.Drawing.Point(3, 3);
31 | this.textBox1.Name = "textBox1";
32 | this.textBox1.Size = new System.Drawing.Size(53, 20);
33 | this.textBox1.TabIndex = 0;
34 | //
35 | // textBox2
36 | //
37 | this.textBox2.Location = new System.Drawing.Point(3, 29);
38 | this.textBox2.Name = "textBox2";
39 | this.textBox2.Size = new System.Drawing.Size(53, 20);
40 | this.textBox2.TabIndex = 1;
41 | //
42 | // Class2
43 | //
44 | this.BackColor = System.Drawing.Color.PaleGreen;
45 | this.Controls.Add(this.textBox2);
46 | this.Controls.Add(this.textBox1);
47 | this.Name = "Class2";
48 | this.Size = new System.Drawing.Size(59, 53);
49 | this.ResumeLayout(false);
50 | this.PerformLayout();
51 |
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/test/Class4.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using ControlTreeView;
7 |
8 | namespace test
9 | {
10 | class Class4 : NodeControl
11 | {
12 | private System.Windows.Forms.CheckBox checkBox1;
13 | private System.Windows.Forms.Label label1;
14 |
15 | public Class4(string text)
16 | {
17 | InitializeComponent();
18 | this.label1.Text = text;
19 | this.label1.MouseDown += new MouseEventHandler((sender, e) => { OnMouseDown(e); });
20 | }
21 |
22 | private void InitializeComponent()
23 | {
24 | this.checkBox1 = new System.Windows.Forms.CheckBox();
25 | this.label1 = new System.Windows.Forms.Label();
26 | this.SuspendLayout();
27 | //
28 | // checkBox1
29 | //
30 | this.checkBox1.AutoSize = true;
31 | this.checkBox1.Location = new System.Drawing.Point(0, 0);
32 | this.checkBox1.Name = "checkBox1";
33 | this.checkBox1.Size = new System.Drawing.Size(15, 14);
34 | this.checkBox1.TabIndex = 0;
35 | this.checkBox1.UseVisualStyleBackColor = true;
36 | //
37 | // label1
38 | //
39 | this.label1.AutoSize = true;
40 | this.label1.Location = new System.Drawing.Point(12, 0);
41 | this.label1.Name = "label1";
42 | this.label1.Size = new System.Drawing.Size(35, 13);
43 | this.label1.TabIndex = 1;
44 | this.label1.Text = "label1";
45 | //
46 | // Class4
47 | //
48 | this.Controls.Add(this.checkBox1);
49 | this.Controls.Add(this.label1);
50 | this.Name = "Class4";
51 | this.Size = new System.Drawing.Size(75, 13);
52 | this.ResumeLayout(false);
53 | this.PerformLayout();
54 |
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ControlTreeView/INodeContainer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace ControlTreeView
8 | {
9 | ///
10 | /// The container for CTreeNodeCollection.
11 | ///
12 | public interface INodeContainer
13 | {
14 | #region Properties
15 |
16 | ///
17 | /// Gets the collection of tree nodes that are assigned to this INodeContainer.
18 | ///
19 | CTreeNodeCollection Nodes { get; }
20 |
21 | ///
22 | /// Gets the first child tree node in the tree node collection.
23 | ///
24 | CTreeNode FirstNode { get; }
25 |
26 | ///
27 | /// Gets the last child tree node in the tree node collection.
28 | ///
29 | CTreeNode LastNode { get; }
30 |
31 | ///
32 | /// Gets the TreeView that the CTreeNodeCollection of this INodeContainer is assigned to.
33 | ///
34 | CTreeView OwnerCTreeView { get; }
35 |
36 | ///
37 | /// Gets the bounds of this INodeContainer includes all child tree nodes.
38 | ///
39 | Rectangle BoundsSubtree { get; }
40 |
41 | ///
42 | /// Gets or sets the name of the INodeContainer.
43 | ///
44 | string Name { get; set; }
45 |
46 | #endregion
47 |
48 | #region Methods
49 |
50 | ///
51 | /// Expands all the tree nodes of this INodeContainer.
52 | ///
53 | void ExpandAll();
54 |
55 | ///
56 | /// Collapses all the tree nodes of this INodeContainer.
57 | ///
58 | void CollapseAll();
59 |
60 | ///
61 | /// Returns the number of child tree nodes.
62 | ///
63 | /// true if the resulting count includes all tree nodes indirectly rooted at the tree node collection; otherwise, false.
64 | /// The number of child tree nodes assigned to the CTreeNodeCollection.
65 | int GetNodeCount(bool includeSubTrees);
66 |
67 | #endregion
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/test/Class1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Drawing;
7 | using ControlTreeView;
8 |
9 | namespace test
10 | {
11 | class Class1 : NodeControl
12 | {
13 | private Button button1;
14 | private CheckBox checkBox1;
15 |
16 | public Class1(string text)
17 | : base()
18 | {
19 | InitializeComponent();
20 | button1.Text = Name = text;
21 | }
22 |
23 | private void InitializeComponent()
24 | {
25 | this.button1 = new System.Windows.Forms.Button();
26 | this.checkBox1 = new System.Windows.Forms.CheckBox();
27 | this.SuspendLayout();
28 | //
29 | // button1
30 | //
31 | this.button1.Location = new System.Drawing.Point(3, 3);
32 | this.button1.Name = "button1";
33 | this.button1.Size = new System.Drawing.Size(75, 23);
34 | this.button1.TabIndex = 0;
35 | this.button1.UseVisualStyleBackColor = true;
36 | this.button1.Click += new System.EventHandler(this.button1_Click);
37 | //
38 | // checkBox1
39 | //
40 | this.checkBox1.AutoSize = true;
41 | this.checkBox1.Location = new System.Drawing.Point(84, 8);
42 | this.checkBox1.Name = "checkBox1";
43 | this.checkBox1.Size = new System.Drawing.Size(15, 14);
44 | this.checkBox1.TabIndex = 1;
45 | this.checkBox1.UseVisualStyleBackColor = true;
46 | this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
47 | //
48 | // Class1
49 | //
50 | this.BackColor = System.Drawing.Color.PaleTurquoise;
51 | this.Controls.Add(this.checkBox1);
52 | this.Controls.Add(this.button1);
53 | this.Name = "Class1";
54 | this.Size = new System.Drawing.Size(102, 30);
55 | this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Class1_MouseClick);
56 | this.ResumeLayout(false);
57 | this.PerformLayout();
58 |
59 | }
60 |
61 | private void checkBox1_CheckedChanged(object sender, EventArgs e)
62 | {
63 | if (checkBox1.Checked) BackColor = Color.PaleGreen;
64 | else BackColor = Color.PaleTurquoise;
65 | }
66 |
67 | private void button1_Click(object sender, EventArgs e)
68 | {
69 | MessageBox.Show("Button_Click!");
70 | }
71 |
72 | private void Class1_MouseClick(object sender, MouseEventArgs e)
73 | {
74 | if (e.Button == MouseButtons.Right)
75 | {
76 |
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/test/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:2.0.50727.5420
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace test.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("test.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ControlTreeView/obj/Release/ControlTreeView.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\bin\Release\ControlTreeView.dll
2 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\bin\Release\ControlTreeView.pdb
3 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Release\ResolveAssemblyReference.cache
4 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.CTreeView.resources
5 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.NodeControl.resources
6 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.csproj.GenerateResource.Cache
7 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.dll
8 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.pdb
9 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\bin\Release\ControlTreeView.XML
10 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\ControlTreeView\bin\Release\ControlTreeView.XML
11 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\ControlTreeView\bin\Release\ControlTreeView.dll
12 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\ControlTreeView\bin\Release\ControlTreeView.pdb
13 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\ControlTreeView\obj\Release\ResolveAssemblyReference.cache
14 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.CTreeView.resources
15 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.NodeControl.resources
16 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.csproj.GenerateResource.Cache
17 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.dll
18 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.pdb
19 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\bin\Release\ControlTreeView.dll
20 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\bin\Release\ControlTreeView.pdb
21 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Release\ResolveAssemblyReference.cache
22 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.CTreeView.resources
23 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.NodeControl.resources
24 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.csproj.GenerateResource.Cache
25 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.dll
26 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Release\ControlTreeView.pdb
27 |
--------------------------------------------------------------------------------
/ControlTreeView/obj/Debug/ControlTreeView.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.XML
2 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.dll
3 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\bin\Debug\ControlTreeView.pdb
4 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ResolveAssemblyReference.cache
5 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.CTreeView.resources
6 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.NodeControl.resources
7 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.csproj.GenerateResource.Cache
8 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.dll
9 | C:\Users\slava\Desktop\ControlTreeView\ControlTreeView\obj\Debug\ControlTreeView.pdb
10 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\bin\Debug\ControlTreeView.dll
11 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\bin\Debug\ControlTreeView.pdb
12 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ResolveAssemblyReference.cache
13 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.CTreeView.resources
14 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.NodeControl.resources
15 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.csproj.GenerateResource.Cache
16 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.dll
17 | C:\Users\slava\Desktop\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.pdb
18 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\bin\Debug\ControlTreeView.XML
19 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\bin\Debug\ControlTreeView.dll
20 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\bin\Debug\ControlTreeView.pdb
21 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ResolveAssemblyReference.cache
22 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.CTreeView.resources
23 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.NodeControl.resources
24 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.csproj.GenerateResource.Cache
25 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.dll
26 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.pdb
27 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\ControlTreeView\bin\Debug\ControlTreeView.XML
28 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\ControlTreeView\bin\Debug\ControlTreeView.dll
29 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\ControlTreeView\bin\Debug\ControlTreeView.pdb
30 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ResolveAssemblyReference.cache
31 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.CTreeView.resources
32 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.NodeControl.resources
33 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.csproj.GenerateResource.Cache
34 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.dll
35 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\ControlTreeView\obj\Debug\ControlTreeView.pdb
36 |
--------------------------------------------------------------------------------
/test/obj/Release/test.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\bin\Release\test.exe
2 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\bin\Release\test.pdb
3 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\bin\Release\ControlTreeView.dll
4 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\bin\Release\ControlTreeView.xml
5 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\ResolveAssemblyReference.cache
6 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\test.Class1.resources
7 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\test.Class2.resources
8 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\test.Class3.resources
9 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\test.Class4.resources
10 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\test.Form1.resources
11 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\test.Properties.Resources.resources
12 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\test.csproj.GenerateResource.Cache
13 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\test.exe
14 | C:\Users\slava\Desktop\Новая папка\ControlTreeViewLibrary\test\obj\Release\test.pdb
15 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Release\test.exe
16 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Release\test.pdb
17 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Release\ControlTreeView.dll
18 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Release\ControlTreeView.pdb
19 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Release\ControlTreeView.xml
20 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\ResolveAssemblyReference.cache
21 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\test.Class1.resources
22 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\test.Class2.resources
23 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\test.Class3.resources
24 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\test.Class4.resources
25 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\test.Form1.resources
26 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\test.Properties.Resources.resources
27 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\test.csproj.GenerateResource.Cache
28 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\test.exe
29 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Release\test.pdb
30 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\test.exe
31 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\test.pdb
32 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Release\test.exe
33 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Release\test.pdb
34 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Release\ControlTreeView.dll
35 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Release\ControlTreeView.pdb
36 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Release\ControlTreeView.xml
37 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\ResolveAssemblyReference.cache
38 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\test.Class1.resources
39 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\test.Class2.resources
40 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\test.Class3.resources
41 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\test.Class4.resources
42 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\test.Form1.resources
43 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\test.Properties.Resources.resources
44 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Release\test.csproj.GenerateResource.Cache
45 |
--------------------------------------------------------------------------------
/ControlTreeView/NodeControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using System.Drawing;
4 | using System.Windows;
5 | using System.Collections.Generic;
6 |
7 | namespace ControlTreeView
8 | {
9 | ///
10 | /// Implements specific selection logic and DragAndDrop logic.
11 | ///
12 | public class NodeControl : UserControl, INodeControl
13 | {
14 | public NodeControl()
15 | {
16 | DoubleBuffered = true;
17 | }
18 |
19 | public CTreeNode OwnerNode { get; set; }
20 |
21 | ///
22 | /// Experimental property for changing control's position relative to lines
23 | ///
24 | public virtual Rectangle Area
25 | {
26 | get { return new Rectangle(Point.Empty,Size); }
27 | }
28 |
29 | private Point mouseDownPosition;
30 | private bool unselectAfterMouseUp, unselectOtherAfterMouseUp; //Flags that indicates what need to do on MouseUp
31 |
32 | ///
33 | /// Raises the MouseDown event.
34 | ///
35 | /// A MouseEventArgs that contains the event data.
36 | protected override void OnMouseDown(MouseEventArgs e)
37 | {
38 | //Set selected nodes depends on selection mode
39 | unselectAfterMouseUp =unselectOtherAfterMouseUp= false;
40 | if (OwnerNode.OwnerCTreeView.SelectionMode != CTreeViewSelectionMode.None)
41 | {
42 | if (((Control.ModifierKeys & Keys.Control) == Keys.Control)&&
43 | (OwnerNode.OwnerCTreeView.SelectionMode == CTreeViewSelectionMode.Multi ||
44 | (OwnerNode.OwnerCTreeView.SelectionMode == CTreeViewSelectionMode.MultiSameParent &&
45 | (OwnerNode.OwnerCTreeView.SelectedNodes.Count == 0 || OwnerNode.OwnerCTreeView.SelectedNodes[0].ParentNode == OwnerNode.ParentNode))))
46 | {
47 | if (!OwnerNode.IsSelected) OwnerNode.IsSelected = true;
48 | else unselectAfterMouseUp = true;
49 | }
50 | else
51 | {
52 | if (!OwnerNode.IsSelected)
53 | {
54 | OwnerNode.OwnerCTreeView.ClearSelection();
55 | OwnerNode.IsSelected = true;
56 | }
57 | else unselectOtherAfterMouseUp = true;
58 | }
59 | }
60 | //Set handlers that handle start or not start dragging
61 | mouseDownPosition = this.OwnerNode.OwnerCTreeView.PointToClient(Cursor.Position);//mouseDownPosition = e.Location;
62 | this.MouseUp += new MouseEventHandler(NotDragging);
63 | this.MouseMove += new MouseEventHandler(StartDragging);
64 |
65 | base.OnMouseDown(e);
66 | }
67 |
68 | //Start dragging if mouse was moved
69 | private void StartDragging(object sender, MouseEventArgs e)
70 | {
71 | Point movePoint = this.OwnerNode.OwnerCTreeView.PointToClient(Cursor.Position);
72 | if (Math.Abs(mouseDownPosition.X - movePoint.X) + Math.Abs(mouseDownPosition.Y - movePoint.Y) > 5)
73 | //if (Math.Abs(mouseDownPosition.X - e.Location.X) + Math.Abs(mouseDownPosition.Y - e.Location.Y)>5)
74 | {
75 | this.MouseUp -= NotDragging;
76 | this.MouseMove -= StartDragging;
77 |
78 | OwnerNode.Drag();
79 | }
80 | }
81 |
82 | //Do not start dragging if mouse was up
83 | private void NotDragging(object sender, MouseEventArgs e)
84 | {
85 | this.MouseMove -= StartDragging;
86 | this.MouseUp -= NotDragging;
87 | if (unselectAfterMouseUp)
88 | {
89 | OwnerNode.IsSelected = false;
90 | }
91 | if (unselectOtherAfterMouseUp)
92 | {
93 | List nodesToUnselect = new List(OwnerNode.OwnerCTreeView.SelectedNodes);
94 | nodesToUnselect.Remove(OwnerNode);
95 | foreach (CTreeNode node in nodesToUnselect) node.IsSelected = false;
96 | }
97 | }
98 |
99 | private void InitializeComponent()
100 | {
101 | this.SuspendLayout();
102 | //
103 | // NodeControl
104 | //
105 | this.Name = "NodeControl";
106 | this.ResumeLayout(false);
107 |
108 | }
109 | }
110 | }
--------------------------------------------------------------------------------
/ControlTreeView/ControlTreeView.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {CDC9BDBF-6F7C-4F08-B9D5-396F39E85DC1}
9 | Library
10 | Properties
11 | ControlTreeView
12 | ControlTreeView
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | bin\Debug\ControlTreeView.XML
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 | bin\Release\ControlTreeView.XML
34 |
35 |
36 |
37 |
38 | 3.5
39 |
40 |
41 |
42 |
43 |
44 | 3.5
45 |
46 |
47 | 3.5
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | Component
56 |
57 |
58 |
59 | Component
60 |
61 |
62 | Component
63 |
64 |
65 |
66 | Component
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | UserControl
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | CTreeView.Internal.cs
86 |
87 |
88 |
89 |
90 | NodeControl.cs
91 |
92 |
93 |
94 |
95 |
96 |
103 |
--------------------------------------------------------------------------------
/test/test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {EBF0A50C-086A-4E46-9911-91F90B736923}
9 | WinExe
10 | Properties
11 | test
12 | test
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | False
36 | ..\ControlTreeView\bin\Debug\ControlTreeView.dll
37 |
38 |
39 |
40 | 3.5
41 |
42 |
43 | 3.5
44 |
45 |
46 | 3.5
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | UserControl
57 |
58 |
59 | UserControl
60 |
61 |
62 | UserControl
63 |
64 |
65 | UserControl
66 |
67 |
68 | Form
69 |
70 |
71 | Form1.cs
72 |
73 |
74 |
75 |
76 | Class1.cs
77 |
78 |
79 | Class2.cs
80 |
81 |
82 | Class3.cs
83 |
84 |
85 | Class4.cs
86 |
87 |
88 | Form1.cs
89 | Designer
90 |
91 |
92 | ResXFileCodeGenerator
93 | Resources.Designer.cs
94 | Designer
95 |
96 |
97 | True
98 | Resources.resx
99 |
100 |
101 | SettingsSingleFileGenerator
102 | Settings.Designer.cs
103 |
104 |
105 | True
106 | Settings.settings
107 | True
108 |
109 |
110 |
111 |
118 |
--------------------------------------------------------------------------------
/test/Class3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using ControlTreeView;
6 | using System.Drawing;
7 |
8 | namespace test
9 | {
10 | class Class3 : NodeControl
11 | {
12 | private System.Windows.Forms.RadioButton radioButton1;
13 | private System.Windows.Forms.RadioButton radioButton2;
14 | private System.Windows.Forms.RadioButton radioButton3;
15 | private System.Windows.Forms.RadioButton radioButton4;
16 |
17 | public Class3()
18 | : base()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | private void InitializeComponent()
24 | {
25 | this.radioButton1 = new System.Windows.Forms.RadioButton();
26 | this.radioButton2 = new System.Windows.Forms.RadioButton();
27 | this.radioButton3 = new System.Windows.Forms.RadioButton();
28 | this.radioButton4 = new System.Windows.Forms.RadioButton();
29 | this.SuspendLayout();
30 | //
31 | // radioButton1
32 | //
33 | this.radioButton1.AutoSize = true;
34 | this.radioButton1.BackColor = System.Drawing.Color.Transparent;
35 | this.radioButton1.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
36 | this.radioButton1.Checked = true;
37 | this.radioButton1.Location = new System.Drawing.Point(3, 3);
38 | this.radioButton1.Name = "radioButton1";
39 | this.radioButton1.Size = new System.Drawing.Size(14, 13);
40 | this.radioButton1.TabIndex = 0;
41 | this.radioButton1.TabStop = true;
42 | this.radioButton1.UseVisualStyleBackColor = false;
43 | this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
44 | //
45 | // radioButton2
46 | //
47 | this.radioButton2.AutoSize = true;
48 | this.radioButton2.BackColor = System.Drawing.Color.Transparent;
49 | this.radioButton2.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
50 | this.radioButton2.Location = new System.Drawing.Point(3, 33);
51 | this.radioButton2.Name = "radioButton2";
52 | this.radioButton2.Size = new System.Drawing.Size(14, 13);
53 | this.radioButton2.TabIndex = 1;
54 | this.radioButton2.TabStop = true;
55 | this.radioButton2.UseVisualStyleBackColor = false;
56 | this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
57 | //
58 | // radioButton3
59 | //
60 | this.radioButton3.AutoSize = true;
61 | this.radioButton3.BackColor = System.Drawing.Color.Transparent;
62 | this.radioButton3.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
63 | this.radioButton3.Location = new System.Drawing.Point(36, 3);
64 | this.radioButton3.Name = "radioButton3";
65 | this.radioButton3.Size = new System.Drawing.Size(14, 13);
66 | this.radioButton3.TabIndex = 2;
67 | this.radioButton3.TabStop = true;
68 | this.radioButton3.UseVisualStyleBackColor = false;
69 | this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
70 | //
71 | // radioButton4
72 | //
73 | this.radioButton4.AutoSize = true;
74 | this.radioButton4.BackColor = System.Drawing.Color.Transparent;
75 | this.radioButton4.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
76 | this.radioButton4.Location = new System.Drawing.Point(36, 33);
77 | this.radioButton4.Name = "radioButton4";
78 | this.radioButton4.Size = new System.Drawing.Size(14, 13);
79 | this.radioButton4.TabIndex = 3;
80 | this.radioButton4.TabStop = true;
81 | this.radioButton4.UseVisualStyleBackColor = false;
82 | this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
83 | //
84 | // Class3
85 | //
86 | this.BackColor = System.Drawing.Color.LightSteelBlue;
87 | this.Controls.Add(this.radioButton2);
88 | this.Controls.Add(this.radioButton1);
89 | this.Controls.Add(this.radioButton3);
90 | this.Controls.Add(this.radioButton4);
91 | this.Name = "Class3";
92 | this.Size = new System.Drawing.Size(53, 49);
93 | this.ResumeLayout(false);
94 | this.PerformLayout();
95 |
96 | }
97 |
98 | private void radioButton1_CheckedChanged(object sender, EventArgs e)
99 | {
100 | if (radioButton1.Checked) BackColor = Color.LightSteelBlue;
101 | }
102 |
103 | private void radioButton4_CheckedChanged(object sender, EventArgs e)
104 | {
105 | if (radioButton4.Checked) BackColor = Color.LightGoldenrodYellow;
106 | }
107 |
108 | private void radioButton3_CheckedChanged(object sender, EventArgs e)
109 | {
110 | if (radioButton3.Checked) BackColor = Color.LightPink;
111 | }
112 |
113 | private void radioButton2_CheckedChanged(object sender, EventArgs e)
114 | {
115 | if (radioButton2.Checked) BackColor = Color.LightCoral;
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/ControlTreeView/ClassDiagram1.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | CTreeNode\CTreeNode.Internal.cs
20 |
21 |
22 |
23 |
24 | CTreeNode\CTreeNode.Internal.cs
25 |
26 |
27 |
28 |
29 | XQBgiQQFAAJrkAAAgAIEQASAAAAICRALBiEAAARwAgA=
30 | CTreeNode\CTreeNode.Internal.cs
31 |
32 |
33 |
34 |
35 |
36 |
37 | ACBAAABAAAAEhAAAiAAAAAAgQAAIICAEBAAEAAAEAAA=
38 | CTreeNodeCollection\CTreeNodeCollection.cs
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | CTreeView\CTreeView.DragDrop.cs
81 |
82 |
83 |
84 |
85 | WJqwSQIAtCBKAAARgGAOBQIGAhqJmUFKOJACBAEAEtE=
86 | CTreeView\CTreeView.DragDrop.cs
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAA=
97 | CTreeViewEventArgs.cs
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | AAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
107 | DragNodeEventArgs.cs
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 | ACAAAAAAAAAggAAAAAAAAAIBAAAAAAAAACAAAAAAAAA=
124 | Other Declarations.cs
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/test/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/test/Class1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/test/Class2.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/test/Class3.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/test/Class4.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/test/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/ControlTreeView/NodeControl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/test/obj/Debug/test.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | D:\IT\ControlTreeView\test\obj\Debug\ResolveAssemblyReference.cache
2 | D:\IT\ControlTreeView\test\obj\Debug\test.Class1.resources
3 | D:\IT\ControlTreeView\test\obj\Debug\test.Form1.resources
4 | D:\IT\ControlTreeView\test\obj\Debug\test.Properties.Resources.resources
5 | D:\IT\ControlTreeView\test\obj\Debug\test.csproj.GenerateResource.Cache
6 | D:\IT\ControlTreeView\test\bin\Debug\test.exe
7 | D:\IT\ControlTreeView\test\bin\Debug\test.pdb
8 | D:\IT\ControlTreeView\test\bin\Debug\ControlTreeView.dll
9 | D:\IT\ControlTreeView\test\bin\Debug\ControlTreeView.pdb
10 | D:\IT\ControlTreeView\test\obj\Debug\test.exe
11 | D:\IT\ControlTreeView\test\obj\Debug\test.pdb
12 | C:\Users\slava\Desktop\ControlTreeView\test\bin\Debug\test.exe
13 | C:\Users\slava\Desktop\ControlTreeView\test\bin\Debug\test.pdb
14 | C:\Users\slava\Desktop\ControlTreeView\test\bin\Debug\ControlTreeView.dll
15 | C:\Users\slava\Desktop\ControlTreeView\test\bin\Debug\ControlTreeView.pdb
16 | C:\Users\slava\Desktop\ControlTreeView\test\bin\Debug\ControlTreeView.xml
17 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\ResolveAssemblyReference.cache
18 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\test.Class1.resources
19 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\test.Class2.resources
20 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\test.Class3.resources
21 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\test.Class4.resources
22 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\test.Form1.resources
23 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\test.Properties.Resources.resources
24 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\test.csproj.GenerateResource.Cache
25 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\test.exe
26 | C:\Users\slava\Desktop\ControlTreeView\test\obj\Debug\test.pdb
27 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\test.exe
28 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\ResolveAssemblyReference.cache
29 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\test.Class1.resources
30 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\test.Class2.resources
31 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\test.Class3.resources
32 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\test.Class4.resources
33 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\test.Form1.resources
34 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\test.Properties.Resources.resources
35 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\test.csproj.GenerateResource.Cache
36 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Debug\test.exe
37 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Debug\test.pdb
38 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Debug\ControlTreeView.dll
39 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Debug\ControlTreeView.pdb
40 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\bin\Debug\ControlTreeView.xml
41 | C:\Users\slava\Desktop\ControlTreeViewLibrary\test\obj\Debug\test.pdb
42 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\test.exe
43 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\test.pdb
44 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Debug\test.exe
45 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Debug\test.pdb
46 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Debug\ControlTreeView.dll
47 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Debug\ControlTreeView.pdb
48 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\bin\Debug\ControlTreeView.xml
49 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\ResolveAssemblyReference.cache
50 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\test.Class1.resources
51 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\test.Class2.resources
52 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\test.Class3.resources
53 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\test.Class4.resources
54 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\test.Form1.resources
55 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\test.Properties.Resources.resources
56 | C:\Users\slava\Desktop\Спрятанная ControlTreeViewLibrary\ControlTreeViewLibrary\test\obj\Debug\test.csproj.GenerateResource.Cache
57 | C:\Users\slava\Desktop\Hide\ControlTreeViewLibrary\test\obj\Debug\test.exe
58 | C:\Users\slava\Desktop\Hide\ControlTreeViewLibrary\test\obj\Debug\test.pdb
59 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\test.exe
60 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\test.pdb
61 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\bin\Debug\test.exe
62 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\bin\Debug\test.pdb
63 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\bin\Debug\ControlTreeView.dll
64 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\bin\Debug\ControlTreeView.pdb
65 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\bin\Debug\ControlTreeView.xml
66 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\ResolveAssemblyReference.cache
67 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\test.Class1.resources
68 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\test.Class2.resources
69 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\test.Class3.resources
70 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\test.Class4.resources
71 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\test.Form1.resources
72 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\test.Properties.Resources.resources
73 | C:\Users\slava\Google Диск\ControlTreeViewLibrary\test\obj\Debug\test.csproj.GenerateResource.Cache
74 |
--------------------------------------------------------------------------------
/ControlTreeView/CTreeView/CTreeView.Internal.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | False
122 |
123 |
--------------------------------------------------------------------------------
/ControlTreeView/CTreeView/CTreeView(T).Internal.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | False
122 |
123 |
--------------------------------------------------------------------------------
/ControlTreeView/CTreeNodeCollection/CTreeNodeCollection.Public.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace ControlTreeView
8 | {
9 | ///
10 | /// Represents a collection of CTreeNode objects.
11 | ///
12 | public partial class CTreeNodeCollection : Collection
13 | {
14 | ///
15 | /// Apply action to each node in CTreeNodeCollection and recursively to child nodes.
16 | ///
17 | /// Action will be applied to the nodes.
18 | public void TraverseNodes(Action action)
19 | {
20 | foreach (CTreeNode childNode in this) childNode.TraverseNodes(action);
21 | }
22 |
23 | ///
24 | /// Apply action to each node in CTreeNodeCollection and recursively to child nodes until the condition is true.
25 | ///
26 | /// Condition that must be satisfied node.
27 | /// Action will be applied to the nodes.
28 | public void TraverseNodes(Func condition, Action action)
29 | {
30 | foreach (CTreeNode childNode in this) childNode.TraverseNodes(condition, action);
31 | }
32 |
33 | ///
34 | /// Adds an array of previously created tree nodes to the collection.
35 | ///
36 | /// An array of CTreeNode objects representing the tree nodes to add to the collection.
37 | /// Nodes is null.
38 | public virtual void AddRange(CTreeNode[] nodes)
39 | {
40 | if (nodes == null) throw new ArgumentNullException("Nodes is null.");
41 | BeginUpdateCTreeView();
42 | foreach (CTreeNode node in nodes) Add(node);
43 | EndUpdateCTreeView();
44 | }
45 |
46 | ///
47 | /// Inserts an array of previously created tree nodes to the collection at the specific position.
48 | ///
49 | /// The zero-based index at which nodes should be inserted.
50 | /// An array of CTreeNode objects representing the tree nodes to add to the collection.
51 | public virtual void InsertRange(int index, CTreeNode[] nodes)
52 | {
53 | if (nodes == null) throw new ArgumentNullException("Nodes is null.");
54 | BeginUpdateCTreeView();
55 | foreach (CTreeNode node in nodes) Insert(index++, node);
56 | EndUpdateCTreeView();
57 | }
58 |
59 | //public virtual void RemoveRange(CTreeNode[] nodes)
60 | //{
61 | // if (nodes == null) throw new ArgumentNullException("Nodes is null.");
62 | // BeginUpdateCTreeView();
63 | // foreach (CTreeNode node in nodes) Remove(node);
64 | // EndUpdateCTreeView();
65 | //}
66 |
67 | ///
68 | /// Gets the tree node with the specified key from the collection.
69 | ///
70 | /// The name of the CTreeNode to retrieve from the collection.
71 | /// The CTreeNode with the specified key.
72 | public virtual CTreeNode this[string key]
73 | {
74 | get
75 | {
76 | foreach (CTreeNode node in this)
77 | {
78 | if (node.Name == key) return node;
79 | }
80 | return null;
81 | }
82 | }
83 |
84 | ///
85 | /// Finds the tree nodes with specified key, optionally searching subnodes.
86 | ///
87 | /// The name of the tree node to search for.
88 | /// true to search child nodes of tree nodes; otherwise, false.
89 | /// An array of CTreeNode objects whose Name property matches the specified key.
90 | public CTreeNode[] Find(string key, bool searchAllChildren)
91 | {
92 | if (key == null || key == "") return new CTreeNode[0];
93 | List foundNodes = new List();
94 | if (searchAllChildren)
95 | {
96 | TraverseNodes(node => { if (node.Name == key) foundNodes.Add(node); });
97 | }
98 | else
99 | {
100 | foreach (CTreeNode node in this) if (node.Name == key) foundNodes.Add(node);
101 | }
102 | return foundNodes.ToArray();
103 | }
104 |
105 | ///
106 | /// Removes the tree node with the specified key from the collection.
107 | ///
108 | /// The name of the tree node to remove from the collection.
109 | public virtual void RemoveByKey(string key)
110 | {
111 | foreach (CTreeNode node in Find(key, false)) Remove(node);
112 | // or
113 | // Remove(this[key]);
114 | // ?
115 | }
116 |
117 | ///
118 | /// Returns the index of the first occurrence of a tree node with the specified key.
119 | ///
120 | /// The name of the tree node to search for.
121 | /// The zero-based index of the first occurrence of a tree node with the specified key, if found; otherwise, -1.
122 | public virtual int IndexOfKey(string key)
123 | {
124 | return IndexOf(this[key]);
125 | }
126 |
127 | ///
128 | /// Determines whether the collection contains a tree node with the specified key.
129 | ///
130 | /// The name of the CTreeNode to search for.
131 | /// true to indicate the collection contains a CTreeNode with the specified key; otherwise, false.
132 | public virtual bool ContainsKey(string key)
133 | {
134 | foreach (CTreeNode node in this)
135 | {
136 | if (node.Name == key) return true;
137 | }
138 | return false;
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/ControlTreeView/CTreeNodeCollection/CTreeNodeCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.ObjectModel;
3 | using System.Drawing;
4 | using System.Drawing.Drawing2D;
5 | using System.Collections.Generic;
6 |
7 | namespace ControlTreeView
8 | {
9 | public partial class CTreeNodeCollection
10 | {
11 | private INodeContainer owner;
12 |
13 | ///
14 | /// Create a new instanse of CTreeNodeCollection assigned to specified owner.
15 | ///
16 | /// CTreeNode or CTreeView.
17 | internal CTreeNodeCollection(INodeContainer owner)
18 | {
19 | this.owner = owner;
20 | }
21 |
22 | ///
23 | /// Gets the parent CTreeView that this collection is assigned to.
24 | ///
25 | internal CTreeView ParentCTreeView
26 | {
27 | get { return owner.OwnerCTreeView; }
28 | }
29 |
30 | private void BeginUpdateCTreeView()
31 | {
32 | if (ParentCTreeView != null) ParentCTreeView.BeginUpdate();
33 | }
34 |
35 | private void EndUpdateCTreeView()
36 | {
37 | if (ParentCTreeView != null) ParentCTreeView.EndUpdate();
38 | }
39 |
40 | ///
41 | /// Inserts an element into the Collection at the specified index.
42 | ///
43 | /// The zero-based index at which item should be inserted.
44 | /// The object to insert. The value can be null for reference types.
45 | protected override void InsertItem(int index, CTreeNode item)
46 | {
47 | if (item.Parent != null)
48 | {
49 | throw new ArgumentException("The node is currently assigned to INodeContainer.");//item.OwnerCollection.Remove(item);
50 | }
51 | else
52 | {
53 | base.InsertItem(index, item);
54 | //item.OwnerCollection = this;
55 | if (owner is CTreeNode)
56 | {
57 | CTreeNode ownerNode = (CTreeNode)owner;
58 | item.ParentNode = ownerNode;
59 | item.Level = ownerNode.Level + 1;
60 | if (!(ownerNode.IsExpanded && ownerNode.Visible)) item.Visible = false;
61 | }
62 | if (ParentCTreeView != null)
63 | {
64 | item.OwnerCTreeView = ParentCTreeView;
65 | ParentCTreeView.SuspendLayout();
66 | item.TraverseNodes(node => { ParentCTreeView.Controls.Add(node.Control); });
67 | ParentCTreeView.ResumeLayout(false);
68 | ParentCTreeView.Recalculate();
69 | }
70 | }
71 | }
72 |
73 | ///
74 | /// Removes the element at the specified index of the Collection.
75 | ///
76 | /// The zero-based index of the element to remove.
77 | protected override void RemoveItem(int index)
78 | {
79 | //CTreeNode removedNode = this[index];
80 | this[index].IsSelected = false;
81 | this[index].ParentNode = null;
82 | //this[index].OwnerCollection = null;
83 | if (ParentCTreeView != null)
84 | {
85 | ParentCTreeView.SuspendLayout();
86 | this[index].TraverseNodes(eachNode => { ParentCTreeView.Controls.Remove(eachNode.Control); });
87 | ParentCTreeView.ResumeLayout(false);
88 | this[index].OwnerCTreeView = null;
89 | }
90 | this[index].Level = 0;
91 | this[index].Visible = true;
92 |
93 | base.RemoveItem(index);
94 | if (ParentCTreeView != null)
95 | {
96 | ParentCTreeView.Recalculate();
97 | }
98 | }
99 |
100 | ///
101 | /// Replaces the element at the specified index.
102 | ///
103 | /// The zero-based index of the element to replace.
104 | /// The new value for the element at the specified index. The value can be null for reference types.
105 | protected override void SetItem(int index, CTreeNode item)
106 | {
107 | //CTreeView.SuspendLayout();
108 | BeginUpdateCTreeView();
109 | RemoveItem(index);//?
110 | InsertItem(index, item);//?
111 | //base.SetItem(index, item);
112 | EndUpdateCTreeView();
113 | //CTreeView.ResumeLayout(false);
114 | }
115 |
116 | ///
117 | /// Removes all elements from the Collection.
118 | ///
119 | protected override void ClearItems()
120 | {
121 | BeginUpdateCTreeView();
122 | foreach (CTreeNode childNode in this)
123 | {
124 | childNode.IsSelected = false;
125 | childNode.ParentNode = null;
126 | //childNode.OwnerCollection = null;
127 | childNode.Level = 0;
128 | childNode.Visible = true;
129 | }
130 | if (ParentCTreeView != null)
131 | {
132 | ParentCTreeView.SuspendLayout();
133 | foreach (CTreeNode childNode in this)
134 | {
135 | childNode.TraverseNodes(eachNode => { ParentCTreeView.Controls.Remove(eachNode.Control); });
136 | childNode.OwnerCTreeView = null;
137 | }
138 | ParentCTreeView.ResumeLayout(false);
139 | ParentCTreeView.Recalculate();//?
140 | }
141 | base.ClearItems();
142 | EndUpdateCTreeView();
143 | }
144 |
145 | ///
146 | /// Get the list includes common line and lines for nodes of this CTreeNodeCollection.
147 | ///
148 | /// Function that calculates common line of nodes collection.
149 | /// Function that calculates line of each node in collection.
150 | /// List of lines of this nodes collection.
151 | internal List GetLines(Func commonLineCalc, Func childLineCalc)
152 | {
153 | List lines = new List();
154 | if (Count > 1) lines.Add(commonLineCalc(this));
155 | foreach (CTreeNode childNode in this) lines.Add(childLineCalc(childNode));
156 | return lines;
157 | }
158 | }
159 | }
--------------------------------------------------------------------------------
/test/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using ControlTreeView;
10 | using System.Collections;
11 | using System.Drawing.Drawing2D;
12 |
13 | namespace test
14 | {
15 | public partial class Form1 : Form
16 | {
17 | Button b = new Button();
18 | public Form1()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | private void radioButtons_CheckedChanged(object sender, EventArgs e)
24 | {
25 | if (radioButton1.Checked) cTreeView1.DrawStyle = CTreeViewDrawStyle.LinearTree;
26 | else if (radioButton2.Checked) cTreeView1.DrawStyle = CTreeViewDrawStyle.HorizontalDiagram;
27 | else if (radioButton3.Checked) cTreeView1.DrawStyle = CTreeViewDrawStyle.VerticalDiagram;
28 | }
29 |
30 | private void radioButton6_CheckedChanged(object sender, EventArgs e)
31 | {
32 | if (radioButton6.Checked) cTreeView1.ShowLines=true;
33 | else if (radioButton7.Checked) cTreeView1.ShowLines = false;
34 | }
35 |
36 | private void radioButton9_CheckedChanged(object sender, EventArgs e)
37 | {
38 | if (radioButton9.Checked) cTreeView1.ShowRootLines = true;
39 | else if (radioButton8.Checked) cTreeView1.ShowRootLines = false;
40 | }
41 |
42 | private void radioButton11_CheckedChanged(object sender, EventArgs e)
43 | {
44 | if (radioButton11.Checked) cTreeView1.ShowPlusMinus = true;
45 | else if (radioButton10.Checked) cTreeView1.ShowPlusMinus = false;
46 | }
47 |
48 | private void radioButton13_CheckedChanged(object sender, EventArgs e)
49 | {
50 | if (radioButton13.Checked) cTreeView1.MinimizeCollapsed = true;
51 | else if (radioButton12.Checked) cTreeView1.MinimizeCollapsed = false;
52 | }
53 |
54 | private void Form1_Load(object sender, EventArgs e)
55 | {
56 | cTreeView2.BeginUpdate();
57 | cTreeView2.Nodes.Add(new CTreeNode(new Class4("root")));
58 | for (int i = 0; i < 2; i++)
59 | {
60 | cTreeView2.Nodes[0].Nodes.Add(new CTreeNode(new Class4("child " + i)));
61 | for (int j = 0; j < 3; j++)
62 | {
63 | cTreeView2.Nodes[0].Nodes[i].Nodes.Add(new CTreeNode(new Class4("child " + i + "-" + j)));
64 | for (int k = 0; k < 3; k++)
65 | {
66 | cTreeView2.Nodes[0].Nodes[i].Nodes[j].Nodes.Add(new CTreeNode(new Class4("child " + i + "-" + j + "-" + k)));
67 | }
68 | }
69 | }
70 | cTreeView2.EndUpdate();
71 |
72 | cTreeView3.BeginUpdate();
73 | cTreeView3.Nodes.Add(new CTreeNode("",new Class1("")));
74 | cTreeView3.Nodes.Add(new CTreeNode("",new Class3()));
75 | cTreeView3.Nodes[1].Nodes.Add(new CTreeNode("",new Class1("")));
76 | CTreeNode n1 = new CTreeNode("",new Class1(""));
77 | n1.Nodes.Add(new CTreeNode("",new Class1("")));
78 | n1.Nodes.Add(new CTreeNode("",new Class2("")));
79 | cTreeView3.Nodes[0].Nodes.Add(n1);
80 | cTreeView3.Nodes[0].Nodes.Add(new CTreeNode("",new Class2("")));
81 | cTreeView3.Nodes[0].Nodes[1].Nodes.Add(new CTreeNode("",new Class1("")));
82 | cTreeView3.Nodes[0].Nodes[1].Nodes.Add(new CTreeNode("",new Class1("")));
83 | cTreeView3.Nodes[0].Nodes[1].Nodes.Add(new CTreeNode("",new Class1("")));
84 | cTreeView3.EndUpdate();
85 |
86 | cTreeView1.BeginUpdate();
87 | cTreeView1.Nodes.Add(new CTreeNode(new Button()));
88 | ((Button)cTreeView1.Nodes[0].Control).Text = "button";
89 | ((Button)cTreeView1.Nodes[0].Control).MouseClick += new MouseEventHandler((sender1, e1) => { MessageBox.Show("MouseClick!"); });
90 | cTreeView1.Nodes.Add(new CTreeNode(new CheckBox()));
91 | ((CheckBox)cTreeView1.Nodes[1].Control).Checked = true;
92 | ((CheckBox)cTreeView1.Nodes[1].Control).Width = 15;
93 | cTreeView1.Nodes[0].Nodes.Add(new CTreeNode(new ComboBox()));
94 | ((ComboBox)cTreeView1.Nodes[0].Nodes[0].Control).Items.AddRange(new string[] { "1", "2", "3"});
95 | cTreeView1.Nodes[0].Nodes.Add(new CTreeNode(new RadioButton()));
96 | ((RadioButton)cTreeView1.Nodes[0].Nodes[1].Control).Width = 15;
97 | ((RadioButton)cTreeView1.Nodes[0].Nodes[1].Control).Checked = true;
98 | cTreeView1.Nodes[0].Nodes[1].Nodes.Add(new CTreeNode(new ProgressBar()));
99 | ((ProgressBar)cTreeView1.Nodes[0].Nodes[1].Nodes[0].Control).Value = 20;
100 | cTreeView1.Nodes[1].Nodes.Add(new CTreeNode(new TextBox()));
101 | ((TextBox)cTreeView1.Nodes[1].Nodes[0].Control).Text = "text box";
102 | cTreeView1.Nodes[1].Nodes.Add(new CTreeNode(new ListBox()));
103 | ((ListBox)cTreeView1.Nodes[1].Nodes[1].Control).Items.AddRange(new string[] { "1", "2", "3", "4","5","6","7","8" });
104 | cTreeView1.Nodes[1].Nodes[1].Nodes.Add(new CTreeNode(new DataGridView()));
105 | ((DataGridView)cTreeView1.Nodes[1].Nodes[1].Nodes[0].Control).Columns.Add("1", "1");
106 | ((DataGridView)cTreeView1.Nodes[1].Nodes[1].Nodes[0].Control).Columns.Add("2", "2");
107 | ((DataGridView)cTreeView1.Nodes[1].Nodes[1].Nodes[0].Control).Rows.Add(new string[] { "a", "b" });
108 | cTreeView1.EndUpdate();
109 | }
110 |
111 | private void cTreeView3_AfterSelect(object sender, CTreeViewEventArgs e)
112 | {
113 | propertyGrid1.SelectedObjects = cTreeView3.SelectedNodes.ToArray();
114 | }
115 |
116 | private void cTreeView3_MouseDown(object sender, MouseEventArgs e)
117 | {
118 | if (cTreeView3.SelectedNodes.Count==0) propertyGrid1.SelectedObject = cTreeView3;
119 | }
120 |
121 | private void checkBox1_CheckedChanged(object sender, EventArgs e)
122 | {
123 | if (checkBox1.Checked) propertyGrid1.BrowsableAttributes = new AttributeCollection();
124 | else propertyGrid1.BrowsableAttributes = new AttributeCollection(BrowsableAttribute.Yes);
125 | }
126 |
127 | private void button1_Click(object sender, EventArgs e)
128 | {
129 | NodeControl c = null;
130 | if (radioButton4.Checked) c = new Class1("new node");
131 | if (radioButton5.Checked) c = new Class2("new node");
132 | if (radioButton14.Checked) c = new Class3();
133 | if (cTreeView3.SelectedNodes.Count == 0) cTreeView3.Nodes.Add(new CTreeNode(c));
134 | else if (cTreeView3.SelectedNodes.Count == 1) cTreeView3.SelectedNodes[0].Nodes.Add(new CTreeNode(c));
135 | }
136 |
137 | private void button2_Click(object sender, EventArgs e)
138 | {
139 | int count = cTreeView3.SelectedNodes.Count;
140 | while (count > 0)
141 | {
142 | if (cTreeView3.SelectedNodes[0].Parent != null) cTreeView3.SelectedNodes[0].Parent.Nodes.Remove(cTreeView3.SelectedNodes[0]);
143 | else cTreeView3.Nodes.Remove(cTreeView3.SelectedNodes[0]);
144 | count--;
145 | }
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/ControlTreeView/ClassDiagram2.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | CTreeView\CTreeView.DragDrop.cs
62 |
63 |
64 |
65 |
66 | WJqwSQIAtCBKAAARgGAOBQIGAhqJmUFKOJACBAEAEtE=
67 | CTreeView\CTreeView.DragDrop.cs
68 |
69 |
70 |
71 |
72 |
73 |
74 | AAACAAQAAAAAAAAAAAAAAAACACAAIAAAIAAQAQACAAA=
75 | NodeControl.cs
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | CTreeNode\CTreeNode.Internal.cs
132 |
133 |
134 |
135 |
136 | CTreeNode\CTreeNode.Internal.cs
137 |
138 |
139 |
140 |
141 | XQBgiQQFAAJrkAAAgAIEQASAAAAICRALBiEAAARwAgA=
142 | CTreeNode\CTreeNode.Internal.cs
143 |
144 |
145 |
146 |
147 |
148 |
149 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAA=
150 | INodeControl.cs
151 |
152 |
153 |
154 |
155 |
156 | UAAgCAAAAABCAAAAAAAAAAQAAAAACQAAAAAAAAAAAAA=
157 | INodeContainer.cs
158 |
159 |
160 |
161 |
162 |
163 | AAAAAAAAAAEAAAAAAAAAAAAAAAAAAQAAAAAAAAAEAAA=
164 | Other Declarations.cs
165 |
166 |
167 |
168 |
169 |
170 | AAAAAAAAAAAAAAAAAAAAAACAAAIAgAAAAAAAAAEAAAA=
171 | Other Declarations.cs
172 |
173 |
174 |
175 |
176 |
177 | ACAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAIAAA=
178 | Other Declarations.cs
179 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/ControlTreeView/CTreeNode/CTreeNode.Internal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 |
5 | namespace ControlTreeView
6 | {
7 | public partial class CTreeNode
8 | {
9 | #region Properties
10 |
11 | private Point _location;
12 | ///
13 | /// The location of this node.
14 | ///
15 | internal Point Location
16 | {
17 | get
18 | {
19 | return _location;
20 | }
21 | set{_location = value;}
22 | }
23 |
24 | //private Size _size;
25 | ///
26 | /// The size of this node.
27 | ///
28 | internal Size Size
29 | {
30 | get
31 | {
32 | if (Control is NodeControl) return ((NodeControl)Control).Area.Size;
33 | else return Control.Size;
34 | }
35 | //set { _size = value; }
36 | }
37 |
38 | ///
39 | /// The list of lines for this node.
40 | ///
41 | internal List Lines { get; set; }
42 | internal struct Line
43 | {
44 | internal Line(Point p1, Point p2)
45 | {
46 | Point1 = p1;
47 | Point2 = p2;
48 | }
49 | internal Point Point1;
50 | internal Point Point2;
51 | }
52 |
53 | ///
54 | /// The plus-sign (+) or minus-sign (-) button's area for this node.
55 | ///
56 | internal NodePlusMinus PlusMinus { get; set; }
57 | internal class NodePlusMinus
58 | {
59 | private const int MinCursorDistance = 3;
60 | private Rectangle underMouseArea;
61 | internal Point Location { get; private set; }
62 | internal NodePlusMinus(Rectangle plusMinusArea)
63 | {
64 | Location = plusMinusArea.Location;
65 | underMouseArea = plusMinusArea;
66 | underMouseArea.Inflate(MinCursorDistance, MinCursorDistance);
67 | }
68 | internal bool IsUnderMouse(Point cursorLocation)
69 | {
70 | if (underMouseArea.Contains(cursorLocation)) return true;
71 | else return false;
72 | }
73 | }
74 | #endregion
75 |
76 | #region Methods
77 |
78 | ///
79 | /// Calculate locations of this node and all child nodes for the CTreeViewDrawStyle.LinearTree.
80 | ///
81 | ///
82 | ///
83 | internal Point NextLocation(Point currentLocation)
84 | {
85 | if (Visible || !OwnerCTreeView.MinimizeCollapsed)
86 | {
87 | Location = currentLocation;
88 | currentLocation.Offset(OwnerCTreeView.IndentDepth, Control.Height + OwnerCTreeView.IndentWidth);
89 | foreach (CTreeNode child in Nodes)
90 | {
91 | currentLocation.Y = child.NextLocation(currentLocation).Y;
92 | }
93 | }
94 | return currentLocation;
95 | }
96 |
97 | ///
98 | /// Calculate locations of this node and all child nodes for the CTreeViewDrawStyle.HorizontalDiagram.
99 | ///
100 | ///
101 | ///
102 | ///
103 | internal int NextYMax(int currentX, int currentYMax)
104 | {
105 | int nextYMax = currentYMax;
106 | if (Nodes.Count > 0 && (IsExpanded || !OwnerCTreeView.MinimizeCollapsed))
107 | {
108 | foreach (CTreeNode child in Nodes)
109 | {
110 | nextYMax = child.NextYMax(currentX + Bounds.Width + OwnerCTreeView.IndentDepth, nextYMax);
111 | }
112 | int minY = FirstNode.Location.Y + FirstNode.Size.Height / 2;
113 | int maxY = LastNode.Location.Y + LastNode.Size.Height / 2;
114 | if (nextYMax - currentYMax - OwnerCTreeView.IndentWidth < Bounds.Height)
115 | {
116 | //
117 | }
118 | Location = new Point(currentX, (minY + maxY) / 2 - Size.Height / 2);
119 | }
120 | else
121 | {
122 | Location = new Point(currentX, nextYMax);
123 | nextYMax += Size.Height + OwnerCTreeView.IndentWidth;
124 | }
125 | return nextYMax;
126 | }
127 |
128 | ///
129 | /// Calculate locations of this node and all child nodes for the CTreeViewDrawStyle.VerticalDiagram.
130 | ///
131 | ///
132 | ///
133 | ///
134 | internal int NextXMax(int currentXMax, int currentY)
135 | {
136 | if (Nodes.Count > 0 && (IsExpanded || !OwnerCTreeView.MinimizeCollapsed))
137 | {
138 | foreach (CTreeNode child in Nodes)
139 | {
140 | currentXMax = child.NextXMax(currentXMax, currentY + Bounds.Height + OwnerCTreeView.IndentDepth);
141 | }
142 | int minX = FirstNode.Location.X + FirstNode.Size.Width / 2;
143 | int maxX = LastNode.Location.X + LastNode.Size.Width / 2;
144 | Location = new Point((minX + maxX) / 2 - Size.Width / 2, currentY);
145 | }
146 | else
147 | {
148 | Location = new Point(currentXMax, currentY);
149 | currentXMax += Size.Width + OwnerCTreeView.IndentWidth;
150 | }
151 | return currentXMax;
152 | }
153 |
154 | ///
155 | /// Calculates coordinats for PlusMinus button of this node and all child nodes.
156 | ///
157 | ///
158 | ///
159 | internal void CalculatePlusMinus(Func plusMinusCalc, bool needRootPlusMinus)
160 | {
161 | if (Visible && Nodes.Count > 0)
162 | {
163 | if (needRootPlusMinus == true)
164 | {
165 | Point locationPlusMinus = plusMinusCalc(this);
166 | locationPlusMinus.Offset(-OwnerCTreeView.PlusMinus.Size.Width / 2, -OwnerCTreeView.PlusMinus.Size.Width / 2);
167 | PlusMinus = new NodePlusMinus(new Rectangle(locationPlusMinus, OwnerCTreeView.PlusMinus.Size));
168 | }
169 | else PlusMinus = null;
170 | foreach (CTreeNode child in Nodes) child.CalculatePlusMinus(plusMinusCalc, true);
171 | }
172 | }
173 |
174 | ///
175 | /// Calculates coordinats for lines of this node and all child nodes.
176 | ///
177 | ///
178 | ///
179 | ///
180 | internal void CalculateLines(Func parentLineCalc, Func commonLineCalc, Func childLineCalc)
181 | {
182 | if (Visible && IsExpanded)
183 | {
184 | if (Nodes.Count > 0)
185 | {
186 | Lines = new List();
187 | Lines.Add(parentLineCalc(this));
188 | Lines.AddRange(Nodes.GetLines(commonLineCalc, childLineCalc));
189 | foreach (CTreeNode child in Nodes) child.CalculateLines(parentLineCalc, commonLineCalc, childLineCalc);
190 | }
191 | else Lines = null;//?
192 | }
193 | }
194 |
195 | ///
196 | /// Calculates fullBounds of this node and all child nodes.
197 | ///
198 | internal void CalculateBounds()
199 | {
200 | _boundsSubtree = new Rectangle(Location, Size);
201 | foreach (CTreeNode child in Nodes)
202 | {
203 | if (child.Visible)
204 | {
205 | child.CalculateBounds();
206 | _boundsSubtree = Rectangle.Union(child.BoundsSubtree, _boundsSubtree);
207 | }
208 | }
209 | }
210 |
211 | private void BeginUpdateCTreeView()
212 | {
213 | if (OwnerCTreeView != null) OwnerCTreeView.BeginUpdate();
214 | }
215 |
216 | private void EndUpdateCTreeView()
217 | {
218 | if (OwnerCTreeView != null) OwnerCTreeView.EndUpdate();
219 | }
220 | #endregion
221 | }
222 | }
--------------------------------------------------------------------------------
/ControlTreeView/CTreeView/CTreeView.Internal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows.Forms;
4 | using System.Drawing;
5 | using System.ComponentModel;
6 |
7 | namespace ControlTreeView
8 | {
9 | public partial class CTreeView
10 | {
11 | private int suspendUpdateCount;
12 | ///
13 | ///
14 | ///
15 | internal bool SuspendUpdate
16 | {
17 | get
18 | {
19 | if (suspendUpdateCount > 0) return true;
20 | else return false;
21 | }
22 | }
23 |
24 | ///
25 | /// The list of lines for the CTreeView.
26 | ///
27 | private List rootLines;
28 |
29 | internal void Recalculate()
30 | {
31 | if (!SuspendUpdate)
32 | {
33 | Func plusMinusCalc = null;
34 | Func parentLineCalc = null;
35 | Func commonLineCalc = null;
36 | Func childLineCalc = null;
37 | const int endLineIndent = 2;
38 | bool showRootPlusMinus = true;
39 |
40 | //Calculate Visible
41 | foreach (CTreeNode rootNode in Nodes)
42 | {
43 | rootNode.Nodes.TraverseNodes(node => { node.Visible = false; });
44 | rootNode.Nodes.TraverseNodes(node => node.ParentNode.IsExpanded, node =>
45 | {
46 | node.Visible = true;
47 | });
48 | }
49 |
50 | switch (DrawStyle)
51 | {
52 | case CTreeViewDrawStyle.LinearTree:
53 | showRootPlusMinus = ShowRootLines;
54 | Point startLocation = new Point(Padding.Left + 3, Padding.Top + 3);
55 | if (ShowRootLines) startLocation.X += IndentDepth;
56 | foreach (CTreeNode node in Nodes) startLocation.Y = node.NextLocation(startLocation).Y;
57 | plusMinusCalc = new Func(eachNode =>
58 | new Point(eachNode.Location.X - IndentDepth + 5, eachNode.Location.Y + eachNode.Bounds.Height / 2));
59 | parentLineCalc = new Func(parent => new CTreeNode.Line(
60 | new Point(parent.Location.X + 5, parent.Location.Y + parent.Bounds.Height + endLineIndent),
61 | new Point(parent.Location.X + 5, parent.FirstNode.Location.Y + parent.FirstNode.Bounds.Height / 2)));
62 | commonLineCalc = new Func(nodes => new CTreeNode.Line(
63 | new Point(nodes[0].Location.X - IndentDepth + 5, nodes[0].Location.Y + nodes[0].Bounds.Height / 2),
64 | new Point(nodes[0].Location.X - IndentDepth + 5, nodes[nodes.Count - 1].Location.Y + nodes[nodes.Count - 1].Bounds.Height / 2)));
65 | childLineCalc = new Func(child => new CTreeNode.Line(
66 | new Point(child.Location.X - IndentDepth + 5, child.Location.Y + child.Bounds.Height / 2),
67 | new Point(child.Location.X - endLineIndent, child.Location.Y + child.Bounds.Height / 2)));
68 | break;
69 |
70 | case CTreeViewDrawStyle.HorizontalDiagram:
71 | int startX = Padding.Left + 3;
72 | int startYMax = Padding.Top + 3;
73 | if (ShowRootLines) startX += IndentDepth;
74 | foreach (CTreeNode node in Nodes) startYMax = node.NextYMax(startX, startYMax);
75 | plusMinusCalc = new Func(eachNode =>
76 | new Point(eachNode.Location.X + eachNode.Bounds.Width + PlusMinus.Size.Width / 2 + 2, eachNode.Location.Y + eachNode.Bounds.Height / 2));
77 | parentLineCalc = new Func(parent => new CTreeNode.Line(
78 | new Point(parent.Location.X + parent.Bounds.Width + endLineIndent, parent.Location.Y + parent.Bounds.Height / 2),
79 | new Point(parent.Location.X + parent.Bounds.Width + IndentDepth / 2, parent.Location.Y + parent.Bounds.Height / 2)));
80 | commonLineCalc = new Func(nodes => new CTreeNode.Line(
81 | new Point(nodes[0].Location.X - IndentDepth / 2, nodes[0].Location.Y + nodes[0].Bounds.Height / 2),
82 | new Point(nodes[0].Location.X - IndentDepth / 2, nodes[nodes.Count - 1].Location.Y + nodes[nodes.Count - 1].Bounds.Height / 2)));
83 | childLineCalc = new Func(child => new CTreeNode.Line(
84 | new Point(child.Location.X - IndentDepth / 2, child.Location.Y + child.Bounds.Height / 2),
85 | new Point(child.Location.X - endLineIndent, child.Location.Y + child.Bounds.Height / 2)));
86 | break;
87 |
88 | case CTreeViewDrawStyle.VerticalDiagram:
89 | int startXMax = Padding.Left + 3;
90 | int startY = Padding.Top + 3;
91 | if (ShowRootLines) startY += IndentDepth;
92 | foreach (CTreeNode node in Nodes) startXMax = node.NextXMax(startXMax, startY);
93 | plusMinusCalc = new Func(eachNode =>
94 | new Point(eachNode.Location.X + eachNode.Bounds.Width / 2, eachNode.Location.Y + eachNode.Bounds.Height + PlusMinus.Size.Width / 2 + 2));
95 | parentLineCalc = new Func(parent => new CTreeNode.Line(
96 | new Point(parent.Location.X + parent.Bounds.Width / 2, parent.Location.Y + parent.Bounds.Height + endLineIndent),
97 | new Point(parent.Location.X + parent.Bounds.Width / 2, parent.Location.Y + parent.Bounds.Height + IndentDepth / 2)));
98 | commonLineCalc = new Func(nodes => new CTreeNode.Line(
99 | new Point(nodes[0].Location.X + nodes[0].Bounds.Width / 2, nodes[0].Location.Y - IndentDepth / 2),
100 | new Point(nodes[nodes.Count - 1].Location.X + nodes[nodes.Count - 1].Bounds.Width / 2, nodes[0].Location.Y - IndentDepth / 2)));
101 | childLineCalc = new Func(child => new CTreeNode.Line(
102 | new Point(child.Location.X + child.Bounds.Width / 2, child.Location.Y - IndentDepth / 2),
103 | new Point(child.Location.X + child.Bounds.Width / 2, child.Location.Y - endLineIndent)));
104 | break;
105 | }
106 |
107 | //Calculate PlusMinus
108 | if (ShowPlusMinus)
109 | {
110 | foreach (CTreeNode node in Nodes) node.CalculatePlusMinus(plusMinusCalc, showRootPlusMinus);
111 | }
112 |
113 | //Calculate Lines
114 | if (ShowLines)
115 | {
116 | foreach (CTreeNode node in Nodes) node.CalculateLines(parentLineCalc, commonLineCalc, childLineCalc);
117 | if (ShowRootLines) rootLines = Nodes.GetLines(commonLineCalc, childLineCalc);
118 | else rootLines = null;
119 | }
120 |
121 | //Calculate Bounds
122 | BoundsSubtree = Rectangle.Empty;
123 | foreach (CTreeNode node in Nodes)
124 | {
125 | node.CalculateBounds();
126 | BoundsSubtree = Rectangle.Union(node.BoundsSubtree, BoundsSubtree);
127 | }
128 |
129 | //Locate controls
130 | this.SuspendLayout();
131 | this.Nodes.TraverseNodes(node =>
132 | {
133 | node.Control.Visible = node.Visible;
134 | Point controlLocation = node.Location;
135 | controlLocation.Offset(AutoScrollPosition);
136 | if (node.Control is NodeControl) controlLocation.Offset(-((NodeControl)node.Control).Area.X, -((NodeControl)node.Control).Area.Y);
137 | node.Control.Location = controlLocation;
138 | });
139 | this.ResumeLayout(false);
140 |
141 | this.AutoScrollMinSize = new Size(BoundsSubtree.Width + Padding.Right, BoundsSubtree.Height + Padding.Bottom);
142 | //Invalidate();
143 | //Update();
144 | Refresh();
145 | }
146 | }
147 | }
148 | }
--------------------------------------------------------------------------------
/ControlTreeView/CTreeView/CTreeView(T).Internal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows.Forms;
4 | using System.Drawing;
5 | using System.ComponentModel;
6 |
7 | namespace CTreeView
8 | {
9 | [Designer(typeof(CTreeViewDesigner))]
10 | public partial class CTreeView : ScrollableControl,INodeContainer
11 | {
12 | ///
13 | /// The union of all child nodes bounds.
14 | ///
15 | public Rectangle BoundsSubtree { get; internal set; }
16 |
17 | private int suspendUpdateCount;
18 | ///
19 | ///
20 | ///
21 | internal bool SuspendUpdate
22 | {
23 | get
24 | {
25 | if (suspendUpdateCount > 0) return true;
26 | else return false;
27 | }
28 | }
29 |
30 | ///
31 | /// The list of lines for the CTreeView.
32 | ///
33 | private List rootLines;
34 |
35 | private DragDestination dragDestination;
36 |
37 | internal void Recalculate()
38 | {
39 | if (!SuspendUpdate)
40 | {
41 | Func plusMinusCalc = null;
42 | Func parentLineCalc = null;
43 | Func, CTreeNode.Line> commonLineCalc = null;
44 | Func childLineCalc = null;
45 | const int endLineIndent = 2;
46 | bool showRootPlusMinus = true;
47 |
48 | //Calculate Visible (may be optimized)
49 | foreach (CTreeNode rootNode in Nodes)
50 | {
51 | rootNode.Nodes.TraverseNodes(node => { node.Visible = false; });
52 | rootNode.Nodes.TraverseNodes(node => node.Parent.IsExpanded, node =>
53 | {
54 | node.Visible = true;
55 | });
56 | }
57 |
58 | switch (DrawStyle)
59 | {
60 | case CTreeViewDrawStyle.LinearTree:
61 | showRootPlusMinus = ShowRootLines;
62 | Point startLocation = new Point(Padding.Left + 3, Padding.Top + 3);
63 | if (ShowRootLines) startLocation.X += IndentDepth;
64 | foreach (CTreeNode node in Nodes) startLocation.Y = node.NextLocation(startLocation).Y;
65 | plusMinusCalc = new Func(eachNode =>
66 | new Point(eachNode.Location.X - IndentDepth + 5, eachNode.Location.Y + eachNode.Control.Height / 2));
67 | parentLineCalc = new Func(parent => new CTreeNode.Line(
68 | new Point(parent.Location.X + 5, parent.Location.Y + parent.Control.Height + endLineIndent),
69 | new Point(parent.Location.X + 5, parent.FirstNode.Location.Y + parent.FirstNode.Control.Height / 2)));
70 | commonLineCalc = new Func, CTreeNode.Line>(nodes => new CTreeNode.Line(
71 | new Point(nodes[0].Location.X - IndentDepth + 5, nodes[0].Location.Y + nodes[0].Control.Height / 2),
72 | new Point(nodes[0].Location.X - IndentDepth + 5, nodes[nodes.Count - 1].Location.Y + nodes[nodes.Count - 1].Control.Height / 2)));
73 | childLineCalc = new Func(child => new CTreeNode.Line(
74 | new Point(child.Location.X - IndentDepth + 5, child.Location.Y + child.Control.Height / 2),
75 | new Point(child.Location.X - endLineIndent, child.Location.Y + child.Control.Height / 2)));
76 | break;
77 |
78 | case CTreeViewDrawStyle.HorizontalDiagram:
79 | int startX = Padding.Left + 3;
80 | int startYMax = Padding.Top + 3;
81 | if (ShowRootLines) startX += IndentDepth;
82 | foreach (CTreeNode node in Nodes) startYMax = node.NextYMax(startX, startYMax);
83 | plusMinusCalc = new Func(eachNode =>
84 | new Point(eachNode.Location.X + eachNode.Control.Width + PlusMinus.Size.Width / 2 + 2, eachNode.Location.Y + eachNode.Control.Height / 2));
85 | parentLineCalc = new Func(parent => new CTreeNode.Line(
86 | new Point(parent.Location.X + parent.Control.Width + endLineIndent, parent.Location.Y + parent.Control.Height / 2),
87 | new Point(parent.Location.X + parent.Control.Width + IndentDepth / 2, parent.Location.Y + parent.Control.Height / 2)));
88 | commonLineCalc = new Func, CTreeNode.Line>(nodes => new CTreeNode.Line(
89 | new Point(nodes[0].Location.X - IndentDepth / 2, nodes[0].Location.Y + nodes[0].Control.Height / 2),
90 | new Point(nodes[0].Location.X - IndentDepth / 2, nodes[nodes.Count - 1].Location.Y + nodes[nodes.Count - 1].Control.Height / 2)));
91 | childLineCalc = new Func(child => new CTreeNode.Line(
92 | new Point(child.Location.X - IndentDepth / 2, child.Location.Y + child.Control.Height / 2),
93 | new Point(child.Location.X - endLineIndent, child.Location.Y + child.Control.Height / 2)));
94 | break;
95 |
96 | case CTreeViewDrawStyle.VerticalDiagram:
97 | int startXMax = Padding.Left + 3;
98 | int startY = Padding.Top + 3;
99 | if (ShowRootLines) startY += IndentDepth;
100 | foreach (CTreeNode node in Nodes) startXMax = node.NextXMax(startXMax, startY);
101 | plusMinusCalc = new Func(eachNode =>
102 | new Point(eachNode.Location.X + eachNode.Control.Width / 2, eachNode.Location.Y + eachNode.Control.Height + PlusMinus.Size.Width / 2 + 2));
103 | parentLineCalc = new Func(parent => new CTreeNode.Line(
104 | new Point(parent.Location.X + parent.Control.Width / 2, parent.Location.Y + parent.Control.Height + endLineIndent),
105 | new Point(parent.Location.X + parent.Control.Width / 2, parent.Location.Y + parent.Control.Height + IndentDepth / 2)));
106 | commonLineCalc = new Func, CTreeNode.Line>(nodes => new CTreeNode.Line(
107 | new Point(nodes[0].Location.X + nodes[0].Control.Width / 2, nodes[0].Location.Y - IndentDepth / 2),
108 | new Point(nodes[nodes.Count - 1].Location.X + nodes[nodes.Count - 1].Control.Width / 2, nodes[0].Location.Y - IndentDepth / 2)));
109 | childLineCalc = new Func(child => new CTreeNode.Line(
110 | new Point(child.Location.X + child.Control.Width / 2, child.Location.Y - IndentDepth / 2),
111 | new Point(child.Location.X + child.Control.Width / 2, child.Location.Y - endLineIndent)));
112 | break;
113 | }
114 |
115 | //Calculate PlusMinus
116 | if (ShowPlusMinus)
117 | {
118 | foreach (CTreeNode node in Nodes) node.CalculatePlusMinus(plusMinusCalc, showRootPlusMinus);
119 | }
120 |
121 | //Calculate Lines
122 | if (ShowLines)
123 | {
124 | foreach (CTreeNode node in Nodes) node.CalculateLines(parentLineCalc, commonLineCalc, childLineCalc);
125 | if (ShowRootLines) rootLines = Nodes.GetLines(commonLineCalc, childLineCalc);
126 | else rootLines = null;
127 | }
128 |
129 | //Calculate Bounds
130 | BoundsSubtree = Rectangle.Empty;
131 | foreach (CTreeNode node in Nodes)
132 | {
133 | node.CalculateBounds();
134 | BoundsSubtree = Rectangle.Union(node.BoundsSubtree, BoundsSubtree);
135 | }
136 |
137 | //Locate controls
138 | this.SuspendLayout();
139 | this.Nodes.TraverseNodes(node =>
140 | {
141 | node.Control.Visible = node.Visible;
142 | //if (node.Control.Visible == true)
143 | //{
144 | Point controlLocation = node.Location;
145 | controlLocation.Offset(AutoScrollPosition);
146 | node.Control.Location = controlLocation;
147 | //}
148 | });
149 | this.ResumeLayout(false);
150 |
151 | this.AutoScrollMinSize = new Size(BoundsSubtree.Width + Padding.Right, BoundsSubtree.Height + Padding.Bottom);
152 | //Invalidate();
153 | //Update();
154 | Refresh();
155 | }
156 | }
157 | }
158 | }
--------------------------------------------------------------------------------
/ControlTreeView/CTreeView/CTreeView.Protected.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using System.Drawing;
4 | using System.Drawing.Drawing2D;
5 | using System.ComponentModel;
6 | using System.Collections.Generic;
7 |
8 | namespace ControlTreeView
9 | {
10 | public partial class CTreeView
11 | {
12 | ///
13 | /// Gets the default size of the control.
14 | ///
15 | /// The default Size of the control.
16 | protected override Size DefaultSize
17 | {
18 | get { return new Size(100, 100); }
19 | }
20 |
21 | #region Methods
22 | ///
23 | /// Raises the CollapseNode event.
24 | ///
25 | /// A CTreeViewEventArgs that contains the event data.
26 | protected internal virtual void OnCollapseNode(CTreeViewEventArgs e)
27 | {
28 | Recalculate();
29 | if (CollapseNode != null) CollapseNode(this, e);
30 | }
31 |
32 | ///
33 | /// Raises the ExpandNode event.
34 | ///
35 | /// A CTreeViewEventArgs that contains the event data
36 | protected internal virtual void OnExpandNode(CTreeViewEventArgs e)
37 | {
38 | Recalculate();
39 | if (ExpandNode != null) ExpandNode(this, e);
40 | }
41 |
42 | ///
43 | /// Raises the SelectNode event.
44 | ///
45 | /// A CTreeViewEventArgs that contains the event data
46 | protected internal virtual void OnSelectNode(CTreeViewEventArgs e)
47 | {
48 | //ParentCTreeView.Invalidate();
49 | //ParentCTreeView.Update();
50 | OwnerCTreeView.Refresh();
51 | if (SelectNode != null) SelectNode(this, e);
52 | }
53 |
54 | ///
55 | /// Raises the DragOver event.
56 | ///
57 | /// A DragEventArgs that contains the event data.
58 | protected override void OnDragOver(DragEventArgs drgevent)
59 | {
60 | if (drgevent.Data.GetDataPresent(typeof(List)) /*&& DragAndDropMode != CTreeViewDragAndDropMode.Nothing*/)
61 | {
62 | List sourceNodes = drgevent.Data.GetData(typeof(List)) as List;
63 | Point dragPoint = this.PointToClient(new Point(drgevent.X, drgevent.Y));
64 | SetScrollDirections(
65 | VScroll && dragPoint.Y < 20,
66 | VScroll && dragPoint.Y > ClientSize.Height - 20,
67 | HScroll && dragPoint.X > ClientSize.Width - 20,
68 | HScroll && dragPoint.X < 20);
69 | dragPoint.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y);
70 | SetDragTargetPosition(dragPoint);
71 | if (sourceNodes[0].OwnerCTreeView == this)
72 | {
73 | if (/*dragDestination.Enabled &&*/ CheckValidDrop(sourceNodes)) drgevent.Effect = DragDropEffects.Move;
74 | else drgevent.Effect = DragDropEffects.None;
75 | }
76 | }
77 | base.OnDragOver(drgevent);
78 | }
79 |
80 | ///
81 | /// Raises the DragEnter event.
82 | ///
83 | /// A DragEventArgs that contains the event data.
84 | protected override void OnDragEnter(DragEventArgs drgevent)
85 | {
86 | if (drgevent.Data.GetDataPresent(typeof(List)) /*&& DragAndDropMode != CTreeViewDragAndDropMode.Nothing*/)
87 | {
88 | List sourceNodes = drgevent.Data.GetData(typeof(List)) as List;
89 | Point dragPoint = this.PointToClient(new Point(drgevent.X, drgevent.Y));
90 | SetScrollDirections(
91 | VScroll && dragPoint.Y < 20,
92 | VScroll && dragPoint.Y > ClientSize.Height - 20,
93 | HScroll && dragPoint.X > ClientSize.Width - 20,
94 | HScroll && dragPoint.X < 20);
95 | dragPoint.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y);
96 | SetDragTargetPosition(dragPoint);
97 | if (sourceNodes[0].OwnerCTreeView == this)
98 | {
99 | if (CheckValidDrop(sourceNodes)) drgevent.Effect = DragDropEffects.Move;
100 | else drgevent.Effect = DragDropEffects.None;
101 | }
102 | }
103 | base.OnDragEnter(drgevent);
104 | }
105 |
106 | ///
107 | /// Raises the DragLeave event.
108 | ///
109 | /// An EventArgs that contains the event data.
110 | protected override void OnDragLeave(EventArgs e)
111 | {
112 | /*if (DragAndDropMode != CTreeViewDragAndDropMode.Nothing)*/
113 | ResetDragTargetPosition();
114 | base.OnDragLeave(e);
115 | }
116 |
117 | ///
118 | /// Raises the DragDrop event.
119 | ///
120 | /// A DragEventArgs that contains the event data.
121 | protected override void OnDragDrop(DragEventArgs drgevent)
122 | {
123 | if (drgevent.Data.GetDataPresent(typeof(List)) /*&& DragAndDropMode != CTreeViewDragAndDropMode.Nothing*/)
124 | {
125 | List sourceNodes = drgevent.Data.GetData(typeof(List)) as List;
126 | Point dropPoint = this.PointToClient(new Point(drgevent.X, drgevent.Y));
127 | dropPoint.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y);
128 | SetDragTargetPosition(dropPoint);
129 |
130 | if (sourceNodes[0].OwnerCTreeView == this && CheckValidDrop(sourceNodes))
131 | {
132 | BeginUpdate();
133 |
134 | foreach (CTreeNode sourceNode in sourceNodes) sourceNode.Parent.Nodes.Remove(sourceNode);
135 | if (DragTargetPosition.NodeDirect != null) DragTargetPosition.NodeDirect.Nodes.AddRange(sourceNodes.ToArray());
136 | else if (DragTargetPosition.NodeBefore != null && !sourceNodes.Contains(DragTargetPosition.NodeBefore))
137 | {
138 | int index = DragTargetPosition.NodeBefore.Index + 1;
139 | DragTargetPosition.NodeBefore.Parent.Nodes.InsertRange(index, sourceNodes.ToArray());
140 | //foreach (CTreeNode sourceNode in sourceNodes) DragTargetPosition.NodeBefore.Parent.Nodes.Insert(index++, sourceNode);
141 | }
142 | else if (DragTargetPosition.NodeAfter != null && !sourceNodes.Contains(DragTargetPosition.NodeAfter))
143 | {
144 | int index = DragTargetPosition.NodeAfter.Index;
145 | DragTargetPosition.NodeAfter.Parent.Nodes.InsertRange(index, sourceNodes.ToArray());
146 | //foreach (CTreeNode sourceNode in sourceNodes) DragTargetPosition.NodeAfter.Parent.Nodes.Insert(index++, sourceNode);
147 | }
148 | EndUpdate();
149 | }
150 | //ResetDragTargetPosition();
151 | }
152 | base.OnDragDrop(drgevent);
153 | ResetDragTargetPosition();
154 | }
155 |
156 | ///
157 | /// Raises the MouseDown event.
158 | ///
159 | /// A MouseEventArgs that contains the event data.
160 | protected override void OnMouseDown(MouseEventArgs e)
161 | {
162 | if (e.Button == MouseButtons.Left && ShowPlusMinus)
163 | {
164 | if (!Focused) Focus();//?
165 | CTreeNode toggleNode = null;
166 | this.Nodes.TraverseNodes(node => node.Visible && node.Nodes.Count > 0, node =>
167 | {
168 | Point cursorLocation = e.Location;
169 | cursorLocation.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y);
170 | if (node.PlusMinus != null && node.PlusMinus.IsUnderMouse(cursorLocation))
171 | {
172 | toggleNode = node;
173 | }
174 | });
175 | ClearSelection();
176 | if (toggleNode != null)
177 | {
178 | toggleNode.Toggle();
179 | if (SelectionMode != CTreeViewSelectionMode.None) toggleNode.IsSelected = true;
180 | }
181 | }
182 |
183 | base.OnMouseDown(e);
184 | }
185 |
186 | ///
187 | /// Raises the Paint event.
188 | ///
189 | /// A PaintEventArgs that contains the event data.
190 | protected override void OnPaint(PaintEventArgs e)
191 | {
192 | e.Graphics.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);
193 |
194 | //Paint lines
195 | if (ShowLines)
196 | {
197 | this.Nodes.TraverseNodes(node => node.IsExpanded, node =>
198 | {
199 | if (node.Lines != null) foreach (CTreeNode.Line line in node.Lines) e.Graphics.DrawLine(LinesPen, line.Point1, line.Point2);
200 | });
201 | if (rootLines != null) foreach (CTreeNode.Line line in rootLines) e.Graphics.DrawLine(LinesPen, line.Point1, line.Point2);
202 | }
203 |
204 | //Paint drag and drop destination animation.
205 | if (DragTargetPosition.Enabled)
206 | {
207 | if (!dragDropRectangle.IsEmpty) e.Graphics.FillRectangle(selectionBrush, dragDropRectangle);
208 | if (!dragDropLinePoint1.IsEmpty && !dragDropLinePoint2.IsEmpty) e.Graphics.DrawLine(dragDropLinePen, dragDropLinePoint1, dragDropLinePoint2);
209 | }
210 |
211 | //Paint selection
212 | foreach (CTreeNode node in SelectedNodes)
213 | {
214 | Rectangle selectionRectangle = node.Bounds;
215 | selectionRectangle.Inflate(2, 2);
216 | if (!DragTargetPosition.Enabled) e.Graphics.FillRectangle(selectionBrush, selectionRectangle);
217 | selectionRectangle.Width--; selectionRectangle.Height--;//костыль
218 | e.Graphics.DrawRectangle(selectionPen, selectionRectangle);
219 | }
220 |
221 | //Paint PlusMinus buttons
222 | if (ShowPlusMinus)
223 | {
224 | this.Nodes.TraverseNodes(node => node.Visible && node.Nodes.Count > 0, node =>
225 | {
226 | if (node.PlusMinus != null)
227 | {
228 | if (node.IsExpanded) e.Graphics.DrawImage(PlusMinus.Minus, node.PlusMinus.Location);
229 | else e.Graphics.DrawImage(PlusMinus.Plus, node.PlusMinus.Location);
230 | }
231 | });
232 | }
233 |
234 | ////Test bounds
235 | //this.Nodes.TraverseNodes(node => node.Visible, node =>
236 | //{
237 | // e.Graphics.DrawRectangle(new Pen(Color.Silver, 1.0F), node.BoundsSubtree);
238 | //});
239 |
240 | base.OnPaint(e);
241 | }
242 | #endregion
243 | }
244 | }
--------------------------------------------------------------------------------
/ControlTreeView/CTreeView/CTreeView(T).Protected.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using System.Drawing;
4 | using System.Drawing.Drawing2D;
5 | using System.ComponentModel;
6 | using System.Collections.Generic;
7 |
8 | namespace CTreeView
9 | {
10 | [Designer(typeof(CTreeViewDesigner))]
11 | public partial class CTreeView : ScrollableControl, INodeContainer
12 | {
13 | #region Properties
14 | ///
15 | /// Gets the default size of the control.
16 | ///
17 | /// The default Size of the control.
18 | protected override Size DefaultSize
19 | {
20 | get { return new Size(100, 100); }
21 | }
22 | #endregion
23 |
24 | #region Methods
25 | ///
26 | /// Raises the Collapse event.
27 | ///
28 | /// A CTreeViewEventArgs that contains the event data.
29 | protected internal virtual void OnAfterCollapse(CTreeViewEventArgs e)
30 | {
31 | Recalculate();
32 | if (AfterCollapse != null) AfterCollapse(this, e);
33 | }
34 |
35 | ///
36 | /// Raises the Expand event.
37 | ///
38 | /// A CTreeViewEventArgs that contains the event data
39 | protected internal virtual void OnAfterExpand(CTreeViewEventArgs e)
40 | {
41 | Recalculate();
42 | if (AfterExpand != null) AfterExpand(this, e);
43 | }
44 |
45 | ///
46 | /// Raises the Select event.
47 | ///
48 | /// A CTreeViewEventArgs that contains the event data
49 | protected internal virtual void OnAfterSelect(CTreeViewEventArgs e)
50 | {
51 | //ParentCTreeView.Invalidate();
52 | //ParentCTreeView.Update();
53 | ParentCTreeView.Refresh();
54 | if (AfterSelect != null) AfterSelect(this, e);
55 | }
56 |
57 | ///
58 | /// Raises the ItemDrag event.
59 | ///
60 | /// An ItemDragEventArgs that contains the event data.
61 | protected internal virtual void OnDragNodes(DragNodesEventArgs e)
62 | {
63 | if (DragAndDropMode != CTreeViewDragAndDropMode.Nothing)
64 | {
65 | // Move the dragged node when the left mouse button is used.
66 | if (e.Button == MouseButtons.Left)
67 | {
68 | DoDragDrop(e.Nodes, DragDropEffects.Move);
69 | if (DragNodes != null) DragNodes(this, e);
70 | }
71 | //// Copy the dragged node when the right mouse button is used.
72 | //else if (e.Button == MouseButtons.Right && DragAndDropMode == CTreeViewDragAndDropMode.CopyReplaceReorder)
73 | //{
74 | // DoDragDrop(e.Nodes, DragDropEffects.Copy);
75 | // if (DragNodes != null) DragNodes(this, e);
76 | //}
77 | }
78 | }
79 |
80 | ///
81 | /// Raises the DragOver event.
82 | ///
83 | /// A DragEventArgs that contains the event data.
84 | protected override void OnDragOver(DragEventArgs drgevent)
85 | {
86 | if (drgevent.Data.GetDataPresent(typeof(List)) && DragAndDropMode != CTreeViewDragAndDropMode.Nothing)
87 | {
88 | try
89 | {
90 | List sourceNodes = drgevent.Data.GetData(typeof(List)) as List;
91 | Point dragPosition = this.PointToClient(new Point(drgevent.X, drgevent.Y));
92 | dragDestination.SetScroll(
93 | VScroll && dragPosition.Y <20,
94 | VScroll && dragPosition.Y > ClientSize.Height - 20,
95 | HScroll && dragPosition.X > ClientSize.Width - 20,
96 | HScroll && dragPosition.X < 20);
97 | dragPosition.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y);
98 | dragDestination.Set(dragPosition);
99 | if (/*dragDestination.Enabled &&*/ dragDestination.CheckValidDrop(sourceNodes)) drgevent.Effect = drgevent.AllowedEffect;
100 | else drgevent.Effect = DragDropEffects.None;
101 | }
102 | catch (Exception ex)
103 | {
104 | MessageBox.Show(ex.Message + '\n' + "Исключение в " + ex.Source + '\n' + ex.StackTrace, "Error"); //for debugging
105 | }
106 | }
107 | base.OnDragOver(drgevent);
108 | }
109 |
110 | ///
111 | /// Raises the DragEnter event.
112 | ///
113 | /// A DragEventArgs that contains the event data.
114 | protected override void OnDragEnter(DragEventArgs drgevent)
115 | {
116 | if (drgevent.Data.GetDataPresent(typeof(List)) && DragAndDropMode != CTreeViewDragAndDropMode.Nothing)
117 | {
118 | drgevent.Effect = drgevent.AllowedEffect;
119 | }
120 | base.OnDragEnter(drgevent);
121 | }
122 |
123 | ///
124 | /// Raises the DragLeave event.
125 | ///
126 | /// An EventArgs that contains the event data.
127 | protected override void OnDragLeave(EventArgs e)
128 | {
129 | if (DragAndDropMode != CTreeViewDragAndDropMode.Nothing /*&& dragDestination.Enabled*/) dragDestination.Reset();
130 | base.OnDragLeave(e);
131 | }
132 |
133 | ///
134 | /// Raises the DragDrop event.
135 | ///
136 | /// A DragEventArgs that contains the event data.
137 | protected override void OnDragDrop(DragEventArgs drgevent)
138 | {
139 | if (drgevent.Data.GetDataPresent(typeof(List)) && DragAndDropMode != CTreeViewDragAndDropMode.Nothing)
140 | {
141 | try
142 | {
143 | List sourceNodes = drgevent.Data.GetData(typeof(List)) as List;
144 | Point dragPosition = this.PointToClient(new Point(drgevent.X, drgevent.Y));
145 | dragPosition.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y);
146 | dragDestination.Set(dragPosition);
147 | if (dragDestination.CheckValidDrop(sourceNodes))
148 | {
149 | BeginUpdate();
150 | //if (drgevent.AllowedEffect == DragDropEffects.Copy)
151 | //{
152 | // List copyNodes = new List(sourceNodes.Count);
153 | // foreach (CTreeNode sourceNode in sourceNodes) copyNodes.Add((CTreeNode)sourceNode.Clone());
154 | // if (dragDestination.Node != null) dragDestination.Node.Nodes.AddRange(copyNodes.ToArray());
155 | // else if (dragDestination.NodeBefore != null)
156 | // {
157 | // int index = dragDestination.NodeBefore.Index + 1;
158 | // foreach (CTreeNode copyNode in copyNodes) dragDestination.NodeBefore.OwnerCollection.Insert(index++, copyNode);
159 | // }
160 | // else if (dragDestination.NodeAfter != null)
161 | // {
162 | // int index = dragDestination.NodeAfter.Index;
163 | // foreach (CTreeNode copyNode in copyNodes) dragDestination.NodeAfter.OwnerCollection.Insert(index++, copyNode);
164 | // }
165 | //}
166 | //else
167 | //{
168 | foreach (CTreeNode sourceNode in sourceNodes) sourceNode.OwnerCollection.Remove(sourceNode);
169 | if (dragDestination.Node != null) dragDestination.Node.Nodes.AddRange(sourceNodes.ToArray());
170 | else if (dragDestination.NodeBefore != null && !sourceNodes.Contains(dragDestination.NodeBefore))
171 | {
172 | int index = dragDestination.NodeBefore.Index + 1;
173 | foreach (CTreeNode sourceNode in sourceNodes) dragDestination.NodeBefore.OwnerCollection.Insert(index++, sourceNode);
174 | }
175 | else if (dragDestination.NodeAfter != null && !sourceNodes.Contains(dragDestination.NodeAfter))
176 | {
177 | int index = dragDestination.NodeAfter.Index;
178 | foreach (CTreeNode sourceNode in sourceNodes) dragDestination.NodeAfter.OwnerCollection.Insert(index++, sourceNode);
179 | }
180 | //}
181 | EndUpdate();
182 | }
183 | dragDestination.Reset();
184 | }
185 | catch (Exception ex)
186 | {
187 | MessageBox.Show(ex.Message + '\n' + "Исключение в " + ex.Source + '\n' + ex.StackTrace, "Error"); //for debugging
188 | }
189 | }
190 | base.OnDragDrop(drgevent);
191 | }
192 |
193 | ///
194 | /// Raises the Scroll event.
195 | ///
196 | /// A ScrollEventArgs that contains the event data.
197 | protected override void OnScroll(ScrollEventArgs se)
198 | {
199 | base.OnScroll(se);
200 | //Recalculate();
201 | }
202 |
203 | ///
204 | /// Raises the MouseWheel event.
205 | ///
206 | /// A MouseEventArgs that contains the event data.
207 | protected override void OnMouseWheel(MouseEventArgs e)
208 | {
209 | base.OnMouseWheel(e);
210 | //Recalculate();
211 | }
212 |
213 | ///
214 | /// Raises the MouseDown event.
215 | ///
216 | /// A MouseEventArgs that contains the event data.
217 | protected override void OnMouseDown(MouseEventArgs e)
218 | {
219 | if (e.Button == MouseButtons.Left && ShowPlusMinus)
220 | {
221 | CTreeNode toggleNode = null;
222 | this.Nodes.TraverseNodes(node => node.Visible && node.Nodes.Count > 0, node =>
223 | {
224 | Point cursorLocation = e.Location;
225 | cursorLocation.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y);
226 | if (node.PlusMinus != null && node.PlusMinus.IsUnderMouse(cursorLocation))
227 | {
228 | toggleNode = node;
229 | }
230 | });
231 | ClearSelection();
232 | if (toggleNode != null)
233 | {
234 | toggleNode.Toggle();
235 | if (SelectionMode != CTreeViewSelectionMode.None) toggleNode.IsSelected = true;
236 | }
237 | }
238 | this.Focus();
239 |
240 | base.OnMouseDown(e);
241 | }
242 |
243 | ///
244 | /// Raises the Paint event.
245 | ///
246 | /// A PaintEventArgs that contains the event data.
247 | protected override void OnPaint(PaintEventArgs e)
248 | {
249 | //if (!SuspendUpdate)
250 | //{
251 | e.Graphics.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);
252 |
253 | //Paint lines
254 | if (ShowLines)
255 | {
256 | this.Nodes.TraverseNodes(node => node.IsExpanded, node =>
257 | {
258 | if (node.Lines != null)
259 | {
260 | foreach (CTreeNode.Line line in node.Lines) e.Graphics.DrawLine(LinesPen, line.Point1, line.Point2);
261 | }
262 | });
263 | if (rootLines != null)
264 | {
265 | foreach (CTreeNode.Line line in rootLines) e.Graphics.DrawLine(LinesPen, line.Point1, line.Point2);
266 | }
267 | //g.Dispose();
268 | }
269 |
270 | //Paint drag and drop destination animation.
271 | if (dragDestination.Enabled)
272 | {
273 | dragDestination.DrawEffect(e.Graphics);
274 | }
275 |
276 | //Paint selection
277 | //if (true)
278 | //{
279 | foreach (CTreeNode node in SelectedNodes)
280 | {
281 | Rectangle selectionRectangle = node.Bounds;
282 | selectionRectangle.Inflate(3, 3);
283 | //if(!duringDragging) e.Graphics.FillRectangle(selectionBrush, selectionRectangle);
284 | if (!dragDestination.Enabled) e.Graphics.FillRectangle(selectionBrush, selectionRectangle);
285 | selectionRectangle.Width--; selectionRectangle.Height--;//костыль
286 | e.Graphics.DrawRectangle(selectionPen, selectionRectangle);
287 | }
288 | //}
289 |
290 | //Paint PlusMinus buttons
291 | if (ShowPlusMinus)
292 | {
293 | this.Nodes.TraverseNodes(node => node.Visible && node.Nodes.Count > 0, node =>
294 | {
295 | if (node.PlusMinus != null)
296 | {
297 | if (node.IsExpanded) e.Graphics.DrawImage(PlusMinus.Minus, node.PlusMinus.Location);
298 | else e.Graphics.DrawImage(PlusMinus.Plus, node.PlusMinus.Location);
299 | }
300 | });
301 | }
302 |
303 | //Test bounds
304 | //this.Nodes.TraverseNodes(node => node.Visible, node =>
305 | //{
306 | // e.Graphics.DrawRectangle(new Pen(Color.Silver, 1.0F), node.BoundsSubtree);
307 | //});
308 | //}
309 |
310 | base.OnPaint(e);
311 | }
312 | #endregion
313 | }
314 | }
--------------------------------------------------------------------------------