コード例 #1
0
        private void CreateNewProject()
        {
            try
            {
                if (Directory.Exists(Path.Combine(SelectedPath, ProjectName)))
                {
                    Errorhandler.RaiseMessage("This folder already exists. Please choose another project name.", "Existing Folder", Errorhandler.MessageType.Error);
                    return;
                }

                string projectpath = Path.Combine(SelectedPath, ProjectName);
                Directory.CreateDirectory(projectpath);
                Directory.CreateDirectory(Path.Combine(projectpath, "Source Image"));
                Directory.CreateDirectory(Path.Combine(projectpath, "Planner Files"));

                DominoAssembly main = new DominoAssembly();
                main.Save(Path.Combine(projectpath, ProjectName + Properties.Resources.ProjectExtension));

                if (File.Exists(sPath))
                {
                    string colorPath = Path.Combine(SelectedPath, ProjectName, "Planner Files", $"colors{Properties.Resources.ColorExtension}");
                    File.Copy(sPath, colorPath);
                    main.colorPath = Path.Combine("Planner Files", "colors" + Properties.Resources.ColorExtension);
                }

                main.Save();

                Errorhandler.RaiseMessage($"The project {ProjectName}{Properties.Resources.ProjectExtension} has been created", "Created", Errorhandler.MessageType.Info);
                Close = true;
            }
            catch (Exception e)
            {
                Console.WriteLine("Project creation failed: {0}", e.ToString());
            }
        }
コード例 #2
0
        internal async void AfterStartupChecks()
        {
            if (FirstStartup)
            {
                UserSettings.Instance.StandardColorArray  = Path.Combine(UserSettings.AppDataPath, "colors.DColor");
                UserSettings.Instance.StandardProjectPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "DominoPlanner");
                UserSettings.Instance.OpenProjectList     = Path.Combine(UserSettings.AppDataPath, "OpenProjects.xml");
                if (!File.Exists(UserSettings.Instance.OpenProjectList))
                {
                    File.Create(UserSettings.Instance.OpenProjectList).Close();
                }
                UserSettings.Instance.StructureTemplates = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "Structures.xml");
                Directory.CreateDirectory(UserSettings.Instance.StandardProjectPath);
                Directory.CreateDirectory(UserSettings.AppDataPath);
                OpenProjectSerializer.Create();
                FirstStartup = false;
            }

            while (!File.Exists(UserSettings.Instance.StandardColorArray))
            {
                await Errorhandler.RaiseMessage(_("Please create a default color table."), _("Missing Color Table"), Errorhandler.MessageType.Info);

                await new SetStandardV().ShowDialogWithParent <MainWindow>();
            }
            LoadProjectList();
        }
コード例 #3
0
        public async void SaveHTMLFile()
        {
            SaveFileDialog dlg = new SaveFileDialog
            {
                DefaultExtension = ".html",
                InitialFileName  = Titel,
                Directory        = DialogExtensions.GetCurrentProjectPath()
            };

            dlg.Filters.Add(new FileDialogFilter()
            {
                Extensions = new List <string> {
                    "html"
                }, Name = _("Hypertext Markup Language")
            });
            string filename = await dlg.ShowAsyncWithParent <ProtocolV>();

            if (filename != null && filename != "")
            {
                try
                {
                    FileStream   fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
                    StreamWriter sw = new StreamWriter(fs);
                    sw.Write(CurrentProtocol);
                    sw.Close();
                    var process = new Process();
                    process.StartInfo = new ProcessStartInfo(filename)
                    {
                        UseShellExecute = true
                    };
                    process.Start();
                }
                catch (Exception ex) { await Errorhandler.RaiseMessage(_("Error: ") + ex.Message, _("Error"), Errorhandler.MessageType.Error); }
            }
        }
