Click here to Skip to main content
15,880,392 members
Articles / Programming Languages / Forth.NET

DocMounter 2: A tool to build VS.NET documentation (now with Sandcastle)

,
Rate me:
Please Sign up or sign in to vote.
4.94/5 (29 votes)
15 Nov 2010GPL314 min read 138.2K   1.4K   99  
Tool for creating MS Visual Studio documentation files - XML Summaries, HxS/MSHC help solutions and manuals.
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace TenTec.Utils
{
	internal class ControlTagList : System.Windows.Forms.UserControl
	{
		#region Designer Fields

		private System.Windows.Forms.Button fButtonAdd;
		private System.Windows.Forms.Label fLabelItemText;
		private TreeView fTreeViewItems;
		private TextBox fTextBoxItemText;
		private Label fLabelItems;
		private System.Windows.Forms.Button fButtonRemove;
		#endregion

		#region Component Designer generated code
		private void InitializeComponent()
		{
			this.fTreeViewItems = new System.Windows.Forms.TreeView();
			this.fButtonAdd = new System.Windows.Forms.Button();
			this.fLabelItemText = new System.Windows.Forms.Label();
			this.fButtonRemove = new System.Windows.Forms.Button();
			this.fTextBoxItemText = new System.Windows.Forms.TextBox();
			this.fLabelItems = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// fTreeViewItems
			// 
			this.fTreeViewItems.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
									| System.Windows.Forms.AnchorStyles.Left)
									| System.Windows.Forms.AnchorStyles.Right)));
			this.fTreeViewItems.FullRowSelect = true;
			this.fTreeViewItems.HideSelection = false;
			this.fTreeViewItems.Location = new System.Drawing.Point(0, 30);
			this.fTreeViewItems.Name = "fTreeViewItems";
			this.fTreeViewItems.ShowLines = false;
			this.fTreeViewItems.ShowPlusMinus = false;
			this.fTreeViewItems.Size = new System.Drawing.Size(336, 197);
			this.fTreeViewItems.TabIndex = 0;
			this.fTreeViewItems.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.fTreeViewItems_AfterSelect);
			// 
			// fButtonAdd
			// 
			this.fButtonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.fButtonAdd.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.fButtonAdd.Location = new System.Drawing.Point(168, 0);
			this.fButtonAdd.Name = "fButtonAdd";
			this.fButtonAdd.Size = new System.Drawing.Size(81, 24);
			this.fButtonAdd.TabIndex = 3;
			this.fButtonAdd.Text = "Add";
			this.fButtonAdd.Click += new System.EventHandler(this.fButtonAdd_Click);
			// 
			// fLabelItemText
			// 
			this.fLabelItemText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.fLabelItemText.AutoSize = true;
			this.fLabelItemText.Location = new System.Drawing.Point(3, 240);
			this.fLabelItemText.Name = "fLabelItemText";
			this.fLabelItemText.Size = new System.Drawing.Size(64, 16);
			this.fLabelItemText.TabIndex = 1;
			this.fLabelItemText.Text = "Item text:";
			// 
			// fButtonRemove
			// 
			this.fButtonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.fButtonRemove.Enabled = false;
			this.fButtonRemove.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.fButtonRemove.Location = new System.Drawing.Point(255, 0);
			this.fButtonRemove.Name = "fButtonRemove";
			this.fButtonRemove.Size = new System.Drawing.Size(81, 24);
			this.fButtonRemove.TabIndex = 4;
			this.fButtonRemove.Text = "Remove";
			this.fButtonRemove.Click += new System.EventHandler(this.fButtonRemove_Click);
			// 
			// fTextBoxItemText
			// 
			this.fTextBoxItemText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
									| System.Windows.Forms.AnchorStyles.Right)));
			this.fTextBoxItemText.Enabled = false;
			this.fTextBoxItemText.Location = new System.Drawing.Point(0, 259);
			this.fTextBoxItemText.Multiline = true;
			this.fTextBoxItemText.Name = "fTextBoxItemText";
			this.fTextBoxItemText.Size = new System.Drawing.Size(336, 69);
			this.fTextBoxItemText.TabIndex = 0;
			// 
			// fLabelItems
			// 
			this.fLabelItems.AutoSize = true;
			this.fLabelItems.Location = new System.Drawing.Point(3, 4);
			this.fLabelItems.Name = "fLabelItems";
			this.fLabelItems.Size = new System.Drawing.Size(45, 16);
			this.fLabelItems.TabIndex = 5;
			this.fLabelItems.Text = "Items:";
			// 
			// ControlTagList
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
			this.Controls.Add(this.fLabelItems);
			this.Controls.Add(this.fTextBoxItemText);
			this.Controls.Add(this.fButtonAdd);
			this.Controls.Add(this.fTreeViewItems);
			this.Controls.Add(this.fButtonRemove);
			this.Controls.Add(this.fLabelItemText);
			this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
			this.Name = "ControlTagList";
			this.Size = new System.Drawing.Size(336, 328);
			this.ResumeLayout(false);
			this.PerformLayout();

		}
		#endregion

		#region Common
		public ControlTagList()
		{
			InitializeComponent();
		}
		public void Clear()
		{
			ClearItems();
		}
		#endregion

		#region TreeViewItems

		#region Fields
		private int fOldSelectedIndex = -1;
		private bool fLockSelectedIndexChanged = false;
		#endregion

		#region Methods
		private void SaveItem()
		{
			if(fOldSelectedIndex < 0)
				return;
			fLockSelectedIndexChanged = true;
			try
			{
				fTreeViewItems.Nodes[fOldSelectedIndex].Text = fTextBoxItemText.Text;
			}
			finally
			{
				fLockSelectedIndexChanged = false;
			}
		}
		private void OnSelectedIndexChanged()
		{
			if(fLockSelectedIndexChanged)
				return;
			SaveItem();
			if(fTreeViewItems.SelectedNode != null)
			{
				fButtonRemove.Enabled = true;
				fTextBoxItemText.Enabled = true;
				fTextBoxItemText.Text = fTreeViewItems.SelectedNode.Text as string;
			}
			else
			{
				fButtonRemove.Enabled = false;
				fTextBoxItemText.Enabled = false;
				fTextBoxItemText.Text = string.Empty;
			}
			if (fTreeViewItems.SelectedNode == null)
				fOldSelectedIndex = -1;
			else
				fOldSelectedIndex = fTreeViewItems.SelectedNode.Index;
		}
		private void fTreeViewItems_AfterSelect(object sender, TreeViewEventArgs e)
		{
			OnSelectedIndexChanged();
		}
		private void AddItem()
		{
			TreeNode myNode = fTreeViewItems.Nodes.Add("NewItem");
			fTreeViewItems.SelectedNode = myNode;
			OnItemCountChanged();
		}
		private void RemoveItem()
		{
			if (fTreeViewItems.SelectedNode == null)
				return;
			fOldSelectedIndex = -1;
			int mySelectedIntex = fTreeViewItems.SelectedNode.Index;
			if(mySelectedIntex >= 0)
			{
				fTreeViewItems.Nodes.RemoveAt(mySelectedIntex);
				if(fTreeViewItems.Nodes.Count > mySelectedIntex)
					fTreeViewItems.SelectedNode = fTreeViewItems.Nodes[mySelectedIntex];
				else if(fTreeViewItems.Nodes.Count > 0)
					fTreeViewItems.SelectedNode = fTreeViewItems.Nodes[fTreeViewItems.Nodes.Count-1];
				OnSelectedIndexChanged();
			}
			OnItemCountChanged();
		}
		private void ClearItems()
		{
			fOldSelectedIndex = -1;
			fTreeViewItems.Nodes.Clear();
			OnSelectedIndexChanged();
			OnItemCountChanged();
		}
		private void OnItemCountChanged()
		{
			if(ItemCountChanged != null)
				ItemCountChanged(this, EventArgs.Empty);
		}
		#endregion

		#endregion

		#region Buttons' Handlers
		private void fButtonAdd_Click(object sender, System.EventArgs e)
		{
			AddItem();
		}
		private void fButtonRemove_Click(object sender, System.EventArgs e)
		{
			RemoveItem();
		}
		#endregion

		#region Public Properties
		public string[] Items
		{
			get
			{
				SaveItem();
				string[] Items = new string[fTreeViewItems.Nodes.Count];
				for(int myIndex = 0; myIndex < fTreeViewItems.Nodes.Count; myIndex++)
					Items[myIndex] = fTreeViewItems.Nodes[myIndex].Text;
				return Items;
			}
		}
		public int ItemCount
		{
			get
			{
				return fTreeViewItems.Nodes.Count;
			}
		}
		#endregion

		#region Events
		public event EventHandler ItemCountChanged;
		#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.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Ukraine Ukraine
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This is a Organisation

2 members

Comments and Discussions