public void printText <T>(IEnumerable <T> listlike, string title, int index) { ListBox label; switch (index) { case 1: label = this.label1; break; case 2: label = this.label2; break; default: label = null; break; } ListBox.ObjectCollection oc = label.Items; oc.Clear(); if (label != null) { oc.Add(String.Format("{0}: \n", title)); foreach (T item in listlike) { oc.Add(String.Format("> {0} \n", item.ToString())); } } return; }
public void LogWarning(string message, params object[] args) { string status = String.Format(string.Concat("WARN: ", message), args); items.Add(status); using (StreamWriter logfile = File.AppendText("log.xml")) { logfile.WriteLine(status); } }
public void LogWarning(string message, params object[] args) { // Log the information the standard way baseLogger.LogWarning(message, args); // Try to update the list item in the form // **** NOTE **** This class will not work and generates a multitasking error which we will fix later string status = String.Format(string.Concat("WARN: ", message), args); items.Add(status); }
private void UpdateHostListControl() { ListBox.ObjectCollection list = HostSelectionList.Items; list.Clear(); list.Add("Favorites:"); foreach (var item in HostList.FavoriteHosts.ToArray()) list.Add(item); list.Add("Recent:"); foreach (var item in HostList.RecentHosts.ToArray()) list.Add(item); }
public void ListBox_ObjectCollection_ClearingAll() { _collection = new ListBox.ObjectCollection(new ListBox()); Team team = new Team("Brazil"); Player player = new Player("Ronaldo"); _collection.Add(team); _collection.Add(player); Assert.IsNotEmpty(_collection); _collection.Clear(); Assert.IsEmpty(_collection); }
public void ListBox_ObjectCollection() { _collection = new ListBox.ObjectCollection(new ListBox()); Team team = new Team("Brazil"); Player player = new Player("Ronaldo"); _collection.Add(team); _collection.Add(player); Assert.IsInstanceOf <Team>(_collection[0]); Assert.IsInstanceOf <Player>(_collection[1]); Assert.AreNotSame(_collection[0], _collection[1]); Assert.AreEqual(_collection[0].ToTeam().Id, team.Id); Assert.AreEqual(_collection[1].ToPlayer().Id, player.Id); }
public void Process(ListBox listBox) { RegexOptions options = RegexOptions.None; if (Register) { options = RegexOptions.IgnoreCase; } if (Multiline) { options = options | RegexOptions.Multiline; } ListBox.ObjectCollection newCollection = new ListBox.ObjectCollection(listBox); Regex regex = new Regex(_regularExpression, options); if (regex.IsMatch(_sourceText)) { MatchCollection matches = regex.Matches(_sourceText); foreach (var item in matches) { newCollection.Add(item); } } else { MessageBox.Show(@"Совпадений не найдено!", @"ошибка!"); } }
private void BtnDivisorsClick(object sender, EventArgs e) { int n; try { n = int.Parse(tbxNum.Text); } catch (Exception exp) { MessageBox.Show(exp.Message, "Hiba lépett fel"); return; } collection.Clear(); for (int i = 1; i <= n; i++) { if (n % i == 0) { collection.Add(i); } } }
private void RequestAnswerer_UpdateList() { RequestAnswerer_ListBox.Enabled = RequestAnswerer_Listener.IsActive; PeerConnection[] l1, l2; l1 = RequestAnswerer_Listener.GetPendingRequests(); List<PeerConnection> l1l = new List<PeerConnection>(l1); ListBox.ObjectCollection l2r = RequestAnswerer_ListBox.Items; l2 = new PeerConnection[l2r.Count]; // Copy l2r to l2. for (int i = 0; i < l2r.Count; i++) l2[i] = (PeerConnection)l2r[i]; // Remove foreach (PeerConnection item in l2) if (!l1l.Contains(item)) l2r.Remove(item); // Add for (int i = 0; i < l1l.Count; i++) { PeerConnection l1o = l1[i]; PeerConnection l2o = i <= l2.GetUpperBound(0) ? l2[i] : null; if (l1o.GreetingReceived && (l2o == null || l1o != l2o)) { l2r.Add(l1o); if (i == l1l.Count - 1) RequestAnswerer_ListBox.SelectedItem = l1o; } } }
private void LoadTableInfo(ITable itable_1, ListBox.ObjectCollection listBoxItemCollection_0) { listBoxItemCollection_0.Clear(); string str = ""; string str1 = ""; try { if ((itable_1 as IDataset).Workspace.Type == esriWorkspaceType.esriLocalDatabaseWorkspace) { IWorkspace workspace = (itable_1 as IDataset).Workspace; if (workspace.PathName != null && Path.GetExtension(workspace.PathName).ToLower() == ".mdb") { str = "["; str1 = "]"; } } IFields fields = itable_1.Fields; for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.Field[i]; if ((field.Type == esriFieldType.esriFieldTypeGeometry ? false : field.Type != esriFieldType.esriFieldTypeBlob)) { listBoxItemCollection_0.Add(string.Concat(str, field.Name, str1)); } } } catch { } }
public void Ref() { this.listBox1.Items.Clear(); for (int i = 0; i < this.Myapp.zimos.Count; i++) { ListBox.ObjectCollection arg_15A_0 = this.listBox1.Items; string[] array = new string[14]; array[0] = i.ToString(); array[1] = "-"; array[2] = datasize.Myencoding.GetString(this.Myapp.zimodatas[i], 0, (int)this.Myapp.zimos[i].ascstar); array[3] = "(size:"; string[] arg_9C_0 = array; int arg_9C_1 = 4; byte b = this.Myapp.zimos[i].w; arg_9C_0[arg_9C_1] = b.ToString(); array[5] = "X"; string[] arg_C5_0 = array; int arg_C5_1 = 6; b = this.Myapp.zimos[i].h; arg_C5_0[arg_C5_1] = b.ToString(); array[7] = ",encode:"; array[8] = this.Myapp.zimos[i].encode.GetencodeName(); array[9] = ",qyt:"; string[] arg_116_0 = array; int arg_116_1 = 10; uint qyt = this.Myapp.zimos[i].qyt; arg_116_0[arg_116_1] = qyt.ToString(); array[11] = ",datasize:"; array[12] = (this.Myapp.zimodatas[i].Length + datasize.zimoxinxisize).ToString("0,000"); array[13] = ")"; arg_15A_0.Add(string.Concat(array)); } this.label1.Text = this.Myapp.zimos.Count.ToString(); }
private void BTNtabuada_Click(object sender, EventArgs e) { try { this.LSBsaida.Items.Clear(); int num = int.Parse(this.TXTnumero.Text); this.LSBsaida.Items.Add("TABUADA"); this.LSBsaida.Items.Add(""); if ((num < 0 ? true : num > 9)) { MessageBox.Show("Digite valores entre 0 e 9"); this.TXTnumero.Focus(); this.TXTnumero.SelectAll(); } else { for (int i = 0; i <= 10; i++) { ListBox.ObjectCollection items = this.LSBsaida.Items; string[] str = new string[] { num.ToString(), " X ", i.ToString(), " = ", null }; str[4] = (num * i).ToString(); items.Add(string.Concat(str)); } } } catch { MessageBox.Show("Escolha um número antes de processar"); } }
/// <summary> /// 添加或更新更表 /// </summary> /// <param name="oc"></param> /// <param name="item"></param> public static void AddOrUpdate(this ListBox.ObjectCollection oc, object item) { if (!oc.Contains(item)) { oc.Add(item); } }
private void AddDebug(string s) { if (debug != null) { debug.Add(s); } }
private ListBox.ObjectCollection quicksort(ListBox.ObjectCollection list) { ListBox.ObjectCollection sorted = new ListBox.ObjectCollection(new ListBox()); sorted.AddRange(list); if (sorted.Count <= 1) { return(sorted); } int random = randomNumberGenerator.Next(0, sorted.Count - 1); string pivot = (string)list[random]; sorted.RemoveAt(random); ListBox.ObjectCollection lessThan = new ListBox.ObjectCollection(new ListBox()); ListBox.ObjectCollection greaterThan = new ListBox.ObjectCollection(new ListBox()); for (int i = 0; i < sorted.Count; ++i) { sortItem(sorted[i], pivot, lessThan, greaterThan); } sorted = quicksort(lessThan); sorted.Add(pivot); sorted.AddRange(quicksort(greaterThan)); return(sorted); }
private void Form1_Load(object sender, EventArgs e) { ListBox.ObjectCollection items = this.lstbox02.Items; DateTime now = DateTime.Now; items.Add(now.ToString("d")); }
private void View_OnCreateFigureButton_Click(object sender, EventArgs e) { if (_pointsBuffer.Count == 0) { _view.ShowError(new Exception("Список точек пуст!")); return; } var factory = AppDependencies.CreataFactory(); var points = new Point[_pointsBuffer.Count]; for (int i = 0; i < points.Length; i++) { points[i] = (Point)_pointsBuffer[i]; } try { var figure = factory.Create(points); var color = _view.GetSelectedColor(); var figureDrawer = new FigureDrawer( new FiguresDataAdapter(figure), color, System.Drawing.Color.Black, System.Drawing.Color.Black ); _figuresBuffer.Add(figureDrawer); _outFigures.Add(figureDrawer); } catch (Exception err) { _view.ShowError(err); } }
public void UpdateTradeData(IEnumerable <string> lines) { foreach (string line in lines) { tradItems.Add(line); } }
PopulateWithOtherWorkbookNames ( Microsoft.Office.Interop.Excel.Workbook workbook ) { Debug.Assert(workbook != null); AssertValid(); ListBox.ObjectCollection oItems = this.Items; oItems.Clear(); foreach (Microsoft.Office.Interop.Excel.Workbook oOtherWorkbook in workbook.Application.Workbooks) { String sOtherWorkbookName = oOtherWorkbook.Name; // Filter out this workbook and the personal macro workbook. The // Workbook.Name of the personal macro workbook is "Personal1" on // my machine -- can it be "PERSONAL2" or "PERSONAL3" as well? if (sOtherWorkbookName == workbook.Name || sOtherWorkbookName.ToLower().StartsWith("personal")) { continue; } oItems.Add(sOtherWorkbookName); } }
private void Btn_valider_Click(object sender, EventArgs e) { switch (this.state) { case state.modified: Gerant g = (Gerant)items[this.position]; g.Age = (Convert.ToInt32(this.tb_age.Text)); g.Prenom = (this.tb_prenom.Text); g.Nom = (this.tb_nom.Text); g.Password = (this.tb_pwd.Text); g.Budget = (Convert.ToInt32(this.tb_bud.Text)); if (this.old == 0) { g.State1 = (0); } else { g.State1 = (this.state); } items[this.position] = g; break; case state.added: Gerant ge = new Gerant(tb_nom.Text, tb_prenom.Text, Convert.ToInt32(tb_age.Text), tb_pwd.Text, this.state, Convert.ToInt32(tb_bud.Text), lg.LastID); this.lg.Add(ge); items.Add(ge); break; } this.Close(); }
// add data to ListBox private void AddDataToCollection(string[] from, ListBox.ObjectCollection to) { foreach (Object item in from) { to.Add(item); } }
private static void CopyListOfIntsToObjectCollectionInListBox(List <YData> src, ListBox.ObjectCollection dest) { dest.Clear(); foreach (var i in src) { dest.Add(i.Count); } }
private void BtnAddClick(object sender, EventArgs e) { if (tbxInput.Text == "") { return; } collection.Add(tbxInput.Text); }
public static void ToListBox(string repository, DataTable table, ListBox.ObjectCollection collection) { collection.Clear(); foreach (string filter in ToList(repository, table)) { collection.Add(Templater.ToCaptions(table.Columns, RemoveTable(filter))); } }
public void UpdateTradeData(IEnumerable <string> lines) { foreach (string line in lines) { // Parse the lines to the tradeItems collection tradeItems.Add(line); } // Update the trade data }
private void addSortedItem(object item, ListBox.ObjectCollection sorted, ListBox.ObjectCollection reverseSorted) { if (sortOrder == SortOrder.SORTED) { sorted.Add(item); } else { reverseSorted.Add(item); } }
public NotificationForm(ListBox.ObjectCollection p_history) { m_history = p_history; NativeMethods.SetParent(Handle, NativeMethods.HWND_MESSAGE); NativeMethods.AddClipboardFormatListener(Handle); if (Clipboard.ContainsText(System.Windows.Forms.TextDataFormat.Text)) { m_history.Add((String)System.Windows.Forms.Clipboard.GetData(System.Windows.Forms.DataFormats.StringFormat)); } }
private void updateListbox(ListBox.ObjectCollection dst, List <Vector2f> src) { dst.Clear(); string str; foreach (var p in src) { str = p.X.ToString() + ", " + p.Y.ToString(); dst.Add(str); } }
public static void AddRangeDistinct(this ListBox.ObjectCollection lb, ListBox.ObjectCollection lbAdd, string SelectedTables) { foreach (var temp in lbAdd) { var a = SelectedTables + "." + temp.ToString(); if (!lb.Contains(a)) { lb.Add(a); } } }
public void ListBox_ObjectCollection_CompareTeamId() { _collection = new ListBox.ObjectCollection(new ListBox()); Team team = new Team("Brazil"); _collection.Add(team); Team teamCasted = _collection[0].ToTeam(); Assert.AreEqual(teamCasted.Id, team.Id); Assert.AreSame(teamCasted, team); }