コード例 #1
0
 public void Hide()
 {
     if (IconControl is GridIconControl)
     {
         IconControl = null;
         (Resources["HideAnimation"] as Storyboard).Begin();
     }
 }
コード例 #2
0
 public void Hide()
 {
     if (IconControl is GridIconControl)
     {
         IconControl = null;
         (Resources["HideAnimation"] as Storyboard).Begin();
     }
 }
コード例 #3
0
        public void Popup(GridIconControl icon)
        {
            if ((!Config.HoverTextEnabled) || (App.ViewMode != App.ViewModeEnum.Grid))
            {
                return;
            }

            (Resources["HideAnimation"] as Storyboard).Stop();
            if (IsVisible)
            {
                (Resources["KeepPopupAnimation"] as Storyboard).Begin();
                if (IconControl == icon)
                {
                    return;
                }
            }
            else
            {
                (Resources["PopupAnimation"] as Storyboard).Begin();
            }

            IconControl = icon;

            lbTitle.Text = IconControl.Title;

            var size = App.MeasureTextSize(lbTitle.Text, lbTitle.FontFamily, lbTitle.FontStyle, lbTitle.FontWeight, lbTitle.FontStretch, lbTitle.FontSize);

            size.Width  += Border.Padding.Left + Border.Padding.Right;
            size.Height += Border.Padding.Top + Border.Padding.Bottom;

            var bounds = IconControl.TransformToAncestor((App.Current.MainWindow as GridView).GridContent).TransformBounds(new Rect(0, 0, IconControl.ActualWidth, IconControl.ActualHeight));

            var top  = bounds.Top + IconControl.IconSize + 2 - Border.Padding.Top;
            var left = bounds.Left + (bounds.Width - size.Width) / 2;

            if (left + size.Width > (App.Current.MainWindow as GridView).wpContent.ActualWidth)
            {
                left -= left + size.Width - (App.Current.MainWindow as GridView).wpContent.ActualWidth;
            }
            if (left < 0)
            {
                left = 0;
            }
            Margin = new Thickness(left, top, 0, 0);
        }
コード例 #4
0
        public void Popup(GridIconControl icon)
        {
            if ((!Config.HoverTextEnabled) || (App.ViewMode != App.ViewModeEnum.Grid))
            {
                return;
            }

            (Resources["HideAnimation"] as Storyboard).Stop();
            if (IsVisible)
            {
                (Resources["KeepPopupAnimation"] as Storyboard).Begin();
                if (IconControl == icon)
                {
                    return;
                }
            }
            else
            {
                (Resources["PopupAnimation"] as Storyboard).Begin();
            }

            IconControl = icon;

            lbTitle.Text = IconControl.Title;
            
            var size = App.MeasureTextSize(lbTitle.Text, lbTitle.FontFamily, lbTitle.FontStyle, lbTitle.FontWeight, lbTitle.FontStretch, lbTitle.FontSize);
            size.Width += Border.Padding.Left + Border.Padding.Right;
            size.Height += Border.Padding.Top + Border.Padding.Bottom;

            var bounds = IconControl.TransformToAncestor((App.Current.MainWindow as GridView).GridContent).TransformBounds(new Rect(0, 0, IconControl.ActualWidth, IconControl.ActualHeight));

            var top = bounds.Top + IconControl.IconSize + 2 - Border.Padding.Top;
            var left = bounds.Left + (bounds.Width - size.Width) / 2;
            if (left + size.Width > (App.Current.MainWindow as GridView).wpContent.ActualWidth)
            {
                left -= left + size.Width - (App.Current.MainWindow as GridView).wpContent.ActualWidth;
            }
            if (left < 0)
            {
                left = 0;
            }
            Margin = new Thickness(left, top, 0, 0);
        }
コード例 #5
0
 public void MoveHover(GridIconControl icon)
 {
     if (Config.HoverEnabled)
     {
         if (Hover.Opacity == 0)
         {
             var anim = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(Config.HoverPopupDelay)));
             Hover.BeginAnimation(OpacityProperty, anim);
         }
         else
         {
             Hover.BeginAnimation(OpacityProperty, null);
             Hover.Opacity = 1;
         }
         var bounds = icon.TransformToAncestor(wpContent).TransformBounds(new Rect(0, 0, icon.ActualWidth, icon.ActualHeight));
         var anim2 = new ThicknessAnimation(Hover.Margin, new Thickness(bounds.Left - 3, bounds.Top - 3, 0, 0), new Duration(TimeSpan.FromMilliseconds(Config.HoverMoveDealy)));
         anim2.AccelerationRatio = 0.2;
         Hover.BeginAnimation(MarginProperty, null);
         Hover.BeginAnimation(MarginProperty, anim2);
     }
 }