コード例 #4
0
        public MainWindowViewModel()
        {
            Properties.Settings.Default.Upgrade();
            Properties.Settings.Default.StructureTemplates = Properties.Settings.Default.Properties["StructureTemplates"].DefaultValue.ToString();
            if (Properties.Settings.Default.FirstStartup)
            {
                Properties.Settings.Default.StandardColorArray  = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Appdata", "Local", "DominoPlanner", "colors" + Properties.Resources.ColorExtension);
                Properties.Settings.Default.StandardProjectPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Appdata", "Local", "DominoPlanner");
                Properties.Settings.Default.OpenProjectList     = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Appdata", "Local", "DominoPlanner", "OpenProjects.xml");
                Directory.CreateDirectory(Path.GetDirectoryName(Properties.Settings.Default.StandardColorArray));
                OpenProjectSerializer.Create();
                Properties.Settings.Default.FirstStartup = false;
            }
            Properties.Settings.Default.Save();

            while (!File.Exists(Properties.Settings.Default.StandardColorArray))
            {
                Errorhandler.RaiseMessage("Please create a defaultcolortable.", "Missing Color Table", Errorhandler.MessageType.Info);
                new SetStandardV().ShowDialog();
            }

            NewFieldStruct       = new RelayCommand(o => { NewFieldStructure(); });
            MenuSetStandard      = new RelayCommand(o => { new SetStandardV().ShowDialog(); });
            AddExistingProject   = new RelayCommand(o => { AddProject_Exists(); });
            AddExistingItem      = new RelayCommand(o => { AddItem_Exists(); });
            NewProject           = new RelayCommand(o => { CreateNewProject(); });
            SaveAll              = new RelayCommand(o => { SaveAllOpen(); });
            SaveCurrentOpen      = new RelayCommand(o => { SaveCurrentOpenProject(); });
            FileListClickCommand = new RelayCommand(o => { OpenItemFromPath(o); });
            Tabs          = new ObservableCollection <TabItem>();
            Workspace.del = UpdateReference;
            loadProjectList();
        }
コード例 #5
0
        public async void SaveExcelFile()
        {
            SaveFileDialog dlg = new SaveFileDialog
            {
                DefaultExtension = ".xlsx",
                InitialFileName  = Titel,
                Directory        = DialogExtensions.GetCurrentProjectPath()
            };

            dlg.Filters.Add(new FileDialogFilter()
            {
                Extensions = new List <string> {
                    "xlsx"
                }, Name = _("Excel Document")
            });

            string result = await dlg.ShowAsyncWithParent <ProtocolV>();

            if (result != null && result != "")
            {
                try
                {
                    DominoProvider.SaveXLSFieldPlan(result, currentOPP);
                    var process = new Process();
                    process.StartInfo = new ProcessStartInfo(result)
                    {
                        UseShellExecute = true
                    };
                    process.Start();
                }
                catch (Exception ex) { await Errorhandler.RaiseMessage(_("Error: ") + ex.Message, _("Error"), Errorhandler.MessageType.Error); }
            }
        }
コード例 #6
0
        private List <ProjectElement> getProjects(DominoAssembly dominoAssembly)
        {
            List <ProjectElement> returnList = new List <ProjectElement>();

            if (dominoAssembly != null)
            {
                ProjectElement color = new ProjectElement(dominoAssembly.colorPath, @".\Icons\colorLine.ico", null);
                returnList.Add(color);
            }

            foreach (DocumentNode dominoWrapper in dominoAssembly.children.OfType <DocumentNode>().ToList())
            {
                try
                {
                    string relativePath = dominoWrapper.relativePath;
                    string filepath     = Workspace.AbsolutePathFromReference(ref relativePath, dominoWrapper.parent);
                    dominoWrapper.relativePath = relativePath;
                    string         picturepath = ImageHelper.GetImageOfFile(filepath);
                    ProjectElement project     = new ProjectElement(filepath,
                                                                    picturepath, dominoWrapper);
                    returnList.Add(project);
                }
                catch (FileNotFoundException)
                {
                    // Remove file from Project
                    dominoAssembly.children.Remove(dominoWrapper);
                    Errorhandler.RaiseMessage($"The file {dominoWrapper.relativePath} doesn't exist at the current location. \nIt has been removed from the project.", "Missing file", Errorhandler.MessageType.Error);
                    dominoAssembly.Save();
                }
            }
            dominoAssembly.Save();
            return(returnList);
        }
コード例 #7
0
 private void AddItem_Exists()
 {
     if (SelectedProject == null)
     {
         Errorhandler.RaiseMessage("Please choose a project folder.", "Please choose", Errorhandler.MessageType.Error);
         return;
     }
     SelectedProject.AddExistingItem();
 }
