/// <summary> /// navigate /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Viewer_Navigating(object sender, NavigatingCancelEventArgs e) { if (!e.Uri.IsFile) { e.Cancel = true; MyLib.Util.Common.RunApplication(e.Uri.ToString(), false); return; } var file = FileOperator.Create(e.Uri.LocalPath); if (file.IsDirectory) { e.Cancel = true; return; } if (file.Name.EndsWith(Constant.MetaJson)) { e.Cancel = true; this.ShowBook(e.Uri.LocalPath + Uri.UnescapeDataString(e.Uri.Fragment)); } else if (file.Extension == "hbv") { e.Cancel = true; var recentFile = this.ContainsExtractFiles(file.FilePath); if (null != recentFile && System.IO.File.Exists(Constant.CasheMeta(recentFile.CacheDir))) { this.ShowBook(Constant.CasheMeta(recentFile.CacheDir), recentFile.HBVFilePath, recentFile.CacheDir); } else { if (null != recentFile && 0 < recentFile.CacheDir.Length) { this._appData.RecentFiles.Remove(recentFile); this._appData.Save(); } var cacheDir = DateTime.Now.ToString("yyyyMMddHHMMss"); var dialog = new ExtractWindow(this); dialog.HBVFile = file.FilePath; dialog.DestDir = Constant.CacheDir + cacheDir; if (true == dialog.ShowDialog()) { this.ShowBook(Constant.CasheMeta(cacheDir), file.FilePath, cacheDir); } } } }
/// <summary> /// キー入力 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_KeyDown(object sender, KeyEventArgs e) { if (this._loading) { e.Handled = true; return; } switch (e.Key) { case Key.R: if (Common.IsModifierPressed(ModifierKeys.Control) && Common.IsModifierPressed(ModifierKeys.Shift)) { e.Handled = true; var index = this._operator.Index; this._operator.ParseMeta(); this._operator.MoveTo(index); this.ShowPage(); } else if (Common.IsModifierPressed(ModifierKeys.Control)) { e.Handled = true; this.cViewer.Refresh(); } break; case Key.Right: case Key.F: e.Handled = true; if (this._operator.MoveToNext()) { this.ShowPage(); this._appData.RecentFiles[0].LastIndex = this._operator.Index; this._appData.Save(); } break; case Key.Left: case Key.B: e.Handled = true; if (this._operator.MoveToPrevious()) { this.ShowPage(); this._appData.RecentFiles[0].LastIndex = this._operator.Index; this._appData.Save(); } break; case Key.O: e.Handled = true; var tocDialog = new TocWindow(this, this._operator.Toc, this._operator.Index); if (true == tocDialog.ShowDialog()) { this._operator.Index = tocDialog.Index; this.ShowPage(); this._appData.RecentFiles[0].LastIndex = this._operator.Index; this._appData.Save(); } break; case Key.P: e.Handled = true; var fileName = new MyLib.File.FileOperator(this._operator.CurrentPage); if (Common.IsModifierPressed(ModifierKeys.Shift)) { MessageBox.Show(fileName.Name); } else { Clipboard.SetText(fileName.Name, TextDataFormat.Text); } break; case Key.Q: e.Handled = true; var recentFilesDialog = new RecentFiles(this); if (true == recentFilesDialog.ShowDialog()) { var recentFile = recentFilesDialog.RecentFile; if (0 < recentFile.CacheDir.Length) { this.ShowBook(Constant.CasheMeta(recentFile.CacheDir), recentFile.HBVFilePath, recentFile.CacheDir); } else { this.ShowBook(recentFile.FilePath); } } break; case Key.J: if (Common.IsModifierPressed(ModifierKeys.Control)) { e.Handled = true; var jumpPageDialog = new JumpPage(this, this._operator.Index); if (true == jumpPageDialog.ShowDialog()) { var index = jumpPageDialog.Index; if (0 <= index) { this._operator.Index = jumpPageDialog.Index; this.ShowPage(); this._appData.RecentFiles[0].LastIndex = this._operator.Index; this._appData.Save(); } } } break; case Key.Down: e.Handled = true; this.ScrollTo(true); break; case Key.Up: e.Handled = true; this.ScrollTo(false); break; } }