/// <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 frm_AddStep(Etape prevStep, Etape step,Procedure procedure,Operation operation) { InitializeComponent(); this.Step = step; this.Procedure = procedure; this._Operation = operation; this.prevStep = prevStep; }
public usrStep(RenderForm parent,usrProcedure brother,Etape prevStep, Etape step,Procedure procedure,Operation operation) { InitializeComponent(); pParent = parent; Brother = brother; this.Step = step; this.Procedure = procedure; this._Operation = operation; this.prevStep = prevStep; }
public static Etape GetByID(int id) { Etape ret = null; try { ret = Manager.XMLResourceManager.XMLStep.GetById(id); } catch (System.IO.FileNotFoundException) { return(null); } catch (Exception x) { System.Windows.Forms.MessageBox.Show(x.ToString()); } return(ret); }
public static bool Add(Etape etape) { //If the file exists we insert a new element. //The number root children must be at least and element and the MaxID element = 2. if (Helper.service.FileExists("etape.xml")) { //System.Windows.Forms.MessageBox.Show("Insert"); return Insert(etape); } else //Otherwise we create the file and insert the first elemet. { //System.Windows.Forms.MessageBox.Show("FirstAdd"); return FirstAdd(etape); } }
public frm_Add3dObject(Control paretn,Etape step,Object3d lastObj) { InitializeComponent(); this.pParetn = paretn; btn_DrawObject.Enabled = false; grpbx_Manipulation.Enabled = false; this.Step = step; this.LastObj = lastObj; //this._Operation = operation; //if (this._Operation == Operation.AddNew) { //MessageBox.Show("Step.Name: "+this.Step.getName(),"frm_AddP=Object.Constructor"); if (LastObj != null) number = LastObj.getNb() + 1; if (this.Step != null) { lbl_StepName.Text = "Etape: "+this.Step.getName(); //MessageBox.Show("frm_AddStep.RenderForm.Objects.count: " + RenderForm.Objects.Count.ToString()); if (RenderForm.Objects != null && RenderForm.Objects.Count > 0) { foreach (Object3d obj in RenderForm.Objects) { //Fill the list box of the created objects. { lstbx_Objects.Items.Add(obj); //obj.LoadMesh(); //lstbx_Objets.Items.Add(file_info); tabControl1.SelectedIndex = 0; } } } //---------------------------------- } else MessageBox.Show("Step null","frm_AddObject.Constructor"); } //else { } }
/// <summary> /// inserts a step to "etape.xml". /// </summary> /// <param name="expert">The object holding the data</param> /// <returns></returns> private static bool Insert(Etape etape) { try { XmlDocument XmlDoc = new XmlDocument(); XPathNavigator Navigator; XPathNodeIterator Nodes; Int32 ID; /* Variable utilisée pour savoir quel est l'ID qu'il faut affecter au nouveau * noeud créé */ string rslt = Helper.service.LoadFile("etape.xml").ToString(); StreamWriter sw = new StreamWriter(System.Windows.Forms.Application.StartupPath + "\\temp.xml"); sw.Write(rslt); sw.Close(); XmlDoc.Load(System.Windows.Forms.Application.StartupPath + "\\temp.xml"); Navigator = XmlDoc.CreateNavigator(); /* Recherche du noeud MaxID pour déterminer quelle sera l'ID du nouveau * procedure. */ string ExpXPath = "//MaxID"; Nodes = Navigator.Select(Navigator.Compile(ExpXPath)); Nodes.MoveNext(); /* On place l'ID le plus élevé du document dans la variable ID */ ID = Nodes.Current.ValueAsInt; /* On incrémente la valeur du noeud MaxID car une fois notre nouveau noeud * créé, l'ID le plus élevé du document sera aussi incrémenté */ Nodes.Current.SetValue((ID + 1).ToString()); /* On se place sur le noeud ayant l'ID le plus élevé */ //ExpXPath = "//etape[@id='" + ID.ToString() + "']"; //Nodes = Navigator.Select(Navigator.Compile(ExpXPath)); if (Nodes.Count != 0) { //Nodes.MoveNext(); /* On crée le noeud principal (etape). */ Nodes.Current.MoveToPrevious(); //System.Windows.Forms.MessageBox.Show("Current.Previous: " + Nodes.Current.Name,"XMLStep.Insert"); Nodes.Current.InsertElementAfter("", "etape", "", ""); /* On se place sur le noeud ainsi créé. */ Nodes.Current.MoveToNext(XPathNodeType.Element); ID++; /* On incrémente ID pour que sa valeur soit identique à celle se * trouvant dans le noeud MaxID. */ /* Encodage des données */ Nodes.Current.CreateAttribute("", "id", "", ID.ToString()); Nodes.Current.AppendChildElement("", "libelle", "", etape.getName()); Nodes.Current.AppendChildElement("", "description", "", etape.getDescription()); int count = 0; //System.Windows.Forms.MessageBox.Show("3d obj "+etape.getObjectList().Count.ToString()); Nodes.Current.AppendChildElement("", "objets", "", "");//Create node objets. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to libelle. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to description. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to objets. //System.Windows.Forms.MessageBox.Show("Before Loop:" + Nodes.Current.Name); foreach (Object3d obj in etape.getObjectList()) { //System.Windows.Forms.MessageBox.Show("count:" + count); Nodes.Current.AppendChildElement("", "objet", "", "");//Create node objet. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to objet. //Move pass all the created object elements. for (int i = 0; i < count + 1; i++) { //Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to objet. Nodes.Current.MoveToNext(); } //System.Windows.Forms.MessageBox.Show("for Loop:"+Nodes.Current.Name); Nodes.Current.CreateAttribute("", "id", "", obj.getId().ToString()); //Nodes.Current.CreateAttribute("", "nb", "", obj.getNb().ToString()); Nodes.Current.CreateAttribute("", "nb", "", count.ToString()); count++; Nodes.Current.AppendChildElement("", "position", "", "");//Create node position. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to node position. //Transform axis float X, Y, Z; X = obj.getPosition().X; Y = obj.getPosition().Y; Z = obj.getPosition().Z; Helper.TransformAxis(ref X, ref Y, ref Z, Transformation.Translation, true); Nodes.Current.CreateAttribute("", "x", "", (X / translateFactor).ToString()); Nodes.Current.CreateAttribute("", "y", "", (Y / translateFactor).ToString()); Nodes.Current.CreateAttribute("", "z", "", (zFactor * Z / translateFactor).ToString()); Nodes.Current.MoveToParent();//Move back to objet. Nodes.Current.AppendChildElement("", "rotation", "", "");//Create node rotation. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to node position. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to node rotation. float angleRad = Helper.DegreesToRadians(Constante.stableAngle); Vector3 v = Vector3.Multiply(obj.getRotation(), 1 / angleRad); Vector3 N = Helper.Normalize(v); //System.Windows.Forms.MessageBox.Show("obj/angle: " + v.ToString() + "\nNorm: " + v1.ToString()); angleRad = angleRad / (N.X / v.X); //angle = Helper.RadiansToDegrees(angleRad); angle = Constante.stableAngle; if (obj.getRotation().X + obj.getRotation().Y + obj.getRotation().Z == 0) Nodes.Current.CreateAttribute("", "angle", "", (0).ToString()); else Nodes.Current.CreateAttribute("", "angle", "", (angle).ToString()); //System.Windows.Forms.MessageBox.Show("Befor: X: " + obj.getRotation().X); X = obj.getRotation().X; Y = obj.getRotation().Y; Z = obj.getRotation().Z; Helper.TransformAxis(ref X, ref Y, ref Z, Transformation.Rotation, true); //System.Windows.Forms.MessageBox.Show("After: X: " + obj.getRotation().X); Nodes.Current.CreateAttribute("", "x", "", (Helper.RadiansToDegrees(X) / angle).ToString()); Nodes.Current.CreateAttribute("", "y", "", (Helper.RadiansToDegrees(Y) / angle).ToString()); Nodes.Current.CreateAttribute("", "z", "", (Helper.RadiansToDegrees(Z) / angle).ToString()); Nodes.Current.MoveToParent();//Move back to objet. Nodes.Current.AppendChildElement("", "scale", "", "");//Create node scale. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to node position. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to node rotation. Nodes.Current.MoveToFollowing(XPathNodeType.Element);//Move to node scale. Nodes.Current.CreateAttribute("", "x", "", (obj.getScale().X * scaleFactor).ToString()); Nodes.Current.CreateAttribute("", "y", "", (obj.getScale().Y * scaleFactor).ToString()); Nodes.Current.CreateAttribute("", "z", "", (obj.getScale().Z * scaleFactor).ToString()); Nodes.Current.MoveToParent();//Move back to objet. //System.Windows.Forms.MessageBox.Show("End "+Nodes.Current.Name); Nodes.Current.MoveToParent();//Move back to objets. //System.Windows.Forms.MessageBox.Show("End "+Nodes.Current.Name); //System.Windows.Forms.MessageBox.Show(Nodes.Current.Name); //return false; } Nodes.Current.MoveToParent();//Move back to etape. //System.Windows.Forms.MessageBox.Show(Nodes.Current.Name); Nodes.Current.AppendChildElement("", "procedure", "", etape.getprocedure().getId().ToString()); //return false; //XmlDoc.Save((Stream)Helper.service.LoadFile("etape.xml"); //System.Windows.Forms.MessageBox.Show("Saving:"+ Helper.service.SaveXmlFile("etape.xml", XmlDoc).ToString(),"XMLStep.Insert"); Helper.service.SaveXmlFile("etape.xml", XmlDoc); } else { return false; } } catch (System.IO.FileNotFoundException x) { } catch (Exception x) { System.Windows.Forms.MessageBox.Show(x.ToString()); } return true; }
public void removeEtape(Etape etape) { etapes.Remove(etape); }
/// <summary> /// Creates the file "etape.xml" and inserts the first step to it. /// </summary> /// <param name="expert">The object holding the data.</param> /// <returns></returns> private static bool FirstAdd(Etape etape) { try { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.Indent = true; System.IO.MemoryStream ms = new System.IO.MemoryStream(); XmlWriter xw = XmlWriter.Create(ms, wSettings);// Write Declaration xw.WriteStartDocument(); // Write the root node xw.WriteStartElement("Etapes"); xw.WriteStartElement("etape"); xw.WriteStartAttribute("id"); xw.WriteString("0"); xw.WriteEndAttribute(); //---------------- xw.WriteStartElement("libelle"); xw.WriteString(etape.getName()); xw.WriteEndElement(); //----------------- xw.WriteStartElement("description"); xw.WriteString(etape.getDescription()); xw.WriteEndElement(); //----------------- xw.WriteStartElement("objets"); //System.Windows.Forms.MessageBox.Show("Step.Objects.Count: " + etape.getObjectList().Count, "XMLStep.FirstAdd"); for (int i = 0; i < etape.getObjectList().Count; i++) { Object3d obj = etape.getObjectList()[i]; xw.WriteStartElement("objet");//<objet> xw.WriteStartAttribute("id"); xw.WriteString(obj.getId().ToString()); xw.WriteEndAttribute(); xw.WriteStartAttribute("nb"); xw.WriteString(i.ToString()); xw.WriteEndAttribute(); xw.WriteStartElement("position");//<position> //Transform axis float X, Y, Z; X=obj.getPosition().X; Y=obj.getPosition().Y; Z=obj.getPosition().Z; Helper.TransformAxis(ref X, ref Y, ref Z, Transformation.Translation, true); xw.WriteStartAttribute("x"); xw.WriteString((X / translateFactor).ToString()); xw.WriteEndAttribute(); xw.WriteStartAttribute("y"); xw.WriteString((Y / translateFactor).ToString()); xw.WriteEndAttribute(); xw.WriteStartAttribute("z"); xw.WriteString((zFactor * Z / translateFactor).ToString()); xw.WriteEndAttribute(); xw.WriteEndElement();//</position> xw.WriteStartElement("rotation");//<rotation> //Transform axis X = obj.getRotation().X; Y = obj.getRotation().Y; Z = obj.getRotation().Z; Helper.TransformAxis(ref X, ref Y, ref Z, Transformation.Rotation, true); float angleRad = Helper.DegreesToRadians(Constante.stableAngle); Vector3 v = Vector3.Multiply(obj.getRotation(), 1 / angleRad); Vector3 N = Helper.Normalize(v); //System.Windows.Forms.MessageBox.Show("obj/angle: " + v.ToString() + "\nNorm: " + v1.ToString()); angleRad = angleRad / (N.X / v.X); //angle = Helper.RadiansToDegrees(angleRad); angle = Constante.stableAngle; xw.WriteStartAttribute("angle"); if (obj.getRotation().X + obj.getRotation().Y + obj.getRotation().Z == 0) xw.WriteString((0).ToString()); else xw.WriteString((angle).ToString()); xw.WriteEndAttribute(); xw.WriteStartAttribute("x"); xw.WriteString((Helper.RadiansToDegrees(X) / angle).ToString()); xw.WriteEndAttribute(); xw.WriteStartAttribute("y"); xw.WriteString((Helper.RadiansToDegrees(Y) / angle).ToString()); xw.WriteEndAttribute(); xw.WriteStartAttribute("z"); xw.WriteString((Helper.RadiansToDegrees(Z) / angle).ToString()); xw.WriteEndAttribute(); xw.WriteEndElement();//</rotation> xw.WriteStartElement("scale");//<scale> xw.WriteStartAttribute("x"); xw.WriteString((obj.getScale().X * scaleFactor).ToString()); xw.WriteEndAttribute(); xw.WriteStartAttribute("y"); xw.WriteString((obj.getScale().Y * scaleFactor).ToString()); xw.WriteEndAttribute(); xw.WriteStartAttribute("z"); xw.WriteString((obj.getScale().Z * scaleFactor).ToString()); xw.WriteEndAttribute(); xw.WriteEndElement();//</scale> xw.WriteEndElement();//</objet> } xw.WriteEndElement(); xw.WriteStartElement("procedure"); xw.WriteString(etape.getprocedure().getId().ToString()); xw.WriteEndElement(); //----------------- xw.WriteEndElement(); xw.WriteStartElement("MaxID"); xw.WriteString("0"); xw.WriteEndElement(); // Close the document xw.WriteEndDocument(); // Flush the write xw.Flush(); Byte[] buffer = new Byte[ms.Length]; buffer = ms.ToArray(); string xmlOutput = System.Text.Encoding.UTF8.GetString(buffer); //File.WriteAllText((Stream)Helper.service.LoadFile("etape.xml", xmlOutput); Helper.service.CreateXmlFile("etape.xml", xmlOutput); } catch (System.IO.FileNotFoundException x) { } catch (Exception x) { System.Windows.Forms.MessageBox.Show(x.ToString()); } return true; }
/// <summary> /// Modifies the etape Data. /// </summary> /// <param name="login">The id of the target Etape object.</param> /// <param name="admin">The object that holds the new data.</param> /// <returns></returns> public static bool Update(int id, Etape etape) { try { /* On utilise un XmlDocument et non un XPathDocument car ce dernier ne permet * pas l'édition des données XML. */ XmlDocument XmlDoc = new XmlDocument(); XPathNavigator Navigator; XPathNodeIterator Nodes; string rslt = Helper.service.LoadFile("etape.xml").ToString(); StreamWriter sw = new StreamWriter(System.Windows.Forms.Application.StartupPath + "\\temp.xml"); sw.Write(rslt); sw.Close(); XmlDoc.Load(System.Windows.Forms.Application.StartupPath + "\\temp.xml"); Navigator = XmlDoc.CreateNavigator(); string ExpXPath = "//etape[@id='" + id.ToString() + "']"; Nodes = Navigator.Select(Navigator.Compile(ExpXPath)); if (Nodes.Count != 0) { /* Encodage des nouvelles données */ Nodes.MoveNext(); Nodes.Current.MoveToFirstAttribute(); Nodes.Current.SetValue(id.ToString()); Nodes.Current.MoveToParent(); Nodes.Current.MoveToFirstChild(); //System.Windows.Forms.MessageBox.Show(Nodes.Current.Name.ToString() + " | " + Nodes.Current.Value.ToString()); Nodes.Current.SetValue(etape.getName()); Nodes.Current.MoveToNext(XPathNodeType.Element); Nodes.Current.SetValue(etape.getDescription()); Nodes.Current.MoveToNext(XPathNodeType.Element); //System.Windows.Forms.MessageBox.Show("Update: "+Nodes.Current.Name); { //Delete the set of objects. Nodes.Current.DeleteSelf(); //Recreate the objects. //System.Windows.Forms.MessageBox.Show("XMLStep.Update.Objects.Count: " + etape.getObjectList().Count.ToString()); if (etape.getObjectList().Count > 0) InsertObjects(id, etape.getObjectList(), Nodes); } Nodes.Current.MoveToFirstChild(); Nodes.Current.MoveToNext();//Move to Libelle. Nodes.Current.MoveToNext();//Move to Description. //System.Windows.Forms.MessageBox.Show("Update: " + Nodes.Current.Name); Nodes.Current.MoveToNext(XPathNodeType.Element); Nodes.Current.SetValue(etape.getprocedure().getId().ToString()); //System.Windows.Forms.MessageBox.Show("Update: " + Nodes.Current.Name); //return false; //XmlDoc.Save((Stream)Helper.service.LoadFile("etape.xml"); Helper.service.SaveXmlFile("etape.xml", XmlDoc); } else { return false; } } catch (System.IO.FileNotFoundException x) { } catch (Exception x) { System.Windows.Forms.MessageBox.Show(x.ToString()); } return true; }
/// <summary> /// Get the list of steps for a specified procedure. /// </summary> /// <param name="Id">The id of the procedure</param> /// <returns></returns> public static List<Etape> GetByProcedure(int Id) { /* On déclare et on crée une instance des variables nécéssaires pour la recherche */ List<Etape> steps = new List<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 crée un navigateur */ Navigator = XPathDocu.CreateNavigator(); /* On crée ici l'expression XPath de recherche d'expert à partir de l'id */ //To eleminate the case sensetive in XPath we use the methode translate(). string ExpXPath = "//etape[procedure='" + Id + "']"; /* On lance la recherche */ Nodes = Navigator.Select(Navigator.Compile(ExpXPath)); /* On vérifie si la recherche a été fructueuse */ if (Nodes.Count != 0) { while (Nodes.MoveNext()) // NOTE: Necéssaire pour se placer sur le noeud recherché { Etape step = new Etape(); /* Encodage des données dans la classe Expert */ step.setId(Convert.ToInt32(Nodes.Current.GetAttribute("id", ""))); /* Pas besoin de chercher cette donnée vu que c'est notre * critère de recherche, on peut donc directement * l'encoder. */ 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(); // On se déplace sur le noeud suivant "Objets" // //Get all the objects of the current step. // foreach (Object3d obj in XML3dObject.GetStepObjects(step.getId())) { step.addObject3d(obj); //System.Windows.Forms.MessageBox.Show("obj.Id: " + obj.getId() + "\nPosX: " + obj.getPosition().X // + "\nPosY: " + obj.getPosition().Y + "\nPosZ: " + obj.getPosition().Z, "XMLStep.GetByProcedure"); } Nodes.Current.MoveToNext(); // On se déplace sur le noeud suivant "Procedure" //step.setprocedure(Convert.ToInt32(Nodes.Current.Value)); steps.Add(step); } } } catch (System.IO.FileNotFoundException x) { } catch (Exception x) { System.Windows.Forms.MessageBox.Show(x.ToString()); return null; } /* Renvoi de toutes les données dans une instance de la classe "Client" */ return steps; }
public void setStep(Etape step) { this.Step = step; }
private void frm_AddStep_Load(object sender, EventArgs e) { lstVw_3dObjects.Width++; lstVw_3dObjects.Width--; //Set the name of the procedure to whom this Step belongs. if (this.Procedure != null) lbl_ProcedureName.Text = this.Procedure.getName(); else MessageBox.Show("Procedure Null", "frm_AddStep.Constructor"); if (this._Operation == Operation.AddNew) { this.Step = new Etape(); //Since the automatic configuration of the Id depends on the etape.xml file //and the creation of multiple steps doesn't use the etape.xml file for each time //so we set our new Id depending on the previous step's ID which makes our new Id = ID+1. if (prevStep != null) this.Step.setId(prevStep.getId() + 1); //Reinitialise the list of 3d RenderForm.Objects RenderForm.Objects = new List<Object3d>(); } else//If this form is used to update a step, we load its data to the text fields first. { if (Step != null) { txtBx_Title.Text = Step.getName(); txtBx_Description.Text = Step.getDescription(); //RenderForm.Objects = Step.getObjectList(); //---------------------------------- if (this.Step.getObjectList() != null) { RenderForm.Objects = new List<Object3d>(); foreach (Object3d obj in this.Step.getObjectList()) RenderForm.Objects.Add(obj); } //MessageBox.Show("Step.Objects.count: " + Step.getObjectList().Count.ToString(),"frm_AddStep.FormLoad"); if (RenderForm.Objects != null && RenderForm.Objects.Count > 0) { foreach (Object3d obj in RenderForm.Objects) { //MessageBox.Show("obj.path: " + obj.getPath() + ". name: " + obj.getName() + ". type: " + obj.getObjType(), "frm_AddStep.RenderForm"); obj.setDevice(RenderForm.m_Device); obj.LoadMesh(); //Fill the list view with the RenderForm.Objects data. //System.Windows.Forms.MessageBox.Show("obj.Id: " + obj.getId() + "\nPosX: " + obj.getPosition().X + "\nPosY: " + obj.getPosition().Y + // "\nPosZ: " + obj.getPosition().Z,"frm_AddStep.FromLoad"); ListViewItem item = new ListViewItem(new string[] { obj.getId().ToString(),obj.getNb().ToString(),Path.GetFileNameWithoutExtension(obj.getName()), obj.getObjType(), VectorToString(obj.getPosition()), VectorToString(obj.getRotation()), VectorToString(obj.getScale()) }); lstVw_3dObjects.Items.Add(item); } } } } txtBx_Id.Text = this.Step.getId().ToString(); }
public void addEtape(Etape etape) { etape.setprocedure(this); steps.Add(etape); }
public void removeEtape(Etape etape) { etape.setprocedure(null); steps.Remove(etape); }
public void addEtape(Etape etape) { etapes.Add(etape); }
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); }
private void frm_AddStep_Load(object sender, EventArgs e) { #region Load the data lstVw_3dObjects.Width++; //Set the name of the procedure to whom this Step belongs. if (this.Procedure != null) lbl_ProcedureName.Text = "Procedure: " + this.Procedure.getName(); else MessageBox.Show("Procedure Null", "frm_AddStep.Constructor"); if (this._Operation == Operation.AddNew) { this.Step = new Etape(); //Since the automatic configuration of the Id depends on the etape.xml file //and the creation of multiple steps doesn't use the etape.xml file for each time //so we set our new Id depending on the previous step's ID which makes our new Id = ID+1. if (prevStep != null) this.Step.setId(prevStep.getId() + 1); //Reinitialise the list of 3d RenderForm.Objects RenderForm.Objects = new List<Object3d>(); } else//If this form is used to update a step, we load its data to the text fields first. { if (Step != null) { txtBx_Title.Text = Step.getName(); txtBx_Description.Text = Step.getDescription(); RenderForm.Objects = Step.getObjectList(); //---------------------------------- if (this.Step.getObjectList() != null) { RenderForm.Objects = new List<Object3d>(); foreach (Object3d obj in this.Step.getObjectList()) RenderForm.Objects.Add(obj); } //MessageBox.Show("Step.Objects.count: " + Step.getObjectList().Count.ToString(),"frm_AddStep.FormLoad"); if (RenderForm.Objects != null && RenderForm.Objects.Count > 0) { foreach (Object3d obj in RenderForm.Objects) { //MessageBox.Show("obj.path: " + obj.getPath() + ". name: " + obj.getName() + ". type: " + obj.getObjType(), "frm_AddStep.RenderForm"); obj.setDevice(RenderForm.m_Device); try { obj.LoadMesh(); } catch (FileNotFoundException) { string str = "Le modèle " + obj.getName() + " n'existe pas dans le chemain " + obj.getPath(); MessageBox.Show(this, str, "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } //Fill the list view with the RenderForm.Objects data. //System.Windows.Forms.MessageBox.Show("obj.Id: " + obj.getId() + "\nPosX: " + obj.getPosition().X + "\nPosY: " + obj.getPosition().Y + // "\nPosZ: " + obj.getPosition().Z,"frm_AddStep.FromLoad"); ListViewItem item = new ListViewItem(new string[] { obj.getId().ToString(),obj.getNb().ToString(),Path.GetFileNameWithoutExtension(obj.getName()), obj.getObjType(), VectorToString(obj.getPosition(),false), VectorToString(obj.getRotation(),true), VectorToString(obj.getScale(),false) }); lstVw_3dObjects.Items.Add(item); } } } } txtBx_Id.Text = this.Step.getId().ToString(); #endregion #region Load buttons design // //buttons video button // lstBtnImgs = new List<Image>(); lstBtnImgs.Add(Image.FromFile("images\\SmallButton.png")); lstBtnImgs.Add(Image.FromFile("images\\SmallButton-hover.png")); lstBtnImgs.Add(Image.FromFile("images\\SmallButton-click.png")); #endregion // //Add Step button // lstAddModelsBtnImgs = new List<Image>(); lstAddModelsBtnImgs.Add(Image.FromFile("images\\UpdateButton.png")); lstAddModelsBtnImgs.Add(Image.FromFile("images\\UpdateButton-hover.png")); lstAddModelsBtnImgs.Add(Image.FromFile("images\\UpdateButton-click.png")); // //Remove Step button // lstRemoveModelBtnImgs = new List<Image>(); lstRemoveModelBtnImgs.Add(Image.FromFile("images\\RemoveButton.png")); lstRemoveModelBtnImgs.Add(Image.FromFile("images\\RemoveButton-hover.png")); lstRemoveModelBtnImgs.Add(Image.FromFile("images\\RemoveButton-click.png")); }
public void setParentStep(Etape etape) { this.Step = etape; }