コード例 #8
0
 /// <summary>
 /// Neues Unterprojekt starten
 /// </summary>
 private void NewFieldStructure()
 {
     if (SelectedProject == null)
     {
         Errorhandler.RaiseMessage("Please choose a project folder.", "Please choose", Errorhandler.MessageType.Error);
         return;
     }
     SelectedProject.NewFieldStructure();
 }
コード例 #9
0
        private void SetColorPath()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            try
            {
                openFileDialog.InitialDirectory = ColorVM.FilePath;
                openFileDialog.Filter           = $"All color files |*{Properties.Resources.ColorExtension};*.clr;*.farbe|" +
                                                  $"DominoPlanner 3.x color files (*{Properties.Resources.ColorExtension})|*{Properties.Resources.ColorExtension}|" +
                                                  "DominoPlanner 2.x color files (*.clr)|*.clr|" +
                                                  "Dominorechner color files (*.farbe)|*.farbe|" +
                                                  "All files (*.*)|*.*";
                openFileDialog.InitialDirectory = Path.Combine(Environment.CurrentDirectory, "Resources");
            }
            catch (Exception) { }

            if (openFileDialog.ShowDialog() == true)
            {
                if (File.Exists(openFileDialog.FileName))
                {
                    ColorRepository colorList;
                    int             colorListVersion = 0;
                    try
                    {
                        colorList        = Workspace.Load <ColorRepository>(openFileDialog.FileName);
                        colorListVersion = 3;
                    }
                    catch
                    {
                        // Colorlist version 1 or 2
                        try
                        {
                            colorList        = new ColorRepository(openFileDialog.FileName);
                            colorListVersion = 1;
                        }
                        catch
                        {
                            // file not readable
                            Errorhandler.RaiseMessage("Color repository file is invalid", "Error", Errorhandler.MessageType.Error);
                            return;
                        }
                    }
                    File.Delete(Properties.Settings.Default.StandardColorArray);
                    if (colorListVersion == 3)
                    {
                        File.Copy(openFileDialog.FileName, Properties.Settings.Default.StandardColorArray);
                    }
                    else if (colorListVersion != 0)
                    {
                        colorList.Save(Properties.Settings.Default.StandardColorArray);
                    }
                }
                Workspace.CloseFile(Properties.Settings.Default.StandardColorArray);
                ColorVM.Reload(Properties.Settings.Default.StandardColorArray);
            }
        }
コード例 #10
0
        public async Task <bool> CheckIfParentProjectMissing()
        {
            if (SelectedAssembly == null)
            {
                await Errorhandler.RaiseMessage(_("Objects require a parent project, which contains the color list to be used. Please choose a parent project in the project panel."), _("Select parent project"), Errorhandler.MessageType.Error);

                return(true);
            }
            return(false);
        }
コード例 #11
0
 /// <summary>
 /// Save current project
 /// </summary>
 private void SaveCurrentOpenProject()
 {
     if (SelectedTab.Content.Save())
     {
         Errorhandler.RaiseMessage("Save all changes!", "Save all changes", Errorhandler.MessageType.Info);
     }
     else
     {
         Errorhandler.RaiseMessage("Error!", "Error saving changes!", Errorhandler.MessageType.Error);
     }
 }
コード例 #12
0
        private async void LoadProject(OpenProject newProject)
        {
            bool   remove      = true;
            string projectpath = Path.Combine(newProject.path, $"{newProject.name}.{Declares.ProjectExtension}");

            if (File.Exists(projectpath))
            {
                remove = false;

                AssemblyNodeVM node = null;

                try
                {
                    AssemblyNode mainnode = new AssemblyNode(projectpath);
                    // check if the file can be deserialized properly
                    node = new AssemblyNodeVM(mainnode, OpenItem, RemoveNodeFromTabs, GetTab);
                    if (node.BrokenFile || (node.Model as AssemblyNode).Obj.ColorListBroken)
                    {
                        remove = true;
                    }
                }
                catch (Exception)
                {
                    try
                    {
                        AssemblyNode restored = await AssemblyNodeVM.RestoreAssembly(projectpath);

                        node = new AssemblyNodeVM(restored, OpenItem, RemoveNodeFromTabs, GetTab);
                    }
                    catch (FileNotFoundException)
                    {
                        remove = true;
                    }
                    catch
                    {
                        await Errorhandler.RaiseMessage(String.Format(_("The main project file of project {0} was damaged. An attempt to restore the file has been unsuccessful. \nThe project will be removed from the list of opened projects."), projectpath), _("Damaged File"), Errorhandler.MessageType.Error);

                        remove = true;
                    }
                }
                if (!remove)
                {
                    Projects.Add(node);
                }
            }
            if (remove)
            {
                await Errorhandler.RaiseMessage(string.Format(_("Unable to load project {0}. It might have been moved or damaged. \nPlease re-add it at its current location.\n\nThe project has been removed from the list of opened projects."), newProject.name), _("Error"), Errorhandler.MessageType.Error);

                OpenProjectSerializer.RemoveOpenProject(newProject.id);
            }
        }
