/// <summary> /// 新建项目 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewProject_Click(object sender, RoutedEventArgs e) { try { NewProject nProject = new NewProject(); ///设置项目类 nProject.SetProjectClass(_myProject, _solution); nProject.ShowDialog(); if (_myProject.RootPath != "") { ///设置项目根目录 Solution.RootPath = _myProject.RootPath; ///创建主类和主函数信息 PicTabPage mainpage = new PicTabPage((new Random()).Next(1, 2000000), this.ChileEventCallBack, "Program.cx"); CodeBox mainbox = mainpage.CreateXCodeBox("Main", PicTabPage.CenterPoint, CodeBox.XAType.XMain); mainbox.AddAttribute(MyXAribute.XAribute.XAttributeType.XExc, MyXAribute.XAribute.XAttributeSpec.XNone, MyXAribute.XAribute.XPositonStyle.right, "出口", MyXAribute.XAribute.CanLinkType.One, "主函数出口", ""); ///添加主信息 _myProject.AddPicTabPage(mainpage); ///将代码图添加到tab页 AddLayoutDocument(ContentPanel, mainpage); ///绑定各个面板数据 BindingPanels(mainpage); } ///保存配置文件路径 Solution.SolutionConfigPath = XCreateConfigurationInformation.SolutionConfigPath; ///添加到解决方案 Solution.AddProjectClass(MyProject); } catch (Exception ex) { LoggerHelp.WriteLogger(ex.ToString()); } }
/// <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); }