Ejemplo n.º 1
0
        public ICommand CreateCommand()
        {
            if (app.WorldDirty)
            {
                DialogResult dlgRes = MessageBox.Show("You have unsaved changes.  You will have to save the file or cancel", "Save Changes?", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                switch (dlgRes)
                {
                case DialogResult.OK:
                    EventArgs e = new EventArgs();
                    if (app.WorldRoot != null && app.WorldRoot.WorldFilePath != null && !String.Equals(app.WorldRoot.WorldFilePath, ""))
                    {
                        app.SaveWorld(app.WorldRoot.WorldFilePath);
                        app.ResetDirtyWorld();
                    }
                    else
                    {
                        using (SaveFileDialog dlg = new SaveFileDialog())
                        {
                            string filename = "";

                            dlg.Title      = "Save World";
                            dlg.DefaultExt = "mvw";
                            if (app.WorldRoot != null && app.WorldRoot.WorldFilePath != null)
                            {
                                filename     = app.WorldRoot.WorldFilePath;
                                dlg.FileName = app.WorldRoot.WorldFilePath;
                                foreach (WorldObjectCollection obj in app.WorldRoot.WorldObjectCollections)
                                {
                                    obj.Filename = "";
                                }
                            }
                            else
                            {
                                if (app.WorldRoot == null)
                                {
                                    return(null);
                                }
                            }
                            dlg.Filter           = "Multiverse World files (*.mvw)|*.mvw|xml files (*.xml)|*.xml|All files (*.*)|*.*";
                            dlg.RestoreDirectory = true;
                            if (dlg.ShowDialog() == DialogResult.OK)
                            {
                                app.WorldRoot.WorldFilePath = dlg.FileName;
                                string title = String.Format("World Editor : {0}", dlg.FileName.Substring(dlg.FileName.LastIndexOf("\\") + 1));
                                app.SaveWorld(dlg.FileName);
                                app.ResetDirtyWorld();
                            }
                        }
                    }
                    break;

                case DialogResult.Cancel:
                    return(null);
                }
            }
            ICommand cmd = new UnloadCollectionCommand(app, topCollection);

            return(cmd);
        }
        public ICommand CreateCommand()
        {
            if (app.WorldDirty)
            {
                DialogResult dlgRes = MessageBox.Show("You have unsaved changes.  You will have to save the file or cancel", "Save Changes?", MessageBoxButtons.OKCancel , MessageBoxIcon.Information);
                switch (dlgRes)
                {
                    case DialogResult.OK:
                        EventArgs e = new EventArgs();
                        if (app.WorldRoot != null && app.WorldRoot.WorldFilePath != null && !String.Equals(app.WorldRoot.WorldFilePath, ""))
                        {
                            app.SaveWorld(app.WorldRoot.WorldFilePath);
                            app.ResetDirtyWorld();
                        }
                        else
                        {
                            using (SaveFileDialog dlg = new SaveFileDialog())
                            {
                                string filename = "";

                                dlg.Title = "Save World";
                                dlg.DefaultExt = "mvw";
                                if (app.WorldRoot != null && app.WorldRoot.WorldFilePath != null)
                                {
                                    filename = app.WorldRoot.WorldFilePath;
                                    dlg.FileName = app.WorldRoot.WorldFilePath;
                                    foreach (WorldObjectCollection obj in app.WorldRoot.WorldObjectCollections)
                                    {
                                        obj.Filename = "";
                                    }
                                }
                                else
                                {
                                    if (app.WorldRoot == null)
                                    {
                                        return null;
                                    }
                                }
                                dlg.Filter = "Multiverse World files (*.mvw)|*.mvw|xml files (*.xml)|*.xml|All files (*.*)|*.*";
                                dlg.RestoreDirectory = true;
                                if (dlg.ShowDialog() == DialogResult.OK)
                                {
                                    app.WorldRoot.WorldFilePath = dlg.FileName;
                                    string title = String.Format("World Editor : {0}", dlg.FileName.Substring(dlg.FileName.LastIndexOf("\\") + 1));
                                    app.SaveWorld(dlg.FileName);
                                    app.ResetDirtyWorld();
                                }
                            }
                        }
                        break;
                    case DialogResult.Cancel:
                        return null;
                }
            }
            ICommand cmd = new UnloadCollectionCommand(app, topCollection);
            return cmd;
        }