/// <summary> /// 设置选中的Part,加载其属性 /// </summary> /// <param name="element"></param> public void SetSelectPartAsCurrent(UIElement element) { var node = Part.FindAncestor <Node>(element); if (node != null) { var data = node.Data as ActivityNode; //将当前元素设为选择元素 node.Diagram.SelectedPart = node; //属性设计器加载当前元素属性 WebMethod.LoadProperty(WorkflowUtils.CLIENTSCRIPT_PARAM_ACTIVITY, node.Diagram.Tag.ToString(), WorkflowUtils.ExtractActivityInfoJson(data)); return; } var link = Part.FindAncestor <Link>(element); if (link != null) { var data = link.Data as ActivityLink; link.Diagram.SelectedPart = link; WebMethod.LoadProperty(WorkflowUtils.CLIENTSCRIPT_PARAM_TRANSITION, link.Diagram.Tag.ToString(), WorkflowUtils.ExtractTransitionInfoJson(data)); } }
protected override bool DoAcceptText() { //先保留一个编辑元素的对象引用 var part = this.AdornedPart.Data; //完成text编辑 bool result = base.DoAcceptText(); //将编辑后的元素更新到property grid控件 var node = part as ActivityNode; if (node != null) { _webMethod.UpdateProcess(WorkflowUtils.CLIENTSCRIPT_PARAM_ACTIVITY, this.Diagram.Tag.ToString(), node.Key, WorkflowUtils.ExtractActivityInfoJson(node)); return(result); } var link = part as ActivityLink; if (link != null) { _webMethod.UpdateProcess(WorkflowUtils.CLIENTSCRIPT_PARAM_TRANSITION, this.Diagram.Tag.ToString(), link.Key, WorkflowUtils.ExtractTransitionInfoJson(link)); } return(result); }
////初始化过程中也会执行!!! protected override void OnNodeAdded(Node node) { base.OnNodeAdded(node); ActivityNode data = node.Data as ActivityNode; if (data == null) { return; } if (IsOverviewDiagram(node)) { return; } if (data.IsDynamic == false) { ActivityType nodeType = (ActivityType)Enum.Parse(typeof(ActivityType), data.Category, false); if (!IsValidKey(data.Key, nodeType, node.Diagram)) { data.Key = CreateActivityKey(); } } else { if (!IsValidKey(data.Key, ActivityType.Normal, node.Diagram)) { data.Key = CreateActivityKey(); } data.IsDynamic = true; } _webMethod.LoadProperty(WorkflowUtils.CLIENTSCRIPT_PARAM_ACTIVITY, node.Diagram.Tag.ToString(), WorkflowUtils.ExtractActivityInfoJson(data)); }
private void ContextMenu_Opened(object sender, RoutedEventArgs e) { //var position = this.mainDiagram.LastMousePointInModel; //ContextMenuService.GetContextMenu(sender as FrameworkElement); //(sender as Shared.Silverlight.Controls.ContextMenu).OpenPopup(position); Northwoods.GoXam.PartManager.PartBinding currentBinding = (Northwoods.GoXam.PartManager.PartBinding)((sender as FrameworkElement).DataContext); ActivityNode nodeData = currentBinding.Data as ActivityNode; if (nodeData == null) { return; } string strKey = string.Format("{0}@{1}", this.mainDiagram.Tag.ToString(), nodeData.Key); if (string.Compare(strKey, WorkflowUtils.CurrentKey) != 0) { HtmlPage.Window.Invoke("LoadProperty", WorkflowUtils.CLIENTSCRIPT_PARAM_ACTIVITY, this.mainDiagram.Tag.ToString(), WorkflowUtils.ExtractActivityInfoJson(nodeData)); WorkflowUtils.CurrentKey = strKey; } }
public override void DoMouseDown() { base.DoMouseDown(); Diagram diagram = this.Diagram; if (diagram == null) { return; } //得到当前的Part Part currentPart = FindPartAt(diagram.LastMousePointInModel, true); if (currentPart == null) { //活动上下文菜单 var form = this.Diagram.PartsModel.FindNodeByKey(DiagramPage.ACTCONTEXT_MENU); if (form != null) { form.Visible = false; } //流程上下文菜单 form = this.Diagram.PartsModel.FindNodeByKey(DiagramPage.WFCONTEXT_MENU); if (form != null) { form.Visible = false; } //如果Part和当前Part不一致,则切换属性 if (string.Compare(diagram.Tag.ToString(), WorkflowUtils.CurrentKey) != 0) { HtmlPage.Window.Invoke("LoadProperty", WorkflowUtils.CLIENTSCRIPT_PARAM_WORKFLOW, diagram.Tag.ToString(), WorkflowUtils.ExtractWorkflowInfoJson(diagram)); WorkflowUtils.CurrentKey = diagram.Tag.ToString(); } } else { if (currentPart.DataContext is Northwoods.GoXam.PartManager.PartBinding) { Northwoods.GoXam.PartManager.PartBinding currentBinding = (Northwoods.GoXam.PartManager.PartBinding)((currentPart as FrameworkElement).DataContext); if (currentBinding.Data == null) { return; } if (currentBinding.Data is ActivityNode) { ActivityNode nodeData = currentBinding.Data as ActivityNode; if (nodeData == null) { return; } string strKey = string.Format("{0}@{1}", diagram.Tag.ToString(), nodeData.Key); if (string.Compare(strKey, WorkflowUtils.CurrentKey) != 0) { HtmlPage.Window.Invoke("LoadProperty", WorkflowUtils.CLIENTSCRIPT_PARAM_ACTIVITY, diagram.Tag.ToString(), WorkflowUtils.ExtractActivityInfoJson(nodeData)); WorkflowUtils.CurrentKey = strKey; } } } } }
public override void DoActivate() { base.DoActivate(); var part = this.AdornedPart.Data; ActivityNode nodeData = part as ActivityNode; string strKey = string.Format("{0}@{1}", this.Diagram.Tag.ToString(), nodeData.Key); if (string.Compare(this.Diagram.Tag.ToString(), WorkflowUtils.CurrentKey) != 0) { HtmlPage.Window.Invoke("LoadProperty", WorkflowUtils.CLIENTSCRIPT_PARAM_ACTIVITY, this.Diagram.Tag.ToString(), WorkflowUtils.ExtractActivityInfoJson(nodeData)); WorkflowUtils.CurrentKey = strKey; } }