Example #1
0
        private TextBox m_tbx = new TextBox();                          //Retrieve the textbox
        /// <summary>
        /// Construct a STNode tree control
        /// </summary>
        public STNodeTreeView()
        {
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            this.MinimumSize   = new System.Drawing.Size(100, 60);
            this.Size          = new System.Drawing.Size(200, 150);
            m_items_draw       = m_items_source;
            m_pen              = new Pen(Color.Black);
            m_brush            = new SolidBrush(Color.White);
            m_sf               = new StringFormat();
            m_sf.LineAlignment = StringAlignment.Center;
            m_dt.Pen           = m_pen;
            m_dt.SolidBrush    = m_brush;
            this.ForeColor     = Color.FromArgb(255, 220, 220, 220);
            this.BackColor     = Color.FromArgb(255, 35, 35, 35);
            m_tbx.Left         = 6;
            m_tbx.BackColor    = Color.FromArgb(255, 30, 30, 30);
            m_tbx.ForeColor    = this.ForeColor;
            m_tbx.BorderStyle  = BorderStyle.None;
            m_tbx.MaxLength    = 20;
            m_tbx.TextChanged += new EventHandler(m_tbx_TextChanged);
            this.Controls.Add(m_tbx);
            this.AllowDrop = true;

            this._Editor       = new STNodeEditor();
            this._PropertyGrid = new STNodePropertyGrid();
        }
Example #2
0
        public FrmNodePreviewPanel(Type stNodeType, Point ptHandle, int nHandleSize, bool bRight, STNodeEditor editor, STNodePropertyGrid propertyGrid)
        {
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            if (m_last_frm != null)
            {
                m_last_frm.Close();
            }
            m_last_frm = this;

            m_editor                   = editor;
            m_property                 = propertyGrid;
            m_editor.Size              = new Size(200, 200);
            m_property.Size            = new Size(200, 200);
            m_editor.Location          = new Point(1 + (bRight ? nHandleSize : 0), 1);
            m_property.Location        = new Point(m_editor.Right, 1);
            m_property.InfoFirstOnDraw = true;
            this.Controls.Add(m_editor);
            this.Controls.Add(m_property);
            this.ShowInTaskbar   = false;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Size            = new Size(402 + nHandleSize, 202);

            m_type        = stNodeType;
            m_ptHandle    = ptHandle;
            m_nHandleSize = nHandleSize;
            m_bRight      = bRight;

            this.AutoBorderColor = true;
            this.BorderColor     = Color.DodgerBlue;
        }
Example #3
0
            public override ConnectionStatus CanConnect(STNodeOption op)
            {
                if (op == STNodeOption.Empty)
                {
                    return(ConnectionStatus.EmptyOption);
                }
                if (this.DataType != typeof(object))
                {
                    return(base.CanConnect(op));
                }
                if (this.IsInput == op.IsInput)
                {
                    return(ConnectionStatus.SameInputOrOutput);
                }
                if (op.Owner == null || this.Owner == null)
                {
                    return(ConnectionStatus.NoOwner);
                }
                if (op.Owner == this.Owner)
                {
                    return(ConnectionStatus.SameOwner);
                }
                if (this.Owner.LockOption || op.Owner.LockOption)
                {
                    return(ConnectionStatus.Locked);
                }
                if (this.IsSingle && m_hs_connected.Count == 1)
                {
                    return(ConnectionStatus.SingleOption);
                }
                if (op.IsInput && STNodeEditor.CanFindNodePath(op.Owner, this.Owner))
                {
                    return(ConnectionStatus.Loop);
                }
                if (m_hs_connected.Contains(op))
                {
                    return(ConnectionStatus.Exists);
                }
                if (op.DataType == typeof(object))
                {
                    return(ConnectionStatus.ErrorType);
                }

                if (!this.IsInput)
                {
                    return(ConnectionStatus.Connected);
                }
                foreach (STNodeOption owner_input in this.Owner.InputOptions)
                {
                    foreach (STNodeOption o in owner_input.ConnectedOption)
                    {
                        if (o == op)
                        {
                            return(ConnectionStatus.Exists);
                        }
                    }
                }
                return(ConnectionStatus.Connected);;
            }
