//This method handles TWO files: //(1) The file to initialize as the dictionary. Passed as `fi' //(2) The settings file. Refer to `settingsFile' member. static void initialize(FileInfo fi, Gtk.Entry input, Gtk.Button send, Gtk.Notebook nb, Gtk.Button leftButton, Gtk.Button rightButton) { if(teh != null) { teh.disconnectFromLog(); teh = null; } teh = loadFile(fi.FullName); teh.connectToLog(); if(!monitor.IsAlive) { monitor.Start(); } else { monitor.Abort(); monitor = new System.Threading.Thread(MainClass.ConsoleEater); monitor.Start(); } if(!teh.reparse()) { Gtk.MessageDialog m_d = new Gtk.MessageDialog(mainwindow, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, "Error: Your dictionary file could not be parsed. Make sure it is not open in any other application, check the format, and try again.", new object[]{"Ok"}); m_d.Run(); System.Environment.Exit(0); } //We're still here, there were no fatal exceptions, so this dict is "safe" for opening on startup (we hope) //Remember this fact in the .tehthuconfig file. if(settingsFile != null) { TextWriter tw = new StreamWriter(settingsFile.OpenWrite()); tw.WriteLine(teh.getFile().FullName); tw.Flush(); tw.Close(); } input.IsEditable = true; input.Sensitive = true; send.Sensitive = true; Gtk.Label inputTabLabel = (Gtk.Label) nb.GetTabLabel(nb.GetNthPage(0)); inputTabLabel.Text = "Input (" + (leftToRight ? teh.getLeftLanguageName() : teh.getRightLanguageName()) + ")"; Gtk.Label outputTabLabel = (Gtk.Label) nb.GetTabLabel(nb.GetNthPage(1)); outputTabLabel.Text = "Output (" + (leftToRight ? teh.getRightLanguageName() : teh.getLeftLanguageName()) + ")"; leftButton.Label = teh.getLeftLanguageName() + "-to-" + teh.getRightLanguageName(); rightButton.Label = teh.getRightLanguageName() + "-to-" + teh.getLeftLanguageName(); input.GrabFocus(); }