public void DeleteView() { if ((this.treeView.SelectedNode is SCADAViewNode) && (MessageBox.Show("是否要删除" + this.treeView.SelectedNode.Text + "视图?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)) { try { SCADAViewNode selectedNode = (SCADAViewNode)this.treeView.SelectedNode; FlowProjectNode parent = (FlowProjectNode)this.treeView.SelectedNode.Parent; parent.Project.GraphList.Remove(selectedNode.GraphSite); parent.Nodes.Remove(selectedNode); for (int i = 0; i < this.mediator.DockPanel.Documents.Count <DockContent>(); i++) { if ((this.mediator.DockPanel.Documents[i] is WorkForm) && ((this.mediator.DockPanel.Documents[i] as WorkForm) == selectedNode.View)) { this.mediator.DockPanel.Documents[i].Hide(); this.mediator.DockPanel.Documents[i].Dispose(); this.mediator.DockPanel.Documents[i] = null; } } FlowManager.AddLogToMainLog("删除视图成功!" + parent.Text + "//" + selectedNode.Text); } catch (Exception exception) { FlowManager.AddLogToMainLog("删除视图失败!" + exception.InnerException); } } }
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 应用背景到其它视图ToolStripMenuItem_Click(object sender, EventArgs e) { try { if ((this.treeView.SelectedNode is SCADAViewNode) && (FrmDialog.ShowDialog(this, "是否应用到其它视图?", "提示", true, false, false, true, null) == DialogResult.OK)) { SCADAViewNode selectedNode = this.treeView.SelectedNode as SCADAViewNode; FlowProjectNode parent = this.treeView.SelectedNode.Parent as FlowProjectNode; for (int i = 0; i < parent.Project.GraphList.Count; i++) { if (selectedNode.GraphSite.backImage != null) { parent.Project.GraphList[i].backImage = (Image)selectedNode.GraphSite.backImage.Clone(); } parent.Project.GraphList[i].mBackgroundColor = selectedNode.GraphSite.mBackgroundColor; parent.Project.GraphList[i].mBackgroundImagePath = selectedNode.GraphSite.mBackgroundImagePath; parent.Project.GraphList[i].mBackgroundType = selectedNode.GraphSite.mBackgroundType; parent.Project.GraphList[i].mGradientBottom = selectedNode.GraphSite.mGradientBottom; parent.Project.GraphList[i].mGradientMode = selectedNode.GraphSite.mGradientMode; parent.Project.GraphList[i].mGradientTop = selectedNode.GraphSite.mGradientTop; parent.Project.GraphList[i].MapHeight = selectedNode.GraphSite.MapHeight; parent.Project.GraphList[i].MapWidth = selectedNode.GraphSite.MapWidth; } } } 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); } } }
public void InitTreeView(FlowProject project) { TreeNodeEx ex = new TreeNodeEx(TreeNodeType.View); if (this.treeView.Nodes.Count <= 0) { ex.Text = "SCADA流程图"; this.treeView.Nodes.Add(ex); } else { ex = (TreeNodeEx)this.treeView.Nodes[0]; } FlowProjectNode node = new FlowProjectNode(project) { ToolTipText = project.FileFullName, ContextMenuStrip = this.contextMenuProject }; for (int i = 0; i < project.GraphList.Count; i++) { SCADAViewNode node2 = new SCADAViewNode { ContextMenuStrip = this.contextMenuView, View = (WorkForm)this.mediator.CreateWorkForm(project.GraphList[i].ViewTitle, project.GraphList[i].MapWidth, project.GraphList[i].MapHeight, project.GraphList[i]) }; node2.View.GraphControl.Abstract = project.GraphList[i]; node2.View.GraphControl.Abstract.Site = node2.View.GraphControl; node2.View.GraphControl.BasicLayer = project.GraphList[i].Layers[0]; for (int j = 0; j < project.GraphList[i].Shapes.Count; j++) { project.GraphList[i].Shapes[j].Layer = node2.View.GraphControl.BasicLayer; } node2.Text = node2.GraphSite.ViewTitle; node2.View.GraphControl.LoadPropertiesEvent(); node2.View.GraphControl.SaveViewResult = delegate(bool res, string msg) { if (res) { this.LoadTreeViewTemplate(); } else { MessageBox.Show(this, msg); } }; node.Nodes.Add(node2); } node.ExpandAll(); ex.Nodes.Add(node); }
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 EditView() { if (this.treeView.SelectedNode is SCADAViewNode) { SCADAViewNode selectedNode = this.treeView.SelectedNode as SCADAViewNode; if (selectedNode.View != null) { selectedNode.View.Activate(); } else { selectedNode.View = (WorkForm)this.mediator.CreateWorkForm(selectedNode.GraphSite.GraphInformation.Title, selectedNode.GraphSite.MapWidth, selectedNode.GraphSite.MapHeight, selectedNode.GraphSite); } } }
private void 拷贝视图ToolStripMenuItem_Click(object sender, EventArgs e) { try { if (this.treeView.SelectedNode is SCADAViewNode) { Clipboard.Clear(); SCADAViewNode selectedNode = this.treeView.SelectedNode as SCADAViewNode; Clipboard.SetDataObject(new DataObject("Scada.FlowGraphEngine.GraphicsMap.GraphSite.Copy", selectedNode.GraphSite)); } } catch (Exception exception1) { MessageBox.Show(exception1.Message); } }
private void toolStripSaveTemplateView_Click(object sender, EventArgs e) { try { if (this.treeView.SelectedNode is SCADAViewNode) { SCADAViewNode selectedNode = this.treeView.SelectedNode as SCADAViewNode; SaveViewTemplateFrm frm = new SaveViewTemplateFrm { TemplateName = selectedNode.GraphSite.ViewTitle }; if (frm.ShowDialog(this) == DialogResult.OK) { if (!Directory.Exists(Application.StartupPath + "/ScadaTemplate/TemplateViews/" + frm.TemplateClassic)) { Directory.CreateDirectory(Application.StartupPath + "/ScadaTemplate/TemplateViews/" + frm.TemplateClassic); } string[] files = Directory.GetFiles(Application.StartupPath + "/ScadaTemplate/TemplateViews/" + frm.TemplateClassic, "*.vtpl"); bool flag = false; for (int i = 0; i < files.Length; i++) { if (Path.GetFileNameWithoutExtension(files[i]).Trim().ToLower() == frm.TemplateName.Trim().ToLower()) { flag = true; break; } } if (flag) { MessageBox.Show(this, "已经存在此名称的模板,请重新命名"); } else { string[] textArray1 = new string[] { Application.StartupPath, "/ScadaTemplate/TemplateViews/", frm.TemplateClassic, "/", frm.TemplateName, ".vtpl" }; ((GraphControl)selectedNode.GraphSite.Site).SaveView(string.Concat(textArray1), frm.TemplateName); } } } } catch (Exception exception1) { MessageBox.Show(exception1.Message); } }
private void 编辑名称ToolStripMenuItem_Click(object sender, EventArgs e) { try { if (this.treeView.SelectedNode is SCADAViewNode) { SCADAViewNode selectedNode = this.treeView.SelectedNode as SCADAViewNode; EditViewDialog dialog = new EditViewDialog(selectedNode.View); if (dialog.ShowDialog(this) == DialogResult.OK) { selectedNode.Text = dialog.ViewName; } } } catch (Exception exception1) { MessageBox.Show(exception1.Message); } }
private void 编辑权限ToolStripMenuItem_Click(object sender, EventArgs e) { try { if (this.treeView.SelectedNode is SCADAViewNode) { SCADAViewNode selectedNode = this.treeView.SelectedNode as SCADAViewNode; FlowUserPickerEditor editor = new FlowUserPickerEditor(); editor.InitUsers(ServiceViewsGlobel.Users, selectedNode.View.GraphControl.Abstract.RoleUsers); if (editor.ShowDialog(this) == DialogResult.OK) { selectedNode.View.GraphControl.Abstract.RoleUsers = editor.GetCheckUsers(); } } } catch (Exception exception1) { MessageBox.Show(exception1.Message); } }
private void 设为主视图ToolStripMenuItem_Click(object sender, EventArgs e) { try { if (this.treeView.SelectedNode is SCADAViewNode) { FlowProjectNode parent = this.treeView.SelectedNode.Parent as FlowProjectNode; for (int i = 0; i < parent.Project.GraphList.Count; i++) { parent.Project.GraphList[i].Index = false; } SCADAViewNode selectedNode = this.treeView.SelectedNode as SCADAViewNode; selectedNode.GraphSite.Index = true; selectedNode.ForeColor = Color.Red; } } catch (Exception exception1) { MessageBox.Show(exception1.Message); } }
private void treeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { try { if (e.Node is SCADAViewNode) { SCADAViewNode node = e.Node as SCADAViewNode; if (node.View != null) { node.View.Activate(); } else { node.View = (WorkForm)this.mediator.CreateWorkForm(node.GraphSite.GraphInformation.Title, node.GraphSite.MapWidth, node.GraphSite.MapHeight, node.GraphSite); } } } catch (Exception exception1) { MessageBox.Show(exception1.Message); } }