Beispiel #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connections"></param>
        public FormConnection()
        {
            InitializeComponent();

            using (new HourGlass(this))
            {
                _connections = new Connections();
                string ret = _connections.Load();
                if (ret.Length > 0)
                {
                    UserInterface.DisplayErrorMessageBox(this, "An error occurred whilst loading the connections");
                    return;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (listConnections.SelectedObjects.Count != 1)
            {
                return;
            }

            Connection connection = (Connection)listConnections.SelectedObjects[0];

            Connections connections = new Connections();
            string ret = connections.Load();
            if (ret.Length > 0)
            {
                UserInterface.DisplayErrorMessageBox(this, "An error occurred whilst loading the connections");
                return;
            }

            DialogResult dialogResult = MessageBox.Show(this,
                                                        "Are you sure you want to delete the connection? " + Environment.NewLine + Environment.NewLine +
                                                        "Name: " + connection.Name,
                                                        Application.ProductName,
                                                        MessageBoxButtons.YesNo,
                                                        MessageBoxIcon.Question);

            if (dialogResult == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            int numRemoved = connections.Data.RemoveAll(c => c.Name == connection.Name & c.ConnectionString == connection.ConnectionString);
            if (numRemoved == 0)
            {
                UserInterface.DisplayErrorMessageBox(this, "The connection could not be removed");
                return;
            }

            ret = connections.Save();
            if (ret.Length > 0)
            {
                UserInterface.DisplayErrorMessageBox(this, "An error occurred whilst saving the connections");
                return;
            }

            LoadConnections();
        }
Beispiel #3
0
        /// <summary>
        /// 
        /// </summary>
        private void LoadConnections()
        {
            using (new HourGlass(this))
            {
                Connections connections = new Connections();
                string ret = connections.Load();
                if (ret.Length > 0)
                {
                    UserInterface.DisplayErrorMessageBox(this, "An error occurred whilst loading the connections");
                    return;
                }

                listConnections.SetObjects(connections.Data);
                SetButtonState();

                if (connections.Data.Count > 0)
                {
                    olvcConnectionString.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                    listConnections.SelectedObject = connections.Data[0];
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 
        /// </summary>
        private void LoadConnections()
        {
            using (new HourGlass(this))
            {
                _connections = new Connections();
                string ret = _connections.Load();
                if (ret.Length > 0)
                {
                    UserInterface.DisplayErrorMessageBox(this, "An error occurred whilst loading the connections: " + ret);
                    return;
                }

                cboConnections.Items.Clear();
                cboConnections.ComboBox.DisplayMember = "Name";
                cboConnections.ComboBox.ValueMember = "ConnectionString";
                cboConnections.Items.AddRange(_connections.Data.ToArray());

                if (_connections.Data.Count > 0)
                {
                    cboConnections.SelectedIndex = 0;
                    UpdateConnectionString();
                    controlEvents.SetProcessingStatus(true);
                    controlRules.SetProcessingStatus(true);
                    controlSearch.SetProcessingStatus(true);
                    controlSensors.SetProcessingStatus(true);
                }
                else
                {
                    controlEvents.SetProcessingStatus(false);
                    controlRules.SetProcessingStatus(false);
                    controlSearch.SetProcessingStatus(false);
                    controlSensors.SetProcessingStatus(false);
                }
            }
        }