private void AssignEntry(EntryBase?entry)
        {
            View?newView;

            if (entry is EntryMeta)
            {
                newView = null;
            }
            else
            {
                ViewModel.Template.Entry = entry;
                newView = new TextEntryView()
                {
                    BindingContext = new EntryEditViewModel(entry as TextEntry)
                };
            }

            EntryFrame.Content   = newView;
            EntryFrame.IsVisible = EntryFrame.Content != null;
        }
Exemplo n.º 2
0
        public static void Main(string [] args)
        {
            ChapterManager    chapterManager    = null;
            KanjiInputManager kanjiInputManager = null;
            TranslatorThread  translatorThread  = null;
            MiharuMainWindow  mainWindow        = null;

            try {
                App application = new App();


                /*MainWindow mw = new MainWindow();
                 * application.Run(mw);*/


                //Initialize stuff
                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory.ToString());
                if (CheckForTesseract())
                {
                    translatorThread = TranslatorThread.StartThread();

                    string startChapter = null;
                    startChapter = CheckCrash();
                    if (startChapter == null && args.Length > 0 && File.Exists(args [0]))
                    {
                        startChapter = args[0];
                    }

                    /*Logger.Log("Start Chapter: " + startChapter);
                     * Logger.Log("Args Length: " + args.Length);
                     * for (int i = 0; i < args.Length; i++)
                     *      Logger.Log("\t" + args[i]);*/

                    kanjiInputManager = new KanjiInputManager();

                    chapterManager = new ChapterManager(kanjiInputManager, translatorThread);

                    mainWindow = new MiharuMainWindow(chapterManager, startChapter);

                    PageControl pageControl = new PageControl(chapterManager.PageManager);
                    mainWindow.PageControlArea.Child = pageControl;

                    TextEntryView textEntryView = new TextEntryView(chapterManager.PageManager.TextEntryManager, kanjiInputManager);
                    mainWindow.TextEntryArea.Child = textEntryView;

                    application.Run(mainWindow);
                }
            }
            catch (Exception e) {
                CrashHandler.HandleCrash(chapterManager, e);
                FileInfo crashFileInfo = new FileInfo(Logger.CurrentCrashLog);

                TaskDialog dialog = new TaskDialog();
                dialog.WindowTitle     = "Fatal Error";
                dialog.MainIcon        = TaskDialogIcon.Error;
                dialog.MainInstruction = "There was a fatal error. Details can be found in the generated crash log:";
                dialog.Content         = crashFileInfo.FullName;

                TaskDialogButton okButton = new TaskDialogButton("Ok");
                okButton.ButtonType = ButtonType.Ok;
                dialog.Buttons.Add(okButton);
                TaskDialogButton button = dialog.ShowDialog();
            }
            finally {
                mainWindow?.Close();
                translatorThread?.FinalizeThread();
            }
        }