public BlockListViewModel() { this.Owner = Owner; if (Owner != null) { groupLevel = Owner.groupLevel + 1; } UpdateBrushes(); Clear(); }
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (Owner != null && Owner.listBlocks.SelectedItems.Count > 1 && ParentGroup != null) { Owner.listBlocks.SelectedItem = ParentGroup.BlockItem; } bool groupOpen = false; if (listBlocks.SelectedItems.Count == 1) { IBlock block = (IBlock)((ListBoxItem)listBlocks.SelectedItem).Tag; if (block is IBlockGroup) { if (GroupList == null) { GroupList = new BlockList(this); ccGroupList.Content = GroupList; } GroupList.ParentGroup = (IBlockGroup)block; bdrBar.Background = SelectedBrush; BlockList owner = Owner; while (owner != null) { owner.bdrBar.Background = UnselectedBrush; owner = owner.Owner; } SplitterOpen = true; groupOpen = true; } } if (!groupOpen && GroupList != null) { GroupList.ParentGroup = null; bdrBar.Background = UnselectedBrush; if (Owner != null) { Owner.bdrBar.Background = SelectedBrush; } } if (SelectionChanged != null) { SelectionChanged(this, new EventArgs()); } }
public void Select(IBlock block) { // Push block groups on the stack up to the root: Stack <IBlockGroup> groupStack = new Stack <IBlockGroup>(); IBlockGroup group = block.BlockGroup; while (group != null) { groupStack.Push(group); group = group.BlockGroup; } // Pop block groups off the stack and open them: ListBoxItem item; BlockListView bl = this.GetView() as MyView; while (groupStack.Count > 0) { group = groupStack.Pop(); item = group.BlockItem; if (bl.listBlocks.Items.Contains(item)) { if (!bl.SplitterOpen && bl.listBlocks.SelectedItem == item) { bl.listBlocks.SelectedItem = null; } bl.listBlocks.SelectedItem = item; bl.listBlocks.ScrollIntoView(item); } bl = bl.GroupList; } // Select the item: item = block.BlockItem; if (bl != null && bl.listBlocks.Items.Contains(item)) { bl.listBlocks.SelectedItem = item; bl.listBlocks.ScrollIntoView(item); if (bl.GroupList != null) { bl.GroupList.listBlocks.UnselectAll(); } } }
private bool ViewBlockList(int offset) { DataTable dt; using (var sqlc = new MySqlClient(SiaClassicLib.Config.ConnectionString)) { dt = sqlc.FillTable($"SELECT height,timestamp,minerpayouts,tx_count FROM blocks ORDER BY height DESC LIMIT {offset},20"); } if (dt.Rows.Count == 0) { return(false); } dt.AddTimeColumn("time", "timestamp"); BlockListPanel.Visible = true; BlockListView.DataSource = dt; BlockListView.DataBind(); BlockListOffsetLabel.Text = offset.ToString(); return(true); }