Ejemplo n.º 1
0
        public static void Open(MainWindow window, Model model)
        {
            bool goAhead = true;

            if (model != null && model.IsDirty && !CommandDoer.PromptSave(window, model))
            {
                goAhead = false;
            }

            if (goAhead)
            {
                System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
                ofd.InitialDirectory = CommandDoer.MapsDirectory;
                System.Windows.Forms.DialogResult result = ofd.ShowDialog();
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    string    filename  = ofd.FileName;
                    MapParser mapParser = new MapParser(filename, window.TileTemplateLookup);
                    window.ActiveModel         = mapParser.Parse();
                    window.ActiveModel.IsDirty = false;
                    window.InvalidateDrawing();
                    window.UpdateTitle();
                }
            }
        }
Ejemplo n.º 2
0
 public static void Exit(MainWindow window, Model model)
 {
     if (model.IsDirty)
     {
         if (CommandDoer.PromptSave(window, model))
         {
             window.Close();
         }
         else
         {
             // do nothing.
         }
     }
     else
     {
         window.Close();
     }
 }