////////////////////////////////
///Form1.cs - version 0.01412006.0rc4
///BY DOWNLOADING AND USING, YOU AGREE TO THE FOLLOWING TERMS:
///Copyright (c) 2006 by Joseph P. Socoloski III
///LICENSE
///If it is your intent to use this software for non-commercial purposes,
///such as in academic research, this software is free and is covered under
///the GNU GPL License, given here: <http://www.gnu.org/licenses/gpl.txt>
///
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using ConceptNetUtils;
namespace ConceptNet_Demo_App
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItemFile;
private System.Windows.Forms.MenuItem menuItemView;
private System.Windows.Forms.MenuItem menuItemHelp;
private System.Windows.Forms.MenuItem menuItemAbout;
private System.Windows.Forms.MenuItem menuItemToolbar;
private System.Windows.Forms.MenuItem menuItemStatusbar;
private System.Windows.Forms.MenuItem menuItemClose;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;
private System.Windows.Forms.StatusBarPanel statusBarPanel3;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ToolBarButton toolBarButtonClose;
private System.Windows.Forms.ToolBarButton toolBarButtonAbout;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox tbWord;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox cbRelationshipTypes;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox tbMAXResults;
private System.Windows.Forms.CheckBox blCreateOutputFile;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox txtOut;
private System.Windows.Forms.Button btSearch;
private System.Windows.Forms.ToolBarButton tlbFileOptions;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.ComponentModel.IContainer components;
//create an imagelist
private System.Windows.Forms.ImageList _imageList;
protected ImageList imageList1;
////for ConceptNet Demo App////
string TextOutputFilename = "defaultname";
//Initialize ConceptNetUtils
ConceptNetUtils.Search CNSearch = new ConceptNetUtils.Search();
ConceptNetUtils.FoundList CNFoundList = new ConceptNetUtils.FoundList();
ConceptNetUtils.Misc CNMisc = new ConceptNetUtils.Misc();
private System.Windows.Forms.Button btSortbyf;
private System.Windows.Forms.Button btSortbyi;
ArrayList ALFoundList = new ArrayList();
public Form1()
{
//
// 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.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this._imageList = new System.Windows.Forms.ImageList(this.components);
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItemFile = new System.Windows.Forms.MenuItem();
this.menuItemClose = new System.Windows.Forms.MenuItem();
this.menuItemView = new System.Windows.Forms.MenuItem();
this.menuItemToolbar = new System.Windows.Forms.MenuItem();
this.menuItemStatusbar = new System.Windows.Forms.MenuItem();
this.menuItemHelp = new System.Windows.Forms.MenuItem();
this.menuItemAbout = new System.Windows.Forms.MenuItem();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.tlbFileOptions = new System.Windows.Forms.ToolBarButton();
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonClose = new System.Windows.Forms.ToolBarButton();
this.toolBarButtonAbout = new System.Windows.Forms.ToolBarButton();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
this.label1 = new System.Windows.Forms.Label();
this.tbWord = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.cbRelationshipTypes = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.tbMAXResults = new System.Windows.Forms.TextBox();
this.blCreateOutputFile = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtOut = new System.Windows.Forms.TextBox();
this.btSearch = new System.Windows.Forms.Button();
this.btSortbyf = new System.Windows.Forms.Button();
this.btSortbyi = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// _imageList
//
this._imageList.ImageSize = new System.Drawing.Size(20, 20);
this._imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("_imageList.ImageStream")));
this._imageList.TransparentColor = System.Drawing.Color.Transparent;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemFile,
this.menuItemView,
this.menuItemHelp});
//
// menuItemFile
//
this.menuItemFile.Index = 0;
this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemClose});
this.menuItemFile.Text = "&File";
//
// menuItemClose
//
this.menuItemClose.Index = 0;
this.menuItemClose.Text = "&Close";
this.menuItemClose.Click += new System.EventHandler(this.menuItemClose_Click);
//
// menuItemView
//
this.menuItemView.Index = 1;
this.menuItemView.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemToolbar,
this.menuItemStatusbar});
this.menuItemView.Text = "&View";
//
// menuItemToolbar
//
this.menuItemToolbar.Checked = true;
this.menuItemToolbar.Index = 0;
this.menuItemToolbar.Text = "&Toolbar";
this.menuItemToolbar.Click += new System.EventHandler(this.menuItemToolbar_Click);
//
// menuItemStatusbar
//
this.menuItemStatusbar.Checked = true;
this.menuItemStatusbar.Index = 1;
this.menuItemStatusbar.Text = "&Statusbar";
this.menuItemStatusbar.Click += new System.EventHandler(this.menuItemStatusbar_Click);
//
// menuItemHelp
//
this.menuItemHelp.Index = 2;
this.menuItemHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemAbout});
this.menuItemHelp.Text = "&Help";
//
// menuItemAbout
//
this.menuItemAbout.Index = 0;
this.menuItemAbout.Text = "&About";
this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
//
// toolBar1
//
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.tlbFileOptions,
this.toolBarButton1,
this.toolBarButtonClose,
this.toolBarButtonAbout});
this.toolBar1.ButtonSize = new System.Drawing.Size(40, 36);
this.toolBar1.DropDownArrows = true;
this.toolBar1.Font = new System.Drawing.Font("Verdana", 5F);
this.toolBar1.ImageList = this._imageList;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(696, 42);
this.toolBar1.TabIndex = 0;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// tlbFileOptions
//
this.tlbFileOptions.ImageIndex = 0;
this.tlbFileOptions.Text = "Files";
this.tlbFileOptions.ToolTipText = "Point to the predicate files.";
//
// toolBarButton1
//
this.toolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButtonClose
//
this.toolBarButtonClose.ImageIndex = 1;
this.toolBarButtonClose.Text = "Close";
this.toolBarButtonClose.ToolTipText = "Close this application";
//
// toolBarButtonAbout
//
this.toolBarButtonAbout.ImageIndex = 2;
this.toolBarButtonAbout.Text = "About";
this.toolBarButtonAbout.ToolTipText = "About this Application";
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 497);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1,
this.statusBarPanel2,
this.statusBarPanel3});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(696, 16);
this.statusBar1.TabIndex = 1;
this.statusBar1.Text = "statusBar1";
//
// statusBarPanel1
//
this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
this.statusBarPanel1.Width = 480;
//
// label1
//
this.label1.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(16, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(288, 23);
this.label1.TabIndex = 2;
this.label1.Text = "Type Your Subject Here (one word only):";
//
// tbWord
//
this.tbWord.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.tbWord.Location = new System.Drawing.Point(416, 48);
this.tbWord.Name = "tbWord";
this.tbWord.Size = new System.Drawing.Size(264, 23);
this.tbWord.TabIndex = 3;
this.tbWord.Text = "";
this.tbWord.TextChanged += new System.EventHandler(this.tbWord_TextChanged);
this.tbWord.Leave += new System.EventHandler(this.tbWord_Leave);
//
// label2
//
this.label2.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label2.Location = new System.Drawing.Point(16, 88);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(360, 23);
this.label2.TabIndex = 4;
this.label2.Text = "What relationship type do you which to search for?";
//
// cbRelationshipTypes
//
this.cbRelationshipTypes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbRelationshipTypes.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.cbRelationshipTypes.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.cbRelationshipTypes.Items.AddRange(new object[] {
"K-Lines: ConceptuallyRelatedTo",
"K-Lines: ThematicKLine",
"K-Lines: SuperThematicKLine",
"All K-Lines",
"Things: IsA",
"Things: PartOf",
"Things: PropertyOf",
"Things: DefinedAs",
"Things: MadeOf",
"All Things",
"Spatial: LocationOf",
"Events: SubeventOf",
"Events: PrerequisiteEventOf",
"Events: First-SubeventOf",
"Events: LastSubeventOf",
"All Events",
"Causal: EffectOf",
"Causal: DesirousEffectOf",
"All Causal",
"Affective: MotivationOf",
"Affective: DesireOf",
"All Affective",
"Functional: CapableOfReceivingAction",
"Functional: UsedFor",
"All Functional",
"Agents: CapableOf",
"All (Returns all results with word)"});
this.cbRelationshipTypes.Location = new System.Drawing.Point(416, 88);
this.cbRelationshipTypes.Name = "cbRelationshipTypes";
this.cbRelationshipTypes.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cbRelationshipTypes.Size = new System.Drawing.Size(264, 24);
this.cbRelationshipTypes.TabIndex = 5;
this.cbRelationshipTypes.SelectedIndexChanged += new System.EventHandler(this.cbRelationshipTypes_SelectedIndexChanged);
//
// label3
//
this.label3.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label3.Location = new System.Drawing.Point(16, 136);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(384, 23);
this.label3.TabIndex = 6;
this.label3.Text = "Set the Maximum number of results to display (1-999):";
//
// tbMAXResults
//
this.tbMAXResults.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.tbMAXResults.Location = new System.Drawing.Point(416, 136);
this.tbMAXResults.Name = "tbMAXResults";
this.tbMAXResults.Size = new System.Drawing.Size(64, 23);
this.tbMAXResults.TabIndex = 7;
this.tbMAXResults.Text = "50";
//
// blCreateOutputFile
//
this.blCreateOutputFile.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.blCreateOutputFile.Location = new System.Drawing.Point(48, 168);
this.blCreateOutputFile.Name = "blCreateOutputFile";
this.blCreateOutputFile.Size = new System.Drawing.Size(632, 24);
this.blCreateOutputFile.TabIndex = 8;
this.blCreateOutputFile.Text = "Create a text file with results";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btSortbyi);
this.groupBox1.Controls.Add(this.txtOut);
this.groupBox1.Controls.Add(this.btSortbyf);
this.groupBox1.Location = new System.Drawing.Point(8, 240);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(672, 248);
this.groupBox1.TabIndex = 9;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Results...";
//
// txtOut
//
this.txtOut.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.txtOut.Location = new System.Drawing.Point(16, 24);
this.txtOut.MaxLength = 992767;
this.txtOut.Multiline = true;
this.txtOut.Name = "txtOut";
this.txtOut.ReadOnly = true;
this.txtOut.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtOut.Size = new System.Drawing.Size(640, 184);
this.txtOut.TabIndex = 10;
this.txtOut.Text = "";
//
// btSearch
//
this.btSearch.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btSearch.Location = new System.Drawing.Point(311, 208);
this.btSearch.Name = "btSearch";
this.btSearch.TabIndex = 10;
this.btSearch.Text = "Search";
this.btSearch.Click += new System.EventHandler(this.btSearch_Click);
//
// btSortbyf
//
this.btSortbyf.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btSortbyf.Location = new System.Drawing.Point(80, 216);
this.btSortbyf.Name = "btSortbyf";
this.btSortbyf.Size = new System.Drawing.Size(216, 23);
this.btSortbyf.TabIndex = 11;
this.btSortbyf.Text = "Sort by f (# of utterances)";
this.btSortbyf.Click += new System.EventHandler(this.btSortbyf_Click);
//
// btSortbyi
//
this.btSortbyi.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btSortbyi.Location = new System.Drawing.Point(352, 216);
this.btSortbyi.Name = "btSortbyi";
this.btSortbyi.Size = new System.Drawing.Size(240, 23);
this.btSortbyi.TabIndex = 12;
this.btSortbyi.Text = "Sort by i (# of times inferred)";
this.btSortbyi.Click += new System.EventHandler(this.btSortbyi_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(696, 513);
this.Controls.Add(this.btSearch);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.blCreateOutputFile);
this.Controls.Add(this.tbMAXResults);
this.Controls.Add(this.tbWord);
this.Controls.Add(this.label3);
this.Controls.Add(this.cbRelationshipTypes);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.toolBar1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Joe\'s ConceptNet Demo App";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
//Select the first item in the Relationship Types ComboBox DropDownList
cbRelationshipTypes.SelectedIndex = 0;
//Force the FileOptionDialogbox to open and load files
FileOptionsForm frmFileOptions = new FileOptionsForm();
frmFileOptions.ShowDialog(this);
}
private void menuItemClose_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void menuItemAbout_Click(object sender, System.EventArgs e)
{
FormAbout frmAbout = new FormAbout();
frmAbout.ShowDialog(this);
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if(e.Button.Equals(tlbFileOptions))
{
FileOptionsForm frmFileOptionsForm = new FileOptionsForm();
frmFileOptionsForm.ShowDialog(this);
}
if(e.Button.Equals(toolBarButtonClose))
this.Close();
if(e.Button.Equals(toolBarButtonAbout))
{
FormAbout frmAbout = new FormAbout();
frmAbout.ShowDialog(this);
}
}
private void menuItemToolbar_Click(object sender, System.EventArgs e)
{
this.toolBar1.Visible = !(this.toolBar1.Visible);
menuItemToolbar.Checked = this.toolBar1.Visible;
}
private void menuItemStatusbar_Click(object sender, System.EventArgs e)
{
this.statusBar1.Visible = !(this.statusBar1.Visible);
menuItemStatusbar.Checked = this.statusBar1.Visible;
}
/////////////////////////////////////ConceptNet Demo App Methods Below///////////////////////////////////////////
private void btSearch_Click(object sender, System.EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
//Reset txtOut
txtOut.Text = "";
string searchresultstodisplay ="";
string demofolderpath = Application.StartupPath;
//Set/Initialize Predicatefile variables for the class library after loading them from an XML file.
CNSearch.XMLLoadFilePaths(demofolderpath + @"\Settings.xml");
//if there is a word in the Textbox then it's ok to start search...
if(tbWord.Text != "")
{
try
{
//Make sure tbWord.Text is lowercase
tbWord.Text = tbWord.Text.ToLower();
//Reset List(s) to null.
CNSearch.Clear();
CNFoundList.Reset();
ALFoundList.Clear();
//If checked in one of the , Search them...
//Preform Search using ConceptNetUtil Class Library
CNSearch.XMLSearchForChecked(demofolderpath + @"\Settings.xml", tbWord.Text.Trim(), CNMisc.RemoveCategoryString(cbRelationshipTypes.Text), Convert.ToInt32(tbMAXResults.Text), blCreateOutputFile.Checked, demofolderpath + @"\" + TextOutputFilename);
//***Copy the ConceptNetUtils.SearchResultsList.FoundList so not to lose scope***
int numberoflines = CNSearch.GetTotalLineCount();
for(int i = 0; i < numberoflines ; i++)
{
//Copy into a global ArrayList
ALFoundList.Add(CNSearch.GetFoundListLine(i));
//Copy into a global CNFoundList
CNFoundList[i] = CNSearch.GetFoundListLine(i);
}
System.Collections.IEnumerator myEnumerator = ALFoundList.GetEnumerator();
while ( myEnumerator.MoveNext() )
searchresultstodisplay += myEnumerator.Current.ToString() + "\r\n";
//Now display in txtOut
int totalfound = CNSearch.GetTotalLineCount();
searchresultstodisplay += ("---------------------- Done ----------------------\r\n");
searchresultstodisplay += (Convert.ToString(totalfound) + " " + cbRelationshipTypes.Text +" Found.");
txtOut.Text = searchresultstodisplay;
txtOut.Update();
}
catch (Exception ex)
{
//tbWord.Text did not have a subject and/or
//fileandpath may have been incorrect.
MessageBox.Show("Make sure you have a word typed in the inputbox and \r\nMake sure you are pointing to the correct path for ConceptNet.\r\n" + ex.Message);
searchresultstodisplay += "---------------------- Error ----------------------\r\n";
txtOut.Text = searchresultstodisplay;
txtOut.Update();
}
}
else
{
MessageBox.Show("You must type in a word to perform a search.");
}
//Create Text file if checked
if(blCreateOutputFile.Checked)
{
TextOutputFilename = tbWord.Text + "_" + CNMisc.RemoveCategoryString(cbRelationshipTypes.Text) + ".txt";
CNSearch.CreateTextFile(demofolderpath + @"\" + TextOutputFilename);
}
Cursor.Current = Cursors.Default;
}
private void tbWord_TextChanged(object sender, System.EventArgs e)
{
//Create output file name string
TextOutputFilename = tbWord.Text + "_" + CNMisc.RemoveCategoryString(cbRelationshipTypes.Text) + ".txt";
//Update to checkbox text
blCreateOutputFile.Text = "Create a text file with results named: " + tbWord.Text + "_" + CNMisc.RemoveCategoryString(cbRelationshipTypes.Text) + ".txt";
blCreateOutputFile.Update();
}
private void cbRelationshipTypes_SelectedIndexChanged(object sender, System.EventArgs e)
{
cbRelationshipTypes.BeginUpdate();
//If the form just loaded, do not change checkbox Text
if(TextOutputFilename == "defaultname")
{
}
else
{
//Create output file name string
TextOutputFilename = tbWord.Text + "_" + CNMisc.RemoveCategoryString(cbRelationshipTypes.Text) + ".txt";
//Update to checkbox text
blCreateOutputFile.Text = "Create a text file with results named: " + tbWord.Text + "_" + CNMisc.RemoveCategoryString(cbRelationshipTypes.Text) + ".txt";
blCreateOutputFile.Update();
}
cbRelationshipTypes.Update();
cbRelationshipTypes.EndUpdate();
}
private void tbWord_Leave(object sender, System.EventArgs e)
{
//Make sure tbWord.Text is lowercase
tbWord.Text = tbWord.Text.ToLower();
tbWord.Update();
}
private void btSortbyf_Click(object sender, System.EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
//Create ArrayList to hold return sort results
ArrayList Listranked = new ArrayList();
//"Lift" the heaviest relationships to the top of the ArrayList
CNSearch.Sort_f(ALFoundList, out Listranked);
//Overwrite the old ALFoundList with the new ranking
ALFoundList = Listranked;
string searchresultstodisplay = "";
System.Collections.IEnumerator myEnumerator = ALFoundList.GetEnumerator();
while ( myEnumerator.MoveNext() )
searchresultstodisplay += myEnumerator.Current.ToString() + "\r\n";
//Now display in txtOut
searchresultstodisplay += ("---------------------- Done ----------------------\r\n");
searchresultstodisplay += (Convert.ToString(ALFoundList.Count) + " " + cbRelationshipTypes.Text +" Found.");
txtOut.Text = searchresultstodisplay;
txtOut.Update();
Cursor.Current = Cursors.Default;
}
private void btSortbyi_Click(object sender, System.EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
//Create ArrayList to hold return sort results
ArrayList Listranked = new ArrayList();
//"Lift" the heaviest relationships to the top of the ArrayList
CNSearch.Sort_i(ALFoundList, out Listranked);
//Overwrite the old ALFoundList with the new ranking
ALFoundList = Listranked;
string searchresultstodisplay = "";
System.Collections.IEnumerator myEnumerator = ALFoundList.GetEnumerator();
while ( myEnumerator.MoveNext() )
searchresultstodisplay += myEnumerator.Current.ToString() + "\r\n";
//Now display in txtOut
searchresultstodisplay += ("---------------------- Done ----------------------\r\n");
searchresultstodisplay += (Convert.ToString(ALFoundList.Count) + " " + cbRelationshipTypes.Text +" Found.");
txtOut.Text = searchresultstodisplay;
txtOut.Update();
Cursor.Current = Cursors.Default;
}
}
}