Esempio n. 1
0
        public static void ExportProject()
        {
            if (!projectLoadedFromFile)
            {
                SaveFileDialog fileDialog = new SaveFileDialog();
                fileDialog.InitialDirectory = Config.LastVisitedPath;

                fileDialog.Title = "Exporting project";

                fileDialog.Filter     = "FilesMaker Document (*.fmd)|*.fmd";
                fileDialog.DefaultExt = "fmd";

                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    // Save last opened directory
                    Config.LastVisitedPath = Path.GetDirectoryName(fileDialog.FileName);

                    // Start a file handler
                    fileHandler = new BinaryFileHandler(fileDialog.FileName, BinaryFileHandler.FileMode.WRITE);

                    Paper.ExportPaper();
                    Fonts.ExportFonts();
                    //Languages.SaveLanguages();

                    //Resources.SaveResources();
                    //Objects.SaveObjects();

                    fileHandler.Close();
                }
            }
        }
Esempio n. 2
0
        public static void SaveProject(bool SaveAs = false)
        {
            if (!projectLoadedFromFile || SaveAs)
            {
                SaveFileDialog fileDialog = new SaveFileDialog();
                fileDialog.InitialDirectory = Config.LastVisitedPath;

                fileDialog.Title = "Save your project";

                fileDialog.Filter     = "DocMaker Project (*.dmprj)|*.dmprj";
                fileDialog.DefaultExt = "dmprj";

                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Save last opened directory
                    Config.LastVisitedPath = Path.GetDirectoryName(fileDialog.FileName);

                    /*
                     * // Windows already asks if you want to replace file
                     * if (File.Exists(fileDialog.FileName))
                     * {
                     *  if (Funcs.Question("Do you want to overwrite this file ?") != DialogResult.Yes)
                     *      return;
                     * }
                     */

                    // Save the file
                    projectLoadedFromFile = true;
                    projectFile           = fileDialog.FileName;
                    projectTitle          = Path.GetFileName(projectFile);
                }
            }

            if (projectLoadedFromFile)
            {
                //Saving routings

                fileHandler = new BinaryFileHandler(projectFile, BinaryFileHandler.FileMode.WRITE);

                Paper.SavePaper();
                Fonts.SaveFonts();
                Languages.SaveLanguages();

                Resources.SaveResources();
                Objects.SaveObjects();

                fileHandler.Close();
            }
        }
Esempio n. 3
0
        public static void OpenProject()
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.InitialDirectory = Config.LastVisitedPath;

            fileDialog.Title       = "Open a project";
            fileDialog.Multiselect = false;

            fileDialog.Filter     = "DocMaker Project (*.dmprj)|*.dmprj";
            fileDialog.DefaultExt = "dmprj";

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                //Save last opened directory
                Config.LastVisitedPath = Path.GetDirectoryName(fileDialog.FileName);

                if (!File.Exists(fileDialog.FileName))
                {
                    Funcs.Error("Project file not found !");
                    return;
                }

                if (changeList.Count > 0)
                {
                    DialogResult dr = Funcs.Question_YNC("Do you want to save changes before opening the file ?");

                    if (dr == DialogResult.Cancel)
                    {
                        return;
                    }

                    if (dr == DialogResult.Yes)
                    {
                        SaveProject();
                    }
                }

                // Save the file
                projectLoadedFromFile = true;
                projectFile           = fileDialog.FileName;
                projectTitle          = Path.GetFileName(projectFile);

                try
                {
                    InitializeComponents();

                    fileHandler = new BinaryFileHandler(projectFile, BinaryFileHandler.FileMode.READ);

                    Paper.LoadPaper();
                    Fonts.LoadFonts();
                    Languages.LoadLanguages();

                    Resources.LoadResources();
                    Objects.LoadObjects();

                    fileHandler.Close();
                }
                catch (Exception ex)
                {
                    Funcs.Error("Error while loading the project file.\n" + ex.Message);
                    fileHandler.Close(); // Force closing file

                    NewProject();
                }
            }
        }