/// <summary>
        /// 添加父类目标
        /// </summary>
        /// <param name="item">结点</param>
        /// <param name="exname">类名</param>
        /// /// <param name="nameSpace">类命名空间</param>
        public static void AddTargetXAribute(MyXTreeItem item, string exname, string nameSpace)
        {
            XAributeItem xaitem = new XAributeItem("Target", MyXAribute.XAribute.CanLinkType.One, MyXAribute.XAribute.XAttributeSpec.XNone
                                                   , MyXAribute.XAribute.XAttributeType.XTarget, MyXAribute.XAribute.XPositonStyle.Left, "该成员的所有者类型为:" + nameSpace + "." + exname, nameSpace + exname);

            item.MyXaributeChildren.Add(xaitem);
        }
 /// <summary>
 /// 组装读取的数据
 /// </summary>
 /// <param name="RootTreeItem">根节点数据</param>
 /// <param name="root">根节点XML</param>
 protected void LoadData(MyXTreeItem RootTreeItem, XmlNode root)
 {
     ///检查是否已经存在
     foreach (XmlNode node in root.SelectNodes("CodeBox"))
     {
         XmlElement  codeNode   = (XmlElement)node;
         MyXTreeItem RetreeItem = new MyXTreeItem();
         RetreeItem.IsSelected       = false;
         RetreeItem.IsExpanded       = false;
         RetreeItem.XName            = codeNode.GetAttribute("Name");
         RetreeItem.MyHitText        = codeNode.GetAttribute("HitText");
         RetreeItem.MyCodeBoxType    = CodeBox.CodeBoxTypeMapping(codeNode.GetAttribute("CodeBoxType"));
         RetreeItem.SystemCodeString = codeNode.GetAttribute("SystemCodeString");
         RetreeItem.ReturnValue      = codeNode.GetAttribute("ReturnValue");
         foreach (XmlNode xNode in codeNode.SelectNodes("XAribute"))
         {
             ///MyXTreeItem的子项
             XAributeItem xaItem = new XAributeItem();
             ///将内容提出填装
             XmlElement xaNode = (XmlElement)xNode;
             xaItem.Parameter_name   = xaNode.GetAttribute("Name");
             xaItem.MyXAttributeType = XAribute.XAttributeTypeMapping(((XmlElement)xaNode.SelectSingleNode("PointTypeitem")).InnerText);
             xaItem.MyXAttributeSpec = XAribute.XAttributeSpecMapping(((XmlElement)xaNode.SelectSingleNode("ListTypeitem")).InnerText);
             xaItem.MyXPositonStyle  = XAribute.XPositonStyleMapping(((XmlElement)xaNode.SelectSingleNode("PositionTypeitem")).InnerText);
             xaItem.MyCanLinkType    = XAribute.CanLinkTypeMapping(((XmlElement)xaNode.SelectSingleNode("LinkTypeitem")).InnerText);
             xaItem.MyHittext        = ((XmlElement)xaNode.SelectSingleNode("TipTypeitem")).InnerText;
             xaItem.MyLastExText     = ((XmlElement)xaNode.SelectSingleNode("LastExTexteitem")).InnerText;
             ///添加到子项中
             RetreeItem.MyXaributeChildren.Add(xaItem);
         }
         ///添加子节点
         RootTreeItem.ChildrenItem.Add(RetreeItem);
     }
 }
        /// <summary>
        /// 添加一个入口的属性节点
        /// </summary>
        /// <param name="item">要添加结点</param>
        public static void AddEnterXAribute(MyXTreeItem item)
        {
            XAributeItem xaitem = new XAributeItem("入口", MyXAribute.XAribute.CanLinkType.More, MyXAribute.XAribute.XAttributeSpec.XNone
                                                   , MyXAribute.XAribute.XAttributeType.XEnter, MyXAribute.XAribute.XPositonStyle.Left, "入口", "");

            item.MyXaributeChildren.Add(xaitem);
        }
        /// <summary>
        ///  添加一个出口属性节点
        /// </summary>
        /// <param name="item">要添加的节点</param>
        public static void AddExcXAribute(MyXTreeItem item)
        {
            XAributeItem xaitem = new XAributeItem("出口", MyXAribute.XAribute.CanLinkType.One, MyXAribute.XAribute.XAttributeSpec.XNone
                                                   , MyXAribute.XAribute.XAttributeType.XExc, MyXAribute.XAribute.XPositonStyle.right, "出口节点", "");

            item.MyXaributeChildren.Add(xaitem);
        }
        /// <summary>
        /// 添加一个返回值参数
        /// </summary>
        /// <param name="item">要添加返回值的节点</param>
        /// <param name="type">返回值的类型</param>
        public static void AddReturnTypeXAribute(MyXTreeItem item, Type type)
        {
            XAributeItem xaitem = new XAributeItem(type.Name, MyXAribute.XAribute.CanLinkType.More, MyXAribute.XAribute.XAttributeSpec.XNone,
                                                   MyXAribute.XAribute.XAttributeType.XClass, MyXAribute.XAribute.XPositonStyle.right, "类型: " + type.Namespace + "." + type.Name,
                                                   type.Namespace + "." + type.Name);

            item.MyXaributeChildren.Add(xaitem);
        }
        /// <summary>
        /// 添加一个参数
        /// </summary>
        /// <param name="item">要添加参数的节点</param>
        /// <param name="info">要添加的参数信息</param>
        public static void AddParameterXAribute(MyXTreeItem item, ParameterInfo info)
        {
            XAributeItem xaitem = new XAributeItem(info.Name, MyXAribute.XAribute.CanLinkType.One, MyXAribute.XAribute.XAttributeSpec.XNone
                                                   , MyXAribute.XAribute.XAttributeType.XClass, MyXAribute.XAribute.XPositonStyle.Left, "参数的类型" + info.ParameterType.Namespace + "." + info.ParameterType.Name,
                                                   info.ParameterType.Namespace + "." + info.ParameterType.Name);

            item.MyXaributeChildren.Add(xaitem);
        }
        /// <summary>
        /// 添加一个正常的属性
        /// </summary>
        /// <param name="item">要添加属性的结点</param>
        /// <param name="info">属性具体内容</param>
        /// /// <param name="type">作为输入还是输出(0 为输入 1 位输出)</param>
        public static void AddNormailzeXAribute(MyXTreeItem item, PropertyInfo info, int type)
        {
            XAributeItem xaitem = new XAributeItem(info.Name, type == 0 ? MyXAribute.XAribute.CanLinkType.One : MyXAribute.XAribute.CanLinkType.More,
                                                   MyXAribute.XAribute.XAttributeSpec.XNone, MyXAribute.XAribute.XAttributeType.XClass, type == 0 ? MyXAribute.XAribute.XPositonStyle.Left : MyXAribute.XAribute.XPositonStyle.right,
                                                   "属性类型:" + info.DeclaringType.Namespace + "." + info.DeclaringType.Name, info.DeclaringType.Namespace + "." + info.DeclaringType.Name);

            item.MyXaributeChildren.Add(xaitem);
        }
