using System; using System.Drawing; using System.ComponentModel; using System.Drawing.Drawing2D; namespace DevComponents.AdvTree { /// /// Represents node connector. Node connector is the line that is drawn to indicate connection between child and parent node. /// [ToolboxItem(false),System.ComponentModel.DesignTimeVisible(false),TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))] public class NodeConnector:Component { #region Private Variables private int m_LineWidth=1; private Color m_LineColor=SystemColors.Highlight; private eNodeConnectorType m_ConnectorType=eNodeConnectorType.Line; //private bool m_UnderlineNoBorderNode=true; //private eConnectorCap m_EndCap=eConnectorCap.Ellipse; //private eConnectorCap m_StartCap=eConnectorCap.None; //private Size m_EndCapSize=new Size(5,5); //private Size m_StartCapSize=new Size(5,5); #endregion #region Events /// /// Occurs when appearance of the connector has changed as result of changed settings on the connector. /// public event EventHandler AppearanceChanged; #endregion #region Public Interface /// /// Default Constructor. /// public NodeConnector() { } /// /// Creates new instance of the object with specified parameters. /// /// Connector line width. /// Connector type. public NodeConnector(int lineWidth, eNodeConnectorType type) { this.LineWidth=lineWidth; this.ConnectorType=type; } /// /// Gets or sets the connector line width. /// [Browsable(true),DefaultValue(1),Category("Appearance"),Description("Indicates connector line width.")] public int LineWidth { get {return m_LineWidth;} set { m_LineWidth=value; OnAppearanceChanged(); } } /// /// Gets or sets the color of the connector line. /// [Browsable(true),Category("Appearance"),Description("Indicates color of the connector line.")] public Color LineColor { get {return m_LineColor;} set { m_LineColor=value; OnAppearanceChanged(); } } /// /// Returns true if editor should serialize LineColor property. /// [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeLineColor() { return m_LineColor!=SystemColors.Highlight; } /// /// Gets or sets the type of the connector. /// /// /// See eNodeConnectorType enum for list of /// available connectors. /// /// eNodeConnectorType Enumeration [Browsable(false),DefaultValue(eNodeConnectorType.Line),Category("Appearance"),Description("Indicates visual type of the connector.")] public eNodeConnectorType ConnectorType { get {return m_ConnectorType;} set { m_ConnectorType=value; OnAppearanceChanged(); } } private DashStyle _DashStyle = DashStyle.Dot; /// /// Gets or sets the DashStyle for the connector line. Default value is DashStyle.Dot. /// [DefaultValue(DashStyle.Dot), Category("Appearance"), Description("Indicates DashStyle for the connector line")] public DashStyle DashStyle { get { return _DashStyle; } set { _DashStyle = value; } } ///// ///// Gets or sets whether the child node without borders is underlined as a ///// continuation of the connector from node's parent. Default value is true. ///// ///// ///// To enhance visual appearance of the connectors that are connecting to the node ///// with no borders assigned the connector is continued as a single line under the node ///// when this property is set to true (default) value. ///// //[Browsable(true), DefaultValue(true), Category("Behavior"), Description("Indicates whether connector is drawn under the nodes with no borders assigned.")] //public bool UnderlineNoBorderNode //{ // get { return m_UnderlineNoBorderNode; } // set // { // m_UnderlineNoBorderNode = value; // OnAppearanceChanged(); // } //} ///// ///// Gets or sets the type of the cap that connector is ended with. Note that connector starts with parent node and ends with the child node. Default value is Ellipse. ///// //[Browsable(true),DefaultValue(eConnectorCap.Ellipse),Category("Appearance"),Description("Indicates type of the cap that connector is ended with.")] //public eConnectorCap EndCap //{ // get {return m_EndCap;} // set // { // m_EndCap=value; // OnAppearanceChanged(); // } //} ///// ///// Gets or sets the size of the end cap. ///// //[Browsable(true),Category("Appearance"),Description("Indicates the size of the end cap.")] //public System.Drawing.Size EndCapSize //{ // get {return m_EndCapSize;} // set // { // m_EndCapSize=value; // OnAppearanceChanged(); // } //} ///// ///// Returns true if EndCapSize property should be serialized by editor. ///// ///// //[Browsable(false),EditorBrowsable(EditorBrowsableState.Never)] //public bool ShouldSerializeEndCapSize() //{ // return (m_EndCapSize.Width!=5 || m_EndCapSize.Height!=5); //} #endregion #region Private Implementation private void OnAppearanceChanged() { if(AppearanceChanged!=null) AppearanceChanged(this,new EventArgs()); } #endregion // /// // /// Gets or sets the type of the cap that connector is started with. Note that connector starts with parent node and ends with the child node. Default value is None. // /// // [Browsable(true),DefaultValue(eConnectorCap.None),Category("Appearance"),Description("Indicates type of the cap that connector is starts with.")] // public eConnectorCap StartCap // { // get {return m_StartCap;} // set {m_StartCap=value;} // } // // /// // /// Gets or sets the size of the start cap. // /// // [Browsable(true),Category("Appearance"),Description("Indicates the size of the start cap.")] // public System.Drawing.Size StartCapSize // { // get {return m_StartCapSize;} // set {m_StartCapSize=value;} // } // // /// // /// Returns true if StartCapSize property should be serialized by editor. // /// // /// // [Browsable(false),EditorBrowsable(EditorBrowsableState.Never)] // public bool ShouldSerializeStartCapSize() // { // return (m_StartCapSize.Width!=5 || m_StartCapSize.Height!=5); // } } }