/// <summary> /// setup /// </summary> protected override void SetUp() { // setup hotkey and notifiation icon base.SetUpHotKey(ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt, Key.L); // create a context menu base.AddContextMenu("Show", (sender, e) => this.OnContextMenuShowClick()); base.AddContextMenu("Import", (sender, e) => this.OnContextMenuImportClick()); base.AddContextMenuSeparator(); base.AddContextMenu("Exit", (sender, e) => this.OnContextMenuExitClick()); // add event this.Loaded += (sender, e) => { // create SearchResultRenderer after BrowserControl is loaded var userMemoryDictionary = AppSettingsRepo.GetInstance().UseMemoryDicitonary; if (userMemoryDictionary) { this.IsEnabled = false; this.cBrowser.NavigateToString("<html><body><h4 style='text-align:center;'>now loading...</h4></body></html>"); } this._renderer = new SearchResultRenderer(this.cBrowser, this.CompleteSearch); // set title FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); this._windowTitle = $"{versionInfo.ProductName}({versionInfo.FileVersion})"; this.ShowWindowTitle(); // set up obserber this._copyObserver = new CopyObserver(this, this.ClipboardChanged); // set up timer this._timer = new Timer(3000); this._timer.Elapsed += OnTimedEvent; // タスクトレイのアイコンが正しく表示されないようなので対症療法としてLoadでも設定 base.SetupNofityIcon("SimpleTranslationLocal", new System.Drawing.Icon("app.ico")); }; this.Closing += (sender, e) => { e.Cancel = true; if (this.ShowInTaskbar) { base.SetWindowsState(true); } }; this.Activated += (sender, e) => { this.cKeyword.Focus(); this._isActivated = true; }; this.Minimized += this.MainWindowMinimized; // set view model var model = new MainWindowViewModel(); this.DataContext = model; }
/// <summary> /// Window Closed event /// </summary> private void MainWindowMinimized() { if (this._isActivated) { var setting = AppSettingsRepo.GetInstance(); setting.X = this.Left; setting.Y = this.Top; setting.Height = this.Height; setting.Width = this.Width; setting.Save(); this._copyMode = CopyMode.None; this._copyObserver.Stop(); this.ShowWindowTitle(); } }
void IImportServiceCallback.OnSuccess() { var settings = AppSettingsRepo.GetInstance(); switch (this._dicType) { case Constants.DicType.Eijiro: settings.EijiroFile = EijiroFile; break; case Constants.DicType.Webster: settings.WebsterFile = WebsterFile; break; } settings.Save(); this._owner.Dispatcher.Invoke((Action)(() => { Messages.ShowInfo(this._owner, Messages.InfoId.Info001); })); }
/// <summary> /// データベース選択クリック時の処理 /// </summary> private void SelectDatabaseClick() { var dialog = new SaveFileDialog() { FileName = "app.data", Filter = "すべてのファイル|*.*|データベース ファイル|*.data", FilterIndex = 2, OverwritePrompt = false }; if (true == dialog.ShowDialog()) { var filename = dialog.FileName; try { var repo = AppSettingsRepo.GetInstance(); repo.SetDatabaseFile(filename); } catch (Exception ex) { Message.ShowError(this._window, Message.ErrId.Err002, ex.Message); } } this.ShowDataByRecordedOn(); }
/// <summary> /// アプリデータベース /// </summary> //public static readonly string DatabaseFile = AppSettingsRepo.GetInstance().DatabaseFile; public static string DatabaseFile() { return(AppSettingsRepo.GetInstance().DatabaseFile); }