Пример #1
0
        private void FillList()
        {
            SigButDefs.Refresh();
            SigButDefElements.Refresh();
            if (listComputers.SelectedIndex == -1)          //although I don't know how this could happen
            {
                listComputers.SelectedIndex = 0;
            }
            if (listComputers.SelectedIndex == 0)
            {
                SubList = SigButDefs.GetByComputer("");
            }
            else
            {
                //remember, defaults are mixed into this list unless overridden:
                SubList = SigButDefs.GetByComputer(Computers.List[listComputers.SelectedIndex - 1].CompName);
            }
            int selected = listButtons.SelectedIndex;

            listButtons.Items.Clear();
            SigButDef button;

            SigButDefElement[] elements;
            string             s;

            for (int i = 0; i < 20; i++)
            {
                button = SigButDefs.GetByIndex(i, SubList);
                if (button == null)
                {
                    listButtons.Items.Add("-" + (i + 1).ToString() + "-");
                }
                else
                {
                    s        = button.ButtonText;
                    elements = SigButDefElements.GetForButton(button.SigButDefNum);
                    for (int e = 0; e < elements.Length; e++)
                    {
                        if (e == 0)
                        {
                            s += " (";
                        }
                        else
                        {
                            s += ", ";
                        }
                        s += SigElementDefs.GetElement(elements[e].SigElementDefNum).SigText;
                        if (e == elements.Length - 1)
                        {
                            s += ")";
                        }
                    }
                    if (button.ComputerName == "" && listComputers.SelectedIndex != 0)
                    {
                        s += " " + Lan.g(this, "(all)");
                    }
                    listButtons.Items.Add(s);
                }
            }
        }
Пример #2
0
        private void butDown_Click(object sender, EventArgs e)
        {
            if (listButtons.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select an item first.");
                return;
            }
            int selected = listButtons.SelectedIndex;

            if (selected == listButtons.Items.Count - 1)
            {
                return;
            }
            SigButDef button = SigButDefs.GetByIndex(selected, _arraySigButDefs);

            if (button == null)
            {
                return;
            }
            if (button.ButtonIndex == _maxNumButtonsInList - 1)
            {
                MsgBox.Show(this, $"No more than {_maxNumButtonsInList} buttons are allowed.");
                return;
            }
            _arraySigButDefs = SigButDefs.MoveDown(button, _arraySigButDefs);
            FillList();
            listButtons.SelectedIndex = selected + 1;
        }
Пример #3
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textSynchIcon.errorProvider1.GetError(textSynchIcon) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textButtonText.Text == "")
     {
         MsgBox.Show(this, "Please enter a text description first.");
         return;
     }
     if (textSynchIcon.Text == "")
     {
         textSynchIcon.Text = "0";
     }
     _sigButDefCur.ButtonText            = textButtonText.Text;
     _sigButDefCur.SynchIcon             = PIn.Byte(textSynchIcon.Text);
     _sigButDefCur.SigElementDefNumUser  = (comboTo.SelectedIndex > 0) ? _arraySigElementDefUser[comboTo.SelectedIndex - 1].SigElementDefNum : 0;
     _sigButDefCur.SigElementDefNumExtra = (comboExtras.SelectedIndex > 0) ? _arraySigElementDefExtras[comboExtras.SelectedIndex - 1].SigElementDefNum : 0;
     _sigButDefCur.SigElementDefNumMsg   = (comboMessage.SelectedIndex > 0) ? _arraySigElementDefMessages[comboMessage.SelectedIndex - 1].SigElementDefNum : 0;
     if (IsNew)
     {
         SigButDefs.Insert(_sigButDefCur);
     }
     else
     {
         SigButDefs.Update(_sigButDefCur);
     }
     DialogResult = DialogResult.OK;
 }
