private Container ICSelector() { ScrolledWindow sw = new ScrolledWindow(); ICStore = new ListStore((int)GLib.TypeFundamentals.TypeString, (int)GLib.TypeFundamentals.TypeInt); ICView = new TreeView(ICStore); TreeViewColumn col = new TreeViewColumn(); TreeIter iter; CellRenderer renderer = new CellRendererText(); col.Title = "MemberType"; col.PackStart(renderer, true); col.AddAttribute(renderer, "markup", 0); ICView.AppendColumn(col); ICView.HeadersVisible = false; ICStore.Append(out iter); ICStore.SetValue(iter, 0, new GLib.Value(ICLabel("all", factory.staticCount + factory.instanceCount))); ICStore.SetValue(iter, 1, new GLib.Value((int)(BindingFlags.Static | BindingFlags.Instance))); ICStore.Append(out iter); ICStore.SetValue(iter, 0, new GLib.Value(ICLabel("instance", factory.instanceCount))); ICStore.SetValue(iter, 1, new GLib.Value((int)BindingFlags.Instance)); ICStore.Append(out iter); ICStore.SetValue(iter, 0, new GLib.Value(ICLabel("class", factory.staticCount))); ICStore.SetValue(iter, 1, new GLib.Value((int)BindingFlags.Static)); ICView.Selection.SelectPath(new TreePath("0")); ICView.Selection.Changed += new EventHandler(ICSelectionChanged); ICView.BorderWidth = 5; sw.Add(ICView); return(sw); }
/// <summary> /// Populates the completion window with data. /// </summary> /// <param name="items">List of completion data.</param> public void Populate(List<ICompletionItem> items) { completionModel.Clear(); // Add empty first row. completionModel.Append(); foreach (ICompletionItem item in items) { IEnumerable<string> descriptionLines = item.Description?.Split(Environment.NewLine.ToCharArray()).Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)).Take(2); string description = descriptionLines?.Count() < 2 ? descriptionLines.FirstOrDefault() : descriptionLines?.Aggregate((x, y) => x + Environment.NewLine + y); completionModel.AppendValues(item.Image, item.DisplayText, item.Units, item.ReturnType, description, item.CompletionText, item.IsMethod); } }
private Container MemberSelector() { ScrolledWindow sw = new ScrolledWindow(); memberStore = new ListStore((int)GLib.TypeFundamentals.TypeString, (int)GLib.TypeFundamentals.TypeInt); MTView = new TreeView(memberStore); TreeViewColumn col = new TreeViewColumn(); TreeIter iter; CellRenderer renderer = new CellRendererText(); col.Title = "MemberType"; col.PackStart(renderer, true); col.AddAttribute(renderer, "markup", 0); MTView.AppendColumn(col); MTView.HeadersVisible = false; foreach (MemberRecordFactory rv in recordFactory) { memberStore.Append(out iter); memberStore.SetValue(iter, 0, new GLib.Value(rv.FullTitle)); } MTView.Selection.SelectPath(new TreePath("0")); MTView.Selection.Changed += new EventHandler(MemberFilterSelectionChanged); MTView.BorderWidth = 5; sw.Add(MTView); return(sw); }
private void UpdateSearchBox() { _searchResultsStore.Clear(); _searchResultsStoreCount = 0; foreach (var m in Book.SearchTitles(_searchTextView.Buffer.Text)) { _searchResultsStore.SetValue(_searchResultsStore.Append(), 0, new TitleSearchResult(m.Key, _searchResultsStoreCount, m.Value)); ++_searchResultsStoreCount; if (_searchResultsStoreCount >= 100) { break; } } if (_searchResultsStoreCount == 1) { SelectedIndex = 0; } else { SelectedIndex = -1; } }
void addButton_Clicked(object sender, EventArgs e) { //create the object object instance = System.Activator.CreateInstance(types[0]); //get existing selection and insert after it TreeIter oldIter, newIter; TreeModel model; if (itemTree.Selection.GetSelected(out model, out oldIter)) { newIter = itemStore.InsertAfter(oldIter); } //or append if no previous selection else { newIter = itemStore.Append(); } itemStore.SetValue(newIter, 0, instance); //select, set name and update all the indices itemTree.Selection.SelectIter(newIter); UpdateName(newIter); UpdateIndices(); }
public TreeIter NewRow() { TreeIter rowTreeIter = new TreeIter(); store.Append(out rowTreeIter); return(rowTreeIter); }
private void FillGrid(int start, int count) { grid.Model = null; int end = start + count; if (dataSource.Rows.Count < end) { end = dataSource.Rows.Count; } store.Clear(); for (int i = start; i < end; i++) { DataRow row = dataSource.Rows[i]; TreeIter iter = store.Append(); for (int j = 0; j < columnCount; j++) { //HACK: this is a hack for a bug that doesn't allow gchars in a liststore if (conversionLookup.ContainsKey(j)) { ConvertObjectFunc func = conversionLookup[j]; store.SetValue(iter, j, func(row[j])); } else { store.SetValue(iter, j, row[j]); } } } grid.Model = store; }
public static void Copy(TreeModel tree, TreeIter tree_iter, ListStore list, bool first) { // Copy this iter's values to the list TreeIter list_iter = list.Append(); for (int i = 0; i < list.NColumns; i++) { list.SetValue(list_iter, i, tree.GetValue(tree_iter, i)); if (i == 1) { //Console.WriteLine("Copying {0}", list.GetValue(list_iter, i)); } } // Copy the first child, which will trigger the copy if its siblings (and their children) TreeIter child_iter; if (tree.IterChildren(out child_iter, tree_iter)) { Copy(tree, child_iter, list, true); } // Add siblings and their children if we are the first child, otherwise doing so would repeat if (first) { while (tree.IterNext(ref tree_iter)) { Copy(tree, tree_iter, list, false); } } }
private void FillListView(string serverPath) { _listStore.Clear(); var versionControl = projectCollection.GetService <RepositoryService>(); var itemSet = versionControl.QueryItemsExtended(this._currentWorkspace, new ItemSpec(serverPath, RecursionType.OneLevel), DeletedState.NonDeleted, ItemType.Any); foreach (var item in itemSet.Skip(1).OrderBy(i => i.ItemType).ThenBy(i => i.TargetServerItem)) { var row = _listStore.Append(); _listStore.SetValue(row, 0, item); _listStore.SetValue(row, 1, GetItemImage(item.ItemType)); _listStore.SetValue(row, 2, item.ServerPath.ItemName); if (this._currentWorkspace != null) { if (item.ChangeType != ChangeType.None && !item.HasOtherPendingChange) { _listStore.SetValue(row, 3, item.ChangeType.ToString()); _listStore.SetValue(row, 4, this._currentWorkspace.OwnerName); } if (item.HasOtherPendingChange) { var remoteChanges = this._currentWorkspace.GetPendingSets(item.SourceServerItem, RecursionType.None); List <string> changeNames = new List <string>(); List <string> userNames = new List <string>(); foreach (var remoteChange in remoteChanges) { var pChange = remoteChange.PendingChanges.FirstOrDefault(); if (pChange == null) { continue; } changeNames.Add(pChange.ChangeType.ToString()); userNames.Add(remoteChange.Owner); } _listStore.SetValue(row, 3, string.Join(", ", changeNames)); _listStore.SetValue(row, 4, string.Join(", ", userNames)); } } if (!IsMapped(item.ServerPath)) { _listStore.SetValue(row, 5, "Not mapped"); } else { if (!item.IsInWorkspace) { _listStore.SetValue(row, 5, "Not downloaded"); } else { _listStore.SetValue(row, 5, item.IsLatest ? "Yes" : "No"); } } _listStore.SetValue(row, 6, item.CheckinDate.ToString("yyyy-MM-dd HH:mm")); } }
private void AddToStore(ListStore store, GLib.Value field, GLib.Value value, GLib.Value details, GLib.Value icon) { TreeIter iter = store.Append(); store.SetValue(iter, 0, field); store.SetValue(iter, 1, value); store.SetValue(iter, 2, details); store.SetValue(iter, 3, icon); }
private void Append(ListStore store, MemberRecord mr, Type type) { TreeIter iter; store.Append(out iter); store.SetValue(iter, 0, new GLib.Value(mr.Label)); store.SetValue(iter, 1, new GLib.Value(type.FullName)); store.SetValue(iter, 2, new GLib.Value(mr.Icon)); store.SetValue(iter, 3, new GLib.Value(mr.GetType() == typeof(TypeRecord))); }
void PopulateData() { // performance, would get raised for each new row store.RowChanged -= HandleTreeStoreRowChanged; foreach (Table2D table2D in data.List2D) { TreeIter newNode = store.Append(); SetNodeContent(newNode, table2D); } store.RowChanged += HandleTreeStoreRowChanged; }
private void AddFile(string fileName) { Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(fileName); if (pixbuf.Width > 80 | pixbuf.Height > 80) { pixbuf = pixbuf.ScaleSimple(80, 80, Gdk.InterpType.Hyper); } TreeIter iter = store.Append(); store.SetValue(iter, 0, pixbuf); store.SetValue(iter, 1, fileName); }
private void HeightCellEdited(object o, EditedArgs args) { Gtk.TreeIter iter; Gtk.TreePath path = new Gtk.TreePath(args.Path); heightModel.GetIter(out iter, path); int row = path.Indices[0]; int col; for (col = 0; col < treeview1.Columns.Count(); col++) { if (treeview1.Columns[col].CellRenderers[0] == o) { break; } } if (col == treeview1.Columns.Count()) { return; // Could not locate the column! } string value = args.NewText.Trim(); if (value == (string)heightModel.GetValue(iter, col)) { return; } if (value == String.Empty) { heightModel.SetValue(iter, col, value); } else if (col == 0) { DateTime dateval; if (DateTime.TryParse(args.NewText, out dateval)) { heightModel.SetValue(iter, col, value); } } else { double numval; if (Double.TryParse(args.NewText, out numval)) { heightModel.SetValue(iter, col, value); } } if (!String.IsNullOrEmpty(value) && row == heightModel.IterNChildren() - 1) // Entry on the last row? Add a new blank one { heightModel.Append(); } }
public void SetupHeights(DateTime[] dates, double[] heights, double[] NDemands, double[] CanopyWidths, double[] TreeLeafAreas) { while (treeview1.Columns.Length > 0) { TreeViewColumn col = treeview1.GetColumn(0); foreach (CellRenderer render in col.CellRenderers) { if (render is CellRendererText) { CellRendererText textRender = render as CellRendererText; textRender.Edited -= HeightCellEdited; } } treeview1.RemoveColumn(treeview1.GetColumn(0)); } string[] colLabels = new string[] { "Date", "Height (m)", "N Demands (g/m2)", "Canopy Width (m)", "Tree Leaf Area (m2)" }; // Begin by creating a new ListStore with the appropriate number of // columns. Use the string column type for everything. Type[] colTypes = new Type[5]; for (int i = 0; i < 5; i++) { colTypes[i] = typeof(string); CellRendererText textRender = new Gtk.CellRendererText(); textRender.Editable = true; textRender.Edited += HeightCellEdited; textRender.Xalign = i == 0 ? 0.0f : 1.0f; // For right alignment of text cell contents; left align the first column TreeViewColumn column = new TreeViewColumn(colLabels[i], textRender, "text", i); column.Sizing = TreeViewColumnSizing.Autosize; column.Resizable = true; column.Alignment = 0.5f; // For centered alignment of the column header treeview1.AppendColumn(column); } // Add an empty column at the end; auto-sizing will give this any "leftover" space TreeViewColumn fillColumn = new TreeViewColumn(); fillColumn.Sizing = TreeViewColumnSizing.Autosize; treeview1.AppendColumn(fillColumn); heightModel = new ListStore(colTypes); for (int i = 0; i < dates.Count(); i++) { heightModel.AppendValues(dates[i].ToShortDateString(), (heights[i] / 1000).ToString(), NDemands[i].ToString(), CanopyWidths[i].ToString(), TreeLeafAreas[i].ToString()); } // Add an empty row to allow for adding new values heightModel.Append(); treeview1.Model = heightModel; }
void PopulateData() { // performance, would get raised for each new row store.RowChanged -= HandleTreeStoreRowChanged; TreeIter newNode; foreach (var table3D in data.List3D) { // TreeStore: newNode = store.AppendNode (); // ListStore: newNode = store.Append(); SetNodeContent(newNode, table3D); } store.RowChanged += HandleTreeStoreRowChanged; }
public static ListStore PopulateComboBox(ComboBox comboBox, params string[] values) { var cmbStore = new ListStore(typeof(string)); foreach (var text in values) { var iter = cmbStore.Append(); cmbStore.SetValue(iter, 0, text); } comboBox.Model = cmbStore; var cell = new CellRendererText(); cell.Ellipsize = Pango.EllipsizeMode.End; comboBox.PackStart(cell, true); comboBox.AddAttribute(cell, "text", 0); return(cmbStore); }
/// <summary> /// Handles the add button clicked event. /// </summary> /// <param name="sender"> /// A <see cref="System.Object"/> /// </param> /// <param name="a"> /// A <see cref="EventArgs"/> /// </param> private void OnAddBtnClicked(object sender, EventArgs a) { TreeIter iter = symbolLabelsModel.Append(); // We select and scroll to the new row. symbolLabelsTV.Selection.SelectIter(iter); symbolLabelsTV.ScrollToCell(symbolLabelsTV.Selection.GetSelectedRows()[0], symbolLabelsTV.Columns[0], true, 1.0f, 0.0f); TreeIter selected; symbolLabelsTV.Selection.GetSelected(out selected); if (!EditIter(selected)) { // If we pressed the cancel button, we remove the new iter. symbolLabelsModel.Remove(ref iter); } changes = true; }
protected virtual void addFileAssociation(object sender, System.EventArgs e) { bool foundExisting = false; TreeIter newIter = TreeIter.Zero; foreach (TreeIter iter in WalkStore(defaultAssociationsStore)) { if (string.IsNullOrEmpty((string)defaultAssociationsStore.GetValue(iter, COL_EXT))) { foundExisting = true; newIter = iter; } } if (!foundExisting) { newIter = defaultAssociationsStore.Append(); } defaultAssociationsView.SetCursor( defaultAssociationsStore.GetPath(newIter), defaultAssociationsView.GetColumn(COL_EXT), true); }
public override void LaunchDialogue() { //the Type in the collection IList collection = (IList)Value; string displayName = Inspector.DisplayName; //populate list with existing items ListStore itemStore = new ListStore(typeof(object), typeof(int), typeof(string)); for (int i = 0; i < collection.Count; i++) { itemStore.AppendValues(collection [i], i, collection [i].ToString()); } #region Building Dialogue TreeView itemTree; InspectorGrid grid; TreeIter previousIter = TreeIter.Zero; //dialogue and buttons Dialog dialog = new Dialog() { Title = displayName + " Editor", Modal = true, AllowGrow = true, AllowShrink = true, }; var toplevel = this.Container.Toplevel as Window; if (toplevel != null) { dialog.TransientFor = toplevel; } dialog.AddActionWidget(new Button(Stock.Cancel), ResponseType.Cancel); dialog.AddActionWidget(new Button(Stock.Ok), ResponseType.Ok); //three columns for items, sorting, PropGrid HBox hBox = new HBox(); dialog.VBox.PackStart(hBox, true, true, 5); //propGrid at end grid = new InspectorGrid(base.EditorManager) { CurrentObject = null, WidthRequest = 200, ShowHelp = false }; hBox.PackEnd(grid, true, true, 5); //followed by a ButtonBox VBox buttonBox = new VBox(); buttonBox.Spacing = 6; hBox.PackEnd(buttonBox, false, false, 5); //add/remove buttons Button addButton = new Button(new Image(Stock.Add, IconSize.Button)); buttonBox.PackStart(addButton, false, false, 0); if (types [0].IsAbstract) { addButton.Sensitive = false; } Button removeButton = new Button(new Gtk.Image(Stock.Remove, IconSize.Button)); buttonBox.PackStart(removeButton, false, false, 0); //sorting buttons Button upButton = new Button(new Image(Stock.GoUp, IconSize.Button)); buttonBox.PackStart(upButton, false, false, 0); Button downButton = new Button(new Image(Stock.GoDown, IconSize.Button)); buttonBox.PackStart(downButton, false, false, 0); //Third column has list(TreeView) in a ScrolledWindow ScrolledWindow listScroll = new ScrolledWindow(); listScroll.WidthRequest = 200; listScroll.HeightRequest = 320; hBox.PackStart(listScroll, false, false, 5); itemTree = new TreeView(itemStore); itemTree.Selection.Mode = SelectionMode.Single; itemTree.HeadersVisible = false; listScroll.AddWithViewport(itemTree); //renderers and attribs for TreeView CellRenderer rdr = new CellRendererText(); itemTree.AppendColumn(new TreeViewColumn("Index", rdr, "text", 1)); rdr = new CellRendererText(); itemTree.AppendColumn(new TreeViewColumn("Object", rdr, "text", 2)); #endregion #region Events addButton.Clicked += delegate { //create the object object instance = System.Activator.CreateInstance(types[0]); //get existing selection and insert after it TreeIter oldIter, newIter; if (itemTree.Selection.GetSelected(out oldIter)) { newIter = itemStore.InsertAfter(oldIter); } //or append if no previous selection else { newIter = itemStore.Append(); } itemStore.SetValue(newIter, 0, instance); //select, set name and update all the indices itemTree.Selection.SelectIter(newIter); UpdateName(itemStore, newIter); UpdateIndices(itemStore); }; removeButton.Clicked += delegate { //get selected iter and the replacement selection TreeIter iter, newSelection; if (!itemTree.Selection.GetSelected(out iter)) { return; } newSelection = iter; if (!IterPrev(itemStore, ref newSelection)) { newSelection = iter; if (!itemStore.IterNext(ref newSelection)) { newSelection = TreeIter.Zero; } } //new selection. Zeroing previousIter prevents trying to update name of deleted iter. previousIter = TreeIter.Zero; if (itemStore.IterIsValid(newSelection)) { itemTree.Selection.SelectIter(newSelection); } //and the removal and index update itemStore.Remove(ref iter); UpdateIndices(itemStore); }; upButton.Clicked += delegate { TreeIter iter, prev; if (!itemTree.Selection.GetSelected(out iter)) { return; } //get previous iter prev = iter; if (!IterPrev(itemStore, ref prev)) { return; } //swap the two itemStore.Swap(iter, prev); //swap indices too object prevVal = itemStore.GetValue(prev, 1); object iterVal = itemStore.GetValue(iter, 1); itemStore.SetValue(prev, 1, iterVal); itemStore.SetValue(iter, 1, prevVal); }; downButton.Clicked += delegate { TreeIter iter, next; if (!itemTree.Selection.GetSelected(out iter)) { return; } //get next iter next = iter; if (!itemStore.IterNext(ref next)) { return; } //swap the two itemStore.Swap(iter, next); //swap indices too object nextVal = itemStore.GetValue(next, 1); object iterVal = itemStore.GetValue(iter, 1); itemStore.SetValue(next, 1, iterVal); itemStore.SetValue(iter, 1, nextVal); }; itemTree.Selection.Changed += delegate { TreeIter iter; if (!itemTree.Selection.GetSelected(out iter)) { removeButton.Sensitive = false; return; } removeButton.Sensitive = true; //update grid object obj = itemStore.GetValue(iter, 0); grid.CurrentObject = obj; //update previously selected iter's name UpdateName(itemStore, previousIter); //update current selection so we can update //name next selection change previousIter = iter; }; grid.Changed += delegate { TreeIter iter; if (itemTree.Selection.GetSelected(out iter)) { UpdateName(itemStore, iter); } }; TreeIter selectionIter; removeButton.Sensitive = itemTree.Selection.GetSelected(out selectionIter); dialog.ShowAll(); grid.ShowToolbar = false; #endregion //if 'OK' put items back in collection if (GtkExtensions.ShowCustomDialog(dialog, toplevel) == (int)ResponseType.Ok) { DesignerTransaction tran = CreateTransaction(Instance); object old = collection; try { collection.Clear(); foreach (object[] o in itemStore) { collection.Add(o[0]); } EndTransaction(Instance, tran, old, collection, true); } catch { EndTransaction(Instance, tran, old, collection, false); throw; } } }
/// <summary> /// Populate the grid from the DataSource. /// Note that we don't statically set the contents of the grid cells, but rather do this /// dynamically in OnSetCellData. However, we do set up appropriate attributes for /// cell columns, and a set of cell renderers. /// </summary> private void PopulateGrid() { // WaitCursor = true; // Set the cursor directly rather than via the WaitCursor property, as the property setter // runs a message loop. This is normally desirable, but in this case, we have lots // of events associated with the grid data, and it's best to let them be handled in the // main message loop. if (mainWindow != null) { mainWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Watch); } ClearGridColumns(); fixedcolview.Visible = false; colLookup.Clear(); // Begin by creating a new ListStore with the appropriate number of // columns. Use the string column type for everything. int nCols = DataSource != null ? this.DataSource.Columns.Count : 0; Type[] colTypes = new Type[nCols]; for (int i = 0; i < nCols; i++) { colTypes[i] = typeof(string); } gridmodel = new ListStore(colTypes); gridview.ModifyBase(StateType.Active, fixedcolview.Style.Base(StateType.Selected)); gridview.ModifyText(StateType.Active, fixedcolview.Style.Text(StateType.Selected)); fixedcolview.ModifyBase(StateType.Active, gridview.Style.Base(StateType.Selected)); fixedcolview.ModifyText(StateType.Active, gridview.Style.Text(StateType.Selected)); image1.Visible = false; // Now set up the grid columns for (int i = 0; i < nCols; i++) { /// Design plan: include renderers for text, toggles and combos, but hide all but one of them CellRendererText textRender = new Gtk.CellRendererText(); CellRendererPixbuf pixbufRender = new CellRendererPixbuf(); pixbufRender.Pixbuf = new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Save.png"); pixbufRender.Xalign = 0.5f; if (i == 0) { colLookup.Add(textRender, i); } else { colLookup.Add(pixbufRender, i); } textRender.FixedHeightFromFont = 1; // 1 line high pixbufRender.Height = 23; textRender.Editable = !isReadOnly; textRender.Xalign = ((i == 0) || (i == 1) && isPropertyMode) ? 0.0f : 1.0f; // For right alignment of text cell contents; left align the first column TreeViewColumn column = new TreeViewColumn(); column.Title = this.DataSource.Columns[i].Caption; if (i == 0) { column.PackStart(textRender, true); // 0 } else { column.PackStart(pixbufRender, false); // 3 } column.Sizing = TreeViewColumnSizing.Autosize; column.Resizable = true; if (i == 0) { column.SetCellDataFunc(textRender, OnSetCellData); } else { column.SetCellDataFunc(pixbufRender, RenderActivityStatus); } if (i == 1 && isPropertyMode) { column.Alignment = 0.0f; } else { column.Alignment = 0.5f; // For centered alignment of the column header } gridview.AppendColumn(column); // Gtk Treeview doesn't support "frozen" columns, so we fake it by creating a second, identical, TreeView to display // the columns we want frozen // For now, these frozen columns will be treated as read-only text TreeViewColumn fixedColumn = new TreeViewColumn(this.DataSource.Columns[i].ColumnName, textRender, "text", i); fixedColumn.Sizing = TreeViewColumnSizing.Autosize; fixedColumn.Resizable = true; fixedColumn.SetCellDataFunc(textRender, OnSetCellData); fixedColumn.Alignment = 0.5f; // For centered alignment of the column header fixedColumn.Visible = false; fixedcolview.AppendColumn(fixedColumn); } if (!isPropertyMode) { // Add an empty column at the end; auto-sizing will give this any "leftover" space TreeViewColumn fillColumn = new TreeViewColumn(); gridview.AppendColumn(fillColumn); fillColumn.Sizing = TreeViewColumnSizing.Autosize; } int nRows = DataSource != null ? this.DataSource.Rows.Count : 0; gridview.Model = null; fixedcolview.Model = null; for (int row = 0; row < nRows; row++) { // We could store data into the grid model, but we don't. // Instead, we retrieve the data from our datastore when the OnSetCellData function is called gridmodel.Append(); } gridview.Model = gridmodel; SetColumnHeaders(gridview); SetColumnHeaders(fixedcolview); gridview.EnableSearch = false; fixedcolview.EnableSearch = false; gridview.Show(); if (mainWindow != null) { mainWindow.Cursor = null; } }
private void RecentTrades_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { var coll = sender as ICollection <PublicTrade>; var tmax = viewModel.TradesMaxItemCount; switch (e.Action) { case NotifyCollectionChangedAction.Add: Debug.Assert(e.NewItems.Count == 1); Debug.Assert(e.NewStartingIndex == 0); Debug.Print($"PublicTrades: Added {e.NewItems.Count} items."); Gtk.Application.Invoke(delegate { if (count < tmax) { store.Append(); count += 1; } // [count-1] point to latest item! we need to copy [count-2] to [count-1]. TreeIter iter, slctIter = GetSelection(); for (int ind = count - 1; ind > 0; ind -= 1) { store.GetIterFromString(out iter, (ind - 1).ToString()); var value = store.GetValue(iter, 0); store.GetIterFromString(out iter, ind.ToString()); store.SetValue(iter, 0, value); } store.GetIterFirst(out iter); store.SetValue(iter, 0, e.NewItems[0]); // try restore selection. if (!slctIter.Equals(TreeIter.Zero)) { if (store.IterNext(ref slctIter)) { nodeview1.Selection.SelectIter(slctIter); } else { nodeview1.Selection.UnselectAll(); } } }); break; case NotifyCollectionChangedAction.Move: break; case NotifyCollectionChangedAction.Remove: Debug.Print($"PublicTrades: Removed {e.OldItems.Count} items."); //Gtk.Application.Invoke(delegate { //TreeIter iter; // store.GetIterFirst(out iter); // for (int i = 0; i < e.OldStartingIndex; ++i) // store.IterNext(ref iter); // for (int i = 0; i < e.OldItems.Count; ++i) // { // //store.Remove(ref iter); // store.IterNext(ref iter); // } ////nodeview1.ScrollToPoint(0, 0); //}); break; case NotifyCollectionChangedAction.Replace: break; case NotifyCollectionChangedAction.Reset: Debug.Print($"PublicTrades: Reset. {coll.Count} items."); Gtk.Application.Invoke(delegate { store.Clear(); count = 0; foreach (var item in coll.ToList()) { store.AppendValues(item); count += 1; } }); break; } }
public TreeIter NewRow() { return(store.Append()); }