using System; using System.Collections.ObjectModel; using Eto.Forms; using Rhino; public class GeometryItem : IComparable { public int ID; public string Text { get; set; } public GeometryItem(int id, string text) { ID = id; Text = text; } public int CompareTo(GeometryItem other) { return ID.CompareTo(other.ID); } } public class GeometryGrid : GridView { private ObservableCollection Items; public GeometryGrid() { Items = new ObservableCollection(); for (int i = 0; i < 10; i++) { Items.Add(new GeometryItem(i, "Curve " + i)); } TextBoxCell cell = new TextBoxCell("Text"); cell.TextAlignment = TextAlignment.Center; GridColumn col = new GridColumn { Width = 150, Editable = false, Resizable = false, DataCell = cell }; AllowDrop = true; AllowEmptySelection = true; AllowMultipleSelection = true; RowHeight = 24; DataStore = Items; ShowHeader = false; GridLines = GridLines.None; Width = 150; Border = BorderType.None; Columns.Add(col); } protected override void OnCellClick(GridCellMouseEventArgs e) { base.OnCellClick(e); GeometryItem item = (GeometryItem)e.Item; RhinoApp.WriteLine("OnCellClick, Item {0}", item.ID); if (e.Modifiers == Keys.None) { DataObject data = new DataObject(); data.SetString(item.ID.ToString(), "int"); DoDragDrop(data, DragEffects.Move); } } protected override void OnCellDoubleClick(GridCellMouseEventArgs e) { base.OnCellDoubleClick(e); GeometryItem item = (GeometryItem)e.Item; RhinoApp.WriteLine("OnCellDoubleClick, Item {0}", item.ID); } protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); } protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); } protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); } protected override void OnDragEnter(DragEventArgs e) { base.OnDragEnter(e); } protected override void OnDragOver(DragEventArgs e) { base.OnDragOver(e); RhinoApp.WriteLine("OnDragOver, data: {0}", e.Data.GetString("int")); } protected override void OnDragLeave(DragEventArgs e) { base.OnDragLeave(e); } protected override void OnDragDrop(DragEventArgs e) { base.OnDragDrop(e); RhinoApp.WriteLine("OnDragDrop, data: {0}", e.Data.GetString("int")); } }