Esempio n. 1
0
        private void mnuOpen_Click(object sender, EventArgs e)
        {
            // TODO: Check for changes before closing.
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "FlowSharp (*.fsd)|*.fsd";
            DialogResult res = ofd.ShowDialog();

            if (res == DialogResult.OK)
            {
                filename = ofd.FileName;
            }
            else
            {
                return;
            }

            string data = File.ReadAllText(filename);
            List <GraphicElement> els = Persist.Deserialize(canvas, data);

            elements.Clear();
            elements.AddRange(els);
            elements.ForEach(el => el.UpdatePath());
            canvas.Invalidate();
            UpdateCaption();
        }
Esempio n. 2
0
        private void mnuImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "FlowSharp (*.fsd)|*.fsd";
            DialogResult res = ofd.ShowDialog();

            if (res == DialogResult.OK)
            {
                BaseController        canvasController = serviceManager.Get <IFlowSharpCanvasService>().ActiveController;
                string                importFilename   = ofd.FileName;
                string                data             = File.ReadAllText(importFilename);
                List <GraphicElement> els = Persist.Deserialize(canvasController.Canvas, data);
                List <GraphicElement> selectedElements = canvasController.SelectedElements.ToList();

                canvasController.UndoStack.UndoRedo("Import",
                                                    () =>
                {
                    canvasController.DeselectCurrentSelectedElements();
                    canvasController.AddElements(els);
                    canvasController.Elements.ForEach(el => el.UpdatePath());
                    canvasController.SelectElements(els);
                    canvasController.Canvas.Invalidate();
                },
                                                    () =>
                {
                    canvasController.DeselectCurrentSelectedElements();
                    els.ForEach(el => canvasController.DeleteElement(el));
                    canvasController.SelectElements(selectedElements);
                });
            }
        }
        private void mnuOpen_Click(object sender, EventArgs e)
        {
            if (CheckForChanges())
            {
                return;
            }
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "FlowSharp (*.fsd)|*.fsd";
            DialogResult res = ofd.ShowDialog();

            if (res == DialogResult.OK)
            {
                filename = ofd.FileName;
            }
            else
            {
                return;
            }

            string data = File.ReadAllText(filename);
            List <GraphicElement> els = Persist.Deserialize(canvasController.Canvas, data);

            canvasController.Clear();
            canvasController.UndoStack.ClearStacks();
            ElementCache.Instance.ClearCache();
            canvasController.MouseController.ClearState();
            canvasController.AddElements(els);
            canvasController.Elements.ForEach(el => el.UpdatePath());
            canvasController.Canvas.Invalidate();
            UpdateCaption();
        }
Esempio n. 4
0
 public void TestXmlPersistFromFile()
 {
     string  file    = @"d:\DavidPrac\Vývoje\0061146 Dílenské plánování D4\Zálohy\serial-Manufacturing.xml";
     string  serial  = System.IO.File.ReadAllText(file, Encoding.UTF8);
     object  result  = Persist.Deserialize(serial);
     GuiData guiData = result as GuiData;
 }
Esempio n. 5
0
        protected void LoadFileIntoCanvas(string filename, string canvasName, BaseController canvasController)
        {
            canvasController.Filename   = filename;     // set now, in case of relative image files, etc...
            canvasController.CanvasName = canvasName;
            string data = File.ReadAllText(filename);
            List <GraphicElement> els = Persist.Deserialize(canvasController.Canvas, data);

            canvasController.Clear();
            canvasController.UndoStack.ClearStacks();
            ElementCache.Instance.ClearCache();
            ServiceManager.Get <IFlowSharpMouseControllerService>().ClearState();
            canvasController.AddElements(els);
            canvasController.Elements.ForEach(el => el.UpdatePath());
            canvasController.Canvas.Invalidate();
        }
