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);
        }
Exemple #2
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());
            }
        }
 public NewObjectVM(string folderpath, DominoAssembly parentProject)
 {
     this.parentProject = parentProject;
     FillObjects();
     ProjectPath  = folderpath;
     CreateIt     = new RelayCommand(o => { MCreateIt(); });
     SelectedType = 0;
 }
        public static AssemblyNode CreateProject()
        {
            string rootpath = Path.GetFullPath("tests/");

            DominoAssembly main = new DominoAssembly();

            main.Save(Path.Combine(rootpath, "main.DProject"));
            main.colorPath = "colors.DColor";
            var             mainnode = new AssemblyNode(Path.Combine(rootpath, "main.DProject"));
            FieldParameters field1   = new FieldParameters(Path.GetFullPath("tests/field1.DObject"), "mountain.jpg", main.colorPath, 8, 8, 24, 8, 10000, Emgu.CV.CvEnum.Inter.Lanczos4,
                                                           new CieDe2000Comparison(), new Dithering(), new NoColorRestriction());

            field1.Save();
            new FieldNode("field1.DObject", main);
            StreamReader        sr        = new StreamReader(new FileStream("Structures.xml", FileMode.Open));
            XElement            xml       = XElement.Parse(sr.ReadToEnd());
            StructureParameters structure = new StructureParameters(Path.GetFullPath("tests/structure.DObject"),
                                                                    "transparent.png", xml.Elements().ElementAt(1), 30000,
                                                                    main.colorPath, ColorDetectionMode.Cie1976Comparison, new Dithering(),
                                                                    AverageMode.Corner, new NoColorRestriction(), true);

            structure.Save();
            new StructureNode("structure.DObject", main);
            DominoAssembly sub     = new DominoAssembly();
            string         subpath = "sub.DProject";

            sub.Save(Workspace.AbsolutePathFromReference(ref subpath, main));
            sub.colorPath = "colors.DColor";
            new AssemblyNode("sub.DProject", main);
            FieldParameters sub1 = new FieldParameters(Path.GetFullPath("tests/field2.DObject"), "transparent.png", main.colorPath, 8, 8, 24, 8, 10000, Emgu.CV.CvEnum.Inter.Lanczos4,
                                                       new CieDe2000Comparison(), new Dithering(), new NoColorRestriction());

            field1.Save();
            new FieldNode("field2.DObject", sub);
            new FieldNode("field1.DObject", sub);
            sub.Save();

            foreach (AssemblyNode node in main.children.Where(child => child is AssemblyNode))
            {
                node.obj.Save();
            }
            if (field1 == ((FieldNode)sub.children[1]).obj)
            {
                Console.WriteLine("references to field1 identical");
            }
            main.Save(mainnode.Path);
            PrintProjectStructure(mainnode, "");

            return(mainnode);
        }
        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());
            }
        }
Exemple #6
0
 public ColorListControlVM(DominoAssembly dominoAssembly) : this(Workspace.AbsolutePathFromReferenceLoseUpdate(dominoAssembly.colorPath, dominoAssembly))
 {
     this.DominoAssembly = dominoAssembly;
 }