private const Int32 NumCheckWords = 100; //maximum number of words the program will check to make a decision on key public static void Main(string[] args) { try { #region Variables String filename; String encryptedText; #region initializing spellchecker var dict = new NetSpell.SpellChecker.Dictionary.WordDictionary { DictionaryFolder = String.Concat(Environment.CurrentDirectory, Path.DirectorySeparatorChar, "data"), DictionaryFile = "en-US.dic" }; dict.Initialize(); _spell = new NetSpell.SpellChecker.Spelling { Dictionary = dict }; #endregion #endregion #region Get File and Location if (args.Length > 0)//tries to read filename from arguments { filename = args[0]; } else//if theres no argument (double clicked exe) program need to ask for the filename { Console.WriteLine("Enter the file name without extension (must be a .txt file)"); filename = Console.ReadLine(); } filename += ".txt"; //gives .txt extension to the name var filepath = String.Concat(DefaultInputPath, filename); //concats path and filename #endregion encryptedText = File.ReadAllText(filepath); //puts all text in a single string to work with // gets the most suitable key for the given text var key = FindKey(encryptedText); var text = TranslateText(encryptedText, key); Console.WriteLine(text); Console.ReadKey(); } catch (FileNotFoundException) { Console.WriteLine("File not found!"); Console.ReadKey(); } catch (Exception) { Console.WriteLine("Something really unexpected happened! :( \n" + "Shutting down the application..."); Console.ReadKey(); } }
public bool CheckSpelling(string content) { var spelling = new Spelling(); spelling.ShowDialog = ShowDialog; return spelling.SpellCheck(content); }
public void SetUp() { _SpellChecker = new Spelling(); _SpellChecker.Dictionary.DictionaryFolder = @"..\..\..\..\dic"; _SpellChecker.Dictionary.Initialize(); _SpellChecker.ShowDialog = false; _SpellChecker.MaxSuggestions = 0; }
/// <summary> /// Default Constructor /// </summary> public SuggestionForm(Spelling spell) { this.SpellChecker = spell; this.AttachEvents(); InitializeComponent(); #if BEPOE_EXTENSIONS this.Shown += new EventHandler(this.Form_Shown); #endif }
public NetSpellDictWrapper() { WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary(); oDict.DictionaryFile = "en-US.dic"; //load and initialize the dictionary oDict.Initialize(); Spelling = new Spelling(); Spelling.Dictionary = oDict; }
public frmDocument(String template, Building build) { building = build; InitializeComponent(); if (!String.IsNullOrEmpty(template)) { content = template; } spellCheck = new Spelling(); dictionary = new NetSpell.SpellChecker.Dictionary.WordDictionary { DictionaryFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dic") }; spellCheck.Dictionary = dictionary; spellCheck.EndOfText += spellCheck_EndOfText; spellCheck.DeletedWord += spellCheck_DeletedWord; spellCheck.ReplacedWord += spellCheck_ReplacedWord; }
public ucHTML() { _srcHTMLText = string.Empty; InitializeComponent(); _wb.Navigate("about:blank"); //pImageCollection = null; #region ToolsStrip Image _tsbCut.Image = Bitmap.FromHicon(ToolsRes.iiCut.Handle); _tsbCopy.Image = Bitmap.FromHicon(ToolsRes.iiCopy.Handle); _tsbPaste.Image = Bitmap.FromHicon(ToolsRes.iiPaste.Handle); _tsbBold.Image = Bitmap.FromHicon(ToolsRes.iiBold.Handle); _tsbItalic.Image = Bitmap.FromHicon(ToolsRes.iiItalic.Handle); _tsbUnderline.Image = Bitmap.FromHicon(ToolsRes.iiUnderline.Handle); _tsbLeft.Image = Bitmap.FromHicon(ToolsRes.iiJustifyLeft.Handle); _tsbCenter.Image = Bitmap.FromHicon(ToolsRes.iiJustifyCenter.Handle); _tsbRight.Image = Bitmap.FromHicon(ToolsRes.iiJustifyRight.Handle); _tsbUndo.Image = Bitmap.FromHicon(ToolsRes.iiUndo.Handle); _tsbRedo.Image = Bitmap.FromHicon(ToolsRes.iiRedo.Handle); //_tscFont.Image = Bitmap.FromHicon(ToolsRes.iifo.Handle); _tsbPrint.Image = Bitmap.FromHicon(ToolsRes.iiPrint.Handle); _tsbPreview.Image = Bitmap.FromHicon(ToolsRes.iiPreview.Handle); #endregion #region ToolsStrip ToolTipText _tsbCut.ToolTipText = ToolsRes.fCut; _tsbCopy.ToolTipText = ToolsRes.fCopy; _tsbPaste.ToolTipText = ToolsRes.fPaste; _tsbBold.ToolTipText = ToolsRes.fBold; _tsbItalic.ToolTipText = ToolsRes.fItalic; _tsbUnderline.ToolTipText = ToolsRes.fUnderline; _tsbLeft.ToolTipText = ToolsRes.fJustifyLeft; _tsbCenter.ToolTipText = ToolsRes.fJustifyCenter; _tsbRight.ToolTipText = ToolsRes.fJustifyRight; _tsbUndo.ToolTipText = ToolsRes.fUndo; _tsbRedo.ToolTipText = ToolsRes.fRedo; _tscFont.ToolTipText = ToolsRes.fFontChange; _tsbPrint.ToolTipText = ToolsRes.fPrintText; _tsbPreview.ToolTipText = ToolsRes.fPrintPreviewText; _tsbSpellChecker.ToolTipText = ToolsRes.fSpellChecker; #endregion int ind = 0; foreach (FontFamily ff in FontFamily.Families) { if (ff.IsStyleAvailable(FontStyle.Regular)) ind = _tscFont.Items.Add(ff.Name); } _tscFont.ComboBox.DropDownWidth = _tscFont.ComboBox.Width * 2; for (ind = 1; ind < 8; ind++) _tscSize.Items.Add(ind); Controls.Remove(pTS); //_wb. //_wb.GotFocus += new EventHandler(_wb_GotFocus); _tsbSpellChecker.Image = ToolsRes.Spelling; this.components = new System.ComponentModel.Container(); _spell = new Spelling(this.components); _spell.Dictionary = pWordDic; //_spell.ReplacedWord += new Spelling.ReplacedWordEventHandler(_spell_ReplacedWord); //_spell.DeletedWord += new Spelling.DeletedWordEventHandler(_spell_DeletedWord); _spell.EndOfText += new Spelling.EndOfTextEventHandler(_spell_EndOfText); }
private Spelling NewSpellChecker() { Spelling _SpellChecker = new Spelling(); _SpellChecker.Dictionary = _dictionary; _SpellChecker.ShowDialog = false; _SpellChecker.DeletedWord += new NetSpell.SpellChecker.Spelling.DeletedWordEventHandler(SpellChecker_DeletedWord); _SpellChecker.DoubledWord +=new NetSpell.SpellChecker.Spelling.DoubledWordEventHandler(SpellChecker_DoubledWord); _SpellChecker.EndOfText +=new NetSpell.SpellChecker.Spelling.EndOfTextEventHandler(SpellChecker_EndOfText); _SpellChecker.IgnoredWord +=new NetSpell.SpellChecker.Spelling.IgnoredWordEventHandler(SpellChecker_IgnoredWord); _SpellChecker.MisspelledWord +=new NetSpell.SpellChecker.Spelling.MisspelledWordEventHandler(SpellChecker_MisspelledWord); _SpellChecker.ReplacedWord +=new NetSpell.SpellChecker.Spelling.ReplacedWordEventHandler(SpellChecker_ReplacedWord); return _SpellChecker; }
public static String decode(String cipher) { //decodes with the Caesar cipher List <object> retList = establishVariables(); cipher = cipher.ToLower(); String alphabet = Convert.ToString(retList[0]); Dictionary <char, int> characterToInteger = retList[1] as Dictionary <char, int>; Dictionary <int, char> integerToCharacter = retList[2] as Dictionary <int, char>; char[] cipherText = cipher.ToCharArray(); //so we have a permanent copy char[] guessText = cipher.ToCharArray(); //this will be manipulated int iter = 0; bool found = false; // when to break out of the while loop while (iter <= 25) { // constructs the shift "guess" var textList = new List <char>(); foreach (char elem in guessText) { if (alphabet.Contains(elem.ToString())) { int val = characterToInteger[elem]; val = (val + iter) % 26; //performs shift textList.Add(integerToCharacter[val]); } else { textList.Add(elem); } } String result = MakeString(textList); string[] strRes = result.Split(' '); // checks to see if NetSpell is working correctly NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary(); String path = "..//..//en-US.dic"; oDict.DictionaryFile = path; oDict.Initialize(); NetSpell.SpellChecker.Spelling oSpell = new NetSpell.SpellChecker.Spelling(); oSpell.Dictionary = oDict; // checks to see if the guess is proper English by at least 50% double englishThreshold = 0.5; int sizeOfGuess = strRes.Length; int properEnglishCount = 0; foreach (String current in strRes) { if (oSpell.TestWord(current)) { properEnglishCount++; } double thresholdCheck = (double)properEnglishCount / (double)sizeOfGuess; if (thresholdCheck >= englishThreshold) { int shiftValue = 26 - iter; found = true; } } if (found == true) { return(result); } //iterates the while iter++; } return("I'm sorry, indecipherable with a shift cipher."); }
/// <summary> /// Default Constructor /// </summary> public OptionForm(ref Spelling spell) { this.SpellChecker = spell; InitializeComponent(); }
/// <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(StartupForm)); System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); this.trayMenu = new System.Windows.Forms.ContextMenu(); this.menuSpellCheck = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuHistory = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuExit = new System.Windows.Forms.MenuItem(); this.menuOptions = new System.Windows.Forms.MenuItem(); this.menuAbout = new System.Windows.Forms.MenuItem(); this.trayIcon = new System.Windows.Forms.NotifyIcon(this.components); this.spelling = new NetSpell.SpellChecker.Spelling(this.components); // // trayMenu // this.trayMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuSpellCheck, this.menuItem2, this.menuHistory, this.menuItem3, this.menuExit, this.menuOptions, this.menuAbout}); this.trayMenu.Popup += new System.EventHandler(this.trayMenu_Popup); // // menuSpellCheck // this.menuSpellCheck.Index = 0; this.menuSpellCheck.Text = "Spell Check Clipboard"; this.menuSpellCheck.Click += new System.EventHandler(this.menuSpellCheck_Click); // // menuItem2 // this.menuItem2.Index = 1; this.menuItem2.Text = "-"; // // menuHistory // this.menuHistory.Index = 2; this.menuHistory.Text = "Clipboard History"; // // menuItem3 // this.menuItem3.Index = 3; this.menuItem3.Text = "-"; // // menuExit // this.menuExit.Index = 4; this.menuExit.Text = "Exit"; this.menuExit.Click += new System.EventHandler(this.menuExit_Click); // // menuOptions // this.menuOptions.Index = 5; this.menuOptions.Text = "Options ..."; this.menuOptions.Click += new System.EventHandler(this.menuOptions_Click); // // menuAbout // this.menuAbout.Index = 6; this.menuAbout.Text = "About ..."; this.menuAbout.Click += new System.EventHandler(this.menuAbout_Click); // // trayIcon // this.trayIcon.ContextMenu = this.trayMenu; this.trayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("trayIcon.Icon"))); this.trayIcon.Text = "Spell Check Clipboard"; this.trayIcon.Visible = true; this.trayIcon.DoubleClick += new System.EventHandler(this.trayIcon_DoubleClick); // // spelling // this.spelling.IgnoreAllCapsWords = ((bool)(configurationAppSettings.GetValue("spelling.IgnoreAllCapsWords", typeof(bool)))); this.spelling.IgnoreWordsWithDigits = ((bool)(configurationAppSettings.GetValue("spelling.IgnoreWordsWithDigits", typeof(bool)))); this.spelling.MainDictionary = ((string)(configurationAppSettings.GetValue("spelling.MainDictionary", typeof(string)))); this.spelling.MaxSuggestions = ((int)(configurationAppSettings.GetValue("spelling.MaxSuggestions", typeof(int)))); this.spelling.UserDictionary = ((string)(configurationAppSettings.GetValue("spelling.UserDictionary", typeof(string)))); this.spelling.EndOfText += new NetSpell.SpellChecker.Spelling.EndOfTextEventHandler(this.spelling_EndOfText); // // StartupForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(178, 78); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "StartupForm"; this.ShowInTaskbar = false; this.Text = "Tray Spell"; this.WindowState = System.Windows.Forms.FormWindowState.Minimized; this.Load += new System.EventHandler(this.StartupForm_Load); }
/// <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(StartupForm)); System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); this.trayMenu = new System.Windows.Forms.ContextMenu(); this.menuSpellCheck = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuHistory = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuExit = new System.Windows.Forms.MenuItem(); this.menuOptions = new System.Windows.Forms.MenuItem(); this.menuAbout = new System.Windows.Forms.MenuItem(); this.trayIcon = new System.Windows.Forms.NotifyIcon(this.components); this.spelling = new NetSpell.SpellChecker.Spelling(this.components); // // trayMenu // this.trayMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuSpellCheck, this.menuItem2, this.menuHistory, this.menuItem3, this.menuExit, this.menuOptions, this.menuAbout }); this.trayMenu.Popup += new System.EventHandler(this.trayMenu_Popup); // // menuSpellCheck // this.menuSpellCheck.Index = 0; this.menuSpellCheck.Text = "Spell Check Clipboard"; this.menuSpellCheck.Click += new System.EventHandler(this.menuSpellCheck_Click); // // menuItem2 // this.menuItem2.Index = 1; this.menuItem2.Text = "-"; // // menuHistory // this.menuHistory.Index = 2; this.menuHistory.Text = "Clipboard History"; // // menuItem3 // this.menuItem3.Index = 3; this.menuItem3.Text = "-"; // // menuExit // this.menuExit.Index = 4; this.menuExit.Text = "Exit"; this.menuExit.Click += new System.EventHandler(this.menuExit_Click); // // menuOptions // this.menuOptions.Index = 5; this.menuOptions.Text = "Options ..."; this.menuOptions.Click += new System.EventHandler(this.menuOptions_Click); // // menuAbout // this.menuAbout.Index = 6; this.menuAbout.Text = "About ..."; this.menuAbout.Click += new System.EventHandler(this.menuAbout_Click); // // trayIcon // this.trayIcon.ContextMenu = this.trayMenu; this.trayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("trayIcon.Icon"))); this.trayIcon.Text = "Spell Check Clipboard"; this.trayIcon.Visible = true; this.trayIcon.DoubleClick += new System.EventHandler(this.trayIcon_DoubleClick); // // spelling // this.spelling.IgnoreAllCapsWords = ((bool)(configurationAppSettings.GetValue("spelling.IgnoreAllCapsWords", typeof(bool)))); this.spelling.IgnoreWordsWithDigits = ((bool)(configurationAppSettings.GetValue("spelling.IgnoreWordsWithDigits", typeof(bool)))); this.spelling.MainDictionary = ((string)(configurationAppSettings.GetValue("spelling.MainDictionary", typeof(string)))); this.spelling.MaxSuggestions = ((int)(configurationAppSettings.GetValue("spelling.MaxSuggestions", typeof(int)))); this.spelling.UserDictionary = ((string)(configurationAppSettings.GetValue("spelling.UserDictionary", typeof(string)))); this.spelling.EndOfText += new NetSpell.SpellChecker.Spelling.EndOfTextEventHandler(this.spelling_EndOfText); // // StartupForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(178, 78); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "StartupForm"; this.ShowInTaskbar = false; this.Text = "Tray Spell"; this.WindowState = System.Windows.Forms.FormWindowState.Minimized; this.Load += new System.EventHandler(this.StartupForm_Load); }
/// <summary> /// Default Constructor /// </summary> public SuggestionForm(Spelling spell) { this.SpellChecker = spell; this.AttachEvents(); InitializeComponent(); }
public static String decode(String cipherText) { List <object> retList = establishVariables(); cipherText = cipherText.ToLower(); String alphabet = Convert.ToString(retList[0]); Dictionary <char, int> characterToInteger = retList[1] as Dictionary <char, int>; Dictionary <int, char> integerToCharacter = retList[2] as Dictionary <int, char>; for (int i = 1; i <= 26; i++) { //Iterate through all possible "a" values int inverse = calculateInverse(i); if (inverse == 0 || i == 13) { // This value of a has no inverse, skip } else { for (int b = 0; b <= 26; b++) { //iterate through all possible "b" values var cipherTextGuess = new List <char>(); foreach (char letter in cipherText) { if (alphabet.Contains(letter.ToString())) { int value = characterToInteger[letter]; int affineValue = (inverse * (value - b)) % 26; //perform affine calculation if (affineValue < 0) { affineValue = affineValue + 26; } char charValue = integerToCharacter[affineValue]; cipherTextGuess.Add(charValue); } else { cipherTextGuess.Add(letter); } } String guess = MakeString(cipherTextGuess); string[] strRes = guess.Split(' '); NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary(); String path = "..//..//en-US.dic"; oDict.DictionaryFile = path; oDict.Initialize(); NetSpell.SpellChecker.Spelling oSpell = new NetSpell.SpellChecker.Spelling(); oSpell.Dictionary = oDict; // checks to see if the guess is proper English by at least 60% double englishThreshold = 0.6; int sizeOfGuess = strRes.Length; int properEnglishCount = 0; foreach (String current in strRes) { if (oSpell.TestWord(current)) { properEnglishCount++; } double thresholdCheck = (double)properEnglishCount / (double)sizeOfGuess; if (thresholdCheck >= englishThreshold) { //if threshold met, return guess return(guess); } } } } } return("I'm sorry, indecipherable cipher."); }
public void Dispose() { if (this._spelling != null) { try { this._spelling.Dispose(); } catch { } this._spelling = null; } }
internal Worker(SpellChecker spellChecker, CultureInfo cultureInfo, System.ComponentModel.IContainer container) { this._cultureInfo = cultureInfo; this._currentResult = null; this._currentReason = CallReasons.None; this._currentText = null; this._currentTextBox = null; this._spelling = new Spelling(); if (container == null) this._spelling.Dictionary = new WordDictionary(); else this._spelling.Dictionary = new WordDictionary(container); this._spelling.Dictionary.DictionaryFolder = spellChecker.DictionaryFolderPath; this._spelling.Dictionary.DictionaryFile = spellChecker.GetDictionaryFileName(this._cultureInfo); this._spelling.Dictionary.EnableUserFile = true; this._spelling.Dictionary.UserFile = spellChecker.GetUserDictionaryFileName(this._cultureInfo); this._spelling.IgnoreAllCapsWords = false; this._spelling.IgnoreHtml = false; this._spelling.IgnoreWordsWithDigits = false; this._spelling.DoubledWord += this._spelling_DoubledWord; this._spelling.MisspelledWord += this._spelling_MisspelledWord; this._spelling.DeletedWord += this._spelling_DeletedWord; this._spelling.ReplacedWord += this._spelling_ReplacedWord; }
public void SetSpellChecker(TextBoxBase extendee, Spelling value) { _spellChecker = value; }
private void EditNetSpellLoad(object sender, EventArgs e) { MistakeFont = new Font(TextBox.Font, FontStyle.Underline); components = new Container(); _spelling = new Spelling(components) { ShowDialog = false, IgnoreAllCapsWords = true, IgnoreWordsWithDigits = true }; // // spelling // _spelling.ReplacedWord += SpellingReplacedWord; _spelling.DeletedWord += SpellingDeletedWord; _spelling.MisspelledWord += SpellingMisspelledWord; // // wordDictionary // LoadDictionary(); }
private Spelling NewSpellChecker() { Spelling _SpellChecker = new Spelling(); _SpellChecker.Dictionary = _dictionary; _SpellChecker.ShowDialog = false; return _SpellChecker; }
private void EditNetSpellLoad(object sender, EventArgs e) { MistakeFont = new Font(TextBox.Font, FontStyle.Underline); TextBoxFont = TextBox.Font; ShowWatermark(); components = new Container(); _spelling = new Spelling(components) { ShowDialog = false, IgnoreAllCapsWords = true, IgnoreWordsWithDigits = true }; _autoCompleteListTask.ContinueWith( w => _spelling.AddAutoCompleteWords(w.Result.Select(x => x.Word)), _autoCompleteCancellationTokenSource.Token, TaskContinuationOptions.NotOnCanceled, TaskScheduler.FromCurrentSynchronizationContext() ); // // spelling // _spelling.ReplacedWord += SpellingReplacedWord; _spelling.DeletedWord += SpellingDeletedWord; _spelling.MisspelledWord += SpellingMisspelledWord; // // wordDictionary // LoadDictionary(); }