From 4c773738d7085904bd94076b4a169c7b8a92b57f Mon Sep 17 00:00:00 2001 From: Faryan Rezagholi Date: Sun, 24 May 2020 22:37:47 +0200 Subject: [PATCH] moved ADTree classes into mremoteng project --- ADTree | 1 - mRemoteV1.sln | 22 --- mRemoteV1/Tools/ADhelper.cs | 39 ++++ mRemoteV1/UI/Controls/AdTree.Designer.cs | 74 +++++++ mRemoteV1/UI/Controls/AdTree.cs | 115 +++++++++++ mRemoteV1/UI/Controls/AdTree.resx | 183 ++++++++++++++++++ .../ActiveDirectoryImportWindow.Designer.cs | 41 ++-- .../UI/Window/ActiveDirectoryImportWindow.cs | 78 +++----- mRemoteV1/mRemoteV1.csproj | 13 +- 9 files changed, 470 insertions(+), 96 deletions(-) delete mode 160000 ADTree create mode 100644 mRemoteV1/Tools/ADhelper.cs create mode 100644 mRemoteV1/UI/Controls/AdTree.Designer.cs create mode 100644 mRemoteV1/UI/Controls/AdTree.cs create mode 100644 mRemoteV1/UI/Controls/AdTree.resx diff --git a/ADTree b/ADTree deleted file mode 160000 index 2066d150..00000000 --- a/ADTree +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2066d150a5ca0c65206536e2f20ea871fa8cc129 diff --git a/mRemoteV1.sln b/mRemoteV1.sln index 5e056f94..bee62ab1 100644 --- a/mRemoteV1.sln +++ b/mRemoteV1.sln @@ -18,8 +18,6 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Installer", "InstallerProje EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mRemoteNG.Specs", "mRemoteNG.Specs\mRemoteNG.Specs.csproj", "{16AA21E2-D6B7-427D-AB7D-AA8C611B724E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ADTree", "ADTree\ADTree.csproj", "{EAE4E722-5F97-4454-A40C-CD2D88F87232}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Portable|Any CPU = Debug Portable|Any CPU @@ -120,26 +118,6 @@ Global {16AA21E2-D6B7-427D-AB7D-AA8C611B724E}.Release|Any CPU.ActiveCfg = Release|x86 {16AA21E2-D6B7-427D-AB7D-AA8C611B724E}.Release|x86.ActiveCfg = Release|x86 {16AA21E2-D6B7-427D-AB7D-AA8C611B724E}.Release|x86.Build.0 = Release|x86 - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Debug Portable|Any CPU.ActiveCfg = Debug|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Debug Portable|Any CPU.Build.0 = Debug|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Debug Portable|x86.ActiveCfg = Debug|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Debug Portable|x86.Build.0 = Debug|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Debug|x86.ActiveCfg = Debug|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Debug|x86.Build.0 = Debug|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release Installer|Any CPU.ActiveCfg = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release Installer|Any CPU.Build.0 = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release Installer|x86.ActiveCfg = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release Installer|x86.Build.0 = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release Portable|Any CPU.ActiveCfg = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release Portable|Any CPU.Build.0 = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release Portable|x86.ActiveCfg = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release Portable|x86.Build.0 = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release|Any CPU.Build.0 = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release|x86.ActiveCfg = Release|Any CPU - {EAE4E722-5F97-4454-A40C-CD2D88F87232}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/mRemoteV1/Tools/ADhelper.cs b/mRemoteV1/Tools/ADhelper.cs new file mode 100644 index 00000000..bf927627 --- /dev/null +++ b/mRemoteV1/Tools/ADhelper.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections; +using System.DirectoryServices; +using System.Runtime.InteropServices; + +namespace mRemoteNG.Tools +{ + public class ADhelper + { + private DirectoryEntry _dEntry; + + public ADhelper(string domain) + { + Children = new Hashtable(); + Domain = domain; + } + + public Hashtable Children { get; } + + private string Domain { get; } + + public void GetChildEntries(string adPath = "") + { + _dEntry = adPath.Length <= 0 + ? Domain.Length <= 0 ? new DirectoryEntry() : new DirectoryEntry("LDAP://" + Domain) + : new DirectoryEntry(adPath); + try + { + foreach (DirectoryEntry child in _dEntry.Children) + Children.Add(child.Name, child.Path); + } + catch (COMException ex) + { + if (ex.Message.ToLower().Equals("the server is not operational")) + throw new Exception("Could not find AD Server", ex); + } + } + } +} \ No newline at end of file diff --git a/mRemoteV1/UI/Controls/AdTree.Designer.cs b/mRemoteV1/UI/Controls/AdTree.Designer.cs new file mode 100644 index 00000000..3c7140dc --- /dev/null +++ b/mRemoteV1/UI/Controls/AdTree.Designer.cs @@ -0,0 +1,74 @@ +namespace mRemoteNG.UI.Controls +{ + partial class AdTree + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AdTree)); + this.TvAd = new System.Windows.Forms.TreeView(); + this.ImglTree = new System.Windows.Forms.ImageList(this.components); + this.SuspendLayout(); + // + // TvAd + // + this.TvAd.Dock = System.Windows.Forms.DockStyle.Fill; + this.TvAd.Location = new System.Drawing.Point(0, 0); + this.TvAd.Name = "TvAd"; + this.TvAd.Size = new System.Drawing.Size(800, 450); + this.TvAd.TabIndex = 0; + this.TvAd.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.TvAD_AfterExpand); + this.TvAd.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TvAD_AfterSelect); + // + // ImglTree + // + this.ImglTree.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ImglTree.ImageStream"))); + this.ImglTree.TransparentColor = System.Drawing.Color.Transparent; + this.ImglTree.Images.SetKeyName(0, "Root.png"); + this.ImglTree.Images.SetKeyName(1, "OU.png"); + this.ImglTree.Images.SetKeyName(2, "Folder.png"); + this.ImglTree.Images.SetKeyName(3, "Question.png"); + // + // AdTree + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.TvAd); + this.Name = "AdTree"; + this.Text = "AdTree2"; + this.Load += new System.EventHandler(this.ADtree_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TreeView TvAd; + private System.Windows.Forms.ImageList ImglTree; + } +} \ No newline at end of file diff --git a/mRemoteV1/UI/Controls/AdTree.cs b/mRemoteV1/UI/Controls/AdTree.cs new file mode 100644 index 00000000..980bec05 --- /dev/null +++ b/mRemoteV1/UI/Controls/AdTree.cs @@ -0,0 +1,115 @@ +using mRemoteNG.Tools; +using System; +using System.Runtime.CompilerServices; +using System.Windows.Forms; + +namespace mRemoteNG.UI.Controls +{ + public partial class AdTree : UserControl + { + public AdTree() + { + InitializeComponent(); + } + + private void TvAD_AfterExpand(object sender, TreeViewEventArgs e) + { + try + { + foreach (TreeNode node in e.Node.Nodes) + AddTreeNodes(node); + } + catch (Exception ex) + { + Console.WriteLine(ex.StackTrace); + } + } + + private void TvAD_AfterSelect(object sender, TreeViewEventArgs e) + { + AdPath = e.Node.Tag.ToString(); + var pathChangedEvent = AdPathChanged; + pathChangedEvent?.Invoke(this); + } + + public event AdPathChangedEventHandler AdPathChanged; + + public delegate void AdPathChangedEventHandler(object sender); + + private string _domain; + + public string AdPath { get; set; } + + public string Domain + { + private get => string.IsNullOrEmpty(_domain) == false ? _domain : Environment.UserDomainName; + set => _domain = value; + } + public BorderStyle BorderStyle { get; internal set; } + public object SelectedNode { get; internal set; } + + private void ADtree_Load(object sender, EventArgs e) + { + TvAd.Nodes.Clear(); + var treeNode = new TreeNode(Domain) { Tag = "" }; + TvAd.Nodes.Add(treeNode); + AddTreeNodes(treeNode); + TvAd.Nodes[0].Expand(); + } + + private void AddTreeNodes(TreeNode tNode) + { + var adhelper = new ADhelper(Domain); + adhelper.GetChildEntries(tNode.Tag.ToString()); + var enumerator = adhelper.Children.GetEnumerator(); + TvAd.BeginUpdate(); + while (enumerator.MoveNext()) + { + var flag1 = false; + if (enumerator.Key == null) continue; + var node1 = new TreeNode(enumerator.Key.ToString().Substring(3)) + { + Tag = RuntimeHelpers.GetObjectValue(enumerator.Value) + }; + if (!enumerator.Key.ToString().Substring(0, 2).Equals("CN") || + enumerator.Key.ToString().Equals("CN=Computers") || + enumerator.Key.ToString().Equals("CN=Users")) + flag1 = true; + + if (flag1) + { + var flag2 = false; + try + { + foreach (TreeNode node2 in tNode.Nodes) + { + if (!node2.Text.Equals(node1.Text)) continue; + flag2 = true; + break; + } + } + catch (Exception ex) + { + Console.WriteLine(ex.StackTrace); + } + + if (!flag2) + tNode.Nodes.Add(node1); + } + + var imageIndex = GetImageIndex(enumerator.Key.ToString().Substring(0, 2)); + node1.ImageIndex = imageIndex; + node1.SelectedImageIndex = imageIndex; + } + + TvAd.EndUpdate(); + } + + private static int GetImageIndex(string objType) + { + if (objType.Equals("CN")) + return 2; + return objType.Equals("OU") ? 1 : 3; + } + } +} diff --git a/mRemoteV1/UI/Controls/AdTree.resx b/mRemoteV1/UI/Controls/AdTree.resx new file mode 100644 index 00000000..f744ea94 --- /dev/null +++ b/mRemoteV1/UI/Controls/AdTree.resx @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAA4 + DAAAAk1TRnQBSQFMAgEBBAEAARABAAEQAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA + AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5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gApoEegFZAVIB6wEAAfQBiwGGAdUC3AEZAdsCswKt + AosBbAHyAbwF9AEZAf8CpgEJAfQCGQEJAe0BHAXDAqACmgR6AesBAAEcBcMCoAKaBHoB6wEAAf8BCQGt + AdsB3AIZAdwB1QIJAa0CiwGSAf8B8AH0Af8B9AH/AbQBpgEJAa4BXwG0Av8B9AG7AbwKHATtAewBAAoc + BO0B7AIAAf8BzgG0AfAB9AH/ARkB3AHdAQkBswGLAWYB9AEAAfQB8gP/AbUBXwEJAYYBXwG7Av8B8wHv + AfQBHAEaAsMBoAGaARwB8QgAARwBGgLDAaABmgEcAfEKAAHzAYsBBwL/AfQCCQK0AYsBvAMAAvMD/wG1 + Aa0BhgG1Av8B9AG8AfQBAAHxBRwB8QkAAfEFHAHxDAAB8wG0AbsB8gHwAbsCtAGLAfAFAALzB/8B9AHw + Af8mAAH/AfACtAGRAbQBCQH/BwAB/wLzAfQB9gH/AfQB8wH0Af8jAAFCAU0BPgcAAT4DAAEoAwABQAMA + ASADAAEBAQABAQYAAQEWAAP/gQAB4AEHAf8BDwT/AcABAwH4AQ8E/wGAAQMB4AEDAQABAQEAAQEBwAED + AcABAQEAAQEBAAEBAcABAwGAAgABAQEAAQEBgAEBAwABAQEAAQEFAAEBAQABAQUAAQEBAAEBBQABAQEA + AQEFAAEBAQABAQUAAQEBAAEBBQABAQEAAQEBgAEBAwAB/wEAAf8BwAEDAYACAQH/AQEB/wHgAQcBwAED + BP8B8AEPAeABBwT/Cw== + + + \ No newline at end of file diff --git a/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.Designer.cs b/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.Designer.cs index 8593b2e0..4aaa8305 100644 --- a/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.Designer.cs +++ b/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.Designer.cs @@ -1,10 +1,7 @@  - -using mRemoteNG.Themes; - namespace mRemoteNG.UI.Window { - public partial class ActiveDirectoryImportWindow : BaseWindow + public partial class ActiveDirectoryImportWindow { #region Windows Form Designer generated code private void InitializeComponent() @@ -13,7 +10,7 @@ namespace mRemoteNG.UI.Window this.txtDomain = new mRemoteNG.UI.Controls.Base.NGTextBox(); this.lblDomain = new mRemoteNG.UI.Controls.Base.NGLabel(); this.btnChangeDomain = new mRemoteNG.UI.Controls.Base.NGButton(); - this.ActiveDirectoryTree = new ADTree.ADtree(); + this.activeDirectoryTree = new mRemoteNG.UI.Controls.AdTree(); this.btnClose = new mRemoteNG.UI.Controls.Base.NGButton(); this.chkSubOU = new mRemoteNG.UI.Controls.Base.NGCheckBox(); this.SuspendLayout(); @@ -28,7 +25,7 @@ namespace mRemoteNG.UI.Window this.btnImport.TabIndex = 4; this.btnImport.Text = "&Import"; this.btnImport.UseVisualStyleBackColor = true; - this.btnImport.Click += new System.EventHandler(this.btnImport_Click); + this.btnImport.Click += new System.EventHandler(this.BtnImport_Click); // // txtDomain // @@ -39,7 +36,7 @@ namespace mRemoteNG.UI.Window this.txtDomain.Name = "txtDomain"; this.txtDomain.Size = new System.Drawing.Size(406, 22); this.txtDomain.TabIndex = 1; - this.txtDomain.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtDomain_KeyDown); + this.txtDomain.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TxtDomain_KeyDown); // // lblDomain // @@ -60,23 +57,22 @@ namespace mRemoteNG.UI.Window this.btnChangeDomain.TabIndex = 2; this.btnChangeDomain.Text = "Change"; this.btnChangeDomain.UseVisualStyleBackColor = true; - this.btnChangeDomain.Click += new System.EventHandler(this.btnChangeDomain_Click); + this.btnChangeDomain.Click += new System.EventHandler(this.BtnChangeDomain_Click); // // ActiveDirectoryTree // - this.ActiveDirectoryTree.AdPath = null; - this.ActiveDirectoryTree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.activeDirectoryTree.AdPath = null; + this.activeDirectoryTree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.ActiveDirectoryTree.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.ActiveDirectoryTree.Domain = ""; - this.ActiveDirectoryTree.Location = new System.Drawing.Point(12, 52); - this.ActiveDirectoryTree.Margin = new System.Windows.Forms.Padding(4); - this.ActiveDirectoryTree.Name = "ActiveDirectoryTree"; - this.ActiveDirectoryTree.SelectedNode = null; - this.ActiveDirectoryTree.Size = new System.Drawing.Size(510, 285); - this.ActiveDirectoryTree.TabIndex = 3; - this.ActiveDirectoryTree.AdPathChanged += new ADTree.ADtree.AdPathChangedEventHandler(this.ActiveDirectoryTree_ADPathChanged); + this.activeDirectoryTree.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.activeDirectoryTree.Location = new System.Drawing.Point(12, 52); + this.activeDirectoryTree.Margin = new System.Windows.Forms.Padding(4); + this.activeDirectoryTree.Name = "ActiveDirectoryTree"; + this.activeDirectoryTree.SelectedNode = null; + this.activeDirectoryTree.Size = new System.Drawing.Size(510, 285); + this.activeDirectoryTree.TabIndex = 3; + this.activeDirectoryTree.AdPathChanged += new mRemoteNG.UI.Controls.AdTree.AdPathChangedEventHandler(this.ActiveDirectoryTree_ADPathChanged); // // btnClose // @@ -88,7 +84,7 @@ namespace mRemoteNG.UI.Window this.btnClose.TabIndex = 5; this.btnClose.Text = "Close"; this.btnClose.UseVisualStyleBackColor = true; - this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + this.btnClose.Click += new System.EventHandler(this.BtnClose_Click); // // chkSubOU // @@ -112,7 +108,7 @@ namespace mRemoteNG.UI.Window this.ClientSize = new System.Drawing.Size(534, 381); this.Controls.Add(this.chkSubOU); this.Controls.Add(this.btnClose); - this.Controls.Add(this.ActiveDirectoryTree); + this.Controls.Add(this.activeDirectoryTree); this.Controls.Add(this.lblDomain); this.Controls.Add(this.txtDomain); this.Controls.Add(this.btnChangeDomain); @@ -122,7 +118,6 @@ namespace mRemoteNG.UI.Window this.Name = "ActiveDirectoryImportWindow"; this.TabText = "Active Directory Import"; this.Text = "Active Directory Import"; - this.Load += new System.EventHandler(this.ADImport_Load); this.ResumeLayout(false); this.PerformLayout(); @@ -131,7 +126,7 @@ namespace mRemoteNG.UI.Window private Controls.Base.NGTextBox txtDomain; private Controls.Base.NGLabel lblDomain; private Controls.Base.NGButton btnChangeDomain; - private ADTree.ADtree ActiveDirectoryTree; + private mRemoteNG.UI.Controls.AdTree activeDirectoryTree; #endregion private Controls.Base.NGButton btnClose; diff --git a/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs b/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs index af220114..eaf58de1 100644 --- a/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs +++ b/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs @@ -8,47 +8,43 @@ using mRemoteNG.Themes; namespace mRemoteNG.UI.Window { - public partial class ActiveDirectoryImportWindow + public partial class ActiveDirectoryImportWindow : BaseWindow { private string _currentDomain; public ActiveDirectoryImportWindow() { - InitializeComponent(); - FontOverrider.FontOverride(this); WindowType = WindowType.ActiveDirectoryImport; DockPnl = new DockContent(); - _currentDomain = Environment.UserDomainName; + InitializeComponent(); + FontOverrider.FontOverride(this); ApplyTheme(); - } - - private new void ApplyTheme() - { - base.ApplyTheme(); - if (ActiveDirectoryTree.Controls.Count < 1) return; - if (!(ActiveDirectoryTree.Controls[0] is TreeView tv)) return; - var tm = ThemeManager.getInstance(); - if (!tm.ActiveAndExtended) return; - tv.BackColor = tm.ActiveTheme.ExtendedPalette.getColor("List_Background"); - tv.ForeColor = tm.ActiveTheme.ExtendedPalette.getColor("List_Item_Foreground"); + ApplyLanguage(); + txtDomain.Text = _currentDomain; + EnableDisableImportButton(); + // Domain doesn't refresh on load, so it defaults to DOMAIN without this... + _currentDomain = Environment.UserDomainName; + ChangeDomain(); } #region Private Methods - #region Event Handlers - - private void ADImport_Load(object sender, EventArgs e) + private new void ApplyTheme() { - ApplyLanguage(); - txtDomain.Text = _currentDomain; - ActiveDirectoryTree.Domain = _currentDomain; - EnableDisableImportButton(); - - // Domain doesn't refresh on load, so it defaults to DOMAIN without this... - ChangeDomain(); + if (!ThemeManager.getInstance().ThemingActive) return; + base.ApplyTheme(); + if (!ThemeManager.getInstance().ActiveAndExtended) return; + // + //base.ApplyTheme(); + //if (activeDirectoryTree.Controls.Count < 1) return; + //if (!(activeDirectoryTree.Controls[0] is TreeView tv)) return; + //var tm = ThemeManager.getInstance(); + //if (!tm.ActiveAndExtended) return; + //adt tv.BackColor = tm.ActiveTheme.ExtendedPalette.getColor("List_Background"); + //tv.ForeColor = tm.ActiveTheme.ExtendedPalette.getColor("List_Item_Foreground"); } - private void btnImport_Click(object sender, EventArgs e) + private void BtnImport_Click(object sender, EventArgs e) { var selectedNode = Windows.TreeForm.SelectedNode; ContainerInfo importDestination; @@ -57,25 +53,17 @@ namespace mRemoteNG.UI.Window else importDestination = Runtime.ConnectionsService.ConnectionTreeModel.RootNodes.First(); - Import.ImportFromActiveDirectory(ActiveDirectoryTree.AdPath, importDestination, chkSubOU.Checked); + Import.ImportFromActiveDirectory(activeDirectoryTree.AdPath, importDestination, chkSubOU.Checked); } - /* - private static void txtDomain_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) - { - if (e.KeyCode == Keys.Enter) - e.IsInputKey = true; - } - */ - - private void txtDomain_KeyDown(object sender, KeyEventArgs e) + private void TxtDomain_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) return; ChangeDomain(); e.SuppressKeyPress = true; } - private void btnChangeDomain_Click(object sender, EventArgs e) + private void BtnChangeDomain_Click(object sender, EventArgs e) { ChangeDomain(); } @@ -85,9 +73,6 @@ namespace mRemoteNG.UI.Window { EnableDisableImportButton(); } - - #endregion - private void ApplyLanguage() { btnImport.Text = Language.strButtonImport; @@ -100,20 +85,19 @@ namespace mRemoteNG.UI.Window private void ChangeDomain() { _currentDomain = txtDomain.Text; - ActiveDirectoryTree.Domain = _currentDomain; - ActiveDirectoryTree.Refresh(); + activeDirectoryTree.Domain = _currentDomain; + activeDirectoryTree.Refresh(); } private void EnableDisableImportButton() { - btnImport.Enabled = !string.IsNullOrEmpty(ActiveDirectoryTree.AdPath); + btnImport.Enabled = !string.IsNullOrEmpty(activeDirectoryTree.AdPath); } - - #endregion - - private void btnClose_Click(object sender, EventArgs e) + private void BtnClose_Click(object sender, EventArgs e) { Close(); } + + #endregion Private Methods } } \ No newline at end of file diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index 80380c73..177bba90 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -48,9 +48,6 @@ true - - References\ADTree.dll - ..\packages\BouncyCastle.1.8.6.1\lib\BouncyCastle.Crypto.dll @@ -347,6 +344,7 @@ Component + @@ -439,6 +437,12 @@ + + UserControl + + + AdTree.cs + Component @@ -899,6 +903,9 @@ ColorMapTheme.Designer.cs mRemoteNG + + AdTree.cs + NGButton.cs