Beispiel #8
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);
        }
Beispiel #9
0
        /// <summary>
        /// 某个类添加了一个函数更新通知
        /// </summary>
        ///  <param name="page">添加了函数的类</param>
        /// <param name="fun">被添加的函数</param>
        public void AddPicFunctionToPicData(PicTabPage page, PicFunctionTabPage fun)
        {
            ///新建项
            MyXTreeItem item = new MyXTreeItem();

            item.ChildrenItem  = null;
            item.MyCodeBoxType = CodeBox.XAType.XFunction;
            item.MyHitText     = fun.Hint;
            item.TypeImagePath = "";
            item.XName         = fun.Title;
            List <XAributeItem> xaitem = new List <XAributeItem>();

            ///如果是C#则要加上函数的所属
            if (Language == LanguageType.CSharp.ToString())
            {
                XAributeItem buteitem = new XAributeItem();
                buteitem.MyXPositonStyle  = XAribute.XPositonStyle.Left;
                buteitem.Parameter_name   = "Target";
                buteitem.MyCanLinkType    = XAribute.CanLinkType.One;
                buteitem.MyXAttributeSpec = XAribute.XAttributeSpec.XNone;
                buteitem.MyXAttributeType = XAribute.XAttributeType.XTarget;
                buteitem.MyHittext        = "函数所属的类";
                buteitem.MyLastExText     = page.Title;
                xaitem.Add(buteitem);
            }
            //else if (Language == LanguageType.C.ToString())
            //{

            //}
            ///循环参数
            foreach (XAribute bute in fun.FunctionEnterBox.RightAribute.Children)
            {
                if (bute.SelectType != XAribute.XAttributeType.XEnter)
                {
                    ///填装信息
                    XAributeItem buteitem = new XAributeItem(bute);
                    //buteitem.Parameter_name = bute.Title;
                    //buteitem.MyCanLinkType = bute.CanLinkNum;
                    //buteitem.MyXAttributeSpec = bute.SelectSpc;
                    //buteitem.MyXAttributeType = bute.SelectType;
                    buteitem.MyXPositonStyle = XAribute.XPositonStyle.Left;
                    //buteitem.MyHittext = bute.Hint;
                    //buteitem.MyLastExText = bute.ExName;
                    ///加入列表
                    xaitem.Add(buteitem);
                }
            }
            ///组成函数的右半边属性
            foreach (XAribute bute in fun.FunctionExcBox.LeftAribute.Children)
            {
                if (bute.SelectType != XAribute.XAttributeType.XExc)
                {
                    XAributeItem buteitem = new XAributeItem(bute);
                    buteitem.MyXPositonStyle = XAribute.XPositonStyle.right;
                    xaitem.Add(buteitem);
                }
            }
            item.MyXaributeChildren = xaitem;
            bool        isExect      = false; ///是否已经存在类
            MyXTreeItem UserTreeItem = null;

            foreach (MyXTreeItem myitem in DataSource)
            {
                if (myitem.XName == page.Title)
                {
                    isExect = true;
                    myitem.ChildrenItem.Add(item);
                    return;
                }
            }
            if (!isExect && UserTreeItem == null)
            {
                UserTreeItem       = new MyXTreeItem();
                UserTreeItem.XName = page.Title;
                UserTreeItem.ChildrenItem.Add(item);
                ///添加信息和修改信息
                DataSource.Add(UserTreeItem);
            }
            //ModityPicTabPageFunction();
        }