コード例 #13
0
        /// <summary>
        /// Save current project
        /// </summary>
        private async Task <bool> SaveCurrentOpenProject()
        {
            var result = SelectedTab.Content.Save();

            if (result)
            {
                await Errorhandler.RaiseMessage(_("All changes saved"), _("Success"), Errorhandler.MessageType.Info);
            }
            else
            {
                await Errorhandler.RaiseMessage(_("Error saving changes"), _("Error"), Errorhandler.MessageType.Error);
            }
            return(result);
        }
コード例 #14
0
 /// <summary>
 /// Save all open projects
 /// </summary>
 private void SaveAllOpen()
 {
     foreach (TabItem curTI in Tabs)
     {
         if (curTI.Content.UnsavedChanges)
         {
             if (!curTI.Content.Save())
             {
                 Errorhandler.RaiseMessage("Error Saving files!", string.Format("Stop saving, because could not save {0}", curTI.Header), Errorhandler.MessageType.Error);
                 return;
             }
         }
     }
     Errorhandler.RaiseMessage("Save all files", "Saves all files!", Errorhandler.MessageType.Info);
 }
コード例 #15
0
        /// <summary>
        /// Save all open projects
        /// </summary>
        private async void SaveAllOpen()
        {
            foreach (UserControls.ViewModel.TabItem curTI in Tabs)
            {
                if (curTI.Content.UnsavedChanges)
                {
                    if (!curTI.Content.Save())
                    {
                        await Errorhandler.RaiseMessage(_("Error saving files!"), string.Format(_("Save aborted, unable to save file {0}"), curTI.Header), Errorhandler.MessageType.Error);

                        return;
                    }
                }
            }
            await Errorhandler.RaiseMessage(_("All files saved"), _("Success"), Errorhandler.MessageType.Info);
        }
コード例 #16
0
        private void CreateNewProject()
        {
            NewProjectVM curNPVM = new NewProjectVM();

            new NewProject(curNPVM).ShowDialog();
            if (curNPVM.Close == true)
            {
                OpenProject newProj = OpenProjectSerializer.AddOpenProject(curNPVM.ProjectName, string.Format(@"{0}\{1}", curNPVM.SelectedPath, curNPVM.ProjectName));
                if (newProj == null)
                {
                    Errorhandler.RaiseMessage("Could not create new Project!", "Error!", Errorhandler.MessageType.Error);
                    return;
                }
                loadProject(newProj);
            }
        }
コード例 #17
0
        private async void CreateNewProject()
        {
            NewProjectVM curNPVM = new NewProjectVM();

            await new NewProject(curNPVM).ShowDialogWithParent <MainWindow>();
            if (curNPVM.Close == true)
            {
                OpenProject newProj = OpenProjectSerializer.AddOpenProject(curNPVM.ProjectName, string.Format(@"{0}/{1}", curNPVM.SelectedPath, curNPVM.ProjectName));
                if (newProj == null)
                {
                    await Errorhandler.RaiseMessage(_("Could not create new Project!"), _("Error!"), Errorhandler.MessageType.Error);

                    return;
                }
                LoadProject(newProj);
            }
        }
