SetFileName() 공개 메소드

public SetFileName ( string filename ) : void
filename string
리턴 void
예제 #1
0
        private void ReadLevel()
        {
            this.updating = true;

            var d = new OpenFileDialog();

            if (d.ShowDialog() == DialogResult.OK)
            {
                this.ClearLevel();


                var level = new Level();
                level.SetFileName(d.FileName);
                this.lstLevel.Items.Add(level);

                XmlDocument xml = new XmlDocument();
                xml.Load(d.FileName);
                level.Read(xml["level"]);
                foreach (XmlElement el in xml["level"]["actors"])
                {
                    Actor actor = new Actor();
                    actor.Read(el);
                }
                foreach (XmlElement el in xml["level"]["physics"])
                {
                    Physic p;
                    if (el.Name == "circle")
                    {
                        p = new Circle();
                    }
                    else if (el.Name == "polygon")
                    {
                        p = new Polygon();
                    }
                    else
                    {
                        MessageBox.Show(string.Format("unsupported physic '{0}'. Element skipped.", el.Name));
                        continue;
                    }
                    p.Read(el);
                }
            }

            this.updating = false;
            this.UpdateControls();
            this.GetCurrent().SelectedItem = this.GetCurrent().Items[0];
        }
예제 #2
0
        private void saveXmlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Level level = (Level)this.lstLevel.Items[0];

            if (level.FileName == string.Empty)
            {
                var d = new SaveFileDialog();
                if (d.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                level.SetFileName(d.FileName);
            }

            XmlWriterSettings writerSettings = new XmlWriterSettings();

            writerSettings.Indent = true;
            XmlWriter writer = XmlWriter.Create(level.FileName, writerSettings);

            this.WriteLevel(writer);
            this.UpdateControls();
        }
예제 #3
0
        private void ReadLevel()
        {
            this.updating = true;

             var d = new OpenFileDialog();
             if (d.ShowDialog() == DialogResult.OK)
             {
            this.ClearLevel();

            var level = new Level();
            level.SetFileName(d.FileName);
            this.lstLevel.Items.Add(level);

            XmlDocument xml = new XmlDocument();
            xml.Load(d.FileName);
            level.Read(xml["level"]);
            foreach (XmlElement el in xml["level"]["actors"])
            {
               Actor actor = new Actor();
               actor.Read(el);
            }
            foreach (XmlElement el in xml["level"]["physics"])
            {
               Physic p;
               if (el.Name == "circle")
                  p = new Circle();
               else if (el.Name == "polygon")
                  p = new Polygon();
               else
               {
                  MessageBox.Show(string.Format("unsupported physic '{0}'. Element skipped.", el.Name));
                  continue;
               }
               p.Read(el);
            }
             }

             this.updating = false;
             this.UpdateControls();
             this.GetCurrent().SelectedItem = this.GetCurrent().Items[0];
        }