Exemplo n.º 1
0
        private void modrules_bSetAction_Click(object sender, EventArgs e)
        {
            //Save the Rule as it stands.
            modrules_tSave.PerformClick();

            var controller = new ActionController();
            if (controller.RetrieveActionsForRule(_rule.Id).Any())
            {
                //Get the actual Action.
                var action = controller.RetrieveActionsForRule(_rule.Id).FirstOrDefault();
                _action = action;

                //Load the values required.
                modact_cEnabled.Checked = action.Enabled;
                modact_tValue.Text = action.OutputValue;
                modact_tRule.Text = _rule.ToString();

                //Download the required communicator
                var commController = new CommunicatorController();
                var comm = commController.GetAllCommunicators().FirstOrDefault(c => c.Id == action.CommunicatorId);

                if (comm != null)
                {
                    _communicator = comm;
                    _action.Communicator = comm;
                    modact_tComm.Text = comm.ToString();
                }
                else
                {
                    modact_tComm.Text = "";
                }

                //Actions exist.
                pTabPanel.SelectedTab = pModifyActions;
            }
            else
            {
                var db = new DataBoard(_communicator,_selectedDevice);
                db.GoToActionPage(_rule);
                db.ShowDialog();

                _action = db.GetAction();
                DebugOutput.Print("Changes made in the Data Manager are saved.");
            }

        }
Exemplo n.º 2
0
        private void modify_bRules_Click(object sender, EventArgs e)
        {
            //Loads the relevant communicators.
            var controller = new RuleController();
            modrules_lbRules.Items.Clear();
            modrules_lbRules.Items.AddRange(
                controller.RetrieveRulesForDevice(_selectedDevice.Id).ToArray());

            if (modrules_lbRules.Items.Count > 0)
            {
                //Select the first element
                modrules_lbRules.SelectedItem = modrules_lbRules.Items[0];



                //Shows the modify tab.
                pTabPanel.SelectedTab = pModifyRules;
            }
            else
            {
                var msg =
                    System.Windows.Forms.MessageBox.Show(
                        "There are no Rules for this Device.", "No Rules Available",
                        MessageBoxButtons.OK, MessageBoxIcon.Hand);

                // -------- Create new rule ----------

                //Create and display the DataBoard form.
                var window = new DataBoard(null, _selectedDevice);
                window.GoToRulePage();
                window.ShowDialog();

                //Get the Comm object created.
                _rule = window.GetRule();
            }
        }
Exemplo n.º 3
0
        private void add_bNewAction_Click(object sender, EventArgs e)
        {
            //Save the new Device.
            add_bSaveNewDevice.PerformClick();

            //Create and display the DataBoard form.
            var window = new DataBoard(_communicator, _selectedDevice);
            window.GoToActionPage();
            window.ShowDialog();

            //Get the Comm object created.
            _action = window.GetAction();

            //Update the labels.
            UpdateStartLabels();
        }
Exemplo n.º 4
0
        private void modify_bComms_Click(object sender, EventArgs e)
        {
            try
            {
                //Loads the relevant communicators.
                var controller = new CommunicatorController();
                modcomms_lbComms.Items.Clear();
                modcomms_lbComms.Items.AddRange(
                    controller.GetAllCommunicators().Where(c => c.Device.Id == _selectedDevice.Id).ToArray());

                if (modcomms_lbComms.Items.Count > 0)
                {
                    //Select the first element
                    modcomms_lbComms.SelectedItem = modcomms_lbComms.Items[0];

                    //Shows the modify tab.
                    pTabPanel.SelectedTab = pModifyCommunicators;
                }
                else
                {
                    var msg =
                        System.Windows.Forms.MessageBox.Show(
                            "There are no Communicators for this Device.", "No Communicators Available",
                            MessageBoxButtons.OK, MessageBoxIcon.Hand);

                    // -------- Create new communicator ----------

                    //Create and display the DataBoard form.
                    var window = new DataBoard(null, _selectedDevice);
                    window.GoToCommunicatorPage();
                    window.ShowDialog();

                    //Get the Comm object created.
                    _communicator = window.GetCommunicator();
                }
            }
            catch (Exception ex)
            {
                DebugOutput.Print("Could not load/store/update information for selected Device", ex.Message);
            }
        }
Exemplo n.º 5
0
        private void modrules_bAddNewRule_Click(object sender, EventArgs e)
        {
            //Create and display the DataBoard form.
            var window = new DataBoard(_communicator, _selectedDevice);
            window.GoToRulePage();
            window.ShowDialog();

            //Get the Comm object created.
            _rule = window.GetRule();

            //Return to Device list
            modrules_tBack.PerformClick();
        }