/// <summary> /// Metoda vytvoří novou tabulku <see cref="MainDataTable"/> s daty dodanými v <see cref="GuiGrid"/>. /// Pokud data neobsahují tabulku s řádky, vrací null. /// Vytvořenou tabulku <see cref="MainDataTable"/> uloží do <see cref="_DataTableList"/>, /// do vizuálního gridu <see cref="GGrid"/> přidá tabulku s řádky z dodaného <see cref="GuiGrid"/>. /// Vytvořenou tabulku <see cref="MainDataTable"/> vrací. /// </summary> /// <param name="gGrid"></param> /// <param name="guiGrid"></param> /// <returns></returns> private MainDataTable _LoadDataToMainTable(GGrid gGrid, GuiGrid guiGrid) { MainDataTable mainDataTable = null; using (App.Trace.Scope(TracePriority.Priority2_Lowest, "SchedulerPanel", "LoadDataToMainTable", "", guiGrid.FullName)) mainDataTable = new MainDataTable(this, gGrid, guiGrid); if (mainDataTable.TableRow == null) { return(null); } this._DataTableList.Add(mainDataTable); mainDataTable.AddTableToGrid(gGrid); return(mainDataTable); }
public void InitializeControlData(Hashtable input) { Control w32ctrl; object objData; foreach (GuiControl control in this.orderedGuiControls) { try { w32ctrl = win32Controls[control.ID] as Control; if (input.Contains(control.ID)) { objData = input[control.ID]; if (control is GuiCheckBox) { GuiCheckBox guiCheckBox = control as GuiCheckBox; CheckBox b = w32ctrl as CheckBox; b.Checked = Convert.ToBoolean(objData); } else if (control is GuiLabel) { GuiLabel guiLabel = control as GuiLabel; Label l = w32ctrl as Label; l.Text = Convert.ToString(objData); } else if (control is GuiTextBox) { GuiTextBox guiTextBox = control as GuiTextBox; TextBox tb = w32ctrl as TextBox; tb.Text = Convert.ToString(objData); } else if (control is GuiComboBox) { GuiComboBox guiComboBox = control as GuiComboBox; ComboBox cb = w32ctrl as ComboBox; foreach (ListControlItem item in cb.Items) { if (item.Value == Convert.ToString(objData)) { cb.SelectedItem = item; break; } } } else if (control is GuiListBox) { GuiListBox guiListBox = control as GuiListBox; ListBox lb = w32ctrl as ListBox; ArrayList list = objData as ArrayList; if (list != null) { for (int i = 0; i < lb.Items.Count; i++) { ListControlItem item = lb.Items[i] as ListControlItem; lb.SetSelected(i, list.Contains(item.Value)); } } } else if (control is GuiGrid) { GuiGrid guiGrid = control as GuiGrid; DataGrid dg = w32ctrl as DataGrid; SimpleTable table = objData as SimpleTable; if (table != null) { guiGrid.DataSource = table; dg.DataSource = SimpleTableTools.ConvertToDataTable(table); } } else if (control is GuiCheckBoxList) { GuiCheckBoxList guiListBox = control as GuiCheckBoxList; CheckedListBox lb = w32ctrl as CheckedListBox; ArrayList list = objData as ArrayList; if (list != null) { for (int i = 0; i < lb.Items.Count; i++) { ListControlItem item = lb.Items[i] as ListControlItem; lb.SetItemChecked(i, list.Contains(item.Value)); } } } } } catch { // Do nothing in the catch for now. We want it to fill in as many items as possible. } } }
protected void UpdateForm(Control eventSource) { Control w32ctrl; foreach (GuiControl control in guiControls.Values) { w32ctrl = win32Controls[control.ID] as Control; if (eventSource != w32ctrl) { if (control is GuiLabel) { GuiLabel guiLabel = control as GuiLabel; Label l = w32ctrl as Label; l.Text = guiLabel.Text; Font font = l.Font; FontStyle style = FontStyle.Regular; if (guiLabel.Bold) { style = style | FontStyle.Bold; } if (guiLabel.Underline) { style = style | FontStyle.Underline; } if (guiLabel.Strikeout) { style = style | FontStyle.Strikeout; } if (guiLabel.Italic) { style = style | FontStyle.Italic; } l.Font = new Font(font, style); } else if (control is GuiButton) { GuiButton guiButton = control as GuiButton; Button b = w32ctrl as Button; b.Text = guiButton.Text; } else if (control is GuiCheckBox) { GuiCheckBox guiCheckBox = control as GuiCheckBox; CheckBox b = w32ctrl as CheckBox; b.CheckedChanged -= new EventHandler(OnCheckBoxClick); b.Checked = guiCheckBox.Checked; b.CheckedChanged += new EventHandler(OnCheckBoxClick); b.Text = guiCheckBox.Text; } else if (control is GuiFilePicker) { GuiFilePicker guiPicker = control as GuiFilePicker; Button b = w32ctrl as Button; b.Text = guiPicker.Text; } else if (control is GuiTextBox) { GuiTextBox guiTextBox = control as GuiTextBox; TextBox tb = w32ctrl as TextBox; tb.Text = guiTextBox.Text; tb.Multiline = guiTextBox.Multiline; tb.WordWrap = guiTextBox.WordWrap; if (guiTextBox.VerticalScroll && guiTextBox.HorizontalScroll) { tb.ScrollBars = ScrollBars.Both; } else if (guiTextBox.VerticalScroll) { tb.ScrollBars = ScrollBars.Vertical; } else if (guiTextBox.HorizontalScroll) { tb.ScrollBars = ScrollBars.Horizontal; } else { tb.ScrollBars = ScrollBars.None; } } else if (control is GuiComboBox) { GuiComboBox guiComboBox = control as GuiComboBox; ComboBox cb = w32ctrl as ComboBox; cb.SelectedValueChanged -= new EventHandler(OnComboBoxChange); cb.Items.Clear(); foreach (string val in guiComboBox.Items) { ListControlItem item = new ListControlItem(val, guiComboBox[val]); cb.Items.Add(item); if (item.Value == guiComboBox.SelectedValue) { cb.SelectedItem = item; } } cb.SelectedValueChanged += new EventHandler(OnComboBoxChange); } else if (control is GuiListBox) { GuiListBox guiListBox = control as GuiListBox; ListBox lb = w32ctrl as ListBox; lb.SelectedValueChanged -= new EventHandler(OnListBoxChange); lb.Items.Clear(); foreach (string val in guiListBox.Items) { ListControlItem item = new ListControlItem(val, guiListBox[val]); lb.Items.Add(item); if (guiListBox.SelectedItems.Contains(val)) { lb.SetSelected(lb.Items.IndexOf(item), true); } } lb.SelectedValueChanged += new EventHandler(OnListBoxChange); lb.SelectionMode = guiListBox.IsMultiSelect ? SelectionMode.MultiExtended : SelectionMode.One; lb.Sorted = guiListBox.Sorted; } else if (control is GuiGrid) { GuiGrid guiGrid = control as GuiGrid; DataGrid dg = w32ctrl as DataGrid; dg.DataSource = SimpleTableTools.ConvertToDataTable(guiGrid.DataSource); } else if (control is GuiCheckBoxList) { GuiCheckBoxList guiCheckBoxList = control as GuiCheckBoxList; CheckedListBox lb = w32ctrl as CheckedListBox; lb.SelectedValueChanged -= new EventHandler(OnCheckedListBoxChange); lb.Items.Clear(); foreach (string val in guiCheckBoxList.Items) { ListControlItem item = new ListControlItem(val, guiCheckBoxList[val]); lb.Items.Add(item); if (guiCheckBoxList.SelectedItems.Contains(val)) { lb.SetItemChecked(lb.Items.IndexOf(item), true); } } lb.SelectedValueChanged += new EventHandler(OnCheckedListBoxChange); lb.Sorted = guiCheckBoxList.Sorted; } } w32ctrl.Left = control.Left; w32ctrl.Top = control.Top; w32ctrl.Width = control.Width; w32ctrl.Height = control.Height; w32ctrl.Visible = control.Visible; w32ctrl.Enabled = control.Enabled; if (control.ForeColor != string.Empty) { w32ctrl.ForeColor = Color.FromName(control.ForeColor); } if (control.BackColor != string.Empty) { w32ctrl.BackColor = Color.FromName(control.BackColor); } tooltip.SetToolTip(w32ctrl, control.ToolTip); } }
public void AddToForm(GuiControl control) { guiControls.Add(control.ID, control); orderedGuiControls.Add(control); if (control is GuiLabel) { GuiLabel guiLabel = control as GuiLabel; Label l = new Label(); l.Left = guiLabel.Left; l.Top = guiLabel.Top; l.Width = guiLabel.Width; l.Height = guiLabel.Height; l.Visible = guiLabel.Visible; l.Enabled = guiLabel.Enabled; l.Enabled = guiLabel.Enabled; l.ForeColor = Color.FromName(guiLabel.ForeColor); if (guiLabel.BackColor != string.Empty) { l.BackColor = Color.FromName(guiLabel.BackColor); } l.TextAlign = ContentAlignment.BottomLeft; l.Name = guiLabel.ID; l.Text = guiLabel.Text; tooltip.SetToolTip(l, guiLabel.ToolTip); Font font = l.Font; FontStyle style = FontStyle.Regular; if (guiLabel.Bold) { style = style | FontStyle.Bold; } if (guiLabel.Underline) { style = style | FontStyle.Underline; } if (guiLabel.Strikeout) { style = style | FontStyle.Strikeout; } if (guiLabel.Italic) { style = style | FontStyle.Italic; } l.Font = new Font(font, style); l.LostFocus += new EventHandler(ControlLostFocus); l.Enter += new EventHandler(ControlEnter); addControl(control, l); } else if (control is GuiButton) { GuiButton guiButton = control as GuiButton; Button b = new Button(); b.Click += new EventHandler(OnButtonClick); b.LostFocus += new EventHandler(ControlLostFocus); b.Enter += new EventHandler(ControlEnter); if (guiButton.ClosesForm) { b.Click += new EventHandler(OnButtonOkClick); } else if (guiButton.CancelGeneration) { b.Click += new EventHandler(OnButtonCancelClick); } b.Text = guiButton.Text; b.Left = guiButton.Left; b.Top = guiButton.Top; b.Width = guiButton.Width; b.Height = guiButton.Height; b.Name = guiButton.ID; b.Visible = guiButton.Visible; b.Enabled = guiButton.Enabled; b.ForeColor = Color.FromName(guiButton.ForeColor); if (guiButton.BackColor != string.Empty) { b.BackColor = Color.FromName(guiButton.BackColor); } tooltip.SetToolTip(b, guiButton.ToolTip); addControl(control, b); } else if (control is GuiCheckBox) { GuiCheckBox guiCheckBox = control as GuiCheckBox; CheckBox cb = new CheckBox(); cb.Checked = guiCheckBox.Checked; cb.CheckedChanged += new EventHandler(OnCheckBoxClick); cb.LostFocus += new EventHandler(ControlLostFocus); cb.Enter += new EventHandler(ControlEnter); cb.Text = guiCheckBox.Text; cb.Left = guiCheckBox.Left; cb.Top = guiCheckBox.Top; cb.Width = guiCheckBox.Width; cb.Height = guiCheckBox.Height; cb.Name = guiCheckBox.ID; cb.Visible = guiCheckBox.Visible; cb.Enabled = guiCheckBox.Enabled; cb.ForeColor = Color.FromName(guiCheckBox.ForeColor); if (guiCheckBox.BackColor != string.Empty) { cb.BackColor = Color.FromName(guiCheckBox.BackColor); } tooltip.SetToolTip(cb, guiCheckBox.ToolTip); addControl(control, cb); } else if (control is GuiFilePicker) { GuiFilePicker guiPicker = control as GuiFilePicker; Button b = new Button(); if (guiPicker.PicksFolder) { b.Click += new EventHandler(OnFolderSelectorClick); } else { b.Click += new EventHandler(OnFileSelectorClick); } b.Text = guiPicker.Text; b.Left = guiPicker.Left; b.Top = guiPicker.Top; b.Width = guiPicker.Width; b.Height = guiPicker.Height; b.Name = guiPicker.ID; b.Visible = guiPicker.Visible; b.Enabled = guiPicker.Enabled; b.ForeColor = Color.FromName(guiPicker.ForeColor); if (guiPicker.BackColor != string.Empty) { b.BackColor = Color.FromName(guiPicker.BackColor); } tooltip.SetToolTip(b, guiPicker.ToolTip); b.LostFocus += new EventHandler(ControlLostFocus); b.Enter += new EventHandler(ControlEnter); addControl(control, b); } else if (control is GuiTextBox) { GuiTextBox guiTextBox = control as GuiTextBox; TextBox tb = new TextBox(); tb.Left = guiTextBox.Left; tb.Top = guiTextBox.Top; tb.Width = guiTextBox.Width; tb.Height = guiTextBox.Height; tb.Visible = guiTextBox.Visible; tb.Enabled = guiTextBox.Enabled; tb.Multiline = guiTextBox.Multiline; tb.WordWrap = guiTextBox.WordWrap; if (guiTextBox.VerticalScroll && guiTextBox.HorizontalScroll) { tb.ScrollBars = ScrollBars.Both; } else if (guiTextBox.VerticalScroll) { tb.ScrollBars = ScrollBars.Vertical; } else if (guiTextBox.HorizontalScroll) { tb.ScrollBars = ScrollBars.Horizontal; } else { tb.ScrollBars = ScrollBars.None; } tb.ForeColor = Color.FromName(guiTextBox.ForeColor); if (guiTextBox.BackColor != string.Empty) { tb.BackColor = Color.FromName(guiTextBox.BackColor); } tb.Name = guiTextBox.ID; tb.Text = guiTextBox.Text; tooltip.SetToolTip(tb, guiTextBox.ToolTip); tb.KeyPress += new KeyPressEventHandler(OnTextBoxKeyPress); tb.LostFocus += new EventHandler(ControlLostFocus); tb.Enter += new EventHandler(ControlEnter); addControl(control, tb); } else if (control is GuiComboBox) { GuiComboBox guiComboBox = control as GuiComboBox; ComboBox cb = new ComboBox(); cb.DropDownStyle = ComboBoxStyle.DropDownList; cb.Sorted = guiComboBox.Sorted; foreach (string val in guiComboBox.Items) { ListControlItem item = new ListControlItem(val, guiComboBox[val]); cb.Items.Add(item); if (val == guiComboBox.SelectedValue) { cb.SelectedItem = item; } } cb.SelectedValueChanged += new EventHandler(OnComboBoxChange); cb.LostFocus += new EventHandler(ControlLostFocus); cb.Enter += new EventHandler(ControlEnter); cb.Left = guiComboBox.Left; cb.Top = guiComboBox.Top; cb.Width = guiComboBox.Width; cb.Height = guiComboBox.Height; cb.Visible = guiComboBox.Visible; cb.Enabled = guiComboBox.Enabled; cb.ForeColor = Color.FromName(guiComboBox.ForeColor); if (guiComboBox.BackColor != string.Empty) { cb.BackColor = Color.FromName(guiComboBox.BackColor); } cb.Name = guiComboBox.ID; tooltip.SetToolTip(cb, guiComboBox.ToolTip); addControl(control, cb); } else if (control is GuiListBox) { GuiListBox guiListBox = control as GuiListBox; ListBox lb = new ListBox(); if (guiListBox.IsMultiSelect) { lb.SelectionMode = SelectionMode.MultiExtended; } else { lb.SelectionMode = SelectionMode.One; } lb.Sorted = guiListBox.Sorted; lb.Left = guiListBox.Left; lb.Top = guiListBox.Top; lb.Width = guiListBox.Width; lb.Height = guiListBox.Height; lb.Visible = guiListBox.Visible; lb.Enabled = guiListBox.Enabled; lb.ForeColor = Color.FromName(guiListBox.ForeColor); if (guiListBox.BackColor != string.Empty) { lb.BackColor = Color.FromName(guiListBox.BackColor); } lb.Name = guiListBox.ID; tooltip.SetToolTip(lb, guiListBox.ToolTip); foreach (string val in guiListBox.Items) { ListControlItem item = new ListControlItem(val, guiListBox[val]); int index = lb.Items.Add(item); if (guiListBox.SelectedItems.Contains(val)) { lb.SetSelected(index, true); } } // For some reason this fixes all of my timing issues! object s; foreach (object o in lb.SelectedIndices) { s = o; } lb.KeyUp += new KeyEventHandler(OnListBoxKeyUp); lb.SelectedValueChanged += new EventHandler(OnListBoxChange); lb.LostFocus += new EventHandler(ControlLostFocus); lb.Enter += new EventHandler(ControlEnter); addControl(control, lb); } else if (control is GuiGrid) { GuiGrid guiGrid = control as GuiGrid; DataGrid dg = new DataGrid(); dg.Left = guiGrid.Left; dg.Top = guiGrid.Top; dg.Width = guiGrid.Width; dg.Height = guiGrid.Height; dg.Visible = guiGrid.Visible; dg.Enabled = guiGrid.Enabled; if (guiGrid.ForeColor != string.Empty) { dg.ForeColor = Color.FromName(guiGrid.ForeColor); } else if (guiGrid.BackColor != string.Empty) { dg.BackColor = Color.FromName(guiGrid.BackColor); } dg.Name = guiGrid.ID; dg.DataSource = SimpleTableTools.ConvertToDataTable(guiGrid.DataSource); tooltip.SetToolTip(dg, guiGrid.ToolTip); dg.LostFocus += new EventHandler(ControlLostFocus); dg.Enter += new EventHandler(ControlEnter); addControl(control, dg); } else if (control is GuiCheckBoxList) { GuiCheckBoxList guiCheckBoxList = control as GuiCheckBoxList; CheckedListBox lb = new CheckedListBox(); lb.Sorted = guiCheckBoxList.Sorted; lb.CheckOnClick = true; lb.Left = guiCheckBoxList.Left; lb.Top = guiCheckBoxList.Top; lb.Width = guiCheckBoxList.Width; lb.Height = guiCheckBoxList.Height; lb.Visible = guiCheckBoxList.Visible; lb.Enabled = guiCheckBoxList.Enabled; lb.ForeColor = Color.FromName(guiCheckBoxList.ForeColor); if (guiCheckBoxList.BackColor != string.Empty) { lb.BackColor = Color.FromName(guiCheckBoxList.BackColor); } lb.Name = guiCheckBoxList.ID; tooltip.SetToolTip(lb, guiCheckBoxList.ToolTip); foreach (string val in guiCheckBoxList.Items) { ListControlItem item = new ListControlItem(val, guiCheckBoxList[val]); int index = lb.Items.Add(item); if (guiCheckBoxList.SelectedItems.Contains(val)) { lb.SetItemChecked(index, true); } } // For some reason this fixes all of my timing issues! object s; foreach (object o in lb.CheckedItems) { s = o; } lb.KeyUp += new KeyEventHandler(OnCheckedListBoxKeyUp); lb.SelectedValueChanged += new EventHandler(OnCheckedListBoxChange); lb.LostFocus += new EventHandler(ControlLostFocus); lb.Enter += new EventHandler(ControlEnter); addControl(control, lb); } }
public void UpdateData() { Control w32ctrl; foreach (GuiControl control in guiControls.Values) { w32ctrl = win32Controls[control.ID] as Control; if (control is GuiLabel) { GuiLabel guiLabel = control as GuiLabel; Label l = w32ctrl as Label; guiLabel.Text = l.Text; } else if (control is GuiButton) { GuiButton guiButton = control as GuiButton; Button b = w32ctrl as Button; guiButton.Text = b.Text; } else if (control is GuiCheckBox) { GuiCheckBox guiCheckBox = control as GuiCheckBox; CheckBox cb = w32ctrl as CheckBox; guiCheckBox.Text = cb.Text; guiCheckBox.Checked = cb.Checked; } else if (control is GuiFilePicker) { GuiFilePicker guiPicker = control as GuiFilePicker; Button b = w32ctrl as Button; guiPicker.Text = b.Text; b.Tag = win32Controls[guiPicker.TargetControl]; } else if (control is GuiTextBox) { GuiTextBox guiTextBox = control as GuiTextBox; TextBox tb = w32ctrl as TextBox; guiTextBox.Text = tb.Text; } else if (control is GuiComboBox) { GuiComboBox guiComboBox = control as GuiComboBox; ComboBox cb = w32ctrl as ComboBox; if (cb.SelectedItem is ListControlItem) { guiComboBox.SelectedValue = ((ListControlItem)cb.SelectedItem).Value; } } else if (control is GuiListBox) { GuiListBox guiListBox = control as GuiListBox; ListBox lb = w32ctrl as ListBox; guiListBox.Clear(); foreach (ListControlItem item in lb.Items) { guiListBox[item.Value] = item.Text; } foreach (ListControlItem item in lb.SelectedItems) { guiListBox.SelectedItems.Add(item.Value); } } else if (control is GuiGrid) { GuiGrid guiGrid = control as GuiGrid; DataGrid dg = w32ctrl as DataGrid; guiGrid.DataSource = SimpleTableTools.ConvertToSimpleTable(dg.DataSource as DataTable); } else if (control is GuiCheckBoxList) { GuiCheckBoxList guiCheckBoxList = control as GuiCheckBoxList; CheckedListBox lb = w32ctrl as CheckedListBox; guiCheckBoxList.Clear(); foreach (ListControlItem item in lb.Items) { guiCheckBoxList[item.Value] = item.Text; } foreach (ListControlItem item in lb.CheckedItems) { guiCheckBoxList.SelectedItems.Add(item.Value); } } } }
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 + "."); } }