Esempio n. 1
0
        private static void saveSceneTo(MainWindow window)
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            dlg.InitialDirectory = appPath + "\\scene";
            dlg.DefaultExt       = ".Sce";
            dlg.Filter           = "场景文件(*.Sce)|*.Sce";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                HandleSources.saveScene(window.myContainer, filename);
                MyListBoxItem lbi = new MyListBoxItem();
                lbi.DataContext = dlg.FileName;

                lbi.resolution = window.myContainer.Width + "," + window.myContainer.Height;
                lbi.Content    = dlg.SafeFileName.Substring(0, dlg.SafeFileName.Length - 4) + "{" + lbi.resolution + "}";
                window.scenes.Items.Add(lbi);
                //window.scenesArray.Add(dlg.FileName);
                window.scenes.SelectedIndex = window.scenes.Items.Count - 1;
            }
        }
Esempio n. 2
0
 private static void saveScene(MainWindow window)
 {
     if (window.scenes.SelectedIndex == -1)
     {
         saveSceneTo(window);
     }
     else
     {
         string filename = (window.scenes.SelectedItem as MyListBoxItem).DataContext as string;
         (window.scenes.SelectedItem as MyListBoxItem).resolution = window.myContainer.Width + "," + window.myContainer.Height;
         HandleSources.saveScene(window.myContainer, filename);
     }
 }