예제 #1
0
 public InputBox(JPChar txtContent, KanjiInputManager kanjiInputManager)
 {
     InitializeComponent();
     _txtContent          = txtContent;
     ContentLabel.Content = _txtContent.Lit;
     SelectedCircleRectangle.Visibility = _txtContent.IsSelected ? Visibility.Visible : Visibility.Hidden;
     _kanjiInputManager           = kanjiInputManager;
     _txtContent.SelectedChanged += _txtContent_SelectedChanged;
     _txtContent.EnabledChanged  += _txtContent_EnabledChanged;
 }
예제 #2
0
        public static void Main(string[] args)
        {
            Application app = new Application(Eto.Platforms.Wpf);

            ChapterManager    chapterManager    = null;
            string            startChapter      = null;
            KanjiInputManager kanjiInputManager = null;
            TranslatorThread  translatorThread  = null;
            MiharuMainWindow  mainWindow        = null;

            try {
                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory.ToString());

                if (Init.CheckForTesseract())
                {
                    if (Init.CheckForGecko())
                    {
                        translatorThread = TranslatorThread.StartThread();
                    }

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

                    kanjiInputManager = new KanjiInputManager();

                    chapterManager = new ChapterManager(kanjiInputManager, translatorThread);

                    mainWindow = new MiharuMainWindow(chapterManager, startChapter);

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

                MessageBox.Show("There was a fatal error. Details can be found in the generated crash log:" + Environment.NewLine +
                                crashFileInfo.FullName,
                                "Fatal Error",
                                MessageBoxButtons.OK,
                                MessageBoxType.Error,
                                MessageBoxDefaultButton.OK);
            }
            finally {
                mainWindow?.Close();
                translatorThread?.FinalizeThread();
            }
        }
 public TextEntryView(TextEntryManager textEntryManager, KanjiInputManager kanjiInputManager)
 {
     InitializeComponent();
     _textEntryManager                   = textEntryManager;
     _textEntryManager.TextChanged      += OnTextEntryChanged;
     _textEntryManager.TextIndexChanged += OnTextEntryIndexChanged;
     _pageManager                   = _textEntryManager.PageManager;
     _pageManager.PageChanged      += OnPageChanged;
     _pageManager.TextEntryMoved   += OnTextEntryMoved;
     _pageManager.TextEntryRemoved += OnTextEntryRemoved;
     _pageManager.TextEntryAdded   += OnTextEntryAdded;
     _kanjiInputManager             = kanjiInputManager;
     _kanjiByRadInputControl        = new KanjiByRadInputControl(_kanjiInputManager);
     ConfigureButtons();
 }
예제 #4
0
        public KanjiByRadInputControl(KanjiInputManager kanjiInputManager)
        {
            InitializeComponent();

            _clearRadsButton        = (Button)Resources["ClearRadsButton"];
            _clearRadsButton.Click += _clearRadsButton_Click;

            _kanjiInputManager = kanjiInputManager;


            try {
                Mouse.OverrideCursor = Cursors.Wait;
                int currStrokes = 0;
                foreach (JPChar r in _kanjiInputManager.KanjiList)
                {
                    if (r.Strokes > currStrokes)
                    {
                        KanjiWrapPanel.Children.Add(new InputBoxInverted(r));
                        currStrokes = r.Strokes;
                    }
                    KanjiWrapPanel.Children.Add(new InputBox(r, _kanjiInputManager));
                }

                RadWrapPanel.Children.Add(_clearRadsButton);

                currStrokes = 0;
                foreach (JPChar r in _kanjiInputManager.RadList)
                {
                    if (r.Strokes > currStrokes)
                    {
                        RadWrapPanel.Children.Add(new InputBoxInverted(r));
                        currStrokes = r.Strokes;
                    }
                    RadWrapPanel.Children.Add(new InputBox(r, _kanjiInputManager));
                }
            }
            finally {
                Mouse.OverrideCursor = null;
            }

            _kanjiInputManager.KanjiListChanged += _kanjiInputManager_KanjiListChanged;
        }
예제 #5
0
        public TextEntryControl(TextEntryManager textEntryManager, KanjiInputManager kanjiInputManager, KanjiByRadInputControl kanjiByRadInput) : base()
        {
            _textEntryManager = textEntryManager;

            _kanjiInputManager = kanjiInputManager;
            InitializeComponent();


            InitializeSAnimation();



            if (_textEntryManager.IsTextSelected)
            {
                LoadTextEntry();
            }
            _textEntryManager.PageManager.TextEntryRequiresTranslation += OnTextEntryRequiresTranslation;
            TextTabControl.SelectedIndex = _textEntryManager.TabIndex;

            KanjiInputExpander.Content            = kanjiByRadInput;
            KanjiInputExpander.IsExpanded         = _kanjiInputManager.KanjiInputWindowVisibility;
            _kanjiInputManager.VisibilityChanged += KanjiInputManager_VisibilityChanged;
            _kanjiInputManager.KanjiInputEvent   += _kanjiInputManager_KanjiInputEvent;
        }
예제 #6
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();
            }
        }