public void DropNewFiles(string[] pathes) { // 拡大中なら解除 if (TileExpantionPanel.IsShowing) { TileExpantionPanel.Hide(); } // 画像1枚だけ読み込みの時は、親フォルダを読み込む if (Setting.ReadSingleImageAsParentFolder && pathes.Length == 1 && File.Exists(pathes[0]) && ArchiverBase.AllowedFileExt.Any(ext => pathes[0].ToLower().EndsWith(ext))) { DropNewSingleFileAsFolder(pathes[0]); return; } // 読み込み if (Setting.EnabledItemsInHistory.ArchiverPath && pathes.Length == 1 && Setting.History.Any(hi => hi.ArchiverPath == pathes[0]) && Setting.ApplyHistoryInfoInNewArchiverReading) { // 履歴に存在する場合 LoadHistory(pathes[0]); } else { ReadFiles(pathes, false); var t = ImgContainerManager.InitAllContainer(0); } }
public void Reload(bool keepCurrentIdx) { // 現在のページを保持 int currentIndex = ImgContainerManager.CurrentImageIndex; // 拡大パネル表示中なら閉じる if (TileExpantionPanel.IsShowing) { TileExpantionPanel.Hide(); } // 画像情報の読み込みとソート String[] files = Setting.TempProfile.Path.Value.ToArray(); ReadFiles(files, false); // コンテンツ初期化 ImgContainerManager.ImagePool.ReleaseAllBitmapImage(); if (keepCurrentIdx) { var t = ImgContainerManager.InitAllContainer(currentIndex); } else { var t = ImgContainerManager.InitAllContainer(0); } }
private void UIVisibleTimer_Ticked(object sender, EventArgs e) { #if DEBUG //cnt += 1; //Debug.WriteLine("UIVisible Timer Ticked " + cnt.ToString() ); #endif // 設定プロファイル Profile pf = mainWindow.Setting.TempProfile; // ウインドウ幅が狭い時は、ツールバー位置を調整 int p1 = 490; if (mainWindow.Width < p1) { mainWindow.ToolbarWrapper.HorizontalAlignment = HorizontalAlignment.Left; mainWindow.ToolbarWrapper.Margin = new Thickness(10, 10, 80, 0); // ツールバー縮小 //int p2 = 290; //if(mainWindow.Width < p2 ) //{ // double scale = mainWindow.Width / ( p2 + 50 ); // this.mainWindow.ToolbarWrapper.LayoutTransform = new ScaleTransform(scale, scale); //} //else //{ // this.mainWindow.ToolbarWrapper.LayoutTransform = new ScaleTransform(1.0, 1.0); //} } else { mainWindow.ToolbarWrapper.HorizontalAlignment = HorizontalAlignment.Center; mainWindow.ToolbarWrapper.Margin = new Thickness(10, 10, 10, 0); // ツールバー等倍 this.mainWindow.ToolbarWrapper.LayoutTransform = new ScaleTransform(1.0, 1.0); } // マウスボタンが押されているか(リサイズ中かどうか)チェック short stateL = Win32.GetKeyState(Win32.VK_LBUTTON); short stateR = Win32.GetKeyState(Win32.VK_RBUTTON); if ((stateL & 0x8000) != 0 || (stateR & 0x8000) != 0) { return; } // 現在座標(スクリーン上の) Win32.POINT pt = new Win32.POINT(); Win32.GetCursorPos(ref pt); // スクリーン上のカーソル下のプロセスが、このアプリのものであるかチェック IntPtr hwnd = Win32.WindowFromPoint(pt); int pid = Win32.GetPidFromHwnd((int)hwnd); if (this.processId == 0) { this.processId = Win32.GetPidFromHwnd((int)new WindowInteropHelper(mainWindow).Handle); } if (pid != this.processId) { HideAllUI(); uIVisibleTimer.Stop(); return; } // カーソル下がMenuItem等の場合はreturn IntPtr hwndThis = new WindowInteropHelper(mainWindow).Handle; if (hwnd != hwndThis) { return; } // 一定時間のカーソル停止を検知して、タイマーを止める。カーソルも隠す Point d = new Point(Math.Abs(pt.X - ptCursorPause.X), Math.Abs(pt.Y - ptCursorPause.Y)); if (!isCursorPaused && d.X == 0 && d.Y == 0) { cursorPauseTime += 1; if (cursorPauseTime > 15) // 1.5 sec { if (mainWindow.Setting.MouseCursorAutoHide) { if (!pf.IsFullScreenMode.Value && mainWindow.Setting.MouseCursorAutoHideInFullScreenModeOnly) { mainWindow.Cursor = null; } else { mainWindow.Cursor = Cursors.None; } } isCursorPaused = true; this.uIVisibleTimer.Stop(); return; } } else { mainWindow.Cursor = null; ptCursorPause.X = pt.X; ptCursorPause.Y = pt.Y; cursorPauseTime = 0; isCursorPaused = false; } // カーソル位置によってUIの表示を変える Point ptWnd = Win32.GetWindowPos(hwndThis); var h3 = mainWindow.Height / 3; var w3 = mainWindow.Width / 3; // 拡大パネル内ファイル情報表示時 TileExpantionPanel panel = mainWindow.TileExpantionPanel; if (panel.IsShowing) { // ツールバー、シークバーは常に隠す mainWindow.ToolbarWrapper.Visibility = Visibility.Collapsed; HideSeekbar(); // 上部 1/3 if (pt.Y < ptWnd.Y + h3) { mainWindow.SystemButtonWrapper.Visibility = Visibility.Visible; } else { mainWindow.SystemButtonWrapper.Visibility = Visibility.Collapsed; } // 下部 1/3 if (pt.Y > ptWnd.Y + (2 * h3)) { panel.ToolbarWrapper.Visibility = Visibility.Visible; mainWindow.PageInfo.Visibility = Visibility.Visible; } else { panel.ToolbarWrapper.Visibility = Visibility.Collapsed; mainWindow.PageInfo.Visibility = Visibility.Collapsed; } return; } // ツールバー、システムボタン double borderHeight = mainWindow.ToolbarWrapper.ActualHeight + mainWindow.ToolbarWrapper.Margin.Top; if (pt.Y < ptWnd.Y + h3 || pt.Y < ptWnd.Y + borderHeight) { mainWindow.ToolbarWrapper.Visibility = Visibility.Visible; mainWindow.SystemButtonWrapper.Visibility = Visibility.Visible; } else { if (!mainWindow.IsAnyToolbarMenuOpened) { mainWindow.ToolbarWrapper.Visibility = Visibility.Hidden; } mainWindow.SystemButtonWrapper.Visibility = Visibility.Hidden; } // シークバー if (mainWindow.Setting.TempProfile.IsHorizontalSlide) { // 水平 if (pt.Y > ptWnd.Y + h3 * 2) { ShowSeekbar(); } else { HideSeekbar(); } } else { // 垂直 if (pt.X > ptWnd.X + w3 * 2) { ShowSeekbar(); } else { HideSeekbar(); } } }
public void ToggleFullScreen() { if (Setting.TempProfile.IsFullScreenMode.Value) { // 解除 this.MainContent.Margin = new Thickness(Setting.TempProfile.ResizeGripThickness.Value); this.ResizeGrip.Visibility = Visibility.Visible; this.IgnoreResizeEvent = true; this.Left = windowRectBeforeFullScreen.Left; this.Top = windowRectBeforeFullScreen.Top; this.Width = windowRectBeforeFullScreen.Width; this.Height = windowRectBeforeFullScreen.Height; this.IgnoreResizeEvent = false; Setting.TempProfile.IsFullScreenMode.Value = false; FullScreenBase_TopLeft.Visibility = Visibility.Hidden; FullScreenBase_BottomRight.Visibility = Visibility.Hidden; UpdateMainWindowView(); // システムアイコン変更 SystemButton_Maximize_Image.Source = new BitmapImage(new Uri("Resources/maximize.png", UriKind.Relative)); // 拡大パネル if (TileExpantionPanel.IsShowing) { TileExpantionPanel.FitToMainWindow(); } } else { // フルスクリーン開始 windowRectBeforeFullScreen = new Rect(Left, Top, Width, Height); // このウインドウと一番重なりが大きいモニターのサイズを取得 Rect rcMonitor = Win32.GetScreenRectFromRect(new Rect(Left, Top, Width, Height)); // サイズ変更 this.IgnoreResizeEvent = true; this.Left = rcMonitor.Left; this.Top = rcMonitor.Top; this.Width = rcMonitor.Width; this.Height = rcMonitor.Height; this.IgnoreResizeEvent = false; // 適切なコンテナの位置と、拡大率を指定する UpdateFullScreenView(); Setting.TempProfile.IsFullScreenMode.Value = true; this.ResizeGrip.Visibility = Visibility.Hidden; // システムアイコン変更 SystemButton_Maximize_Image.Source = new BitmapImage(new Uri("Resources/normalize.png", UriKind.Relative)); // 拡大パネル if (TileExpantionPanel.IsShowing) { TileExpantionPanel.FitToFullScreenWindow(); } } }
public void LoadUserProfile(Profile userProfile) { // 統合前のTempProfileの設定値 bool before_IsFullScreenMode = Setting.TempProfile.IsFullScreenMode.Value; // 読み込む前のファイルの履歴情報を保存 SaveHistoryItem(); // TempProfileに統合 UpdateTempProfile(); Setting.TempProfile.Marge(userProfile); Profile tp = Setting.TempProfile; // ファイルを読み込む場合は、ページ番号は初期化(有効時は除く) if (userProfile.Path.IsEnabled && !userProfile.LastPageIndex.IsEnabled) { tp.LastPageIndex.Value = 0; } // 透過有効 if (tp.AllowTransparency.Value != this.AllowsTransparency) { MainWindow mw = new MainWindow(this.Setting); mw.Show(); // InitMainWindow()でプロファイル適用 this.Close(); return; } // ウインドウ位置 if (!before_IsFullScreenMode) { this.Left = tp.WindowPos.X; this.Top = tp.WindowPos.Y; this.Width = tp.WindowSize.Width; this.Height = tp.WindowSize.Height; } else { // 既にフルスクリーン中だった場合 windowRectBeforeFullScreen = new Rect(tp.WindowPos.X, tp.WindowPos.Y, tp.WindowSize.Width, tp.WindowSize.Height); } // 画像情報の読み込み、ソート、コンテンツ初期化 if (userProfile.Path.IsEnabled) { String[] files = tp.Path.Value.ToArray(); ReadFiles(files, false); var t = ImgContainerManager.InitAllContainer(tp.LastPageIndex.Value); } else { if (userProfile.FileSortMethod.IsEnabled) { SortOnFileLoaded(); // ファイルは読み込まずにソート } var t = ImgContainerManager.InitAllContainer(tp.LastPageIndex.Value); } // 外観更新 ApplyColorAndOpacitySetting(); // 背景色と不透明度 UpdateUI(); // UI設定 UpdateToolbarViewing(); // ツールバーの見た目 this.Topmost = Setting.TempProfile.TopMost.Value; // 最前面 // フルスクリーン設定 if (userProfile.IsFullScreenMode.IsEnabled) { // UserProfile読み込み前と状態が変わらないなら、ToggleFullScreen()を呼ばない if (tp.IsFullScreenMode.Value && !before_IsFullScreenMode) { tp.IsFullScreenMode.Value = false; ToggleFullScreen(); } else if (!tp.IsFullScreenMode.Value && before_IsFullScreenMode) { tp.IsFullScreenMode.Value = true; ToggleFullScreen(); } } // 拡大中だったら、閉じる if (TileExpantionPanel.IsShowing) { TileExpantionPanel.Hide(); } // 自動再生 if (tp.SlideShowAutoStart.Value) { ImgContainerManager.StartSlideShow(false); } // 読み込み完了メッセージ NotificationBlock.Show("プロファイルのロード完了: " + userProfile.Name, NotificationPriority.High, NotificationTime.Short, NotificationType.None); }
private void InitEvent() { this.SourceInitialized += (s, e) => { // ウインドウ位置復元が正常に行われたかチェック Win32.SetWindowPosProperly(new WindowInteropHelper(this).Handle, (int)this.Left, (int)this.Top, true, 0, true); }; this.SizeChanged += (s, e) => { // 以下の処理は、ウインドウ枠ドラッグでのサイズ変更時のみ有効 if (IgnoreResizeEvent) { return; } // 画像拡大パネルのサイズ更新、拡大中ならリセット if (TileExpantionPanel.IsShowing) { TileExpantionPanel.FitToMainWindow(); } // アス比非固定時 if (Setting.TempProfile.NonFixAspectRatio.Value) { // 現在のプロファイル Profile pf = Setting.TempProfile; // タイルサイズ(アス比)の決定 double w = (this.Width - MainContent.Margin.Left * 2) / pf.NumofMatrix.Col; double h = (this.Height - MainContent.Margin.Left * 2) / pf.NumofMatrix.Row; double gridRatio = h / w; int gridWidth = ImgContainer.StandardInnerTileWidth + pf.TilePadding.Value * 2; int gridHeight = (int)(gridWidth * gridRatio); pf.AspectRatio.Value = new int[] { ImgContainer.StandardInnerTileWidth, gridHeight - pf.TilePadding.Value * 2 }; // コンテナサイズの決定 ImgContainerManager.InitContainerSize(); ImgContainerManager.InitWrapPoint(pf.SlideDirection.Value); // BitmapDecodePixelOfTilewを更新 ImgContainerManager.InitBitmapDecodePixelOfTile(); // 位置を正規化 ImgContainerManager.InitContainerPos(); } // アス比固定・非固定に関わらず拡大縮小 FitMainContentToWindow(); }; this.Closing += (s, e) => { ShortcutManager.UnhookWindowsHook(); }; this.PreviewDragOver += (s, e) => { if (e.Data.GetDataPresent(DataFormats.FileDrop, true)) { e.Effects = DragDropEffects.All; } else { e.Effects = DragDropEffects.None; } e.Handled = true; }; this.Drop += (s, e) => { SaveHistoryItem(); // メインウインドウをアクティブに this.Activate(); string[] files = e.Data.GetData(DataFormats.FileDrop) as string[]; if (IsCtrlOrShiftKeyPressed) { // 追加読み込み ReadFiles(files, true); var t = ImgContainerManager.InitAllContainer(0); } else { // 通常読み込み DropNewFiles(files); } }; // end of method }