예제 #1
0
        public static FieldDocument LoadFieldDocument(string path)
        {
            FieldDocument feld = LoadFieldDocumentWithoutDrawing(path);

            if (feld.filters == null)
            {
                feld.InitFilters();
            }
            feld.filters.Deserialize_Finish(feld.SourcePath);
            feld.img = feld.DrawField();
            return(feld);
        }
예제 #2
0
 public override bool Compare(Document d)
 {
     if (d is FieldDocument)
     {
         FieldDocument doc = d as FieldDocument;
         if (!(doc.dominoes.Rank == this.dominoes.Rank &&
               Enumerable.Range(0, doc.dominoes.Rank).All(dimension => doc.dominoes.GetLength(dimension) == this.dominoes.GetLength(dimension)) &&
               doc.dominoes.Cast <int>().SequenceEqual(this.dominoes.Cast <int>())))
         {
             return(false);
         }
         if (doc.a != this.a || doc.b != this.b || doc.d != this.d || doc.c != this.c)
         {
             return(false);
         }
         if (doc.ResizeMode != this.ResizeMode || doc.ColorRegressionMode != this.ColorRegressionMode || doc.DiffusionMode != this.DiffusionMode)
         {
             return(false);
         }
         if (doc.Colors.Count != this.Colors.Count)
         {
             return(false);
         }
         for (int i = 0; i < doc.Colors.Count; i++)
         {
             if (doc.Colors[i].rgb != this.Colors[i].rgb)
             {
                 return(false);
             }
             if (doc.Colors[i].name != this.Colors[i].name)
             {
                 return(false);
             }
             if (doc.Colors[i].count != this.Colors[i].count)
             {
                 return(false);
             }
         }
         if (doc.Locked != this.Locked)
         {
             return(false);
         }
         return(true);
     }
     return(false);
 }
예제 #3
0
        public static Document FastLoad(String path)
        {
            switch (Path.GetExtension(path))
            {
            case ".clr":
                return(ColorArrayDocument.LoadColorArray(path));

            case ".fld":
                return(FieldDocument.LoadFieldDocumentWithoutDrawing(path));

            case ".sct":
                return(StructureDocument.LoadStructureDocumentWithoutDrawing(path));

            default:
                return(null);
            }
        }
예제 #4
0
        // Berechnet aus der Struktur das Protokoll (bzw. ein Stub-Fielddocument, den Rest macht FieldPlanEditor)
        public FieldDocument GenerateBaseField()
        {
            if (!HasProtocolDefinition)
            {
                return(null);
            }
            // get field dimensions
            int rowmax = 0; int colmax = 0;

            for (int i = 0; i < shapes.Length; i++)
            {
                if (shapes[i].ProtocolDefinition.x > rowmax)
                {
                    rowmax = shapes[i].ProtocolDefinition.x;
                }
                if (shapes[i].ProtocolDefinition.y > colmax)
                {
                    colmax = shapes[i].ProtocolDefinition.y;
                }
            }
            FieldDocument d = new FieldDocument()
            {
                filename = this.filename, dominoes = new int[rowmax + 1, colmax + 1], m_horizontal = true, path = this.path
            };

            for (int i = 0; i < d.dominoes.GetLength(0); i++)
            {
                for (int j = 0; j < d.dominoes.GetLength(1); j++)
                {
                    d.dominoes[i, j] = -1; // -1 ist der Wert für nicht zugewiesener Domino, diese werden im Feldprotokoll bis jetzt ignoriert
                }
            }
            for (int i = 0; i < shapes.Length; i++)
            {
                d.dominoes[(int)shapes[i].ProtocolDefinition.x, (int)shapes[i].ProtocolDefinition.y] = dominoes[i];
                d.Colors = Colors;
            }
            return(d);
        }