private void btn_Up_Click(object sender, EventArgs e) { if (lstVew_Steps.SelectedIndices.Count > 0) { int selected = lstVew_Steps.SelectedIndices[0]; if (selected > 0) { //Save the upper step to move down later. ListViewItem item = (ListViewItem)lstVew_Steps.Items[selected - 1].Clone(); //Keep the order of Ids the same. item.Text = lstVew_Steps.Items[selected].Text; lstVew_Steps.Items[selected].Text = lstVew_Steps.Items[selected - 1].Text; //Remove the item we saved lstVew_Steps.Items.RemoveAt(selected - 1); //Move the step up. lstVew_Steps.Items.Insert(selected, item); //Save the upper step to move down later. //Make a copy of the upper element. Etape etp = new Etape(); etp.setId(this.procedure.steps[selected - 1].getId()); etp.setName(this.procedure.steps[selected - 1].getName()); etp.setDescription(this.procedure.steps[selected - 1].getDescription()); etp.setprocedure(this.procedure.steps[selected - 1].getprocedure()); foreach (Object3d obj in this.procedure.steps[selected - 1].getObjectList()) { etp.addObject3d(obj); } //Keep the order of Ids the same. etp.setId(this.procedure.steps[selected].getId()); this.procedure.steps[selected].setId(this.procedure.steps[selected - 1].getId()); //Remove the item we saved this.procedure.steps.RemoveAt(selected - 1); //Move the step up. this.procedure.steps.Insert(selected, etp); //Use this variable so that the app delete the old steps and reinsert them in the specified order. StepsRemoved = true; //MessageBox.Show("selected-1: " + this.procedure.steps[selected - 1].getId() + " selected: " + this.procedure.steps[selected].getId()); } } else MessageBox.Show(this, "Sélectionner une étape SVP.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); }
/// <summary> /// Gets the step by Id. /// </summary> /// <param name="id">The id of the targeted Step.</param> /// <returns></returns> public static Etape GetById(int id) { /* On déclare et on crée une instance des variables nécéssaires pour la recherche */ Etape step = new Etape(); try { string rslt = Helper.service.LoadFile("etape.xml").ToString(); StreamWriter sw = new StreamWriter(System.Windows.Forms.Application.StartupPath + "\\temp.xml"); sw.Write(rslt); sw.Close(); //XPathDocument XPathDocu = new XPathDocument((Stream)Helper.service.LoadFile("Experts.xml")); XPathDocument XPathDocu = new XPathDocument(System.Windows.Forms.Application.StartupPath + "\\temp.xml"); XPathNavigator Navigator; XPathNodeIterator Nodes; /* On affecte false à la /* On crée un navigateur */ Navigator = XPathDocu.CreateNavigator(); string ExpXPath = "//etape[@id='" + id + "']"; /* On lance la recherche */ Nodes = Navigator.Select(Navigator.Compile(ExpXPath)); /* On vérifie si la recherche a été fructueuse */ if (Nodes.Count != 0) { Nodes.MoveNext(); // NOTE: Necéssaire pour se placer sur le noeud recherché /* Encodage des données dans la classe Etape */ step.setId(id); Nodes.Current.MoveToFirstChild(); /* On se déplace sur le premier noeud * enfant "Libelle" */ step.setName(Nodes.Current.Value); Nodes.Current.MoveToNext(); // On se déplace sur le noeud suivant "Description" step.setDescription(Nodes.Current.Value); Nodes.Current.MoveToNext(); // //Get all the objects // step.setObjectList(XML3dObject.GetStepObjects(id)); Nodes.Current.MoveToNext(); // On se déplace sur le noeud suivant "Procedure" step.setprocedure(XMLProcedure.GetById(Convert.ToInt32(Nodes.Current.Value))); } /* Si aucun expert n'a été trouvé */ else { step = null; } } catch (System.IO.FileNotFoundException x) { } catch (Exception x) { System.Windows.Forms.MessageBox.Show(x.ToString()); } /* Renvoi de toutes les données dans une instance de la classe "etape" */ return step; }
public void removeEtape(Etape etape) { etape.setprocedure(null); steps.Remove(etape); }
public void addEtape(Etape etape) { etape.setprocedure(this); steps.Add(etape); }
public void addEtape(Etape etape) { etape.setprocedure(this); steps.Add(etape); }
public void removeEtape(Etape etape) { etape.setprocedure(null); steps.Remove(etape); }