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);
        }
示例#2
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);
        }
示例#3
0
        public EditProjectVM(IDominoProvider dominoProvider) : base()
        {
            HaveBuildtools = dominoProvider.HasProtocolDefinition ? Visibility.Visible : Visibility.Hidden;

            if (dominoProvider != null && dominoProvider.PrimaryImageTreatment != null)
            {
                if (dominoProvider.PrimaryImageTreatment.FilteredImage != null)
                {
                    FilteredImage = dominoProvider.PrimaryImageTreatment.FilteredImage;
                }
                else
                {
                    BlendFileFilter bff = dominoProvider.PrimaryImageTreatment.ImageFilters.OfType <BlendFileFilter>().FirstOrDefault();
                    if (bff != null)
                    {
                        string relativePath = bff.FilePath;

                        FilteredImage = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(Workspace.AbsolutePathFromReference(ref relativePath, dominoProvider));
                    }
                }
            }

            UICursor         = null;
            selectedDominoes = new List <DominoInCanvas>();
            UnsavedChanges   = false;
            CurrentProject   = dominoProvider;

            _DominoList = new ObservableCollection <ColorListEntry>();

            _DominoList.Clear();
            CurrentProject.colors.Anzeigeindizes.CollectionChanged += Anzeigeindizes_CollectionChanged;
            refreshList();
            selectedColors       = new int[CurrentProject.colors.Length];
            SaveField            = new RelayCommand(o => { Save(); });
            RestoreBasicSettings = new RelayCommand(o => { redoStack = new Stack <PostFilter>(); Editing = false; });

            SelectColor       = new RelayCommand(o => { SelectAllStonesWithColor(); });
            MouseClickCommand = new RelayCommand(o => { ChangeColor(); });
            ClearSelection    = new RelayCommand(o => { ClearFullSelection(); });
            CopyCom           = new RelayCommand(o => { Copy(); });
            PasteCom          = new RelayCommand(o => { Paste(); });

            AddRowAbove         = new RelayCommand(o => { AddRow(false); });
            AddRowBelow         = new RelayCommand(o => { AddRow(true); });
            AddColumnRight      = new RelayCommand(o => { AddColumn(true); });
            AddColumnLeft       = new RelayCommand(o => { AddColumn(false); });
            RemoveRows          = new RelayCommand(o => { RemoveSelRows(); });
            RemoveColumns       = new RelayCommand(o => { RemoveSelColumns(); });
            FlipHorizontallyCom = new RelayCommand(o => { System.Diagnostics.Debug.WriteLine("asdf");; });
            FlipVerticallyCom   = new RelayCommand(o => { System.Diagnostics.Debug.WriteLine("asdf");; });
            ShowImageClick      = new RelayCommand(o => { ShowImage(); });
            MouseInPicture      = new RelayCommand(o => { UICursor = Cursors.Hand; });
            MouseOutPicture     = new RelayCommand(o => { UICursor = null; });
            SelectAllCom        = new RelayCommand(o => { SelectAll(); });
            RefreshCanvas();
            UnsavedChanges = false;
        }