Example #1
0
        public ImageFileContext GetImageFileContextUnderCursor()
        {
            Border border = GetBorderUnderCursor();

            if (border == null)
            {
                return(null);
            }

            ImgContainer parentContainer = WpfTreeUtil.FindAncestor <ImgContainer>(border);

            if (parentContainer == null)
            {
                return(null);
            }
            int idx = parentContainer.MainGrid.Children.IndexOf(border);
            ImageFileContext targetImgFileContext = parentContainer.ImageFileContextMapList[idx];

            return(targetImgFileContext);
        }
Example #2
0
        public Border GetBorderUnderCursor()
        {
            // MainWindow上の座標取得
            Point p = Mouse.GetPosition(this);

            // カーソル下のオブジェクトを取得
            //VisualTreeHelper.HitTest(mw, null, new HitTestResultCallback(OnHitTestResultCallback), new PointHitTestParameters(p));
            IInputElement    ie     = this.InputHitTest(p);
            DependencyObject source = ie as DependencyObject;

            if (source == null)
            {
                return(null);
            }

            Debug.WriteLine("source : " + source.ToString());

            // 拡大時は1つしか候補が無い
            if (TileExpantionPanel.IsShowing)
            {
                return(TileExpantionPanel.TargetBorder);
            }

            // クリックされたBorder
            Border border;

            if (source is Border)
            {
                border = source as Border;
            }
            else
            {
                border = WpfTreeUtil.FindAncestor <Border>(source);
            }
            if (border == null)
            {
                return(null);
            }

            return(border);
        }
        /// <summary>
        /// プロファイルの「有効・無効」をチェックボックスへ入力
        /// </summary>
        private void SetProfileMembaersWhetherEnabled()
        {
            if (Mode == ProfileEditDialogMode.New)
            {
                // 新規作成の場合
                //bool b = false;
                WpfTreeUtil.OperateLogicalChildren(MainStackPanel, obj =>
                {
                    CheckBox cb = obj as CheckBox;
                    if (cb != null)
                    {
                        //if( cb == this.PfCheckBox_AllowTransparency ) b = true;
                        //if( b ) cb.IsChecked = false; // 「外観」以降にはチェックを入れない
                        //else cb.IsChecked = true;

                        cb.IsChecked = false;
                    }
                });
            }
            else if (Mode == ProfileEditDialogMode.Edit)
            {
                // 編集の場合
                WpfTreeUtil.OperateLogicalChildren(MainStackPanel, obj =>
                {
                    CheckBox cb = obj as CheckBox;
                    if (cb != null)
                    {
                        cb.IsChecked = false;
                    }
                });

                Profile pf = EditingUserProfileInfo.Profile;

                // ウインドウの状態
                if (pf.WindowPos.IsEnabled)
                {
                    PfCheckBox_WinPos.IsChecked = true;
                }
                if (pf.WindowSize.IsEnabled)
                {
                    PfCheckBox_WinSize.IsChecked = true;
                }
                if (pf.IsFullScreenMode.IsEnabled)
                {
                    PfCheckBox_IsFullScreenMode.IsChecked = true;
                }
                // 読み込み
                if (pf.Path.IsEnabled)
                {
                    PfCheckBox_Path.IsChecked = true;
                }
                if (pf.LastPageIndex.IsEnabled)
                {
                    PfCheckBox_LastPageIndex.IsChecked = true;
                }
                // 列数・行数
                if (pf.NumofMatrix.IsEnabled)
                {
                    PfCheckBox_NumofMatrix.IsChecked = true;
                }
                // グリッドのアスペクト比
                if (pf.NonFixAspectRatio.IsEnabled)
                {
                    PfCheckBox_FixAspectRatio.IsChecked = true;
                }
                if (pf.AspectRatio.IsEnabled)
                {
                    PfCheckBox_AspectRatio.IsChecked = true;
                }
                // スライド
                if (pf.SlidePlayMethod.IsEnabled)
                {
                    PfCheckBox_SlidePlayMethod.IsChecked = true;
                }
                if (pf.SlideDirection.IsEnabled)
                {
                    PfCheckBox_SlideDirection.IsChecked = true;
                }
                // スライドショー詳細
                if (pf.SlideSpeed.IsEnabled)
                {
                    PfCheckBox_SlideSpeed.IsChecked = true;
                }
                if (pf.SlideInterval.IsEnabled)
                {
                    PfCheckBox_SlideInterval.IsChecked = true;
                }
                if (pf.SlideTimeInIntevalMethod.IsEnabled)
                {
                    PfCheckBox_SlideTimeInIntevalMethod.IsChecked = true;
                }
                if (pf.SlideByOneImage.IsEnabled)
                {
                    PfCheckBox_SlideByOneImage.IsChecked = true;
                }
                if (pf.SlideShowAutoStart.IsEnabled)
                {
                    PfCheckBox_SlideShowAutoStart.IsChecked = true;
                }
                // その他/全般
                if (pf.TopMost.IsEnabled)
                {
                    PfCheckBox_TopMost.IsChecked = true;
                }
                if (pf.FileSortMethod.IsEnabled)
                {
                    PfCheckBox_FileSortMethod.IsChecked = true;
                }
                if (pf.ApplyRotateInfoFromExif.IsEnabled)
                {
                    PfCheckBox_ApplyRotateInfoFromExif.IsChecked = true;
                }
                if (pf.BitmapDecodeTotalPixel.IsEnabled)
                {
                    PfCheckBox_BitmapDecodeTotalPixel.IsChecked = true;
                }
                if (pf.DetectionOfSpread.IsEnabled)
                {
                    PfCheckBox_DetectionOfSpread.IsChecked = true;
                }
                // その他/配置
                if (pf.UseDefaultTileOrigin.IsEnabled)
                {
                    PfCheckBox_UseDefaultTileOrigin.IsChecked = true;
                }
                if (pf.TileOrigin.IsEnabled)
                {
                    PfCheckBox_TileOrigin.IsChecked = true;
                }
                if (pf.TileOrientation.IsEnabled)
                {
                    PfCheckBox_TileOrientation.IsChecked = true;
                }
                if (pf.TileImageStretch.IsEnabled)
                {
                    PfCheckBox_TileImageStretch.IsChecked = true;
                }
                // その他/外観1
                if (pf.AllowTransparency.IsEnabled)
                {
                    PfCheckBox_AllowTransparency.IsChecked = true;
                }
                if (pf.OverallOpacity.IsEnabled)
                {
                    PfCheckBox_OverallOpacity.IsChecked = true;
                }
                if (pf.BackgroundOpacity.IsEnabled)
                {
                    PfCheckBox_BackgroundOpacity.IsChecked = true;
                }
                if (pf.BaseGridBackgroundColor.IsEnabled)
                {
                    PfCheckBox_BaseGridBackgroundColor.IsChecked = true;
                }
                if (pf.UsePlaidBackground.IsEnabled)
                {
                    PfCheckBox_UsePlaidBackground.IsChecked = true;
                }
                if (pf.PairColorOfPlaidBackground.IsEnabled)
                {
                    PfCheckBox_PairColorOfPlaidBackground.IsChecked = true;
                }
                // その他/外観2
                if (pf.ResizeGripThickness.IsEnabled)
                {
                    PfCheckBox_ResizeGripThickness.IsChecked = true;
                }
                if (pf.ResizeGripColor.IsEnabled)
                {
                    PfCheckBox_ResizeGripColor.IsChecked = true;
                }
                if (pf.TilePadding.IsEnabled)
                {
                    PfCheckBox_TilePadding.IsChecked = true;
                }
                if (pf.GridLineColor.IsEnabled)
                {
                    PfCheckBox_GridLineColor.IsChecked = true;
                }
            }
        }
