public void ContextMenuTemplate_Click(object sender, RoutedEventArgs e) { string templateID = Guid.NewGuid().ToString(); HtmlPage.Window.Invoke("SaveActivityTemplate", templateID); ActivityNode nodeData = ((Northwoods.GoXam.PartManager.PartBinding)((sender as FrameworkElement).DataContext)).Data as ActivityNode; //保存到数据库 DiagramUtils.WebInterAct.SaveActivityTemplate(templateID); //保存到palette中 DiagramUtils.AddActivityTemplate(this.mainDiagram, nodeData.WfClone(templateID)); DiagramUtils.GetTemplateKeys(this.mainDiagram).Add(templateID); }
private void btnActivityTempalte_Click(object sender, RoutedEventArgs e) { var element = sender as UIElement; if (!DiagramUtils.IsMainDiagram(element)) { return; } var diagram = Part.FindAncestor <Diagram>(element); if (diagram == null) { return; } var nodeData = diagram.SelectedNode.Data as ActivityNode; if (nodeData == null) { return; } if (nodeData.Category != ActivityType.Normal.ToString()) { MessageBox.Show("只能为Normal节点设置模板"); return; } string templateID = Guid.NewGuid().ToString(); //保存到数据库 DiagramUtils.WebInterAct.SaveActivityTemplate(templateID); //保存到palette中 DiagramUtils.AddActivityTemplate(diagram, nodeData.WfClone(templateID)); DiagramUtils.GetTemplateKeys(diagram).Add(templateID); }