/// <summary> /// Загрузить панели /// </summary> /// <param name="root"></param> private void LoadPanels(XmlNode root) { try { if (root != null) { if (root.HasChildNodes) { foreach (XmlNode child in root.ChildNodes) { switch (child.Name) { case panelName: try { ParametersViewPanel panel = new ParametersViewPanel(); panel.DeSerializeToXmlNode(child); panels.Add(panel); } catch { } break; default: break; } } } } } catch { } }
/// <summary> /// Выбрали панель для отображения /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxPanels_SelectedIndexChanged(object sender, EventArgs e) { try { for (int i = 0; i < graphics.Length; i++) { graphics[i].Description = string.Empty; graphics[i].Units = string.Empty; } int selectedpanel_index = comboBoxPanels.SelectedIndex; if (selectedpanel_index > -1 && selectedpanel_index < _app.Panels.Count) { panelView = _app.Panels[selectedpanel_index]; if (panelView != null) { panelView.Parameter1.Graphic = graphics[0]; panelView.Parameter2.Graphic = graphics[1]; panelView.Parameter3.Graphic = graphics[2]; panelView.Parameter4.Graphic = graphics[3]; panelView.Parameter5.Graphic = graphics[4]; } } LoadData(); manager.Update(); } catch { } }
/// <summary> /// Добавить панель в список панелей /// </summary> /// <param name="panel">Добавляемая панель</param> protected void InsertPanelInlistView(ParametersViewPanel panel) { ListViewItem item = new ListViewItem((listViewPanels.Items.Count + 1).ToString()); ListViewItem.ListViewSubItem desc = new ListViewItem.ListViewSubItem(item, panel.Description); item.SubItems.Add(desc); item.Tag = panel; listViewPanels.Items.Add(item); }
/// <summary> /// редакритуем описание панели /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxDescription_TextChanged(object sender, EventArgs e) { if (selectedPanel != null) { selectedPanel.Description = textBoxDescription.Text; foreach (ListViewItem item in listViewPanels.Items) { ParametersViewPanel itPanel = item.Tag as ParametersViewPanel; if (itPanel != null) { if (itPanel == selectedPanel) { item.SubItems[1].Text = selectedPanel.Description; } } } } }
/// <summary> /// выбрали панель в списке /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listViewPanels_SelectedIndexChanged(object sender, EventArgs e) { try { if (listViewPanels.SelectedItems != null) { if (listViewPanels.SelectedItems.Count > 0) { ParametersViewPanel selected = listViewPanels.SelectedItems[0].Tag as ParametersViewPanel; if (selected != null) { selectedPanel = selected; ShowSelectedPanel(); } } } } catch { } }
/// <summary> /// удаляем панель /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonRemovePanel_Click(object sender, EventArgs e) { if (listViewPanels.SelectedItems != null) { if (listViewPanels.SelectedItems.Count > 0) { foreach (ListViewItem item in listViewPanels.SelectedItems) { ParametersViewPanel panel = item.Tag as ParametersViewPanel; if (panel != null) { _app.Panels.Remove(panel); listViewPanels.Items.Remove(item); buttonClearOptions_Click(null, EventArgs.Empty); } } } } }
/// <summary> /// добавить панель для отображения /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonInsertNewPanel_Click(object sender, EventArgs e) { if (selectedPanel == null) { ParametersViewPanel newPanel = new ParametersViewPanel(); newPanel.Description = textBoxDescription.Text; if (textBoxP1.Tag != null) { newPanel.Parameter1 = textBoxP1.Tag as GraphicPanelParameter; } if (textBoxP2.Tag != null) { newPanel.Parameter2 = textBoxP2.Tag as GraphicPanelParameter; } if (textBoxP3.Tag != null) { newPanel.Parameter3 = textBoxP3.Tag as GraphicPanelParameter; } if (textBoxP4.Tag != null) { newPanel.Parameter4 = textBoxP4.Tag as GraphicPanelParameter; } if (textBoxP5.Tag != null) { newPanel.Parameter5 = textBoxP5.Tag as GraphicPanelParameter; } _app.Panels.Add(newPanel); InsertPanelInlistView(newPanel); selectedPanel = newPanel; } else { MessageBox.Show(this, "", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// очистить настройки /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonClearOptions_Click(object sender, EventArgs e) { if (selectedPanel != null) { selectedPanel = null; textBoxP1.Tag = null; textBoxP1.Text = string.Empty; textBoxP2.Tag = null; textBoxP2.Text = string.Empty; textBoxP3.Tag = null; textBoxP3.Text = string.Empty; textBoxP4.Tag = null; textBoxP4.Text = string.Empty; textBoxP5.Tag = null; textBoxP5.Text = string.Empty; textBoxDescription.Text = string.Empty; } }
private void comboBoxPanels_SelectedIndexChanged(object sender, EventArgs e) { try { for (int i = 0; i < graphics.Length; i++) { graphics[i].Description = string.Empty; graphics[i].Units = string.Empty; } int selectedpanel_index = comboBoxPanels.SelectedIndex; if (selectedpanel_index > -1 && selectedpanel_index < _app.Panels.Count) { panelView = _app.Panels[selectedpanel_index]; if (panelView != null) { digitDisplay1.Digits.Clear(); panelView.Parameter1.Graphic = graphics[0]; Digit dig_1 = new Digit(); dig_1.Color = panelView.Parameter1.Graphic.Color; dig_1.Description = panelView.Parameter1.Graphic.Description; dig_1.Index = 0; digitDisplay1.Digits.Add(dig_1); panelView.Parameter2.Graphic = graphics[1]; Digit dig_2 = new Digit(); dig_2.Color = panelView.Parameter2.Graphic.Color; dig_2.Description = panelView.Parameter2.Graphic.Description; dig_2.Index = 0; digitDisplay1.Digits.Add(dig_2); panelView.Parameter3.Graphic = graphics[2]; Digit dig_3 = new Digit(); dig_3.Color = panelView.Parameter3.Graphic.Color; dig_3.Description = panelView.Parameter3.Graphic.Description; dig_3.Index = 0; digitDisplay1.Digits.Add(dig_3); panelView.Parameter4.Graphic = graphics[3]; Digit dig_4 = new Digit(); dig_4.Color = panelView.Parameter4.Graphic.Color; dig_4.Description = panelView.Parameter4.Graphic.Description; dig_4.Index = 0; digitDisplay1.Digits.Add(dig_4); panelView.Parameter5.Graphic = graphics[4]; Digit dig_5 = new Digit(); dig_5.Color = panelView.Parameter5.Graphic.Color; dig_5.Description = panelView.Parameter5.Graphic.Description; dig_5.Index = 0; digitDisplay1.Digits.Add(dig_5); } } manager.Mode = GraphicComponent.DrawMode.Activ; manager.updTime(); manager.Update(); } catch { } }
/// <summary> /// добавить панель для отображения /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonInsertNewPanel_Click(object sender, EventArgs e) { if (selectedPanel == null) { ParametersViewPanel newPanel = new ParametersViewPanel(); newPanel.Description = textBoxDescription.Text; if (textBoxP1.Tag != null) newPanel.Parameter1 = textBoxP1.Tag as GraphicPanelParameter; if (textBoxP2.Tag != null) newPanel.Parameter2 = textBoxP2.Tag as GraphicPanelParameter; if (textBoxP3.Tag != null) newPanel.Parameter3 = textBoxP3.Tag as GraphicPanelParameter; if (textBoxP4.Tag != null) newPanel.Parameter4 = textBoxP4.Tag as GraphicPanelParameter; if (textBoxP5.Tag != null) newPanel.Parameter5 = textBoxP5.Tag as GraphicPanelParameter; _app.Panels.Add(newPanel); InsertPanelInlistView(newPanel); selectedPanel = newPanel; } else { MessageBox.Show(this, "", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }