Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        private void btn_Down_Click(object sender, EventArgs e)
        {
            if (lstVew_Steps.SelectedIndices.Count > 0)
            {
                int selected = lstVew_Steps.SelectedIndices[0];
                if (selected < lstVew_Steps.Items.Count - 1)
                {
                    //Save the lower step to move up 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 down.
                    lstVew_Steps.Items.Insert(selected, item);


                    //Save the lower 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);
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);

                //Use the Tag object to transfere data between forms.
                this.Tag = Step;
                Close();
            }
            else
            {
                MessageBox.Show(this, "L'étape doit avoir au minimum un objet.", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 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);
        }