示例#1
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;
            }
        }
示例#2
0
        /// <summary>
        /// Returns the list of 3d objects.
        /// </summary>
        /// <returns></returns>
        //public static List<string[]> GetAll3dObjects()
        public static List <ObjForListView> GetAll3dObjects()
        {
            /* On déclare et on crée une instance des variables nécéssaires pour la recherche */
            //List<string[]> objects = new List<string[]>();
            List <ObjForListView> objects = new List <ObjForListView>();

            try
            {
                string rslt = Helper.service.LoadFile("objet3d.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 = "//objet";
                /* On lance la recherche */
                Nodes = Navigator.Select(Navigator.Compile(ExpXPath));
                /* On vérifie si la recherche a été fructueuse */
                //System.Windows.Forms.MessageBox.Show("Node.count. "+Nodes.Count,"XMLObject3d.GetAllObjects");
                if (Nodes.Count != 0)
                {
                    Nodes.MoveNext(); // NOTE: Necéssaire pour se placer sur le noeud recherché
                    /* Encodage des données dans la classe Etape */

                    int tillCount = 0;
                    while (tillCount < Nodes.Count)
                    {
                        //data contains:
                        //0. Id
                        //1. Name
                        //2. Type

                        //string[] data = new string[3];
                        ObjForListView data = new ObjForListView(Nodes.Current.GetAttribute("id", ""), Path.GetFileNameWithoutExtension(Nodes.Current.GetAttribute("nom", "")),
                                                                 Nodes.Current.GetAttribute("type", ""));

                        //data[0] = Nodes.Current.GetAttribute("id", "");

                        //System.Windows.Forms.MessageBox.Show("Attrib. " + Nodes.Current.GetAttribute("id", ""), "XMLObject3d.GetAllObjects");

                        //data[1] = Nodes.Current.GetAttribute("nom", "");
                        //data[2] = Nodes.Current.GetAttribute("type", "");

                        objects.Add(data);
                        Nodes.Current.MoveToNext();
                        tillCount++;
                    }
                }
                /* Si aucun expert n'a été trouvé */
                else
                {
                    objects = 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" */
            //System.Windows.Forms.MessageBox.Show("ret.count " + objects.Count, "XMLObject3d.GetAllObjects");
            return(objects);
        }
示例#3
0
        /// <summary>
        /// Returns the list of 3d objects.
        /// </summary>
        /// <returns></returns>
        //public static List<string[]> GetAll3dObjects()
        public static List<ObjForListView> GetAll3dObjects()
        {
            /* On déclare et on crée une instance des variables nécéssaires pour la recherche */
            //List<string[]> objects = new List<string[]>();
            List<ObjForListView> objects = new List<ObjForListView>();
            try
            {
                string rslt = Helper.service.LoadFile("objet3d.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 = "//objet";
                /* On lance la recherche */
                Nodes = Navigator.Select(Navigator.Compile(ExpXPath));
                /* On vérifie si la recherche a été fructueuse */
                //System.Windows.Forms.MessageBox.Show("Node.count. "+Nodes.Count,"XMLObject3d.GetAllObjects");
                if (Nodes.Count != 0)
                {
                    Nodes.MoveNext(); // NOTE: Necéssaire pour se placer sur le noeud recherché
                    /* Encodage des données dans la classe Etape */

                    int tillCount = 0;
                    while (tillCount < Nodes.Count)
                    {
                        //data contains:
                        //0. Id
                        //1. Name
                        //2. Type

                        //string[] data = new string[3];
                        ObjForListView data = new ObjForListView(Nodes.Current.GetAttribute("id", ""), Path.GetFileNameWithoutExtension(Nodes.Current.GetAttribute("nom", "")),
                            Nodes.Current.GetAttribute("type", ""));

                        //data[0] = Nodes.Current.GetAttribute("id", "");

                        //System.Windows.Forms.MessageBox.Show("Attrib. " + Nodes.Current.GetAttribute("id", ""), "XMLObject3d.GetAllObjects");

                        //data[1] = Nodes.Current.GetAttribute("nom", "");
                        //data[2] = Nodes.Current.GetAttribute("type", "");

                        objects.Add(data);
                        Nodes.Current.MoveToNext();
                        tillCount++;
                    }

                }
                /* Si aucun expert n'a été trouvé */
                else
                {
                    objects = 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" */
            //System.Windows.Forms.MessageBox.Show("ret.count " + objects.Count, "XMLObject3d.GetAllObjects");
            return objects;
        }