Esempio n. 6
0
        protected void Paste()
        {
            string copyBuffer = Clipboard.GetData("FlowSharp")?.ToString();

            if (copyBuffer == null)
            {
                MessageBox.Show("Clipboard does not contain a FlowSharp shape", "Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    List <GraphicElement> els = Persist.Deserialize(canvas, copyBuffer);
                    canvasController.DeselectCurrentSelectedElements();

                    // After deserialization, only move and select elements without parents -
                    // children of group boxes should not be moved, as their parent will handle this,
                    // and children of group boxes cannot be selected.
                    List <GraphicElement> noParentElements = els.Where(e => e.Parent == null).ToList();

                    noParentElements.ForEach(el =>
                    {
                        el.Move(new Point(20, 20));
                        el.UpdateProperties();
                        el.UpdatePath();
                    });

                    List <GraphicElement> intersections = new List <GraphicElement>();

                    els.ForEach(el =>
                    {
                        intersections.AddRange(canvasController.FindAllIntersections(el));
                    });

                    IEnumerable <GraphicElement> distinctIntersections = intersections.Distinct();
                    canvasController.EraseTopToBottom(distinctIntersections);
                    els.ForEach(el => elements.Insert(0, el));
                    canvasController.DrawBottomToTop(distinctIntersections);
                    canvasController.UpdateScreen(distinctIntersections);
                    noParentElements.ForEach(el => canvasController.SelectElement(el));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error pasting shape:\r\n" + ex.Message, "Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 7
0
        private void mnuImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "FlowSharp (*.fsd)|*.fsd";
            DialogResult res = ofd.ShowDialog();

            if (res == DialogResult.OK)
            {
                string importFilename     = ofd.FileName;
                string data               = File.ReadAllText(importFilename);
                List <GraphicElement> els = Persist.Deserialize(canvas, data);
                elements.AddRange(els);
                elements.ForEach(el => el.UpdatePath());
                els.ForEach(el => canvas.Controller.SelectElement(el));
                canvas.Invalidate();
            }
        }
Esempio n. 8
0
        protected void Paste()
        {
            string copyBuffer = Clipboard.GetData("FlowSharp")?.ToString();

            if (copyBuffer == null)
            {
                MessageBox.Show("Clipboard does not contain a FlowSharp shape", "Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    List <GraphicElement> els = Persist.Deserialize(canvas, copyBuffer);
                    canvasController.DeselectCurrentSelectedElements();
                    els.ForEach(el =>
                    {
                        el.Move(new Point(20, 20));
                        el.UpdateProperties();
                        el.UpdatePath();
                    });

                    List <GraphicElement> intersections = new List <GraphicElement>();

                    els.ForEach(el =>
                    {
                        intersections.AddRange(canvasController.FindAllIntersections(el));
                    });

                    IEnumerable <GraphicElement> distinctIntersections = intersections.Distinct();
                    canvasController.EraseTopToBottom(distinctIntersections);
                    els.ForEach(el => elements.Insert(0, el));
                    canvasController.DrawBottomToTop(distinctIntersections);
                    canvasController.UpdateScreen(distinctIntersections);
                    els.ForEach(el => canvasController.SelectElement(el));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error pasting shape:\r\n" + ex.Message, "Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 9
0
        public void TestGuiData()
        {
            GuiData data = new GuiData()
            {
                Name = "Data"
            };

            data.ToolbarItems.Add(new GuiToolbarItem()
            {
                Name = "tlbSave", Title = "Uložit", ToolTip = "Uložit všechna data"
            });
            data.ToolbarItems.Add(new GuiToolbarItem()
            {
                Name = "tlbReload", Title = "Přenačíst", ToolTip = "Znovu načíst všechna data"
            });

            data.ContextMenuItems.Add(new GuiContextMenuItem()
            {
                Name = "cnxAddWork", Title = "Přidá další práci", ToolTip = "Přidá další práci v označeném místě"
            });

            GuiPage page = new GuiPage()
            {
                Name = "pageMain", Title = "Dílna 1", ToolTip = "Zobrazuje veškerá data první dílny"
            };

            data.Pages.Add(page);

            GuiGrid taskGrid = new GuiGrid()
            {
                Name = "taskGrid", Title = "Pracovní úkoly", ToolTip = "Zobrazuje úkoly, které se mají na této dílně provádět"
            };
            GuiDataTable taskRows = new GuiDataTable()
            {
                Name = "taskRows"
            };

            taskRows.ClassId = 1363;
            taskRows.AddColumn(new GuiDataColumn()
            {
                Name = "record_gid", BrowseColumnType = BrowseColumnType.RecordId
            });
            taskRows.AddColumn(new GuiDataColumn()
            {
                Name = "reference", Title = "Reference", Width = 85
            });
            taskRows.AddColumn(new GuiDataColumn()
            {
                Name = "nazev", Title = "Název", Width = 200
            });
            taskRows.AddColumn(new GuiDataColumn()
            {
                Name = "constr_element", Title = "Dílec", Width = 200
            });
            taskGrid.RowTable = taskRows;
            page.LeftPanel.Grids.Add(taskGrid);

            GuiGrid workGrid = new GuiGrid()
            {
                Name = "workGrid", Title = "Pracovní rozvrh", ToolTip = "Zobrazuje prostor dílny a její využití"
            };
            GuiDataTable workRows = new GuiDataTable()
            {
                Name = "workRows"
            };

            workRows.ClassId = 1817;
            workRows.AddColumn(new GuiDataColumn()
            {
                Name = "record_gid", BrowseColumnType = BrowseColumnType.RecordId
            });
            workRows.AddColumn(new GuiDataColumn()
            {
                Name = "reference", Title = "Reference", Width = 85
            });
            workRows.AddColumn(new GuiDataColumn()
            {
                Name = "nazev", Title = "Název", Width = 200
            });
            workRows.AddColumn(new GuiDataColumn()
            {
                Name = "constr_element", Title = "Dílec", Width = 200
            });
            GuiDataRow wr1 = workRows.AddRow(new GuiId(1817, 1), "Refer 1", "Název 1", "Výrobek A");

            wr1.Graph = new GuiGraph();
            wr1.Graph.GraphItems.Add(new GuiGraphItem()
            {
                ItemId = new GuiId(1817, 1), RowId = new GuiId(1364, 1), Time = new GuiTimeRange(new DateTime(2018, 8, 1, 12, 0, 0), new DateTime(2018, 8, 1, 16, 0, 0))
            });
            wr1.Graph.GraphItems.Add(new GuiGraphItem()
            {
                ItemId = new GuiId(1817, 2), RowId = new GuiId(1364, 1), Time = new GuiTimeRange(new DateTime(2018, 8, 1, 16, 0, 0), new DateTime(2018, 8, 1, 20, 0, 0))
            });
            wr1.Graph.GraphItems.Add(new GuiGraphItem()
            {
                ItemId = new GuiId(1817, 3), RowId = new GuiId(1364, 1), Time = new GuiTimeRange(new DateTime(2018, 8, 1, 21, 0, 0), new DateTime(2018, 8, 1, 22, 0, 0))
            });
            GuiDataRow wr2 = workRows.AddRow(new GuiId(1817, 2), "Referen 2", "Náz 2", "Výrobek B");
            GuiDataRow wr3 = workRows.AddRow(new GuiId(1817, 3), "Reference 3", "N 3", "Výrobek C");

            workGrid.RowTable = workRows;

            workGrid.GraphProperties.AxisResizeMode        = AxisResizeContentMode.ChangeScale;
            workGrid.GraphProperties.InteractiveChangeMode = AxisInteractiveChangeMode.Shift;

            GraphItemBehaviorMode graph4BehaviorMode = (GraphItemBehaviorMode.DefaultText | GraphItemBehaviorMode.ResizeTime);
            DateTime graph4Begin = new DateTime(2018, 8, 1, 14, 30, 45, 550);
            DateTime graph4End   = new DateTime(2018, 8, 1, 18, 15, 30, 10);

            wr1.Graph.GraphItems.Add(new GuiGraphItem()
            {
                ItemId = new GuiId(1817, 4), RowId = new GuiId(1364, 2), Time = new GuiTimeRange(graph4Begin, graph4End), BehaviorMode = graph4BehaviorMode
            });

            page.MainPanel.Grids.Add(workGrid);

            data.Finalise();

            string guiMainItems = workRows.FullName;
            string guiItem4Path = wr1.Graph.GraphItems[0].FullName;

            IGuiItem item1 = data.FindByFullName(@"Data\toolBar\tlbSave");
            IGuiItem item2 = data.FindByFullName(@"Data\contextMenu\cnxAddWork");
            IGuiItem item3 = data.FindByFullName(@"Data\pageMain\mainPanel\workGrid\");


            string serial   = Persist.Serialize(data);
            object deserial = Persist.Deserialize(serial);

            if (deserial == null)
            {
                throw new AssertFailedException("Deserializovaný objekt je null.");
            }

            GuiData clone = deserial as GuiData;

            if (clone == null)
            {
                throw new AssertFailedException("Deserializovaný objekt není odpovídající třídy GuiData.");
            }

            if (clone.ToolbarItems.Count != data.ToolbarItems.Count)
            {
                throw new AssertFailedException("Deserializovaný objekt neobsahuje odpovídající počet prvků v ToolbarItems, má být " + data.ToolbarItems.Count + "; je " + clone.ToolbarItems.Count + ".");
            }

            if (clone.ToolbarItems.Items[0].Name != data.ToolbarItems.Items[0].Name)
            {
                throw new AssertFailedException("Deserializovaný objekt neobsahuje odpovídající Name prvku ToolbarItems[0], má být " + data.ToolbarItems.Items[0].Name + "; je " + clone.ToolbarItems.Items[0].Name + ".");
            }

            if (clone.Pages.Count != data.Pages.Count)
            {
                throw new AssertFailedException("Deserializovaný objekt neobsahuje odpovídající počet prvků v Pages, má být " + data.Pages.Count + "; je " + clone.Pages.Count + ".");
            }

            if (clone.Pages[0].Name != data.Pages[0].Name)
            {
                throw new AssertFailedException("Deserializovaný objekt neobsahuje odpovídající Title prvku Pages[0], má být " + data.Pages[0].Title + "; je " + clone.Pages[0].Title + ".");
            }

            if (clone.Pages[0].LeftPanel.Grids.Count != data.Pages[0].LeftPanel.Grids.Count)
            {
                throw new AssertFailedException("Deserializovaný objekt neobsahuje odpovídající počet prvků v Pages[0].LeftPanel.Grids, má být " + data.Pages[0].LeftPanel.Grids.Count + "; je " + clone.Pages[0].LeftPanel.Grids.Count + ".");
            }

            string taskGridText = taskGrid.ToString();
            string taskClonText = clone.Pages[0].LeftPanel.Grids[0].ToString();

            if (taskClonText != taskGridText)
            {
                throw new AssertFailedException("Deserializovaný objekt neobsahuje odpovídající obsah v TaskGridu, má být " + taskGridText + "; je " + taskClonText + ".");
            }

            if (clone.Pages[0].MainPanel.Grids.Count != data.Pages[0].MainPanel.Grids.Count)
            {
                throw new AssertFailedException("Deserializovaný objekt neobsahuje odpovídající počet prvků v Pages[0].MainPanel.Grids, má být " + data.Pages[0].MainPanel.Grids.Count + "; je " + clone.Pages[0].MainPanel.Grids.Count + ".");
            }

            string workGridText = workGrid.ToString();
            string workClonText = clone.Pages[0].MainPanel.Grids[0].ToString();

            if (workClonText != workGridText)
            {
                throw new AssertFailedException("Deserializovaný objekt neobsahuje odpovídající obsah v WorkGridu, má být " + workGridText + "; je " + workClonText + ".");
            }

            GuiGraphTable workItemsB = data.FindByFullName(guiMainItems) as GuiGraphTable;

            GuiGraphItem graphItem4B = data.FindByFullName(guiItem4Path) as GuiGraphItem;

            if (graphItem4B == null)
            {
                throw new AssertFailedException("Deserializovaný objekt neobsahuje grafický prvek 4.");
            }

            if (graphItem4B.BehaviorMode != graph4BehaviorMode)
            {
                throw new AssertFailedException("Deserializovaný grafický prvek 4 nemá správnou hodnotu BehaviorMode, má být " + graph4BehaviorMode + "; je " + graphItem4B.BehaviorMode + ".");
            }
            if (graphItem4B.Time.Begin != graph4Begin)
            {
                throw new AssertFailedException("Deserializovaný grafický prvek 4 nemá správnou hodnotu Begin, má být " + graph4Begin + "; je " + graphItem4B.Time.Begin + ".");
            }
            if (graphItem4B.Time.End != graph4End)
            {
                throw new AssertFailedException("Deserializovaný grafický prvek 4 nemá správnou hodnotu End, má být " + graph4End + "; je " + graphItem4B.Time.End + ".");
            }
        }
Esempio n. 10
0
        public void Paste()
        {
            BaseController canvasController = ServiceManager.Get <IFlowSharpCanvasService>().ActiveController;

            // TODO: This seems klunky.
            if (editBox != null && Clipboard.ContainsText())
            {
                editBox.SelectedText = Clipboard.GetText();
                return;
            }

            string copyBuffer = Clipboard.GetData("FlowSharp")?.ToString();

            if (copyBuffer == null)
            {
                MessageBox.Show("Clipboard does not contain a FlowSharp shape", "Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    List <GraphicElement> els = Persist.Deserialize(canvasController.Canvas, copyBuffer);
                    List <GraphicElement> selectedElements = canvasController.SelectedElements.ToList();

                    // After deserialization, only move and select elements without parents -
                    // children of group boxes should not be moved, as their parent will handle this,
                    // and children of group boxes cannot be selected.
                    List <GraphicElement> noParentElements = els.Where(e => e.Parent == null).ToList();

                    noParentElements.ForEach(el =>
                    {
                        el.Move(new Point(20, 20));
                        el.UpdateProperties();
                        el.UpdatePath();
                    });

                    List <GraphicElement> intersections = new List <GraphicElement>();

                    els.ForEach(el =>
                    {
                        intersections.AddRange(canvasController.FindAllIntersections(el));
                    });

                    IEnumerable <GraphicElement> distinctIntersections = intersections.Distinct();

                    canvasController.UndoStack.UndoRedo("Paste",
                                                        () =>
                    {
                        canvasController.DeselectCurrentSelectedElements();

                        canvasController.EraseTopToBottom(distinctIntersections);

                        els.ForEach(el =>
                        {
                            canvasController.Insert(0, el);
                            ElementCache.Instance.Remove(el);
                        });

                        canvasController.DrawBottomToTop(distinctIntersections);
                        canvasController.UpdateScreen(distinctIntersections);
                        noParentElements.ForEach(el => canvasController.SelectElement(el));
                    }
                                                        ,
                                                        () =>
                    {
                        canvasController.DeselectCurrentSelectedElements();

                        els.ForEach(el =>
                        {
                            canvasController.DeleteElement(el, false);
                            ElementCache.Instance.Add(el);
                        });

                        canvasController.SelectElements(selectedElements);
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error pasting shape:\r\n" + ex.Message, "Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 11
0
        public void TestXmlPersistSimple()
        {
            object[] source = new object[3];
            source[0] = 0;
            source[1] = "XXX";
            object[]        values = new object[3];
            TestSimpleClass value0 = new TestSimpleClass()
            {
                Name = "Name0", Value = 0
            };
            TestSimpleClass value1 = new TestSimpleClass()
            {
                Name = "Name1", Value = "Item1"
            };
            TestSimpleClass value2 = new TestSimpleClass()
            {
                Name = "Name2"
            };
            TestSimpleClass value2a = new TestSimpleClass()
            {
                Name = "Name2a", Value = "Item2a"
            };

            value2.Value = value2a;
            values[0]    = value0;
            values[1]    = value1;
            values[2]    = value2;

            source[2] = values;

            string xml = Persist.Serialize(source, PersistArgs.Default);

            object result = Persist.Deserialize(xml);

            if (result == null)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized = null");
            }

            object[] target = result as object[];
            if (target == null)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized is not array object[]");
            }
            if (target.Length != source.Length)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array has wrong length");
            }

            if (!(target[0] is int))
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array has wrong type of item[0]");
            }
            if (((int)(target[0])) != ((int)(source[0])))
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array has wrong value of item[0]");
            }

            if (!(target[1] is string))
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array has wrong type of item[1]");
            }
            if (((string)(target[1])) != ((string)(source[1])))
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array has wrong value of item[1]");
            }

            if (target[2] == null)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array has wrong item[2] == null");
            }
            object[] clones = target[2] as object[];
            if (clones == null)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array has wrong type item[2], has be object[]");
            }
            if (clones.Length != values.Length)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array in item[2] has wrong length");
            }

            TestSimpleClass clone0 = clones[0] as TestSimpleClass;

            if (clone0 == null)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array in item[2] has wrong item[0]");
            }
            if (clone0.Name != value0.Name)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized clone 0 has wrong Name");
            }
            if (clone0.Value.ToString() != value0.Value.ToString())
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized clone 0 has wrong Value");
            }

            TestSimpleClass clone1 = clones[1] as TestSimpleClass;

            if (clone1 == null)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array in item[2] has wrong item[1]");
            }
            if (clone1.Name != value1.Name)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized clone 1 has wrong Name");
            }
            if (clone1.Value.ToString() != value1.Value.ToString())
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized clone 1 has wrong Value");
            }

            TestSimpleClass clone2 = clones[2] as TestSimpleClass;

            if (clone2 == null)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array in item[2] has wrong item[2]");
            }
            if (clone2.Name != value2.Name)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized clone 2 has wrong Name");
            }

            TestSimpleClass clone2a = clone2.Value as TestSimpleClass;

            if (clone2a == null)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized array in item[2] has wrong item[2].Value");
            }
            if (clone2a.Name != value2a.Name)
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized clone 2a has wrong Name");
            }
            if (clone2a.Value.ToString() != value2a.Value.ToString())
            {
                throw new AssertFailedException("TestXmlPersistSimple: deserialized clone 2a has wrong Value");
            }
        }