Example #4
0
        public async Task Show(Border border)
        {
            // まだ拡大パネルを閉じるアニメーション中
            if (!IsAnimationCompleted)
            {
                return;
            }

            // ターゲット
            this.TargetBorder    = border;
            this.ParentContainer = WpfTreeUtil.FindAncestor <ImgContainer>(border);
            if (ParentContainer == null)
            {
                return;
            }
            int idx = ParentContainer.MainGrid.Children.IndexOf(border);

            this.TargetImgFileContext = ParentContainer.ImageFileContextMapList[idx];

            // 画像変更フラグ初期化
            this.isImageFileChanged = false;

            // 設定プロファイル
            Profile pf = MainWindow.Setting.TempProfile;

            // ダミーをクリックした時
            if (TargetImgFileContext.IsDummy)
            {
                return;
            }

            // 再生中だったら、レジュームの準備
            if (MainWindow.IsPlaying)
            {
                MainWindow.ImgContainerManager.StopSlideShow(false);
                ExpandedDuringPlay = true;
            }
            else
            {
                ExpandedDuringPlay = false;
            }

            // タイル画像をコピー
            ExpandedImage.Source = TargetImgFileContext.BitmapImage;
            if (ExpandedImage.Source == null)
            {
                return;
            }

            // ボーダー色、背景色
            ExpandedBorder.BorderBrush = new SolidColorBrush(pf.GridLineColor.Value);
            if (pf.UsePlaidBackground.Value)
            {
                ExpandedBorder.Background = Util.CreatePlaidBrush(
                    pf.BaseGridBackgroundColor.Value, pf.PairColorOfPlaidBackground.Value);
            }
            else
            {
                ExpandedBorder.Background = new SolidColorBrush(pf.BaseGridBackgroundColor.Value);
            }

            // 表示
            this.Visibility = Visibility.Visible;

            // 表示済みフラグ
            IsShowing = true;

            // ファイル情報のテキストを更新
            UpdateFileInfoText();

            // ファイルパスのテキストを更新
            //UpdateFilePathText();

            // 外部プログラムで開くボタンのツールチップ
            Toolbar_OpenByExternalApp.ToolTip = "規定のプログラムで画像を開く";
            if (MainWindow.Setting.ExternalAppInfoList.Count > 0)
            {
                string appName = MainWindow.Setting.ExternalAppInfoList[0].GetAppName();
                if (appName != null)
                {
                    Toolbar_OpenByExternalApp.ToolTip = appName + "で画像を開く";
                }
            }

            // 現在のTileContainerの拡大率
            double containerScale = MainWindow.MainContent.LayoutTransform.Value.M11;

            // タイルの矩形を取得し位置を合わせる
            Rect rc = GetTileRect();

            this.Width  = rc.Width;
            this.Height = rc.Height;
            this.Margin = new Thickness(rc.Left, rc.Top, 0, 0);

            // 列数・行数が1のときは、視覚効果を出すために初期値調整
            if (ParentContainer.NumofGrid == 1)
            {
                this.Width  = rc.Width - 20;
                this.Height = rc.Height - 20;
                this.Margin = new Thickness(rc.Left + 10, rc.Top + 10, 0, 0);
            }

            // タイル拡大パネルの枠の太さ(拡大前)
            ExpandedBorder.BorderThickness =
                new Thickness(pf.TilePadding.Value * containerScale);

            #region アニメーション準備
            // 拡大アニメーション(パネル自体)
            // --------------------------------------------------------
            storyboard = new Storyboard();
            double duration = 0.2;

            var a1 = new ThicknessAnimation(); // Margin
            Storyboard.SetTarget(a1, this);
            Storyboard.SetTargetProperty(a1, new PropertyPath(TileExpantionPanel.MarginProperty));
            Point mcMargin = new Point( // メインコンテンツのマージン
                MainWindow.MainContent.Margin.Left, MainWindow.MainContent.Margin.Top);
            a1.From     = this.Margin;
            a1.To       = new Thickness(0 + mcMargin.X, 0 + mcMargin.Y, 0, 0);
            a1.Duration = TimeSpan.FromSeconds(duration);
            storyboard.Children.Add(a1);

            var a2 = new DoubleAnimation(); // Width
            Storyboard.SetTarget(a2, this);
            Storyboard.SetTargetProperty(a2, new PropertyPath(TileExpantionPanel.WidthProperty));
            a2.From     = this.Width;
            a2.To       = MainWindow.Width - mcMargin.X * 2;
            a2.Duration = TimeSpan.FromSeconds(duration);
            storyboard.Children.Add(a2);

            var a3 = new DoubleAnimation(); // Height
            Storyboard.SetTarget(a3, this);
            Storyboard.SetTargetProperty(a3, new PropertyPath(TileExpantionPanel.HeightProperty));
            a3.From     = this.Height;
            a3.To       = MainWindow.Height - mcMargin.Y * 2;
            a3.Duration = TimeSpan.FromSeconds(duration);
            storyboard.Children.Add(a3);


            // 拡大アニメーション(枠の太さ)
            // --------------------------------------------------------

            // タイル拡大パネルの拡大率
            double panelScale = pf.NumofMatrix.Col;
            if (pf.NumofMatrix.Col > pf.NumofMatrix.Row)
            {
                panelScale = pf.NumofMatrix.Row;
            }

            var a4 = new ThicknessAnimation(); // BorderThickness
            Storyboard.SetTarget(a4, this.ExpandedBorder);
            Storyboard.SetTargetProperty(a4, new PropertyPath(Border.BorderThicknessProperty));
            a4.From     = ExpandedBorder.BorderThickness;
            a4.To       = new Thickness(ExpandedBorder.BorderThickness.Left * panelScale);
            a4.Duration = TimeSpan.FromSeconds(duration);
            storyboard.Children.Add(a4);

            storyboard.Completed += (s, e) =>
            {
                MainWindow.ImgContainerManager.Hide();
                UpdateFileInfoAreaVisiblity();
                MainWindow.UpdatePageInfo();
                IsAnimationCompleted = true;
            };
            #endregion

            // アニメーションを開始
            IsAnimationCompleted = false;
            storyboard.Begin();

            // アニメーションしながら、大きいサイズの画像をロード
            await LoadImage();
        }