Exemple #1
0
        public void LoadSettings(Main View)
        {
            try
            {
                var settingsPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BleckiTreeWriter\\settings.txt";

                if (System.IO.File.Exists(settingsPath))
                {
                    var text = System.IO.File.ReadAllText(settingsPath);
                    Settings.GlobalSettings = JsonConvert.DeserializeObject <Settings>(text);
                }
            }
            catch (Exception e)
            {
                SpellChecker = new NHunspell.Hunspell("en_US.aff", "en_US.dic");
                Thesaurus    = new NHunspell.MyThes("th_en_US_new.dat");

                System.Windows.Forms.MessageBox.Show("Error loading settings.", "Alert!", System.Windows.Forms.MessageBoxButtons.OK);
            }

            if (Settings.GlobalSettings == null)
            {
                Settings.GlobalSettings = new Settings();
            }

            Settings.GlobalSettings.Verify();

            SpellChecker = new NHunspell.Hunspell(
                Settings.GlobalSettings.Dictionary + ".aff",
                Settings.GlobalSettings.Dictionary + ".dic");
            Thesaurus = new NHunspell.MyThes(Settings.GlobalSettings.Thesaurus);

            foreach (var word in Settings.GlobalSettings.CustomDictionaryEntries)
            {
                SpellChecker.Add(word);
            }


            View.UpdateRecentDocuments();
        }
        public TextDocumentEditor(
            EditableDocument Document,
            ScintillaNET.Document?LinkingDocument,
            NHunspell.Hunspell SpellChecker,
            NHunspell.MyThes Thesaurus)
            : base(Document)
        {
            this.SpellChecker = SpellChecker;
            this.Thesaurus    = Thesaurus;

            this.InitializeComponent();

            // Load document into editor.
            if (!LinkingDocument.HasValue)
            {
                textEditor.Text = Document.GetContents();
            }
            else
            {
                textEditor.Document = LinkingDocument.Value;
            }

            textEditor.Create(SpellChecker, Thesaurus, (a) => InvokeCommand(a));
            textEditor.CustomizeMenu = (menu) =>
            {
                if (CustomizeContextMenu != null)
                {
                    CustomizeContextMenu(menu);
                }
            };

            Text = Document.GetTitle();

            //Register last to avoid spurius events
            this.textEditor.TextChanged += new System.EventHandler(this.textEditor_TextChanged);

            ReloadSettings();
        }
Exemple #3
0
 public void Create(NHunspell.Hunspell SpellChecker, NHunspell.MyThes Thesaurus, Action <ICommand> ControllerCommand)
 {
     this.SpellChecker      = SpellChecker;
     this.Thesaurus         = Thesaurus;
     this.ControllerCommand = ControllerCommand;
 }