コード例 #18
0
        private void loadProject(OpenProject newProject)
        {
            bool   remove      = true;
            string projectpath = Path.Combine(newProject.path, $"{newProject.name}{Properties.Resources.ProjectExtension}");

            if (File.Exists(projectpath))
            {
                remove = false;

                AssemblyNodeVM node = null;

                try
                {
                    AssemblyNode mainnode = new AssemblyNode(projectpath);
                    // check if the file can be deserialized properly
                    node = new AssemblyNodeVM(mainnode, OpenItem, RemoveNodeFromTabs, GetTab);
                }
                catch
                {
                    try
                    {
                        AssemblyNode restored = AssemblyNodeVM.RestoreAssembly(projectpath);
                        node = new AssemblyNodeVM(restored, OpenItem, RemoveNodeFromTabs, GetTab);
                    }
                    catch (FileNotFoundException)
                    {
                        remove = true;
                    }
                    catch
                    {
                        Errorhandler.RaiseMessage($"The main project file of project {projectpath} was damaged. An attempt to restore the file has been unsuccessful. \nThe project will be removed from the list of opened projects.", "Damaged File", Errorhandler.MessageType.Error);
                        remove = true;
                    }
                }
                if (!remove)
                {
                    Projects.Add(node);
                }
            }
            if (remove)
            {
                Errorhandler.RaiseMessage($"Unable to load project {newProject.name}. It might have been moved or damaged. \nPlease re-add it at its current location.\n\nThe project has been removed from the list of opened projects.", "Error!", Errorhandler.MessageType.Error);
                OpenProjectSerializer.RemoveOpenProject(newProject.id);
            }
        }
コード例 #19
0
        /// <summary>
        /// Projektliste laden
        /// </summary>
        private void loadProjectList()
        {
            Projects = new ObservableCollection <AssemblyNodeVM>();
            List <OpenProject> OpenProjects = OpenProjectSerializer.GetOpenProjects();

            if (OpenProjects != null)
            {
                foreach (OpenProject curOP in OpenProjects)
                {
                    loadProject(curOP);
                }
            }
            else
            {
                Errorhandler.RaiseMessage("Error loading opened projects!", "Error", Errorhandler.MessageType.Error);
                OpenProjectSerializer.Create();
            }
        }
コード例 #20
0
        private string UpdateReference(string absolutePath, string parentPath)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = Path.GetDirectoryName(absolutePath);
            ofd.Title            = $"Locate file {Path.GetFileName(absolutePath)}";
            Errorhandler.RaiseMessage($"The object {parentPath} contains a reference to the file {absolutePath}," +
                                      $"which could not be located. Please find the file.", "Missing file", Errorhandler.MessageType.Error);
            string extension = Path.GetExtension(absolutePath);

            ofd.Filter = $"{extension} files|*{extension}|all files|*.*";
            if (ofd.ShowDialog() == true && File.Exists(ofd.FileName))
            {
                return(Workspace.MakeRelativePath(parentPath, ofd.FileName));
            }

            return("");
        }
コード例 #21
0
ファイル: ProtocolVM.cs プロジェクト: dhw970805/DominoPlanner
        public void SaveExcelFile()
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog
            {
                DefaultExt = ".xlsx",
                Filter     = "Excel Document (.xlsx)|*.xlsx",
                FileName   = Titel
            };

            if (dlg.ShowDialog() == true)
            {
                try
                {
                    DominoProvider.SaveXLSFieldPlan(dlg.FileName, currentOPP); // Jojo hier Projektname einfügen
                    Process.Start(dlg.FileName);
                }
                catch (Exception ex) { Errorhandler.RaiseMessage("Error: " + ex.Message, "Error", Errorhandler.MessageType.Error); }
            }
        }
コード例 #22
0
ファイル: ProtocolVM.cs プロジェクト: dhw970805/DominoPlanner
        public void SaveHTMLFile()
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.DefaultExt = ".html";
            dlg.Filter     = "Hypertext Markup Language (.html)|*.html";
            if (dlg.ShowDialog() == true)
            {
                string filename = dlg.FileName;

                try
                {
                    FileStream   fs = new FileStream(filename, FileMode.Create, FileAccess.Write);
                    StreamWriter sw = new StreamWriter(fs);
                    sw.Write(CurrentProtocol);
                    fs.Close();
                    Process.Start(filename);
                }
                catch (Exception ex) { Errorhandler.RaiseMessage("Error: " + ex.Message, "Error", Errorhandler.MessageType.Error); }
            }
        }
