/// <summary> /// Add a new data /// </summary> /// <param name="list">data list</param> /// <param name="po">printer object</param> /// <returns>added variable</returns> public static bool AddNewData(ListBox list, PrinterObject po) { string s = string.Empty; Data d = new Data(); FillVars(d.Controls["vars"] as ListBox, po); DialogResult dr = d.ShowDialog(); if (dr == DialogResult.OK) { bool byVar = (d.Controls["rbVariable"] as RadioButton).Checked; if (byVar) { po.UseVariable(d.Controls["vars"].Text); } else { po.AddData(d.Controls["txtConst"].Text); } list.Items.Add(po.Datas.Last()); list.Refresh(); hasModified = true; return(true); } return(false); }
/// <summary> /// Copy data /// </summary> /// <param name="list">data list</param> /// <param name="po">printer object</param> /// <returns>if at least one item removed</returns> public static bool CopyData(ListBox list, PrinterObject po) { bool atLeastOne = false; for (int index = 0; index < list.SelectedIndices.Count; ++index) { int pos = list.SelectedIndices[index]; string s = po.Datas.ElementAt(pos); if (s.StartsWith("[") && s.EndsWith("]")) { po.UseVariable(s.Substring(1, s.Length - 2)); } else { po.AddData(s); } list.Items.Add(po.Datas.Last()); hasModified = true; atLeastOne = true; } list.Refresh(); return(atLeastOne); }