public PNCanvas Dup() { PNCanvas duplicate = new PNCanvas(); duplicate.LoadFromXml(this.Clone()); duplicate.Node.Text = this.Node.Text + "-Copy"; bool nameExist = true; while (nameExist) { nameExist = false; foreach (TreeNode node in this.Node.Parent.Nodes) { if (node.Text.Equals(duplicate.Node.Text, StringComparison.CurrentCultureIgnoreCase)) { duplicate.Node.Text = duplicate.Node.Text + "-Copy"; nameExist = true; break; } } } return(duplicate); }
public override void LoadFromXML(XmlElement xmlElement, LTSCanvas canvas) { if (canvas is PNCanvas) { PNCanvas myCanvas = canvas as PNCanvas; string startingState = xmlElement.GetAttribute("From"); this.From = myCanvas.FindState(startingState); string endState = xmlElement.GetAttribute("To"); this.To = myCanvas.FindState(endState); if (From is PNTransition) { (From as PNTransition).OutputPlaces.Add(To as PNPlace); } else { (To as PNTransition).InputPlaces.Add(From as PNPlace); } this.Weight = int.Parse(xmlElement.GetAttribute("Weight")); // Add probability of congestion // this.ProbCongestion = double.Parse(xmlElement.GetAttribute("ProbCongestion")); for (int i = 0; i < xmlElement.ChildNodes.Count - 1; i++) { NailItem nail = new NailItem(this); nail.LoadFromXml(xmlElement.ChildNodes[i] as XmlElement); this.Nails.Add(nail); } this.Label.LoadFromXml(xmlElement.ChildNodes[xmlElement.ChildNodes.Count - 1] as XmlElement); } }
/// <summary> /// Parse and load LTS from Xml /// </summary> /// <param name="text">Xml pure text</param> /// <returns></returns> public static PNModel LoadLTSFromXML(string text) { string assertion = string.Empty; List <PNCanvas> canvases = new List <PNCanvas>(); PNExtendInfo extendInfo = null; XmlDocument doc = new XmlDocument(); doc.LoadXml(text); XmlNodeList sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_DECLARATION); //TODO? What is this for? foreach (XmlElement component in sitesNodes) { assertion = component.InnerText; } sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_MODELS); if (sitesNodes.Count > 0) { foreach (XmlElement component in sitesNodes[0].ChildNodes) { // mlqvu -- set value for extend info // load topology from xml if (component.ChildNodes.Count == 4) { XmlElement topologyElement = (XmlElement)component.ChildNodes[0]; extendInfo = loadExtendInfo(topologyElement); } PNCanvas canvas = new PNCanvas(); canvas.LoadFromXml(component); canvases.Add(canvas); } } PNModel model = new PNModel(assertion, canvases); model.mExtendInfo = extendInfo; return(model); }
/// <summary> /// Parse and load LTS from Xml /// </summary> /// <param name="text">Xml pure text</param> /// <returns></returns> public static PNModel LoadLTSFromXML(string text) { string assertion = string.Empty; List<PNCanvas> canvases = new List<PNCanvas>(); PNExtendInfo extendInfo = null; XmlDocument doc = new XmlDocument(); doc.LoadXml(text); XmlNodeList sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_DECLARATION); //TODO? What is this for? foreach (XmlElement component in sitesNodes) assertion = component.InnerText; sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_MODELS); if (sitesNodes.Count > 0) { foreach (XmlElement component in sitesNodes[0].ChildNodes) { // mlqvu -- set value for extend info // load topology from xml if (component.ChildNodes.Count == 4) { XmlElement topologyElement = (XmlElement)component.ChildNodes[0]; extendInfo = loadExtendInfo(topologyElement); } PNCanvas canvas = new PNCanvas(); canvas.LoadFromXml(component); canvases.Add(canvas); } } PNModel model = new PNModel(assertion, canvases); model.mExtendInfo = extendInfo; return model; }
public PNCanvas Dup() { PNCanvas duplicate = new PNCanvas(); duplicate.LoadFromXml(this.Clone()); duplicate.Node.Text = this.Node.Text + "-Copy"; bool nameExist = true; while (nameExist) { nameExist = false; foreach (TreeNode node in this.Node.Parent.Nodes) { if (node.Text.Equals(duplicate.Node.Text, StringComparison.CurrentCultureIgnoreCase)) { duplicate.Node.Text = duplicate.Node.Text + "-Copy"; nameExist = true; break; } } } return duplicate; }
private void addProcessToolStripMenuItem_Click(object sender, EventArgs e) { if (Canvas != null) { Canvas.Visible = false; } TreeNode node = TreeView_Structure.Nodes[0].Nodes["Models"].Nodes.Add("M" + pcounter); pcounter++; Canvas = new PNCanvas(); Canvas.Node = node; node.Tag = Canvas; TreeView_Structure.SelectedNode = node; AddNewProcess(Canvas); //add the first // ---replace by lqv-- // PNPlace classitem = new PNPlace("Place " + Canvas.StateCounter, 1, "", 0); // -- PNPlace classitem = new PNPlace("P" + Canvas.StateCounter, 1, "", 0); // -- Canvas.StateCounter++; classitem.X = 100 / Canvas.Zoom; classitem.Y = 100 / Canvas.Zoom; AddCanvasItem(classitem); Canvas.Refresh(); SetDirty(); }
private void AddNewProcess(PNCanvas Canvas) { Canvas.Dock = DockStyle.Fill; Canvas.ContextMenuStrip = contextMenuStrip1; Canvas.CanvasItemSelected += new EventHandler<CanvasItemEventArgs>(Canvas_CanvasItemSelected); Canvas.CanvasItemsSelected += new EventHandler<CanvasItemsEventArgs>(Canvas_CanvasItemsSelected); Canvas.CanvasRouteSelected += new EventHandler<CanvasRouteEventArgs>(Canvas_CanvasRouteSelected); Canvas.ItemDoubleClick += new EventHandler<CanvasItemEventArgs>(Canvas_ItemDoubleClick); Canvas.RouteDoubleClick += new EventHandler<CanvasRouteEventArgs>(Canvas_RouteDoubleClick); Canvas.LayoutChanged += new EventHandler(Canvas_LayoutChanged); Canvas.SaveCurrentCanvas += new EventHandler(Canvas_SaveCurrentCanvas); this.Button_AddLink.Checked = false; this.Button_AddNewState.Checked = false; this.Button_Delete.Enabled = false; //Canvas.Visible = false; //this.splitContainer1.Panel2.Controls.Add(Canvas); toolStripContainer1.ContentPanel.Controls.Add(Canvas); toolStripContainer1.Visible = false; }
private void TreeView_Structure_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Parent != null && e.Node.Parent.Text == "Models") { toolStripContainer1.Visible = true; if (Canvas != null && Canvas.Visible) { Canvas.Visible = false; } Canvas = (e.Node.Tag as PNCanvas); if (Canvas != null) { Canvas.Visible = true; this.Button_AddLink.Checked = false; this.Button_AddNewState.Checked = false; this.Button_Delete.Enabled = Canvas.itemSelected; } textEditorControl.Visible = false; } else if (e.Node.Text == "Declaration") { toolStripContainer1.Visible = false; textEditorControl.Visible = true; //if (e.Node.Tag != null && textEditorControl.Text != e.Node.Tag.ToString()) //{ // textEditorControl.Text = e.Node.Tag.ToString(); //} } RaiseIsDirtyChanged(); }
private void StoreCanvas(PNCanvas canvas) { canvas.undoStack.RemoveRange(canvas.currentStateIndex + 1, (canvas.undoStack.Count - 1) - (canvas.currentStateIndex + 1) + 1); canvas.undoStack.Add(canvas.Clone()); canvas.currentStateIndex = canvas.undoStack.Count - 1; }
private void duplicateProcessToolStripMenuItem_Click(object sender, EventArgs e) { if (TreeView_Structure.SelectedNode != null) { if (TreeView_Structure.SelectedNode.Parent != null && TreeView_Structure.SelectedNode.Parent.Text == "Models") { PNCanvas currentCanvas = TreeView_Structure.SelectedNode.Tag as PNCanvas; MessageBox.Show(currentCanvas.Node.Text); PNCanvas duplicatedCanvas = currentCanvas.Dup(); TreeNode node = TreeView_Structure.Nodes[0].Nodes["Models"].Nodes.Add(duplicatedCanvas.Node.Text); duplicatedCanvas.Node = node; node.Tag = duplicatedCanvas; TreeView_Structure.SelectedNode = node; AddNewProcess(duplicatedCanvas); duplicatedCanvas.Refresh(); this.Canvas = duplicatedCanvas; SetDirty(); } } }
public ModelEditingForm(PNCanvas canvas) : this() { _canvas = canvas; textBox1.Text = _canvas.Node.Text; }