Esempio n. 12
0
        public void TestXmlPersistClass()
        {
            TestPersist orig  = new TestPersist();
            GuiId       guiId = new GuiId(1180, 123456);

            orig.GuiId = guiId;

            orig.Array    = new object[6];
            orig.Array[0] = "Zkouška\r\nřádku";
            orig.Array[1] = new DateTime(2019, 01, 15, 12, 0, 0);
            orig.Array[2] = 16.02m;
            orig.Array[3] = new Rectangle(5, 10, 100, 50);
            orig.Array[4] = new List <int> {
                10, 20, 30
            };


            GuiId guiId0 = new GuiId(21, 1234);
            GuiId guiId5 = new GuiId(26, 6789);

            orig.GuiIdList = new List <GuiId>();
            orig.GuiIdList.Add(guiId0);
            orig.GuiIdList.Add(new GuiId(22, 2345));
            orig.GuiIdList.Add(null);                    // new GuiId(23, 3456));
            orig.GuiIdList.Add(new GuiId(24, 4567));
            orig.GuiIdList.Add(new GuiId(25, 5678));
            orig.GuiIdList.Add(guiId5);

            orig.Tabulka = new string[3, 2];
            for (int r = 0; r < 3; r++)
            {
                for (int c = 0; c < 2; c++)
                {
                    orig.Tabulka[r, c] = "Pozice(" + r + "," + c + ")";
                }
            }

            orig.Sachovnice = new TestDictionary();
            GuiId key1 = new GuiId(1, 101);
            GuiId key6 = new GuiId(1, 106);

            orig.Sachovnice.Add(key1, new Rectangle(1, 1, 1, 1));
            orig.Sachovnice.Add(new GuiId(1, 102), new Rectangle(2, 2, 2, 2));
            orig.Sachovnice.Add(new GuiId(1, 103), new Rectangle(3, 3, 3, 3));
            orig.Sachovnice.Add(new GuiId(1, 104), new Rectangle(4, 4, 4, 4));
            orig.Sachovnice.Add(new GuiId(1, 105), new Rectangle(5, 5, 5, 5));
            orig.Sachovnice.Add(key6, new Rectangle(6, 6, 6, 6));

            orig.Images = new List <GuiImage>();
            orig.Images.Add(RES.Images.Actions16.DialogNo3Png);
            orig.Images.Add(RES.Images.Actions16.DialogOk3Png);
            orig.Images.Add(RES.Images.Actions16.DialogOkApply3Png);

            string zip = Persist.Serialize(orig, PersistArgs.Compressed);
            string xml = Persist.Serialize(orig, PersistArgs.Default);

            TestPersist copy = Persist.Deserialize(zip) as TestPersist;

            // Test shodného obsahu:
            if (copy.GuiId == null)
            {
                throw new AssertFailedException("TestPersist.GuiId is null");
            }
            if (copy.GuiId != guiId)
            {
                throw new AssertFailedException("TestPersist.GuiId is not equal to original");
            }

            if (copy.GuiIdList == null)
            {
                throw new AssertFailedException("TestPersist.GuiIdList is null");
            }
            if (copy.GuiIdList.Count != 6)
            {
                throw new AssertFailedException("TestPersist.GuiIdList has bad count");
            }
            if (copy.GuiIdList[0] != guiId0)
            {
                throw new AssertFailedException("TestPersist.GuiIdList[0] is not equal to original");
            }
            if (copy.GuiIdList[2] != null)
            {
                throw new AssertFailedException("TestPersist.GuiIdList[2] is not null");
            }
            if (copy.GuiIdList[5] != guiId5)
            {
                throw new AssertFailedException("TestPersist.GuiIdList[5] is not equal to original");
            }

            if (copy.Tabulka == null)
            {
                throw new AssertFailedException("TestPersist.Tabulka is null");
            }
            if (copy.Tabulka.Rank != 2)
            {
                throw new AssertFailedException("TestPersist.Tabulka has Rank != 2");
            }
            if (copy.Tabulka.GetLength(0) != 3)
            {
                throw new AssertFailedException("TestPersist.Tabulka has Length(0) != 3");
            }
            if (copy.Tabulka.GetLength(1) != 2)
            {
                throw new AssertFailedException("TestPersist.Tabulka has Length(1) != 2");
            }
            if (copy.Tabulka[2, 1] != "Pozice(2,1)")
            {
                throw new AssertFailedException("TestPersist.Tabulka has bad value in cell [2,1]");
            }

            if (copy.Sachovnice == null)
            {
                throw new AssertFailedException("TestPersist.Sachovnice is null");
            }
            if (copy.Sachovnice.Count != 6)
            {
                throw new AssertFailedException("TestPersist.Sachovnice has bad count");
            }
            if (!copy.Sachovnice.ContainsKey(key1))
            {
                throw new AssertFailedException("TestPersist.Sachovnice does not contains key0");
            }
            if (copy.Sachovnice[key1].Top != 1)
            {
                throw new AssertFailedException("TestPersist.Sachovnice in [key0] has bad value");
            }
            if (!copy.Sachovnice.ContainsKey(key6))
            {
                throw new AssertFailedException("TestPersist.Sachovnice does not contains key5");
            }
            if (copy.Sachovnice[key6].Top != 6)
            {
                throw new AssertFailedException("TestPersist.Sachovnice in [key5] has bad value");
            }
        }