Example #1
0
        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();
                }
            }
        }
Example #2
0
        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
        }