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); } } }
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; }
///<summary>Gets a list of all SigButDefs when program first opens. Also refreshes SigButDefElements and attaches all elements to the appropriate buttons.</summary> public static void Refresh() { SigButDefElements.Refresh(); string command = "SELECT * FROM sigbutdef ORDER BY ButtonIndex"; DataTable table = General.GetTable(command); Listt = new SigButDef[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { Listt[i] = new SigButDef(); Listt[i].SigButDefNum = PIn.PInt(table.Rows[i][0].ToString()); Listt[i].ButtonText = PIn.PString(table.Rows[i][1].ToString()); Listt[i].ButtonIndex = PIn.PInt(table.Rows[i][2].ToString()); Listt[i].SynchIcon = PIn.PInt(table.Rows[i][3].ToString()); Listt[i].ComputerName = PIn.PString(table.Rows[i][4].ToString()); Listt[i].ElementList = SigButDefElements.GetForButton(Listt[i].SigButDefNum); } }