- Main Page
- Packages
- Classes
- Files

- File List
- File Members

# D:/guillaume/guillara/3D/DXGfx/Editor/NewSceneDialog.cs

Go to the documentation of this file.

    00001 using System;
    00002 using System.IO;
    00003 using System.Collections.Generic;
    00004 using System.ComponentModel;
    00005 using System.Data;
    00006 using System.Drawing;
    00007 using System.Text;
    00008 using System.Windows.Forms;
    00009
    00010 namespace Editor
    00011 {
    00012     public partial class NewSceneDialog : Form
    00013     {
    00014         public NewSceneDialog()
    00015         {
    00016             InitializeComponent();
    00017         }
    00018
    00019         private void NewSceneDialog_Load(object sender, EventArgs e)
    00020         {
    00021
    00022         }
    00023
    00024         private void btnOk_Click(object sender, EventArgs e)
    00025         {
    00026             // Check that we have a valid file name for the scene.
    00027             // If we don't have any valid file name don't do anything!
    00028
    00029             if (File.Exists(fileNameTextBox.Text))
    00030             {
    00031                 DirectoryInfo dInf = Directory.GetParent(fileNameTextBox.Text);
    00032
    00033                 if (dInf.Exists)
    00034                 {
    00035                     DialogResult = DialogResult.OK;
    00036                 }
    00037             }
    00038             else
    00039             {
    00040                 MessageBox.Show("Please enter a valid file name!");
    00041             }
    00042         }
    00043
    00044         private void fileNameTextBox_TextChanged(object sender, EventArgs e)
    00045         {
    00046
    00047         }
    00048
    00049         private void browseBtn_Click(object sender, EventArgs e)
    00050         {
    00051             SaveFileDialog dlg = new SaveFileDialog();
    00052
    00053             // Set the properties on dlg so the user is
    00054             // prompted to create the file if it doesn't exist
    00055             // or overwrite the file if it does exist.
    00056             dlg.CreatePrompt = true;
    00057             dlg.OverwritePrompt = true;
    00058
    00059             // Set the file name to myText.txt, set the type filter
    00060             // to text files, and set the initial directory to drive C.
    00061             dlg.FileName = "myScene";
    00062             dlg.DefaultExt = "xml";
    00063             dlg.Filter = "Scene files (*.xml)|*.xml";
    00064
    00065             // Call ShowDialog and check for a return value of DialogResult.OK,
    00066             // which indicates that the file was saved.
    00067             DialogResult result = dlg.ShowDialog();
    00068             System.IO.Stream fileStream;
    00069
    00070             if (result == DialogResult.OK)
    00071
    00072             // Open the file, copy the contents of memoryStream to fileStream,
    00073             // and close fileStream. Set the memoryStream.Position value to 0 to
    00074             // copy the entire stream.
    00075             {
    00076                 fileStream = dlg.OpenFile();
    00077                 StreamWriter sw = new StreamWriter(fileStream);
    00078                 sw.Write("Empty. File was created but no scene information was ever persisted here!");
    00079                 fileStream.Close();
    00080
    00081                 fileNameTextBox.Text = dlg.FileName;
    00082             }
    00083
    00084         }
    00085
    00086         private void BtnCancel_Click(object sender, EventArgs e)
    00087         {
    00088             DialogResult = DialogResult.Cancel;
    00089         }
    00090     }
    00091 }