SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
AddAlert.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 
10 namespace SeciUserInterface.Dialogs.Alerts
11 {
12  public partial class AddAlert : Form
13  {
14  public String Block;
15  public String BlockType;
16  public String Low;
17  public String High;
18  public Boolean SubConfig;
19  public String OldLow;
20  public String OldHigh;
21 
22  public AddAlert()
23  {
24  InitializeComponent();
25 
26  for (int i = 0; i < Seci.Managers.BlockMgr.Blocks.Count; ++i)
27  {
28  comBlocks.Items.Add(Seci.Managers.BlockMgr.Blocks[i].BlockName);
29  }
30  }
31 
32  private void AddAlert_Load(object sender, EventArgs e)
33  {
34  if (!String.IsNullOrEmpty(Block))
35  {
36  comBlocks.SelectedItem = Block;
37  comBlocks.Enabled = false;
38  txtLow.Text = OldLow;
39  txtHigh.Text = OldHigh;
40  this.Text = "Edit Alert";
41  }
42  }
43 
44  private void comBlocks_SelectedIndexChanged(object sender, EventArgs e)
45  {
46  if (comBlocks.SelectedIndex != -1)
47  {
48  var block = Seci.Managers.BlockMgr.Blocks[comBlocks.SelectedIndex];
49  var type = Seci.Managers.LabViewMgr.GetControlType(block.ParentVI, block.ReadControl);
50  lblType.Text = type.ToString();
51  }
52  }
53 
54  private void btnOK_Click(object sender, EventArgs e)
55  {
56  if (comBlocks.SelectedIndex == -1)
57  {
58  MessageBox.Show("Please select a Block");
59  return;
60  }
61 
62  if (lblType.Text == "NUMERIC")
63  {
64  BlockType = Seci.Definitions.ControlType.NUMERIC.ToString();
65 
66  Double low;
67  Double high;
68 
69  if (!Double.TryParse(txtLow.Text, out low))
70  {
71  MessageBox.Show("Low limit must be numeric");
72  return;
73  }
74 
75  if (!Double.TryParse(txtHigh.Text, out high))
76  {
77  MessageBox.Show("High limit must be numeric");
78  return;
79  }
80 
81  Block = comBlocks.SelectedItem.ToString();
82 
83  if (low > high)
84  {
85  Low = high.ToString();
86  High = low.ToString();
87  }
88  else
89  {
90  Low = low.ToString();
91  High = high.ToString();
92  }
93  }
94  else
95  {
96  MessageBox.Show("Currently alerts can only be set for numeric blocks");
97  return;
98  }
99 
100  if (SubConfig)
101  {
102  MessageBox.Show("This alert was loaded from a sub-configuration; the changes will not be saved in the sub-configuration");
103  }
104 
105  DialogResult = System.Windows.Forms.DialogResult.OK;
106  Close();
107  }
108 
109 
110 
111  }
112 }
void AddAlert_Load(object sender, EventArgs e)
Definition: AddAlert.cs:32
void comBlocks_SelectedIndexChanged(object sender, EventArgs e)
Definition: AddAlert.cs:44
void btnOK_Click(object sender, EventArgs e)
Definition: AddAlert.cs:54