Example #4
0
 internal STNodeCollection(STNodeEditor owner)
 {
     if (owner == null)
     {
         throw new ArgumentNullException("Owner cannot be null");
     }
     m_owner = owner;
     m_nodes = new STNode[4];
 }
Example #5
0
        public STNodeEditorPannel()
        {
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            m_editor    = new STNodeEditor();
            m_tree      = new STNodeTreeView();
            m_grid      = new STNodePropertyGrid();
            m_grid.Text = "NodeProperty";
            this.Controls.Add(m_editor);
            this.Controls.Add(m_tree);
            this.Controls.Add(m_grid);
            this.Size        = new Size(500, 500);
            this.MinimumSize = new Size(250, 250);
            this.BackColor   = Color.FromArgb(255, 34, 34, 34);

            m_pen = new Pen(this.BackColor, 3);

            Type t   = typeof(ConnectionStatus);
            var  vv  = Enum.GetValues(t);
            var  vvv = vv.GetValue(0);

            foreach (var f in t.GetFields())
            {
                if (!f.FieldType.IsEnum)
                {
                    continue;
                }
                foreach (var a in f.GetCustomAttributes(true))
                {
                    if (!(a is DescriptionAttribute))
                    {
                        continue;
                    }
                    m_dic_status_key.Add((ConnectionStatus)f.GetValue(f), ((DescriptionAttribute)a).Description);
                }
            }

            m_editor.ActiveChanged += (s, e) => m_grid.SetNode(m_editor.ActiveNode);
            m_editor.CanvasScaled  += (s, e) => {
                if (this._ShowScale)
                {
                    m_editor.ShowAlert(m_editor.CanvasScale.ToString("F2"), Color.White, Color.FromArgb(127, 255, 255, 0));
                }
            };
            m_editor.OptionConnected += (s, e) => {
                if (this._ShowConnectionStatus)
                {
                    m_editor.ShowAlert(m_dic_status_key[e.Status], Color.White, e.Status == ConnectionStatus.Connected ? Color.FromArgb(125, Color.Lime) : Color.FromArgb(125, Color.Red));
                }
            };
        }
Example #6
0
 /// <summary>
 /// Check whether the current Option can connect to the target Option
 /// </summary>
 /// <param name="op">Option to connect</param>
 /// <returns>Test results</returns>
 public virtual ConnectionStatus CanConnect(STNodeOption op)
 {
     if (this == STNodeOption.Empty || op == STNodeOption.Empty)
     {
         return(ConnectionStatus.EmptyOption);
     }
     if (this._IsInput == op.IsInput)
     {
         return(ConnectionStatus.SameInputOrOutput);
     }
     if (op.Owner == null || this._Owner == null)
     {
         return(ConnectionStatus.NoOwner);
     }
     if (op.Owner == this._Owner)
     {
         return(ConnectionStatus.SameOwner);
     }
     if (this._Owner.LockOption || op._Owner.LockOption)
     {
         return(ConnectionStatus.Locked);
     }
     if (this._IsSingle && m_hs_connected.Count == 1)
     {
         return(ConnectionStatus.SingleOption);
     }
     if (op.IsInput && STNodeEditor.CanFindNodePath(op.Owner, this._Owner))
     {
         return(ConnectionStatus.Loop);
     }
     if (m_hs_connected.Contains(op))
     {
         return(ConnectionStatus.Exists);
     }
     if (this._IsInput && op._DataType != this._DataType && !op._DataType.IsSubclassOf(this._DataType))
     {
         return(ConnectionStatus.ErrorType);
     }
     return(ConnectionStatus.Connected);
 }