コード例 #6
0
 public void MoveHover(GridIconControl icon)
 {
     if (Config.HoverEnabled)
     {
         if (Hover.Opacity == 0)
         {
             var anim = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(Config.HoverPopupDelay)));
             Hover.BeginAnimation(OpacityProperty, anim);
         }
         else
         {
             Hover.BeginAnimation(OpacityProperty, null);
             Hover.Opacity = 1;
         }
         var bounds = icon.TransformToAncestor(wpContent).TransformBounds(new Rect(0, 0, icon.ActualWidth, icon.ActualHeight));
         var anim2  = new ThicknessAnimation(Hover.Margin, new Thickness(bounds.Left - 3, bounds.Top - 3, 0, 0), new Duration(TimeSpan.FromMilliseconds(Config.HoverMoveDealy)));
         anim2.AccelerationRatio = 0.2;
         Hover.BeginAnimation(MarginProperty, null);
         Hover.BeginAnimation(MarginProperty, anim2);
     }
 }
コード例 #7
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            Hover.Width = Config.IconSize + 16 * 2 + 6;
            Hover.Height = Config.IconSize + 20 + 6;

            wpContent.Children.Clear();

            btnBack.Visibility = Visibility.Collapsed;
            if (App.Path.LastIndexOf('\\') > 2)
            {
                btnBack.Visibility = Visibility.Visible;
            }

            var i = App.Path.LastIndexOf('\\');
            lbTitle.Text = App.Path;
            if (i >= 0)
            {
                if (i == App.Path.Length - 1)
                {
                    lbTitle.Text = lbTitle.Text.Remove(i);
                    i = lbTitle.Text.LastIndexOf('\\');
                    if (i >= 0)
                    {
                        lbTitle.Text = lbTitle.Text.Remove(0, i + 1);
                    }
                }
                else
                {
                    lbTitle.Text = lbTitle.Text.Remove(0, i + 1);
                }
            }

            foreach (var dir in App.Directories)
            {
                var attr = File.GetAttributes(dir);
                if ((attr & (FileAttributes.Hidden | FileAttributes.System)) == 0)
                {
                    var ctrl = new GridIconControl();
                    ctrl.IconSize = Config.IconSize;
                    ctrl.Margin = new Thickness(0, 10, 0, 10);
                    ctrl.Filename = dir;
                    wpContent.Children.Add(ctrl);
                }
            }

            foreach (var file in App.Files)
            {
                var attr = File.GetAttributes(file);
                if ((attr & (FileAttributes.Hidden | FileAttributes.System)) == 0)
                {
                    var ctrl = new GridIconControl();
                    ctrl.IconSize = Config.IconSize;
                    ctrl.Margin = new Thickness(0, 10, 0, 10);
                    ctrl.Filename = file;
                    wpContent.Children.Add(ctrl);
                }
            }

            var bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            var monitorSize = Math.Min(bounds.Width, bounds.Height);

            var cellWidth = Config.IconSize + 16 * 2;
            var cellHeight = Config.IconSize + 20 + 10 + 10;

            var cols = Config.GridMaximumCols;
            var rows = Config.GridMaximumRows;

            if (cols * rows > Math.Max(wpContent.Children.Count, 1))
            {
                var fileCount = Math.Max(wpContent.Children.Count, 1);
                if (fileCount == 1)
                {
                    cols = 1;
                    rows = 1;
                }
                else
                {
                    cols = (int)Math.Sqrt(fileCount) + 1;
                    rows = fileCount / cols;
                    if (cols * rows < fileCount)
                    {
                        cols++;
                    }
                    if (cols * rows < fileCount)
                    {
                        rows++;
                    }
                }
            }

            var rect = DockIcon.IconRect;
            switch (DockIcon.DockEdge)
            {
                case DockIcon.DockEdgeEnum.Bottom:
                    Width = 14 * 2 + 5 * 2 + cellWidth * cols + 10;
                    Height = 24 + 14 * 2 + 20 + 5 * 2 + cellHeight * rows;

                    Left = rect.Left + (rect.Width - Width) / 2;
                    Top = rect.Top - Height + 10;

                    NormalizeOffsets();

                    ArrowBackground.HorizontalAlignment = HorizontalAlignment.Center;
                    ArrowBackground.VerticalAlignment = VerticalAlignment.Bottom;
                    ArrowBackground.Margin = new Thickness(10 + OffsetX * 2, 0, 10, 0);

                    ContentBackground.Margin = new Thickness(0, 0, 0, 20);

                    AnimationPath = AnimationPathEnum.FromBottomToTop;
                    break;

                case DockIcon.DockEdgeEnum.Top:
                    Width = 14 * 2 + 5 * 2 + cellWidth * cols + 10;
                    Height = 24 + 14 * 2 + 20 + 5 * 2 + cellHeight * rows;

                    Left = rect.Left + (rect.Width - Width) / 2;
                    Top = rect.Top + rect.Height - 10;

                    NormalizeOffsets();

                    ArrowBackground.HorizontalAlignment = HorizontalAlignment.Center;
                    ArrowBackground.VerticalAlignment = VerticalAlignment.Top;
                    ArrowBackground.LayoutTransform = new RotateTransform(180);
                    ArrowBackground.Margin = new Thickness(10 + OffsetX * 2, 0, 10, 0);

                    ContentBackground.Margin = new Thickness(0, 20, 0, 0);

                    AnimationPath = AnimationPathEnum.FromTopToBottom;
                    break;

                case DockIcon.DockEdgeEnum.Left:
                    Width = 14 * 2 + 5 * 2 + 20 + cellWidth * cols + 10;
                    Height = 24 + 14 * 2 + 5 * 2 + cellHeight * rows;

                    Left = rect.Left + rect.Width - 10;
                    Top = rect.Top + (rect.Height - Height) / 2;

                    NormalizeOffsets();

                    ArrowBackground.HorizontalAlignment = HorizontalAlignment.Left;
                    ArrowBackground.VerticalAlignment = VerticalAlignment.Center;
                    ArrowBackground.LayoutTransform = new RotateTransform(90);
                    ArrowBackground.Margin = new Thickness(0, 10 + OffsetY * 2, 0, 10);

                    ContentBackground.Margin = new Thickness(20, 0, 0, 0);

                    AnimationPath = AnimationPathEnum.FromLeftToRight;
                    break;

                case DockIcon.DockEdgeEnum.Right:
                    Width = 14 * 2 + 5 * 2 + 20 + cellWidth * cols + 10;
                    Height = 24 + 14 * 2 + 5 * 2 + cellHeight * rows;

                    Left = rect.Left - Width + 10;
                    Top = rect.Top + (rect.Height - Height) / 2;

                    NormalizeOffsets();

                    ArrowBackground.HorizontalAlignment = HorizontalAlignment.Right;
                    ArrowBackground.VerticalAlignment = VerticalAlignment.Center;
                    ArrowBackground.LayoutTransform = new RotateTransform(-90);
                    ArrowBackground.Margin = new Thickness(0, 10 + OffsetY * 2, 0, 10);

                    ContentBackground.Margin = new Thickness(0, 0, 20, 0);

                    AnimationPath = AnimationPathEnum.FromRightToLeft;
                    break;
            }
        }
