Click here to Skip to main content
15,897,226 members
Articles / Programming Languages / C#

Bot Suite

Rate me:
Please Sign up or sign in to vote.
1.35/5 (16 votes)
24 Aug 2008LGPL36 min read 94.4K   877   31  
Bot Suite is a collection of utilities provided to create, schedule and run the chat bots. Bot suite consists of three applications i.e. Bot Studio, Bot Engine & MyMessenger. Bot suite provides the solution for the automated conversation using these applications. We will see their usage here.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using BotSuite.MyWebAssembly;

namespace BotSuite.BotStudio
{
	/// <summary>
	/// Summary description for frmNodesMgr.
	/// </summary>
	public class frmNodesMgr : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ComboBox cboNodes;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button cmdOK;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox txtQ;
		private System.Windows.Forms.CheckBox chkMoveToRoot;
		private System.Windows.Forms.CheckBox chkMoveToBase;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmNodesMgr()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#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.cboNodes = new System.Windows.Forms.ComboBox();
			this.label1 = new System.Windows.Forms.Label();
			this.txtQ = new System.Windows.Forms.TextBox();
			this.cmdOK = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.chkMoveToRoot = new System.Windows.Forms.CheckBox();
			this.chkMoveToBase = new System.Windows.Forms.CheckBox();
			this.SuspendLayout();
			// 
			// cboNodes
			// 
			this.cboNodes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.cboNodes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboNodes.Location = new System.Drawing.Point(56, 40);
			this.cboNodes.Name = "cboNodes";
			this.cboNodes.Size = new System.Drawing.Size(349, 21);
			this.cboNodes.Sorted = true;
			this.cboNodes.TabIndex = 0;
			this.cboNodes.SelectedIndexChanged += new System.EventHandler(this.cboNodes_SelectedIndexChanged);
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label1.Location = new System.Drawing.Point(8, 45);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(48, 16);
			this.label1.TabIndex = 1;
			this.label1.Text = "Nodes";
			// 
			// txtQ
			// 
			this.txtQ.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.txtQ.Location = new System.Drawing.Point(8, 96);
			this.txtQ.Multiline = true;
			this.txtQ.Name = "txtQ";
			this.txtQ.Size = new System.Drawing.Size(397, 240);
			this.txtQ.TabIndex = 2;
			this.txtQ.Text = "txtQ";
			this.txtQ.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
			// 
			// cmdOK
			// 
			this.cmdOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
			this.cmdOK.Location = new System.Drawing.Point(168, 408);
			this.cmdOK.Name = "cmdOK";
			this.cmdOK.Size = new System.Drawing.Size(80, 23);
			this.cmdOK.TabIndex = 3;
			this.cmdOK.Text = "&OK";
			this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
			// 
			// label2
			// 
			this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label2.Location = new System.Drawing.Point(96, 8);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(104, 16);
			this.label2.TabIndex = 4;
			this.label2.Text = "Nodes Manager";
			// 
			// label3
			// 
			this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label3.Location = new System.Drawing.Point(8, 72);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(48, 16);
			this.label3.TabIndex = 5;
			this.label3.Text = "Text";
			// 
			// chkMoveToRoot
			// 
			this.chkMoveToRoot.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.chkMoveToRoot.Location = new System.Drawing.Point(8, 370);
			this.chkMoveToRoot.Name = "chkMoveToRoot";
			this.chkMoveToRoot.Size = new System.Drawing.Size(397, 19);
			this.chkMoveToRoot.TabIndex = 6;
			this.chkMoveToRoot.Text = "Move to Next Node if a response matches";
			this.chkMoveToRoot.CheckedChanged += new System.EventHandler(this.chkMoveToRoot_CheckedChanged);
			// 
			// chkMoveToBase
			// 
			this.chkMoveToBase.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.chkMoveToBase.Location = new System.Drawing.Point(8, 349);
			this.chkMoveToBase.Name = "chkMoveToBase";
			this.chkMoveToBase.Size = new System.Drawing.Size(397, 16);
			this.chkMoveToBase.TabIndex = 7;
			this.chkMoveToBase.Text = "Move To Base Node if no response matches";
			this.chkMoveToBase.CheckedChanged += new System.EventHandler(this.chkMoveToBase_CheckedChanged);
			// 
			// frmNodesMgr
			// 
			this.AcceptButton = this.cmdOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
			this.ClientSize = new System.Drawing.Size(417, 447);
			this.Controls.Add(this.chkMoveToBase);
			this.Controls.Add(this.chkMoveToRoot);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.cmdOK);
			this.Controls.Add(this.txtQ);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.cboNodes);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "frmNodesMgr";
			this.ShowInTaskbar = false;
			this.Text = "Nodes Manager";
			this.Load += new System.EventHandler(this.frmNodesMgr_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmNodesMgr_Load(object sender, System.EventArgs e)
		{
			IDictionaryEnumerator ide = DataSource.Nodes.GetEnumerator();
			while(ide.MoveNext())
			{
				cboNodes.Items.Add(ide.Key.ToString());
			}
			if(cboNodes.Items.Count > 0)
				cboNodes.SelectedIndex = 0;
		}

		private void cboNodes_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(cboNodes.SelectedItem != null)
			{
				CtlNode node = (CtlNode)DataSource.Nodes[cboNodes.SelectedItem];
				txtQ.Text = node.Question ;
				chkMoveToRoot.Checked = node.MoveToRoot; 
				chkMoveToBase.Checked = node.MoveToBase;
			}
		}

		private void textBox1_TextChanged(object sender, System.EventArgs e)
		{
			if(cboNodes.SelectedItem != null)
			{
				CtlNode node = (CtlNode)DataSource.Nodes[cboNodes.SelectedItem];
				node.Question = txtQ.Text;
			}

		}

		private void cmdOK_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void chkMoveToBase_CheckedChanged(object sender, System.EventArgs e)
		{
			if(cboNodes.SelectedItem != null)
			{
				CtlNode node = (CtlNode)DataSource.Nodes[cboNodes.SelectedItem];
				node.MoveToBase = chkMoveToBase.Checked;
			}
		}

		private void chkMoveToRoot_CheckedChanged(object sender, System.EventArgs e)
		{
			if(cboNodes.SelectedItem != null)
			{
				CtlNode node = (CtlNode)DataSource.Nodes[cboNodes.SelectedItem];
				node.MoveToRoot = chkMoveToRoot.Checked;
			}
		}
	}
}

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 Lesser General Public License (LGPLv3)


Written By
Web Developer
Pakistan Pakistan
Mansoor Sarfraz works in a well reputed multinational software development company. Software development is not only his duty but his passion too. In his professional career he was Involved in the development of resource/content management system, workflow based systems, enterprise projects based on MS Windows DNA architecture and .NET framework, web based rich client UI development, Rest based backend web services and windows services for different systems. He was also involved in software designing and architecture. He has expertise in C#.NET, ASP.NET, Sql Server, Adobe Flex, Java, Ajax and JavaScript.

You can reach him through his blog
http://mansoorsarfraz.blogspot.com

Comments and Discussions