/// <summary> /// This method builts a new crozzle after reading the files from the given destination. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void getCrozzleBTN_Click(object sender, EventArgs e) { crozzle = new CrozzleGrid(addressesCB.Text); try { crozzle.ReadCrozzle(); MyTimer = new System.Timers.Timer(crozzle.Config.RUNTIME_LIMIT * 1000); MyTimer.Elapsed += MyTimer_Elasped; MyTimer.Start(); while (MyTimer.Enabled) { crozzle.Fill(); } string endpoint = "BasicHttpBinding_IWordGroupService"; WordGroupServiceClient ws = new WordGroupServiceClient(endpoint); int NumberOfGroups = ws.Count(crozzle.GetGrid()); if (NumberOfGroups >= crozzle.Config.MINIMUM_NUMBER_OF_GROUPS && NumberOfGroups <= crozzle.Config.MAXIMUM_NUMBER_OF_GROUPS) { string result = crozzle.GetHtmlTable(); int score = crozzle.CalculateScore(); result += "<br/><div><p><b> Score = " + score + "</b></p></div>"; webBrowser1.Navigate("about:blank"); HtmlDocument doc = webBrowser1.Document; doc.Write(String.Empty); webBrowser1.DocumentText = result; } else { MessageBox.Show("Crozzle cannot be formed because valid number of groups were not formed"); string result = crozzle.GetHtmlTable(); result += "<br/><div><p><b> Invalid Crozzle is Generated !</b></p></div>"; webBrowser1.Navigate("about:blank"); HtmlDocument doc = webBrowser1.Document; doc.Write(String.Empty); webBrowser1.DocumentText = result; } } catch (Exception) { MessageBox.Show("Network Failure: Cannot Read Crozzle Configurations from the given address!"); } }
private void button2_Click(object sender, EventArgs e) { openFileDialog1.FileName = ""; openFileDialog1.DefaultExt = "txt"; openFileDialog1.Filter = "Crozzle Files (*.czl)|*.czl"; if (openFileDialog1.ShowDialog() != DialogResult.Cancel) { crozzle = new CrozzleGrid(); crozzle.Path = openFileDialog1.FileName; crozzle.ReadFile(); crozzle.Load(); crozzle.ReadWordsFromLocalFile(); string result = crozzle.GetHtmlTable(); int score = crozzle.CalculateScore(); result += "<br/><div><p><b> Score = " + score + "</b></p></div>"; webBrowser1.Navigate("about:blank"); HtmlDocument doc = webBrowser1.Document; doc.Write(String.Empty); webBrowser1.DocumentText = result; } }