From 8cbf56f7a549667d6c3de504836f6d8013e86a25 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 3 Jun 2016 22:13:12 -0400 Subject: [PATCH] Build FilteredPropertyGrid into mRemoteNG No longer load the dll. Makes the small amount of source more maintainable then from the code project. Gets rebuilt with latest build env. --- CREDITS.TXT | 24 +-- mRemoteV1/References/FilteredPropertyGrid.dll | Bin 20480 -> 0 bytes .../FilteredPropertyGrid.cs | 173 ++++++++++++++++++ .../FilteredPropertyGrid.designer.cs | 34 ++++ .../FilteredPropertyGrid/ObjectWrapper.cs | 99 ++++++++++ mRemoteV1/UI/Window/ConfigWindow.cs | 2 +- mRemoteV1/mRemoteV1.csproj | 11 +- 7 files changed, 324 insertions(+), 19 deletions(-) delete mode 100644 mRemoteV1/References/FilteredPropertyGrid.dll create mode 100644 mRemoteV1/UI/Controls/FilteredPropertyGrid/FilteredPropertyGrid.cs create mode 100644 mRemoteV1/UI/Controls/FilteredPropertyGrid/FilteredPropertyGrid.designer.cs create mode 100644 mRemoteV1/UI/Controls/FilteredPropertyGrid/ObjectWrapper.cs diff --git a/CREDITS.TXT b/CREDITS.TXT index aa4c975d..05cef011 100644 --- a/CREDITS.TXT +++ b/CREDITS.TXT @@ -34,22 +34,22 @@ Copyright MIT License http://www.codeproject.com/KB/recipes/command_line.aspx -DotNetVer -Copyright © 2010 David Grinberg -Copyright © 2010-2011 Brandon Hansen -http://nsis.sourceforge.net/DotNetVer +FilteredPropertyGrid +Copyright © 2006 Azuria +http://www.codeproject.com/KB/cs/FilteredPropertyGrid.aspx Hotkey Selection Control for .NET Copyright © 2006 Thomas Backman http://www.codeproject.com/Articles/15085/A-simple-hotkey-selection-control-for-NET +InputBox +Copyright © 2016 Jan Slama +http://www.csharp-examples.net/inputbox/ + IP TextBox Copyright © 2005 mawnkay http://www.codeproject.com/Articles/11576/IP-TextBox -InputBox -Copyright © 2016 Jan Slama -http://www.csharp-examples.net/inputbox/ Included Components =================== @@ -64,14 +64,10 @@ Copyright Modified New BSD License http://www.mentalis.org/ -DockPanel Suite 2.3.1 -Copyright © 2007 Weifen Luo +DockPanel Suite 2.10.0.beta2 +Copyright © 2015 @roken and @lextm (formerly Weifen Luo) MIT License -http://sourceforge.net/projects/dockpanelsuite/ - -FilteredPropertyGrid 1.0.0.0 -Copyright © 2006 Azuria -http://www.codeproject.com/KB/cs/FilteredPropertyGrid.aspx +https://github.com/dockpanelsuite/dockpanelsuite GeckoFX 1.8.1.4 Copyright © 2008 Skybound Software diff --git a/mRemoteV1/References/FilteredPropertyGrid.dll b/mRemoteV1/References/FilteredPropertyGrid.dll deleted file mode 100644 index 4561e8a9b43d59b80491ab4e23224aec74054dee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20480 zcmeHN32-D=dH(xQ&mn1cdq&5~mgL!ctd#~yt33b*bndRqUS5f{6R)#7()3D=XQqel zp0y>F$QlRV1l$LKUGxV9ocx z?w&&{Q{bwkQbqTu|My?-fB*a5F|T`cu*i5=;<&A7>YkZp@`uG&l zVM(FyY8xhl)?T8-=4L5Ml!k_HTo3LCN#h>H%_NOtqn9^0kw2Go9yj!SpXjxsleHat9vYF`C>ZX`Anv+r6xnBOqhP_2bEPx5*>4ng-8D)yUMGfZh(L%yh(L%y zh(L%yh(L%yh(L%yh(L(IZx8}yey+yF&!#dp(G5F@W_2P-Xn%e3LD|8RXM7d)RXKw| zaXFJB(qwr>gDR7Rrmt6C!K1d?x9pWlwoPtZmAQtp$_6>piYn~J%D!dAW8kKEZf$Ga z@R+am{Vv>?$+p6cnOc~pz|M@YGvnJ!UTOn!Tc5}^?ji@-YUdOvHK@=MU_gI#-w#4bbm>bN5LTE*%>2(4f90(h?S3d3gMl|Un2JN%ZZ zkFG^NFTe}H1o=pPem!K2=nP>0tXFa)@s6PbzSIdR72DOO$GDBS8$rL~vXPcNk%;)+@8s%}_N84^C3?=jT(~d6${6Es>pL#r2tJHp* zv;jd7?o*Qfl$2op+Ci20of2k%KQ{yzo$up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W|jE?Xrd%UEOF_P5=N1*L%f)SG0G_5mLI*LperDau3HAZhN}r791#t@Ja$7qU$Bv zw%gck>>Jwq#({mi2loz)><8IDGBP)?J2x~m^2XuZ+(>Q?FE02jNj*4SR=2A3*Plpx zC%g3U;NV`OE{WRKI~Wo*OQdlX#!<P@F6FFbJ${{V*5 zB`?TR*iLZ#M1fUw;pu|moLVp0^_5ssr?6ESSUl@GWXpMgbjJVP0L|08m`^iz^%eZS zP_vw#ug$RTQgb0KPgb0KP{2w5|zY7rFs?qtz z#=Kt%aEiK0&wht+-!e*c%KJfuRp9Z<5uL=l#M7WtbOPKoeq}fcc^dQpc)tEzedUVx z_Rc^2h&OpeZxvSj=!KHcIQ7>g1PM`dIHw=LNxgtm`ZUh(e2(X9o2WGlYYtim_8d;~ zCafi4C;FoLRRooglXup~bIm%DJ}i6&@$dHDX9Uj#zyLSDtDHc*BAzF>jV1Ib2gwle z$7mVP4*U#}6Y?zHTuRmWlkjqAUf9bGd3k-|XAT>89>0w>KCv7Wb@C$SAP$tZm?uRY zr>>7fltrGwjsNMOF8DJ_Ui=brE7WEEtG1m*UIl#kn#D|!=rGz|5YZTsGO*yDFVG@d zB7st)E=^D1uvm{#nuZ0!I9Jmtk>@c#hKYPR&tQ~U@=$&~`5qSI;Gvqw2+bqI`f>YJ zV{+d|1pbY&){es3F*qdNS&w1#9bi_(Y$}N7(ATOr3|#i$cR7AjKLl + /// This class overrides the standard PropertyGrid provided by Microsoft. + /// It also allows to hide (or filter) the properties of the SelectedObject displayed by the PropertyGrid. + /// + public partial class FilteredPropertyGrid : PropertyGrid + { + ///

