/// <summary>
        /// 初始化基本信息
        /// </summary>
        protected override void InitBaseInfo()
        {
            base.InitBaseInfo();
            ///创建函数入口代码块
            FunctionEnterBox            = CreateXCodeBox("方法入口", CenterPoint, CodeBox.XAType.XFunctionEnter);
            FunctionEnterBox.OpenButton = 2;
            FunctionEnterBox.AddXExcXAribute();
            FunctionEnterBox.XAributeChangeMessage = () => { XAributeChangeMessage(this); };///属性消息变更通知
            ///创建函数出口代码块
            CodeBox functionExc = CreateXCodeBox("方法出口", new Point(CenterPoint.X + 250, CenterPoint.Y), CodeBox.XAType.XFunctionExc);

            functionExc.OpenButton = 1;
            functionExc.AddXEnterXAribute();
            functionExc.XAributeChangeMessage = () => { XAributeChangeMessage(this); };///属性消息变更通知
            ///保存函数出口代码块的地址
            FunctionExcBox = functionExc;

            ///添加初始连线
            XAribute   FirstXa      = FunctionEnterBox.GetRightExc()[0];
            XAribute   SecondXa     = functionExc.GetLeftEnter();
            BezierLine MyBezierLine = new BezierLine(CreateBezierID(), FirstXa.BorderColor, FirstXa.GetWorldPosition(), FirstXa.SelectPositionStyle);

            AddBezierLine(MyBezierLine);
            FirstXa.AddBezierLine(MyBezierLine);
            MyBezierLine.StartPoint.LinkAribute = FirstXa;
            SecondXa.AddBezierLine(MyBezierLine);
            MyBezierLine.EndPoint.LinkAribute = SecondXa;
            MyBezierLine.SetBezierLine(SecondXa.GetWorldPosition(), SecondXa.SelectPositionStyle);
        }
        /// <summary>
        /// 直接设置贝塞尔曲线的2个点
        /// </summary>
        /// <param name="start">起始位置</param>
        /// <param name="end">终止位置</param>
        public void DirectSetBezierLineTwoPoint(XAribute start, XAribute end)
        {
            StartPoint.LinkAribute  = start;
            StartPoint.position     = start.GetWorldPosition();
            StartPoint.positionType = start.SelectPositionStyle;
            EndPoint.LinkAribute    = end;
            EndPoint.position       = end.GetWorldPosition();
            EndPoint.positionType   = end.SelectPositionStyle;

            InitLineInformation();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 鼠标抬起的时候
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseUp(MouseButtonEventArgs e)
 {
     base.OnMouseUp(e);
     ///释放鼠标焦点
     this.ReleaseMouseCapture();
     #region 取消框选
     MyPanel.IsToSelect = false;
     #endregion
     #region 对贝塞尔曲线的操作
     ///成功连接
     if (isDrawBezier && isOverAribute && SecondXa != null && SecondXa.IsCanLin(FirstXa))
     {
         #region 将属性和连线的关系赋值
         FirstXa.AddBezierLine(MyBezierLine);
         MyBezierLine.StartPoint.LinkAribute = FirstXa;
         SecondXa.AddBezierLine(MyBezierLine);
         MyBezierLine.EndPoint.LinkAribute = SecondXa;
         MyBezierLine.SetBezierLine(SecondXa.GetWorldPosition(), SecondXa.SelectPositionStyle);
         #endregion
     }
     ///失败连接
     else if (isDrawBezier)
     {
         ///删除失败的贝塞尔曲线
         DelBezierLine(MyBezierLine);
     }
     ///清空贝塞尔曲线对象,防止对此的再次操作
     if (MyBezierLine != null)
     {
         MyBezierLine = null;
         #region 初始化信息
         FirstXa       = null;
         SecondXa      = null;
         isOverAribute = false;
         isDrawBezier  = false;
         SecondXa      = null;
         #endregion
     }
     #endregion
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 子控件事件回调处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ms"></param>
        protected override object ChileEventCallBack(Object sender, MouseState ms, XObjectData data = null)
        {
            base.ChileEventCallBack(sender, ms);
            Type sendtype = sender.GetType();

            switch (ms)
            {
            case MouseState.XClick:
                if (SelectIDList.Count <= 1 && sendtype.Name == "CodeBox")
                {
                    SetChildControlState(((XObject)sender).Id);      ///设置选中状态
                }
                break;

            case MouseState.XDown:
                break;

            case MouseState.XToChildControl:
                AddChildControlMsg(sender);
                break;

            case MouseState.XToStopControl:
                DelChildControlMsg();
                break;

            case MouseState.XToDrawBezier:
                isDrawBezier = true;
                FirstXa      = (XAribute)sender;   ///将发出信号的子控件 赋值
                ///如果ALT键被按下则删除该节点上的曲线
                if (_isPressingAlt)
                {
                    FirstXa.ClearBezierLine();
                }
                if (FirstXa != null)
                {
                    MyBezierLine = new BezierLine(CreateBezierID(), FirstXa.BorderColor, FirstXa.GetWorldPosition(), FirstXa.SelectPositionStyle);
                    AddBezierLine(MyBezierLine);
                }
                break;

            case MouseState.XMouseEnter:
                if (isDrawBezier)
                {
                    if (sendtype.Name == "XAribute")
                    {
                        SecondXa = (XAribute)sender;        ///将发出信号的子控件 赋值
                        if (SecondXa != FirstXa)
                        {
                            isOverAribute = true;
                        }
                    }
                }
                break;

            case MouseState.XMouseLeave:
                isOverAribute = false;
                break;

            case MouseState.XMoveControl:
                if (sendtype.Name == "CodeBox")
                {
                    MoveSelectControl((Point)data.data, ((CodeBox)sender));
                }
                break;

            case MouseState.XDelBezier:
                if (sendtype.Name == "XAribute" && data != null)
                {
                    DelBezierLine((BezierLine)data.data);
                }
                break;

            case MouseState.XCreateCodeBox:
                #region 用户选择创建代码块
                ///根据用户选择创建代码块
                if (sendtype.Name == "XMTreeView")
                {
                    MyXTreeItem mitem = (MyXTreeItem)data.data;
                    CodeBox     box   = CreateXCodeBox(mitem.XName, _createBoxPosition, mitem.MyCodeBoxType);
                    box.Hint             = mitem.MyHitText;
                    box.SystemCodeString = mitem.SystemCodeString;
                    box.ReturnValueName  = mitem.ReturnValue;
                    for (int i = 0; i < mitem.MyXaributeChildren.Count; i++)
                    {
                        XAributeItem aItem = mitem.MyXaributeChildren[i];
                        box.AddAttribute(aItem.MyXAttributeType, aItem.MyXAttributeSpec, aItem.MyXPositonStyle,
                                         aItem.Parameter_name, aItem.MyCanLinkType, aItem.MyHittext, aItem.MyLastExText);
                    }
                    ///创建完成隐藏
                    HiddenPopup();
                }
                #endregion
                #region 属性方式选择框的回调事件
                ///如果是属性方式选择框的回调事件
                else if (sendtype.Name == "XAributeDropSelect")
                {
                    XAribute bute = data.data as XAribute;
                    string   type = data.state as string;
                    ///如果数据没有丢失
                    if (bute != null && type != null)
                    {
                        if (type == "set")
                        {
                            CodeBox box = CreateXCodeBox("设置:" + bute.Title + " 的值", _createBoxPosition, CodeBox.XAType.set);
                            box.Hint = "设置当前类中的这个属性的值,类型:" + bute.ExName;
                            box.AddAttribute(XAribute.XAttributeType.XEnter, XAribute.XAttributeSpec.XNone, XAribute.XPositonStyle.Left, "入口"
                                             , XAribute.CanLinkType.More, "执行入口", "");
                            box.AddAttribute(XAribute.XAttributeType.XExc, XAribute.XAttributeSpec.XNone, XAribute.XPositonStyle.right,
                                             "出口", XAribute.CanLinkType.One, "执行出口", "");
                            box.AddAttribute(bute.SelectType, bute.SelectSpc, XAribute.XPositonStyle.Left, bute.Title, XAribute.CanLinkType.One
                                             , bute.Hint, bute.ExName);
                            XAribute rightBute = box.AddAttribute(bute.SelectType, bute.SelectSpc, XAribute.XPositonStyle.right, bute.Title, XAribute.CanLinkType.More
                                                                  , bute.Hint, bute.ExName);
                            ///同样的属性不用绘制2次名称
                            rightBute.IsDirText = false;
                        }
                        else if (type == "get")
                        {
                            CodeBox box = CreateXCodeBox("获取:" + bute.Title + " 的值", _createBoxPosition, CodeBox.XAType.get);
                            box.Hint = "获取当前类中的这个属性的值,类型:" + bute.ExName;
                            XAribute rightbute = box.AddAttribute(bute.SelectType, bute.SelectSpc, XAribute.XPositonStyle.right, bute.Title, XAribute.CanLinkType.More
                                                                  , bute.Hint, bute.ExName);
                        }
                    }
                    ///隐藏选择框
                    HiddenXAributeSelectPopup();
                }
                #endregion
                break;
            }
            return(null);
        }