コード例 #23
0
        private async void CreateNewProject()
        {
            try
            {
                if (Directory.Exists(Path.Combine(SelectedPath, ProjectName)))
                {
                    await Errorhandler.RaiseMessageWithParent <NewProject>(_("This folder already exists. Please choose another project name."), GetParticularString("Error on project creation", "Existing Folder"), Errorhandler.MessageType.Error);

                    return;
                }

                string projectpath = Path.Combine(SelectedPath, ProjectName);
                Directory.CreateDirectory(projectpath);
                Directory.CreateDirectory(Path.Combine(projectpath, "Source Image"));
                Directory.CreateDirectory(Path.Combine(projectpath, "Planner Files"));

                DominoAssembly main            = new DominoAssembly();
                var            projectfilename = ProjectName + "." + Declares.ProjectExtension;
                main.Save(Path.Combine(projectpath, projectfilename));

                if (File.Exists(sPath))
                {
                    string colorPath = Path.Combine(SelectedPath, ProjectName, "Planner Files", $"colors.{Declares.ColorExtension}");
                    File.Copy(sPath, colorPath);
                    main.ColorPath = Path.Combine("Planner Files", "colors." + Declares.ColorExtension);
                }

                main.Save();

                await Errorhandler.RaiseMessageWithParent <NewProject>(string.Format(_("The project {0} has been created"), projectfilename), _("Project created"), Errorhandler.MessageType.Info);

                Close = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(_("Project creation failed: {0}"), e.ToString());
            }
        }
コード例 #24
0
        private async void SetColorPath()
        {
            var            StandardColorPath = UserSettings.Instance.StandardColorArray;
            OpenFileDialog openFileDialog    = new OpenFileDialog();

            try
            {
                openFileDialog.Filters = new System.Collections.Generic.List <FileDialogFilter>
                {
                    new FileDialogFilter()
                    {
                        Extensions = new System.Collections.Generic.List <string> {
                            Declares.ColorExtension, "clr", "farbe"
                        }, Name = _("All color files")
                    },
                    new FileDialogFilter()
                    {
                        Extensions = new System.Collections.Generic.List <string> {
                            Declares.ColorExtension
                        }, Name = _("DominoPlanner 3.x color files")
                    },
                    new FileDialogFilter()
                    {
                        Extensions = new System.Collections.Generic.List <string> {
                            "clr"
                        }, Name = _("DominoPlanner 2.x color files")
                    },
                    new FileDialogFilter()
                    {
                        Extensions = new System.Collections.Generic.List <string> {
                            "farbe"
                        }, Name = _("Dominorechner color files")
                    },
                };
                if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    openFileDialog.Directory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources");
                }
                else
                {
                    // otherwise, the dialog is opened in the parent directory (see https://github.com/AvaloniaUI/Avalonia/issues/4141)
                    // TODO: check macos
                    openFileDialog.Directory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "lamping.DColor");
                }
            }
            catch (Exception) { }
            var result = await openFileDialog.ShowAsyncWithParent <SetStandardV>();

            if (result != null && result.Length != 0)
            {
                var filename = result[0];
                if (File.Exists(filename))
                {
                    ColorRepository colorList;
                    int             colorListVersion;
                    try
                    {
                        colorList        = Workspace.Load <ColorRepository>(filename);
                        colorListVersion = 3;
                    }
                    catch
                    {
                        // Colorlist version 1 or 2
                        try
                        {
                            colorList        = new ColorRepository(filename);
                            colorListVersion = 1;
                        }
                        catch
                        {
                            // file not readable
                            await Errorhandler.RaiseMessage(GetParticularString("When importing color list fails", "Color repository file is invalid"), _("Error"), Errorhandler.MessageType.Error);

                            return;
                        }
                    }
                    File.Delete(StandardColorPath);
                    if (colorListVersion == 3)
                    {
                        File.Copy(filename, StandardColorPath);
                    }
                    else if (colorListVersion != 0)
                    {
                        colorList.Save(StandardColorPath);
                    }
                }
                Workspace.CloseFile(StandardColorPath);
                ColorVM.Reload(StandardColorPath);
            }
        }