public void CreateView() { if ((this.treeView.SelectedNode != null) && (this.treeView.SelectedNode.GetType() == typeof(FlowProjectNode))) { FlowProjectNode selectedNode = this.treeView.SelectedNode as FlowProjectNode; CreateViewDialog dialog = new CreateViewDialog(); if (dialog.ShowDialog(this) == DialogResult.OK) { SCADAViewNode node = new SCADAViewNode { Text = dialog.ViewName, ContextMenuStrip = this.contextMenuView, View = (WorkForm)this.mediator.CreateWorkForm(dialog.ViewName, (float)dialog.PageWidth, (float)dialog.PageHeight) }; node.View.GraphControl.SaveViewResult = delegate(bool res, string msg) { if (res) { this.LoadTreeViewTemplate(); } else { MessageBox.Show(this, msg); } }; selectedNode.Nodes.Add(node); selectedNode.Project.GraphList.Add(node.View.GraphControl.Abstract); } } }
private void 粘贴视图ToolStripMenuItem1_Click(object sender, EventArgs e) { try { if (this.treeView.SelectedNode is FlowProjectNode) { GraphAbstract data = null; IDataObject dataObject = Clipboard.GetDataObject(); if (dataObject.GetDataPresent("Scada.FlowGraphEngine.GraphicsMap.GraphSite.Copy")) { data = dataObject.GetData("Scada.FlowGraphEngine.GraphicsMap.GraphSite.Copy") as GraphAbstract; } if (data != null) { FlowProjectNode selectedNode = this.treeView.SelectedNode as FlowProjectNode; CreateViewDialog dialog = new CreateViewDialog(); if (dialog.ShowDialog(this) == DialogResult.OK) { data.GID = "V_" + GUIDTo16.GuidToLongID(); SCADAViewNode node = new SCADAViewNode { Text = dialog.ViewName, ContextMenuStrip = this.contextMenuView, View = (WorkForm)this.mediator.CreateWorkForm(dialog.ViewName, (float)dialog.PageWidth, (float)dialog.PageHeight) }; node.View.GraphControl.Abstract = data; node.View.GraphControl.Abstract.Site = node.View.GraphControl; node.View.GraphControl.BasicLayer = data.Layers[0]; node.View.GraphControl.SaveViewResult = delegate(bool res, string msg) { if (res) { this.LoadTreeViewTemplate(); } else { MessageBox.Show(this, msg); } }; selectedNode.Nodes.Add(node); selectedNode.Project.GraphList.Add(node.View.GraphControl.Abstract); } Clipboard.Clear(); } } } catch (Exception exception1) { MessageBox.Show(exception1.Message); } }
public void LoadTempViewToProject(string tempFile) { FlowProjectNode selectedNode = null; if (this.treeView.SelectedNode != null) { if (this.treeView.SelectedNode is FlowProjectNode) { selectedNode = this.treeView.SelectedNode as FlowProjectNode; } else if (this.treeView.SelectedNode is SCADAViewNode) { selectedNode = this.treeView.SelectedNode.Parent as FlowProjectNode; } CreateViewDialog dialog = new CreateViewDialog(); if (dialog.ShowDialog(this) == DialogResult.OK) { SCADAViewNode node2 = new SCADAViewNode { Text = dialog.ViewName, ContextMenuStrip = this.contextMenuView, View = (WorkForm)this.mediator.CreateWorkForm(dialog.ViewName, (float)dialog.PageWidth, (float)dialog.PageHeight) }; GraphAbstract @abstract = node2.View.GraphControl.LoadView(tempFile); node2.View.GraphControl.Abstract.MapHeight = @abstract.MapHeight; node2.View.GraphControl.Abstract.MapWidth = @abstract.MapWidth; node2.View.GraphControl.Abstract.ViewTitle = dialog.ViewName; node2.View.GraphControl.Layers.Clear(); node2.View.GraphControl.AddLayer(@abstract.Layers[0]); node2.View.GraphControl.BasicLayer = @abstract.Layers[0]; for (int i = 0; i < @abstract.Shapes.Count; i++) { node2.View.GraphControl.AddShape(@abstract.Shapes[i], AddShapeType.Create, null, -1); } node2.View.GraphControl.SaveViewResult = delegate(bool res, string msg) { if (res) { this.LoadTreeViewTemplate(); } else { MessageBox.Show(this, msg); } }; node2.View.GraphControl.LoadViewResult = (res, msg) => MessageBox.Show(this, msg); selectedNode.Nodes.Add(node2); selectedNode.Project.GraphList.Add(node2.View.GraphControl.Abstract); } } }
/// <summary> /// Creates a view /// </summary> /// <returns>View that was created</returns> private View PromptUserToCreateView() { View newView = null; Project project = field.Page.GetProject(); CreateViewDialog viewDialog = new CreateViewDialog(MainForm, project, txtFieldName.Text); viewDialog.ShowDialog(); if (viewDialog.DialogResult == DialogResult.OK) { string newViewName = viewDialog.ViewName; //newView = ((ProjectNode)projectTree.Nodes[0]).Project.CreateView(newViewName); newView = project.CreateView(newViewName, true); viewDialog.Close(); } return(newView); }
/// <summary> /// Creates a view /// </summary> /// <returns>View that was created</returns> private View PromptUserToCreateView() { View newView = null; Project project = field.Page.GetProject(); CreateViewDialog viewDialog = new CreateViewDialog(MainForm, project, txtFieldName.Text); viewDialog.ShowDialog(); if (viewDialog.DialogResult == DialogResult.OK) { string newViewName = viewDialog.ViewName; //newView = ((ProjectNode)projectTree.Nodes[0]).Project.CreateView(newViewName); newView = project.CreateView(newViewName, true); viewDialog.Close(); } return newView; }