SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
AddComponent.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.Text;
7 using System.Windows.Forms;
8 
9 namespace Sample_Environment_Control_Interface.Dialogs.Config
10 {
11  public partial class AddComponent : Form
12  {
13  public AddComponent()
14  {
15  InitializeComponent();
16 
17  }
18 
19  private void btnBrowse_Click(object sender, EventArgs e)
20  {
21  openFileDialog1.InitialDirectory = Seci.SeciInterface.SeciStatus.CompDir;
22  openFileDialog1.Filter = "SECI Component|*.comp";
23 
24  if (openFileDialog1.ShowDialog() == DialogResult.OK)
25  {
26  txtFile.Text = openFileDialog1.FileName;
27  }
28  }
29 
30  private void btnAdd_Click(object sender, EventArgs e)
31  {
32  if (!String.IsNullOrEmpty(txtFile.Text))
33  {
34  SECI_GUI.Pause_Timers();
35 
36  try
37  {
38  Seci.SeciInterface.Components_Add(openFileDialog1.FileName);
39  }
40  catch (Exception err)
41  {
42  Seci.SeciInterface.Error_LogError("AddComponent", err);
43  MessageBox.Show("Failed to add component!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
44  return;
45  }
46 
47  SECI_GUI.Resume_Timers();
48  DialogResult = DialogResult.OK;
49  Close();
50  }
51  else
52  {
53  MessageBox.Show("Please select a component to add.", "Component Not Selected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
54  }
55  }
56  }
57 }