Contain a reference to the collection of properties to show in the parent PropertyGrid. + /// By default, m_PropertyDescriptors contain all the properties of the object. + List m_PropertyDescriptors = new List(); + /// Contain a reference to the array of properties to display in the PropertyGrid. + private AttributeCollection m_HiddenAttributes = null, m_BrowsableAttributes = null; + /// Contain references to the arrays of properties or categories to hide. + private string[] m_BrowsableProperties = null, m_HiddenProperties = null; + /// Contain a reference to the wrapper that contains the object to be displayed into the PropertyGrid. + private ObjectWrapper m_Wrapper = null; + + /// Public constructor. + public FilteredPropertyGrid() { + InitializeComponent(); + base.SelectedObject = m_Wrapper; + } + + public new AttributeCollection BrowsableAttributes { + get { return m_BrowsableAttributes; } + set { + if(m_BrowsableAttributes != value) { + m_HiddenAttributes = null; + m_BrowsableAttributes = value; + RefreshProperties(); + } + } + } + + /// Get or set the categories to hide. + public AttributeCollection HiddenAttributes { + get { return m_HiddenAttributes; } + set { + if(value != m_HiddenAttributes) { + m_HiddenAttributes = value; + m_BrowsableAttributes = null; + RefreshProperties(); + } + } + } + /// Get or set the properties to show. + /// if one or several properties don't exist. + public string[] BrowsableProperties { + get { return m_BrowsableProperties; } + set { + if(value != m_BrowsableProperties) { + m_BrowsableProperties = value; + //m_HiddenProperties = null; + RefreshProperties(); + } + } + } + + /// Get or set the properties to hide. + public string[] HiddenProperties { + get { return m_HiddenProperties; } + set { + if(value != m_HiddenProperties) { + //m_BrowsableProperties = null; + m_HiddenProperties = value; + RefreshProperties(); + } + } + } + + /// Overwrite the PropertyGrid.SelectedObject property. + /// The object passed to the base PropertyGrid is the wrapper. + public new object SelectedObject { + get { return m_Wrapper != null ? ((ObjectWrapper)base.SelectedObject).SelectedObject : null; } + set { + // Set the new object to the wrapper and create one if necessary. + if(m_Wrapper == null) { + m_Wrapper = new ObjectWrapper(value); + RefreshProperties(); + } + else if(m_Wrapper.SelectedObject != value) { + bool needrefresh = value.GetType() != m_Wrapper.SelectedObject.GetType(); + m_Wrapper.SelectedObject = value; + if(needrefresh) RefreshProperties(); + } + // Set the list of properties to the wrapper. + m_Wrapper.PropertyDescriptors = m_PropertyDescriptors; + // Link the wrapper to the parent PropertyGrid. + base.SelectedObject = m_Wrapper; + } + } + + /// Called when the browsable properties have changed. + private void OnBrowsablePropertiesChanged() { + if(m_Wrapper == null) return; + } + + /// Build the list of the properties to be displayed in the PropertyGrid, following the filters defined the Browsable and Hidden properties. + private void RefreshProperties() { + if(m_Wrapper == null) return; + // Clear the list of properties to be displayed. + m_PropertyDescriptors.Clear(); + // Check whether the list is filtered + if(m_BrowsableAttributes != null && m_BrowsableAttributes.Count > 0) { + // Add to the list the attributes that need to be displayed. + foreach(Attribute attribute in m_BrowsableAttributes) ShowAttribute(attribute); + } else { + // Fill the collection with all the properties. + PropertyDescriptorCollection originalpropertydescriptors = TypeDescriptor.GetProperties(m_Wrapper.SelectedObject); + foreach(PropertyDescriptor propertydescriptor in originalpropertydescriptors) m_PropertyDescriptors.Add(propertydescriptor); + // Remove from the list the attributes that mustn't be displayed. + if(m_HiddenAttributes != null) foreach(Attribute attribute in m_HiddenAttributes) HideAttribute(attribute); + } + // Get all the properties of the SelectedObject + PropertyDescriptorCollection allproperties = TypeDescriptor.GetProperties(m_Wrapper.SelectedObject); + // Hide if necessary, some properties + if(m_HiddenProperties != null && m_HiddenProperties.Length > 0) { + // Remove from the list the properties that mustn't be displayed. + foreach(string propertyname in m_HiddenProperties) { + try { + PropertyDescriptor property = allproperties[propertyname]; + // Remove from the list the property + HideProperty(property); + } catch(Exception ex) { + Runtime.MessageCollector.AddExceptionMessage("FilteredPropertyGrid: Could not hide Property.", ex); + } + } + } + // Display if necessary, some properties + if(m_BrowsableProperties != null && m_BrowsableProperties.Length > 0) { + foreach(string propertyname in m_BrowsableProperties) { + try { + ShowProperty(allproperties[propertyname]); + } catch(Exception knfe) { + Runtime.MessageCollector.AddExceptionMessage("FilteredPropertyGrid: Property not found", knfe); + } + } + } + } + /// Allows to hide a set of properties to the parent PropertyGrid. + /// A set of attributes that filter the original collection of properties. + /// For better performance, include the BrowsableAttribute with true value. + private void HideAttribute(Attribute attribute) { + PropertyDescriptorCollection filteredoriginalpropertydescriptors = TypeDescriptor.GetProperties(m_Wrapper.SelectedObject,new Attribute[] { attribute }); + if(filteredoriginalpropertydescriptors == null || filteredoriginalpropertydescriptors.Count == 0) throw new ArgumentException("Attribute not found",attribute.ToString()); + foreach(PropertyDescriptor propertydescriptor in filteredoriginalpropertydescriptors) HideProperty(propertydescriptor); + } + /// Add all the properties that match an attribute to the list of properties to be displayed in the PropertyGrid. + /// The attribute to be added. + private void ShowAttribute(Attribute attribute) { + PropertyDescriptorCollection filteredoriginalpropertydescriptors = TypeDescriptor.GetProperties(m_Wrapper.SelectedObject,new Attribute[] { attribute }); + if(filteredoriginalpropertydescriptors == null || filteredoriginalpropertydescriptors.Count == 0) throw new ArgumentException("Attribute not found",attribute.ToString()); + foreach(PropertyDescriptor propertydescriptor in filteredoriginalpropertydescriptors) ShowProperty(propertydescriptor); + } + /// Add a property to the list of properties to be displayed in the PropertyGrid. + /// The property to be added. + private void ShowProperty(PropertyDescriptor property) { + if(!m_PropertyDescriptors.Contains(property)) m_PropertyDescriptors.Add(property); + } + /// Allows to hide a property to the parent PropertyGrid. + /// The name of the property to be hidden. + private void HideProperty(PropertyDescriptor property) { + if(m_PropertyDescriptors.Contains(property)) m_PropertyDescriptors.Remove(property); + } + } +} \ No newline at end of file diff --git a/mRemoteV1/UI/Controls/FilteredPropertyGrid/FilteredPropertyGrid.designer.cs b/mRemoteV1/UI/Controls/FilteredPropertyGrid/FilteredPropertyGrid.designer.cs new file mode 100644 index 00000000..586b8813 --- /dev/null +++ b/mRemoteV1/UI/Controls/FilteredPropertyGrid/FilteredPropertyGrid.designer.cs @@ -0,0 +1,34 @@ +namespace mRemoteNG.UI.Controls.FilteredPropertyGrid +{ + partial class FilteredPropertyGrid + { + /// + /// 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 Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/mRemoteV1/UI/Controls/FilteredPropertyGrid/ObjectWrapper.cs b/mRemoteV1/UI/Controls/FilteredPropertyGrid/ObjectWrapper.cs new file mode 100644 index 00000000..3f2f1d62 --- /dev/null +++ b/mRemoteV1/UI/Controls/FilteredPropertyGrid/ObjectWrapper.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; + +namespace mRemoteNG.UI.Controls.FilteredPropertyGrid +{ + /// This class is a wrapper. It contains the object the propertyGrid has to display. + internal class ObjectWrapper : ICustomTypeDescriptor + { + /// Contain a reference to the selected objet that will linked to the parent PropertyGrid. + private object m_SelectedObject = null; + /// Contain a reference to the collection of properties to show in the parent PropertyGrid. + /// By default, m_PropertyDescriptors contain all the properties of the object. + List m_PropertyDescriptors = new List(); + + /// Simple constructor. + /// A reference to the selected object that will linked to the parent PropertyGrid. + internal ObjectWrapper(object obj) { + m_SelectedObject = obj; + } + + /// Get or set a reference to the selected objet that will linked to the parent PropertyGrid. + public object SelectedObject { + get { return m_SelectedObject; } + set { if(m_SelectedObject != value) m_SelectedObject = value; } + } + + /// Get or set a reference to the collection of properties to show in the parent PropertyGrid. + public List PropertyDescriptors { + get { return m_PropertyDescriptors; } + set { m_PropertyDescriptors = value; } + } + + #region ICustomTypeDescriptor Members + public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { + return GetProperties(); + } + + public PropertyDescriptorCollection GetProperties() { + return new PropertyDescriptorCollection(m_PropertyDescriptors.ToArray(),true); + } + + /// GetAttributes. + /// AttributeCollection + public AttributeCollection GetAttributes() { + return TypeDescriptor.GetAttributes(m_SelectedObject,true); + } + /// Get Class Name. + /// String + public String GetClassName() { + return TypeDescriptor.GetClassName(m_SelectedObject,true); + } + /// GetComponentName. + /// String + public String GetComponentName() { + return TypeDescriptor.GetComponentName(m_SelectedObject,true); + } + + /// GetConverter. + /// TypeConverter + public TypeConverter GetConverter() { + return TypeDescriptor.GetConverter(m_SelectedObject,true); + } + + /// GetDefaultEvent. + /// EventDescriptor + public EventDescriptor GetDefaultEvent() { + return TypeDescriptor.GetDefaultEvent(m_SelectedObject,true); + } + + /// GetDefaultProperty. + /// PropertyDescriptor + public PropertyDescriptor GetDefaultProperty() { + return TypeDescriptor.GetDefaultProperty(m_SelectedObject,true); + } + + /// GetEditor. + /// editorBaseType + /// object + public object GetEditor(Type editorBaseType) { + return TypeDescriptor.GetEditor(this,editorBaseType,true); + } + + public EventDescriptorCollection GetEvents(Attribute[] attributes) { + return TypeDescriptor.GetEvents(m_SelectedObject,attributes,true); + } + + public EventDescriptorCollection GetEvents() { + return TypeDescriptor.GetEvents(m_SelectedObject,true); + } + + public object GetPropertyOwner(PropertyDescriptor pd) { + return m_SelectedObject; + } + + #endregion + + } +} diff --git a/mRemoteV1/UI/Window/ConfigWindow.cs b/mRemoteV1/UI/Window/ConfigWindow.cs index 55c04088..790dc7bf 100644 --- a/mRemoteV1/UI/Window/ConfigWindow.cs +++ b/mRemoteV1/UI/Window/ConfigWindow.cs @@ -1,4 +1,3 @@ -using Azuria.Common.Controls; using mRemoteNG.App; using mRemoteNG.Connection; using mRemoteNG.Connection.Protocol.RDP; @@ -13,6 +12,7 @@ using System.Drawing; using System.IO; using System.Net.NetworkInformation; using System.Windows.Forms; +using mRemoteNG.UI.Controls.FilteredPropertyGrid; using WeifenLuo.WinFormsUI.Docking; diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index a7e0aac1..10b902e2 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -105,10 +105,6 @@ False References\DiffieHellman.dll - - False - References\FilteredPropertyGrid.dll - False References\log4net.dll @@ -226,6 +222,13 @@ + + Component + + + FilteredPropertyGrid.cs + + UserControl