コード例 #8
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            Hover.Width  = Config.IconSize + 16 * 2 + 6;
            Hover.Height = Config.IconSize + 20 + 6;

            wpContent.Children.Clear();

            btnBack.Visibility = Visibility.Collapsed;
            if (App.Path.LastIndexOf('\\') > 2)
            {
                btnBack.Visibility = Visibility.Visible;
            }

            var i = App.Path.LastIndexOf('\\');

            lbTitle.Text = App.Path;
            if (i >= 0)
            {
                if (i == App.Path.Length - 1)
                {
                    lbTitle.Text = lbTitle.Text.Remove(i);
                    i            = lbTitle.Text.LastIndexOf('\\');
                    if (i >= 0)
                    {
                        lbTitle.Text = lbTitle.Text.Remove(0, i + 1);
                    }
                }
                else
                {
                    lbTitle.Text = lbTitle.Text.Remove(0, i + 1);
                }
            }

            foreach (var dir in App.Directories)
            {
                var attr = File.GetAttributes(dir);
                if ((attr & (FileAttributes.Hidden | FileAttributes.System)) == 0)
                {
                    var ctrl = new GridIconControl();
                    ctrl.IconSize = Config.IconSize;
                    ctrl.Margin   = new Thickness(0, 10, 0, 10);
                    ctrl.Filename = dir;
                    wpContent.Children.Add(ctrl);
                }
            }

            foreach (var file in App.Files)
            {
                var attr = File.GetAttributes(file);
                if ((attr & (FileAttributes.Hidden | FileAttributes.System)) == 0)
                {
                    var ctrl = new GridIconControl();
                    ctrl.IconSize = Config.IconSize;
                    ctrl.Margin   = new Thickness(0, 10, 0, 10);
                    ctrl.Filename = file;
                    wpContent.Children.Add(ctrl);
                }
            }

            var bounds      = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            var monitorSize = Math.Min(bounds.Width, bounds.Height);

            var cellWidth  = Config.IconSize + 16 * 2;
            var cellHeight = Config.IconSize + 20 + 10 + 10;

            var cols = Config.GridMaximumCols;
            var rows = Config.GridMaximumRows;

            if (cols * rows > Math.Max(wpContent.Children.Count, 1))
            {
                var fileCount = Math.Max(wpContent.Children.Count, 1);
                if (fileCount == 1)
                {
                    cols = 1;
                    rows = 1;
                }
                else
                {
                    cols = (int)Math.Sqrt(fileCount) + 1;
                    rows = fileCount / cols;
                    if (cols * rows < fileCount)
                    {
                        cols++;
                    }
                    if (cols * rows < fileCount)
                    {
                        rows++;
                    }
                }
            }

            var rect = DockIcon.IconRect;

            switch (DockIcon.DockEdge)
            {
            case DockIcon.DockEdgeEnum.Bottom:
                Width  = 14 * 2 + 5 * 2 + cellWidth * cols + 10;
                Height = 24 + 14 * 2 + 20 + 5 * 2 + cellHeight * rows;

                Left = rect.Left + (rect.Width - Width) / 2;
                Top  = rect.Top - Height + 10;

                NormalizeOffsets();

                ArrowBackground.HorizontalAlignment = HorizontalAlignment.Center;
                ArrowBackground.VerticalAlignment   = VerticalAlignment.Bottom;
                ArrowBackground.Margin = new Thickness(10 + OffsetX * 2, 0, 10, 0);

                ContentBackground.Margin = new Thickness(0, 0, 0, 20);

                AnimationPath = AnimationPathEnum.FromBottomToTop;
                break;

            case DockIcon.DockEdgeEnum.Top:
                Width  = 14 * 2 + 5 * 2 + cellWidth * cols + 10;
                Height = 24 + 14 * 2 + 20 + 5 * 2 + cellHeight * rows;

                Left = rect.Left + (rect.Width - Width) / 2;
                Top  = rect.Top + rect.Height - 10;

                NormalizeOffsets();

                ArrowBackground.HorizontalAlignment = HorizontalAlignment.Center;
                ArrowBackground.VerticalAlignment   = VerticalAlignment.Top;
                ArrowBackground.LayoutTransform     = new RotateTransform(180);
                ArrowBackground.Margin = new Thickness(10 + OffsetX * 2, 0, 10, 0);

                ContentBackground.Margin = new Thickness(0, 20, 0, 0);

                AnimationPath = AnimationPathEnum.FromTopToBottom;
                break;

            case DockIcon.DockEdgeEnum.Left:
                Width  = 14 * 2 + 5 * 2 + 20 + cellWidth * cols + 10;
                Height = 24 + 14 * 2 + 5 * 2 + cellHeight * rows;

                Left = rect.Left + rect.Width - 10;
                Top  = rect.Top + (rect.Height - Height) / 2;

                NormalizeOffsets();

                ArrowBackground.HorizontalAlignment = HorizontalAlignment.Left;
                ArrowBackground.VerticalAlignment   = VerticalAlignment.Center;
                ArrowBackground.LayoutTransform     = new RotateTransform(90);
                ArrowBackground.Margin = new Thickness(0, 10 + OffsetY * 2, 0, 10);

                ContentBackground.Margin = new Thickness(20, 0, 0, 0);

                AnimationPath = AnimationPathEnum.FromLeftToRight;
                break;

            case DockIcon.DockEdgeEnum.Right:
                Width  = 14 * 2 + 5 * 2 + 20 + cellWidth * cols + 10;
                Height = 24 + 14 * 2 + 5 * 2 + cellHeight * rows;

                Left = rect.Left - Width + 10;
                Top  = rect.Top + (rect.Height - Height) / 2;

                NormalizeOffsets();

                ArrowBackground.HorizontalAlignment = HorizontalAlignment.Right;
                ArrowBackground.VerticalAlignment   = VerticalAlignment.Center;
                ArrowBackground.LayoutTransform     = new RotateTransform(-90);
                ArrowBackground.Margin = new Thickness(0, 10 + OffsetY * 2, 0, 10);

                ContentBackground.Margin = new Thickness(0, 0, 20, 0);

                AnimationPath = AnimationPathEnum.FromRightToLeft;
                break;
            }
        }