コード例 #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);
        }
コード例 #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);
        }
コード例 #3
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();
        }