예제 #1
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (Step.getObjectList() != null && Step.getObjectList().Count > 0)
            {
                //
                //Crete the Step's elements.
                //
                Step.setName(txtBx_Title.Text);
                Step.setDescription(txtBx_Description.Text);
                Step.setObjectList(RenderForm.Objects);


                if (_Operation == Operation.AddNew)
                {
                    //Add the created step to the steps list of the procedure.

                    this.Brother.procedure.addEtape(Step);

                    //Fill the list view with the step's data.
                    ListViewItem item = new ListViewItem(new string[] { Step.getId().ToString(), Step.getName(), Step.getDescription() });
                    this.Brother.lstVew_Steps.Items.Add(item);
                }
                else
                {
                    //Get the selected item (step) from the list.
                    int          selected = Brother.lstVew_Steps.SelectedIndices[0];
                    ListViewItem item     = Brother.lstVew_Steps.Items[selected];

                    //Add the created step to the steps list of the procedure.

                    //Remove the old version of step.
                    this.Brother.procedure.steps.RemoveAt(selected);

                    //Insert the new version at the same place.
                    this.Brother.procedure.steps.Insert(selected, Step);

                    //Fill the list view with the step's data.
                    item = new ListViewItem(new string[] { Step.getId().ToString(), Step.getName(), Step.getDescription() });

                    //Remove the old version of step.
                    Brother.lstVew_Steps.Items.RemoveAt(selected);
                    //Insert the new version at the same place.
                    Brother.lstVew_Steps.Items.Insert(selected, item);
                }

                Dispose();
            }
            else
            {
                MessageBox.Show(this, "L'étape doit avoir au minimum un objet.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void btn_AddStep_Click(object sender, EventArgs e)
        {
            this.procedure.setName(txtBx_Title.Text);
            this.procedure.setDescription(txtBx_Description.Text);

            //steps[steps.Count - 1] is the previous step of the one which is about to be created.
            //The last step is previous of the one to create now.
            Etape prevStep;

            if (this.procedure.steps != null && this.procedure.steps.Count > 0)
            {
                prevStep = this.procedure.steps[this.procedure.steps.Count - 1];
            }
            else
            {
                prevStep = null;
            }

            frm_AddStep frm = new frm_AddStep(prevStep, null, this.procedure, Operation.AddNew);

            frm.ShowDialog();
            //Add the created step to the steps list of the procedure.
            if (frm.Tag != null)
            {
                Etape step = (Etape)frm.Tag;
                this.procedure.addEtape(step);
                //Fill the list view with the step's data.
                ListViewItem item = new ListViewItem(new string[] { step.getId().ToString(), step.getName(), step.getDescription() });
                lstVew_Steps.Items.Add(item);
            }
        }
예제 #3
0
        private void btn_ModifySetp_Click(object sender, EventArgs e)
        {
            if (lstVew_Steps.SelectedIndices.Count > 0)
            {
                //Set the procedure data if its not already set.
                this.procedure.setName(txtBx_Title.Text);
                this.procedure.setDescription(txtBx_Description.Text);

                //Get the selected item (step) from the list.
                int          selected = lstVew_Steps.SelectedIndices[0];
                ListViewItem item     = lstVew_Steps.Items[selected];

                //Etape step = new Etape(Convert.ToInt32(item.SubItems[0].Text), item.SubItems[1].Text, item.SubItems[2].Text, this.procedure);
                Etape step = null;

                //Gets the id of the selected Step.
                int id = Convert.ToInt32(item.SubItems[0].Text);
                //MessageBox.Show("SelectedStepId: " + id, "frm_AddProcedure.btn_ModifyStep");
                //In the list of the procedure steps we look for the step with the previous Id.
                foreach (Etape stp in this.procedure.steps)
                {
                    if (stp.getId() == id)
                    {
                        step = stp;
                        break;
                    }
                }

                //We send the slected step to the update form.
                frm_AddStep frm = new frm_AddStep(null, step, this.procedure, Operation.Update);
                frm.ShowDialog();

                //Add the created step to the steps list of the procedure.
                if (frm.Tag != null)
                {
                    step = (Etape)frm.Tag;
                    //Remove the old version of step.
                    this.procedure.steps.RemoveAt(selected);

                    //Insert the new version at the same place.
                    this.procedure.steps.Insert(selected, step);

                    //Fill the list view with the step's data.
                    item = new ListViewItem(new string[] { step.getId().ToString(), step.getName(), step.getDescription() });

                    //Remove the old version of step.
                    lstVew_Steps.Items.RemoveAt(selected);
                    //Insert the new version at the same place.
                    lstVew_Steps.Items.Insert(selected, item);
                }
            }
            else
            {
                MessageBox.Show(this, "Sélectionner une étape SVP.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
        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();
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
        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"));
        }