Exemplo n.º 1
0
        private void OnCreateGxtClick(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.FileName    = "";
            dialog.Filter      = "GXT file (*.gxt)|*.gxt|FXT file (*.fxt)|*.fxt";
            dialog.FilterIndex = 2;
            dialog.Title       = "Save as...";
            DialogResult result = dialog.ShowDialog();

            switch (result)
            {
            case DialogResult.OK:
                GameFile file = new GameFile(dialog.FileName);

                switch (file.Extension)
                {
                case ".fxt":
                    FXTFile         fxtFile         = new FXTFile(file.FullPath);
                    FXTEditorWindow fxtEditorWindow = new FXTEditorWindow();

                    try
                    {
                        fxtFile.SaveFile();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    fxtEditorWindow.OpenFile(fxtFile);
                    fxtEditorWindow.Show();
                    break;

                case ".gxt":

                    break;

                default:
                    MessageBox.Show("Unknown file extention!");
                    break;
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens the <paramref name="file"/> in it's associated editor
        /// </summary>
        /// <summary xml:lang="ru">
        /// Открывает файл <paramref name="file"/> в ассоциированным с его типом редакторе
        /// </summary>
        /// <param name="file">File to be opened</param>
        /// <param name="file" xml:lang="ru">Файл который необходимо открыть</param>
        public static void OpenFile(GameFile file)
        {
            // TODO: создать объект с расширениями файлов
            switch (file.Extension.ToLower())
            {
            case ".gxt":
                GXTEditorWindow gxtEditorWindow = new GXTEditorWindow();
                gxtEditorWindow.OpenFile(new GXTFile(file.FullPath));
                gxtEditorWindow.Show();
                break;

            case ".fxt":
                FXTEditorWindow fxtEditorWindow = new FXTEditorWindow();
                fxtEditorWindow.OpenFile(new FXTFile(file.FullPath));
                fxtEditorWindow.Show();
                break;

            case ".ide":
                TestWindow testWindow = new TestWindow();
                testWindow.OpenFile(new IDEFile(file.FullPath));
                testWindow.Show();
                break;

            case ".ipl":
            case ".dat":
            case ".txt":
            case ".log":
            case ".cfg":
            case ".ini":
            case ".zon":
                DataEditorWindow dataEditorWindow = new DataEditorWindow();
                dataEditorWindow.OpenFile(new TextFile(file.FullPath));
                dataEditorWindow.Show();
                break;

            case ".img":
                FileBrowserWindow.GetInstance().OpenArchive((ArchiveFile)file);
                break;

            default:
                MessageBox.Show("Unsupported file type.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
        }