|
using System.Collections;
using System.Windows.Forms;
using System.Collections.Generic;
using Microsoft.VisualStudio.DebuggerVisualizers;
using VisualizerLib;
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(DictionaryVisualizer.DebuggerSide),
typeof(VisualizerObjectSource),
Target = typeof(Dictionary<,>),
Description = "Dictionary Visualizer")]
namespace DictionaryVisualizer
{
public class DebuggerSide : DialogDebuggerVisualizer
{
#region Visualizer Logic
private DictionaryProcessor dictionaryProcessor;
override protected void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
// Initialize datagrid and form
InitializeComponent();
try
{
// Get the dictionary
IDictionary dict = (IDictionary)objectProvider.GetObject();
// Get the keys in the grid view
dictionaryProcessor = new DictionaryProcessor(dict);
dictionaryProcessor.CreateKeyList();
dictionaryProcessor.GetDictionary(true, null, dgvKeys);
// Get the first element value
dgvKeys_CellClick(null, new DataGridViewCellEventArgs(0, 0));
}
catch { }
// Show the grid with the list
windowService.ShowDialog(form);
}
private void dgvKeys_CellClick(object sender, DataGridViewCellEventArgs e)
{
// Get the value in the grid view
if (dictionaryProcessor.KeyList.Count > 0 && e.RowIndex >= 0 &&
e.RowIndex < dictionaryProcessor.KeyList.Count)
{
dgvValues.Columns.Clear();
object key = dictionaryProcessor.KeyList[e.RowIndex];
dictionaryProcessor.GetDictionary(false, key, dgvValues);
}
}
#endregion
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgvKeys = new System.Windows.Forms.DataGridView();
this.dgvValues = new System.Windows.Forms.DataGridView();
this.lblValues = new System.Windows.Forms.Label();
this.lblKeys = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dgvKeys)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgvValues)).BeginInit();
//
// dgvKeys
//
this.dgvKeys.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvKeys.Location = new System.Drawing.Point(12, 21);
this.dgvKeys.Name = "dgvKeys";
this.dgvKeys.Size = new System.Drawing.Size(503, 158);
this.dgvKeys.TabIndex = 0;
this.dgvKeys.ReadOnly = true;
this.dgvKeys.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvKeys_CellClick);
//
// dgvValues
//
this.dgvValues.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvValues.Location = new System.Drawing.Point(12, 205);
this.dgvValues.Name = "dgvValues";
this.dgvValues.Size = new System.Drawing.Size(503, 158);
this.dgvValues.TabIndex = 1;
this.dgvValues.ReadOnly = true;
//
// lblValues
//
this.lblValues.AutoSize = true;
this.lblValues.Location = new System.Drawing.Point(13, 186);
this.lblValues.Name = "lblValues";
this.lblValues.Size = new System.Drawing.Size(42, 13);
this.lblValues.TabIndex = 2;
this.lblValues.Text = "Values:";
//
// lblKeys
//
this.lblKeys.AutoSize = true;
this.lblKeys.Location = new System.Drawing.Point(13, 2);
this.lblKeys.Name = "lblKeys";
this.lblKeys.Size = new System.Drawing.Size(33, 13);
this.lblKeys.TabIndex = 3;
this.lblKeys.Text = "Keys:";
//
// frmDictionaryVisualizer
//
form = new Form();
form.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
form.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
form.ClientSize = new System.Drawing.Size(531, 375);
form.Controls.Add(this.lblKeys);
form.Controls.Add(this.lblValues);
form.Controls.Add(this.dgvValues);
form.Controls.Add(this.dgvKeys);
form.Name = "frmDictionaryVisualizer";
form.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
form.Text = "Dictionary Visualizer";
form.FormBorderStyle = FormBorderStyle.FixedToolWindow;
((System.ComponentModel.ISupportInitialize)(this.dgvKeys)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgvValues)).EndInit();
form.ResumeLayout(false);
form.PerformLayout();
}
private System.Windows.Forms.Form form;
private System.Windows.Forms.DataGridView dgvKeys;
private System.Windows.Forms.DataGridView dgvValues;
private System.Windows.Forms.Label lblValues;
private System.Windows.Forms.Label lblKeys;
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I started development 37 years from now, since MSX basic. Started Windows programming with VB 2.0 and Web programming with ASP 3.0. Then I built Windows Forms, Web Applications, NT services and WPF applications using Microsoft.NET. I am MCP in Visual Basic 6.0, MCAD and MCSD.NET in Framework 1.1, MCPD Web in Framework 2.0, MCTS in .NET 3.5 workflow, MCTS in .NET 3.5 communication foundation, windows presentation foundation and MVC applications. Built MVC Web Application and WCF services using Micro Services architecture proposed by me. Working with AI projects to improve the business performance and customer experience. Besides programming I love running, swimming, reading and movies.