Пример #4
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textSynchIcon.errorProvider1.GetError(textSynchIcon) != ""
                )
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (textButtonText.Text == "")
            {
                MsgBox.Show(this, "Please enter a text description first.");
                return;
            }
            if (textSynchIcon.Text == "")
            {
                textSynchIcon.Text = "0";
            }
            ButtonCur.ButtonText = textButtonText.Text;
            ButtonCur.SynchIcon  = PIn.PInt(textSynchIcon.Text);
            if (IsNew)
            {
                SigButDefs.Insert(ButtonCur);
            }
            else
            {
                SigButDefs.Update(ButtonCur);
            }
            //delete all the existing elements
            SigButDefs.DeleteElements(ButtonCur);
            SigButDefElement element;

            if (comboTo.SelectedIndex != 0)
            {
                element = new SigButDefElement();
                element.SigButDefNum     = ButtonCur.SigButDefNum;
                element.SigElementDefNum = sigElementDefUser[comboTo.SelectedIndex - 1].SigElementDefNum;
                SigButDefElements.Insert(element);
            }
            if (comboExtras.SelectedIndex != 0)
            {
                element = new SigButDefElement();
                element.SigButDefNum     = ButtonCur.SigButDefNum;
                element.SigElementDefNum = sigElementDefExtras[comboExtras.SelectedIndex - 1].SigElementDefNum;
                SigButDefElements.Insert(element);
            }
            if (comboMessage.SelectedIndex != 0)
            {
                element = new SigButDefElement();
                element.SigButDefNum     = ButtonCur.SigButDefNum;
                element.SigElementDefNum = sigElementDefMessages[comboMessage.SelectedIndex - 1].SigElementDefNum;
                SigButDefElements.Insert(element);
            }
            DialogResult = DialogResult.OK;
        }
Пример #5
0
        private void FormSigButDefEdit_Load(object sender, EventArgs e)
        {
            if (ButtonCur.ComputerName == "")
            {
                radioAll.Checked = true;
            }
            else
            {
                radioOne.Checked      = true;
                textComputerName.Text = ButtonCur.ComputerName;
            }
            textButtonText.Text   = ButtonCur.ButtonText;
            textSynchIcon.Text    = ButtonCur.SynchIcon.ToString();
            sigElementDefUser     = SigElementDefs.GetSubList(SignalElementType.User);
            sigElementDefExtras   = SigElementDefs.GetSubList(SignalElementType.Extra);
            sigElementDefMessages = SigElementDefs.GetSubList(SignalElementType.Message);
            SigButDefElement elementUser    = SigButDefs.GetElement(ButtonCur, SignalElementType.User);
            SigButDefElement elementExtra   = SigButDefs.GetElement(ButtonCur, SignalElementType.Extra);
            SigButDefElement elementMessage = SigButDefs.GetElement(ButtonCur, SignalElementType.Message);

            comboTo.Items.Clear();
            comboTo.Items.Add(Lan.g(this, "none"));
            comboTo.SelectedIndex = 0;
            for (int i = 0; i < sigElementDefUser.Length; i++)
            {
                comboTo.Items.Add(sigElementDefUser[i].SigText);
                if (elementUser != null && elementUser.SigElementDefNum == sigElementDefUser[i].SigElementDefNum)
                {
                    comboTo.SelectedIndex = i + 1;
                }
            }
            comboExtras.Items.Clear();
            comboExtras.Items.Add(Lan.g(this, "none"));
            comboExtras.SelectedIndex = 0;
            for (int i = 0; i < sigElementDefExtras.Length; i++)
            {
                comboExtras.Items.Add(sigElementDefExtras[i].SigText);
                if (elementExtra != null && elementExtra.SigElementDefNum == sigElementDefExtras[i].SigElementDefNum)
                {
                    comboExtras.SelectedIndex = i + 1;
                }
            }
            comboMessage.Items.Clear();
            comboMessage.Items.Add(Lan.g(this, "none"));
            comboMessage.SelectedIndex = 0;
            for (int i = 0; i < sigElementDefMessages.Length; i++)
            {
                comboMessage.Items.Add(sigElementDefMessages[i].SigText);
                if (elementMessage != null && elementMessage.SigElementDefNum == sigElementDefMessages[i].SigElementDefNum)
                {
                    comboMessage.SelectedIndex = i + 1;
                }
            }
        }
