Ejemplo n.º 1
0
        public static Object3d GetByNumber(int stepId, int nb)
        {
            /* On déclare et on crée une instance des variables nécéssaires pour la recherche */
            Object3d obj = new Object3d();
            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'obj à  partir du login */
                string ExpXPath = "//objet[@nb='" + nb + "']";
                ExpXPath = "//etape[@id='" + stepId + "']//objet[@nb='" + nb + "']";
                /* On lance la recherche */
                Nodes = Navigator.Select(Navigator.Compile(ExpXPath));
                /* On vérifie si la recherche a été fructueuse */
                //System.Windows.Forms.MessageBox.Show("Nodes.Count: " + Nodes.Count, "XMLObject3d.GetByNumber");
                if (Nodes.Count != 0)
                {
                    Nodes.MoveNext(); // NOTE: Necéssaire pour se placer sur le noeud recherché
                    /* Encodage des données dans la classe Object3d */
                    //System.Windows.Forms.MessageBox.Show("Current: "+Nodes.Current.Name,"XMLObject3d.GetByNumber");
                    //System.Windows.Forms.MessageBox.Show("Current.id: " + Nodes.Current.GetAttribute("id", ""), "XMLObject3d.GetByNumber");
                    obj = GetById(Convert.ToInt32(Nodes.Current.GetAttribute("id", "")));
                    obj.setPath();
                    obj.setNb(nb);
                }
                /* Si aucun obj n'a été trouvé */
                else
                {
                    obj = 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 "Client" */
            return obj;
        }
Ejemplo n.º 2
0
        private void btn_DrawObject_Click(object sender, EventArgs e)
        {
            ListBox listbox = ((ListBox)tabControl1.SelectedTab.GetChildAtPoint(new Point(0, 0)));

            ObjForListView model = (ObjForListView)(listbox.SelectedItem);

            if (model != null)
            {
                Vector3 scale = new Vector3(1f,1f,1f);
                switch (model.Name)
                {
                    case "droid":
                        scale = new Vector3(0.085f, 0.085f, 0.085f);
                        break;
                    case "miku":
                        scale = new Vector3(0.35f, 0.35f, 0.35f);
                        break;
                    case "tournevis":
                        scale = new Vector3(7.7f, 7.7f, 7.7f);
                        break;
                    case "flecheVerte":
                        scale = new Vector3(0.88f, 0.88f, 0.88f);
                        break;
                    case "box":
                        scale = new Vector3(20f, 20f, 20f);
                        break;
                }
                Object3d obj3d = new Object3d(Convert.ToInt32(model.Id), model.Name, model.Type,
                    new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0, 0, 0), scale, RenderForm.m_Device);
                obj3d.setNb(this.number);

                try
                {
                    obj3d.LoadMesh();
                }
                catch (FileNotFoundException)
                {
                    string str = "Le modèle " + obj3d.getName() + " n'existe pas dans le chemain " + obj3d.getPath();
                    MessageBox.Show(this, str, "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                RenderForm.Objects.Add(obj3d);
                lstbx_Objects.Items.Add(model);
                tabControl1.SelectedIndex = 0;
                if (lstbx_Objects.Items.Count > 0)
                {
                    lstbx_Objects.SelectedIndex = lstbx_Objects.Items.Count - 1;
                    lstbx_Objects_Click(null, EventArgs.Empty);
                }
                btn_RemoveObject.Enabled = true;
            }
        }