/// <summary> /// Changes in the columns, items or subitems /// </summary> /// <param name="ctType"></param> /// <param name="column"></param> /// <param name="item"></param> /// <param name="subItem"></param> public ChangedEventArgs(ChangedTypes ctType, GLColumn column, GLItem item, GLSubItem subItem) { m_Column = column; m_Item = item; m_SubItem = subItem; m_ctType = ctType; }
/// <summary> /// remove an item from the list /// </summary> /// <param name="item"></param> public void Remove(GLItem item) { List.Remove(item); if (ChangedEvent != null) { ChangedEvent(this, new ChangedEventArgs(ChangedTypes.ItemCollectionChanged, null, null, null)); } }
/// <summary> /// insert an item into the list at specified index /// </summary> /// <param name="nIndex"></param> /// <param name="strItemText"></param> /// <returns></returns> public GLItem Insert(int nIndex, string strItemText) { GLItem item = new GLItem(Parent); //GLItem item = new GLItem(Parent); item.SubItems[0].Text = strItemText; nIndex = Insert(nIndex, item); return(item); }
/// <summary> /// Clears all selection bits in the item structure /// /// this overload is an optimization to stop a redraw on a re-selection /// </summary> public void ClearSelection(GLItem itemIgnore) { for (int index = 0; index < List.Count; index++) { GLItem citem = this[index]; if (citem != itemIgnore) { citem.Selected = false; // changed will generate an invalidation by themselves } } }
/// <summary> /// Find the index of a specified item /// </summary> /// <param name="item"></param> /// <returns></returns> public int FindItemIndex(GLItem item) // use -1 to have it start from the beginning of the list { for (int nIndex = 0; nIndex < Count; nIndex++) { if (item == this[nIndex]) { return(nIndex); } } return(-1); // couldn't find it }
public bool GLLoad(GLItem item, GLSubItem subItem, GlacialList listctrl) { m_item = item; m_subItem = subItem; m_Parent = listctrl; this.Text = subItem.Text; this.Items.Add("i1"); this.Items.Add("i2"); this.Items.Add("i3"); return(true); }
/// <summary> /// Conversion to string /// </summary> /// <param name="context"></param> /// <param name="culture"></param> /// <param name="value"></param> /// <param name="destinationType"></param> /// <returns></returns> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is GLItem) { GLItem column = (GLItem)value; ConstructorInfo ci = typeof(GLItem).GetConstructor(new Type[] {}); if (ci != null) { return(new InstanceDescriptor(ci, null, false)); } } return(base.ConvertTo(context, culture, value, destinationType)); }
private bool CompareItems(GLItem item1, GLItem item2, CompareDirection direction) { bool dir = false; if (direction == CompareDirection.GreaterThan) { dir = true; } if (this.SortDirection == SortDirections.SortAscending) { dir = !dir; // flip it } if (!this.NumericCompare) { if (dir) { return(item1.SubItems[SortColumn].Text.CompareTo(item2.SubItems[SortColumn].Text) < 0); } else { return(item1.SubItems[SortColumn].Text.CompareTo(item2.SubItems[SortColumn].Text) > 0); } } else { try { double n1 = Double.Parse(item1.SubItems[SortColumn].Text); double n2 = Double.Parse(item2.SubItems[SortColumn].Text); if (dir) { return(n1 < n2); } else { return(n1 > n2); } } catch (Exception ex) { // no numeric value (bad bad) Debug.WriteLine(ex.ToString()); return(false); } } }
public bool GLLoad(GLItem item, GLSubItem subItem, GlacialList listctrl) // populate this control however you wish with item { // set the styles you want for this this.BorderStyle = BorderStyle.None; this.AutoSize = false; m_item = item; m_subItem = subItem; m_Parent = listctrl; this.Text = subItem.Text; return(true); // we don't do any heavy processing in this ctrl so we just return true }
public void sort(GLItemCollection items, int low_0, int high_0) { int lo = low_0; int hi = high_0; if (lo >= hi) { return; } int mid = (lo + hi) / 2; sort(items, lo, mid); sort(items, mid + 1, hi); int end_lo = mid; int start_hi = mid + 1; while ((lo <= end_lo) && (start_hi <= hi)) { if (StopRequested) { return; } if (CompareItems(items[lo], items[start_hi], CompareDirection.LessThan)) { lo++; } else { GLItem T = items[start_hi]; for (int k = start_hi - 1; k >= lo; k--) { items[k + 1] = items[k]; } items[lo] = T; lo++; end_lo++; start_hi++; } } }
public bool GLLoad(GLItem item, GLSubItem subItem, GlacialList listctrl) { this.Format = DateTimePickerFormat.Long; try { m_item = item; m_subItem = subItem; m_Parent = listctrl; this.Text = subItem.Text; //this.Value = subItem.Text; } catch (Exception ex) { Debug.WriteLine(ex.ToString()); this.Text = DateTime.Now.ToString(); } return(true); }
/// <summary> /// lowest level of add/insert. All add and insert routines eventually call this /// /// in the future always have routines call this one as well to keep one point of entry /// </summary> /// <param name="nIndex"></param> /// <param name="item"></param> /// <returns></returns> public int Insert(int nIndex, GLItem item) { item.Parent = this.Parent; item.ChangedEvent += new ChangedEventHandler(Item_Changed); if (nIndex < 0) { nIndex = List.Add(item); // add the item itself } else { List.Insert(nIndex, item); } if (ChangedEvent != null) { ChangedEvent(this, new ChangedEventArgs(ChangedTypes.ItemCollectionChanged, null, null, null)); } return(nIndex); }
/// <summary> /// add an itemto the items collection /// </summary> /// <param name="item"></param> /// <returns></returns> public int Add(GLItem item) { return(Insert(-1, item)); }