Пример #6
0
        private void listButtons_DoubleClick(object sender, EventArgs e)
        {
            if (listButtons.SelectedIndex == -1)           //should never happen
            {
                return;
            }
            //Save any changes to the cache because the item order could have changed.
            if (SigButDefs.UpdateButtonIndexIfChanged(_arraySigButDefs))
            {
                DataValid.SetInvalid(InvalidType.SigMessages);
            }
            int       selected  = listButtons.SelectedIndex;
            SigButDef sigButDef = SigButDefs.GetByIndex(selected, _arraySigButDefs);
            //Keep track of the currently selected computer name so we know what computer buttons to refresh after making changes.
            string computerNameSelected = (listComputers.SelectedIndex > 0) ? _listComputers[listComputers.SelectedIndex - 1].CompName : "";
            //Now create a new computer name variable that will represent the computer name for the SigButDef.
            string computerNameSigButDef = "";

            if (sigButDef == null)           //Add
            {
                sigButDef             = new SigButDef();
                sigButDef.ButtonIndex = selected;
                if (listComputers.SelectedIndex != 0)
                {
                    computerNameSigButDef = _listComputers[listComputers.SelectedIndex - 1].CompName;
                }
                sigButDef.ComputerName = computerNameSigButDef;
                FormSigButDefEdit FormS = new FormSigButDefEdit(sigButDef.Copy());
                FormS.IsNew = true;
                FormS.ShowDialog();
            }
            else if (sigButDef.ComputerName == "" && listComputers.SelectedIndex != 0)
            {
                //create a copy of the default, and treat it as a new
                sigButDef.ComputerName = _listComputers[listComputers.SelectedIndex - 1].CompName;
                FormSigButDefEdit FormS = new FormSigButDefEdit(sigButDef.Copy());
                FormS.IsNew = true;
                FormS.ShowDialog();
            }
            else                                     //edit
            {
                if (listComputers.SelectedIndex > 0) //If "All" is selected, the computerName will already be blank, so it only needs reset if it isn't "All".
                {
                    computerNameSigButDef = _listComputers[listComputers.SelectedIndex - 1].CompName;
                }
                FormSigButDefEdit FormS = new FormSigButDefEdit(sigButDef.Copy());
                FormS.ShowDialog();
            }
            //Refresh our local list to match the cache in case the user edited or added a new button item.
            _arraySigButDefs = SigButDefs.GetByComputer(computerNameSelected);
            FillList();
        }
Пример #7
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         if (!MsgBox.Show(this, true, "Delete?"))
         {
             return;
         }
         SigButDefs.Delete(ButtonCur);                //also deletes elements
         DialogResult = DialogResult.OK;
     }
 }
Пример #8
0
 private void listComputers_Click(object sender, EventArgs e)
 {
     //Cache needs to be saved to the database.
     if (SigButDefs.UpdateButtonIndexIfChanged(_arraySigButDefs))
     {
         DataValid.SetInvalid(InvalidType.SigMessages);
     }
     if (listComputers.SelectedIndex == 0)
     {
         _arraySigButDefs = SigButDefs.GetByComputer("");
     }
     else
     {
         //remember, defaults are mixed into this list unless overridden:
         _arraySigButDefs = SigButDefs.GetByComputer(_listComputers[listComputers.SelectedIndex - 1].CompName);
     }
     FillList();
 }
