コード例 #1
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();
 }
コード例 #2
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);
            }
        }
コード例 #3
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);
        }
コード例 #4
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);
     }
 }
コード例 #5
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);
            }
        }
コード例 #6
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);
        }
コード例 #7
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);
 }
コード例 #8
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);
            }
        }
コード例 #9
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);
        }
コード例 #10
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);
            }
        }
コード例 #11
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);
            }
        }
コード例 #12
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("");
        }
コード例 #13
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();
            }
        }
コード例 #14
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); }
            }
        }
コード例 #15
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); }
            }
        }
コード例 #16
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);
            }
        }