private void Btn_SaveProcess_Click(object sender, EventArgs e) { GraphViewWindow canvas = mdockPanel.ActiveContent as GraphViewWindow; if (canvas == null) { return; } bool bSave = canvas.Save(); if (bSave) { var objs = Flow.Instance.FlowUserObj(canvas.Doc.Name); objs.Clear(); foreach (var item in canvas.Doc) { if (item is GraphNode) { GraphNode nodeItem = (GraphNode)item; (nodeItem.UserObject as ToolBase).SetPropValue("ID", objs.Count); objs.Add((nodeItem.UserObject as ToolBase).Settings); } } Flow.Instance.Save(canvas.Doc.Name); UpdateFlowInfo(); } }
private void Btn_NewProcess_Click(object sender, EventArgs e) { GraphViewWindow canvas = new GraphViewWindow(); canvas.Show(mdockPanel, DockState.Document); canvas.View.UpdateFormInfo(); GraphDoc doc = canvas.View.Doc; //doc.AddTitleAndAnnotation(); doc.UndoManager.Clear(); doc.IsModified = false; }
private void Btn_OpenProcess_Click(object sender, EventArgs e) { var canvas = GraphViewWindow.Open(mdockPanel); if (canvas == null) { return; } LoadUserObject(canvas); UpdateFlowInfo(); }
private void LoadSubForm() { #region GraphViewWindow init var views = GraphViewWindow.OpenAll(); foreach (var item in views) { LoadUserObject(item); } #endregion int index = -1; try { mdockPanel.LoadFromXml(@".\Config\DockPanel.config", delegate(string persistString) { if (persistString == typeof(LogForm).ToString()) { return(LogForm.Instance); } if (persistString == typeof(GraphViewWindow).ToString()) { index++; if (views.Count > index) { return(views[index]); } return(null); } if (User == UserType.Administrator) { if (persistString == typeof(FlowCharter.PaletteForm).ToString()) { return(FlowCharter.PaletteForm.GetInstance()); } if (persistString == typeof(GraphNodeForm).ToString()) { return(GraphNodeForm.GetInstance()); } } return(null); }); for (index++; index < views.Count; index++) { views[index].Show(mdockPanel, DockState.Float); } } catch (Exception) { } UpdateFlowInfo(); }
//protected override void OnMdiChildActivate(EventArgs evt) //{ // base.OnMdiChildActivate(evt); // GraphViewWindow w = dockPanel1.ActiveContent as GraphViewWindow;//this.ActiveMdiChild as GraphViewWindow; // if (w != null) // { // GraphNodeForm.GetInstance().View = w.ActiveControl as GoView; // w.View.UpdateFormInfo(); // } //} private void DockPanel1_ActiveContentChanged(object sender, EventArgs e) { GraphViewWindow w = mdockPanel.ActiveContent as GraphViewWindow; if (w != null /*&& w.ActiveControl as GoView !=null*/) { GoView goView = w.ActiveControl as GoView; if (goView == null) { return; } GraphNodeForm.GetInstance().View = goView; w.View.UpdateFormInfo(); } }
private void LoadUserObject(GraphViewWindow canvas) { var objs = Flow.Instance.FlowUserObj(canvas.Doc.Name); int index = 0; foreach (var item in canvas.Doc) { if (item is GraphNode) { GraphNode nodeItem = (GraphNode)item; try { for (int i = 0; i < objs[index].Count(); i++) { Type type = (nodeItem.UserObject as ToolBase).Settings[i].ProType; object value = null; if (!type.IsValueType && type != typeof(string) && type != typeof(MyComboItemConvert)) { var method = typeof(JToken).GetMethod("ToObject", new Type[0]); JToken token = objs[index][i].Value as JToken; if (token != null) {//object类型 反序列化后 需类型转换 value = method.MakeGenericMethod(type).Invoke(token, null); } } else { value = objs[index][i].Value; } (nodeItem.UserObject as ToolBase).Settings[i].Value = value; } } catch (Exception ex) { } finally { index++; } } } }