Пример #9
0
        private void listButtons_DoubleClick(object sender, EventArgs e)
        {
            if (listButtons.SelectedIndex == -1)          //should never happen
            {
                return;
            }
            int       selected = listButtons.SelectedIndex;
            SigButDef button   = SigButDefs.GetByIndex(selected, SubList);

            if (button == null)          //Add
            {
                FormSigButDefEdit FormS = new FormSigButDefEdit();
                FormS.IsNew        = true;
                button             = new SigButDef();
                button.ElementList = new SigButDefElement[0];
                button.ButtonIndex = selected;
                if (listComputers.SelectedIndex == 0)
                {
                    button.ComputerName = "";
                }
                else
                {
                    button.ComputerName = Computers.List[listComputers.SelectedIndex - 1].CompName;
                }
                FormS.ButtonCur = button.Copy();
                FormS.ShowDialog();
            }
            else if (button.ComputerName == "" && listComputers.SelectedIndex != 0)
            {
                //create a copy of the default, and treat it as a new
                FormSigButDefEdit FormS = new FormSigButDefEdit();
                FormS.IsNew         = true;
                button.ComputerName = Computers.List[listComputers.SelectedIndex - 1].CompName;
                FormS.ButtonCur     = button.Copy();
                FormS.ShowDialog();
            }
            else             //edit
            {
                FormSigButDefEdit FormS = new FormSigButDefEdit();
                FormS.ButtonCur = button.Copy();
                FormS.ShowDialog();
            }
            FillList();
        }
Пример #10
0
        private void FormMessagingButSetup_Load(object sender, EventArgs e)
        {
            _listComputers = Computers.GetDeepCopy();
            listComputers.Items.Clear();
            listComputers.Items.Add(Lan.g(this, "All"));
            string s;

            for (int i = 0; i < _listComputers.Count; i++)
            {
                s = _listComputers[i].CompName;
                if (SystemInformation.ComputerName == _listComputers[i].CompName)
                {
                    s += " " + Lan.g(this, "(this computer)");
                }
                listComputers.Items.Add(s);
            }
            listComputers.SelectedIndex = 0;
            _arraySigButDefs            = SigButDefs.GetByComputer("");
            FillList();
        }
Пример #11
0
        private void butUp_Click(object sender, EventArgs e)
        {
            if (listButtons.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select an item first.");
                return;
            }
            int selected = listButtons.SelectedIndex;

            if (selected == 0)
            {
                return;
            }
            SigButDef button = SigButDefs.GetByIndex(selected, _arraySigButDefs);

            if (button == null)
            {
                return;
            }
            _arraySigButDefs = SigButDefs.MoveUp(button, _arraySigButDefs);
            FillList();
            listButtons.SelectedIndex = selected - 1;
        }
Пример #12
0
        private void butDown_Click(object sender, EventArgs e)
        {
            if (listButtons.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select an item first.");
                return;
            }
            int selected = listButtons.SelectedIndex;

            if (selected == listButtons.Items.Count - 1)
            {
                return;
            }
            SigButDef button = SigButDefs.GetByIndex(selected, SubList);

            if (button == null)
            {
                return;
            }
            SigButDefs.MoveDown(button, SubList);
            FillList();
            listButtons.SelectedIndex = selected + 1;
        }
Пример #13
0
        private void FillList()
        {
            if (listComputers.SelectedIndex == -1)           //although I don't know how this could happen
            {
                listComputers.SelectedIndex = 0;
            }
            int selected = listButtons.SelectedIndex;

            listButtons.Items.Clear();
            SigButDef            sigButDef;
            List <SigElementDef> listSigElementDefs;
            string buttonText;

            for (int i = 0; i < _maxNumButtonsInList; i++)
            {
                sigButDef = SigButDefs.GetByIndex(i, _arraySigButDefs);
                if (sigButDef == null)
                {
                    listButtons.Items.Add("-" + (i + 1).ToString() + "-");
                }
                else
                {
                    buttonText         = sigButDef.ButtonText;
                    listSigElementDefs = SigElementDefs.GetElementsForButDef(sigButDef);
                    if (listSigElementDefs.Count > 0)
                    {
                        buttonText += " (" + string.Join(",", listSigElementDefs.Select(x => x.SigText)) + ")";
                    }
                    if (sigButDef.ComputerName == "" && listComputers.SelectedIndex != 0)
                    {
                        buttonText += " " + Lan.g(this, "(all)");
                    }
                    listButtons.Items.Add(buttonText);
                }
            }
        }
Пример #14
0
 private void FormMessagingButSetup_FormClosing(object sender, FormClosingEventArgs e)
 {
     SigButDefs.UpdateButtonIndexIfChanged(_arraySigButDefs);
     DataValid.SetInvalid(InvalidType.SigMessages);
 }