Пример #1
0
 public ThumbnailLayout(Monitor monitor)
 {
     Monitor = monitor;
     WindowMargin = new Thickness(25);
     ThumbnailMargin = new Thickness(20);
     ThumbnailMargin.Bottom += TextPadding;
 }
Пример #2
0
        public Screen(Monitor monitor)
        {
            LayoutEngine = new ThumbnailLayout(monitor);

            BackdropCanvas = new Canvas();
            BackdropCanvas.Background = Brushes.Black;
            Children.Add(BackdropCanvas);

            ThumbnailCanvas = new Canvas();
            Children.Add(ThumbnailCanvas);

            AnimationStoryboard = new Storyboard();
            AnimationStoryboard.Completed += OnAnimationComplete;
            TargetMonitor = monitor;

            Height = monitor.Height;
            Width = monitor.Width;
            WindowMargin = new Thickness(Width * 0.05, Height * 0.05, Width * 0.05, Height * 0.05);
            ThumbnailMargin = new Thickness(Width * 0.02, Height * 0.02, Width * 0.02, (Height * 0.02) + TEXT_PADDING);

            SetBackgroundToMatchWallpaper();

            SizeChanged += (sender, e) =>
            {
                ThumbnailCanvas.Height = ActualHeight;
                ThumbnailCanvas.Width = ActualWidth;
                BackdropCanvas.Height = ActualHeight;
                BackdropCanvas.Width = ActualWidth;
            };

            MouseUp += (sender, e) =>
            {
                var position = e.GetPosition(this);
                var thumb = FindThumbnailBorder(t => t.TransformedThumbRect.Contains(position));
                if (thumb != null)
                {
                    thumb.ActivateWindow();
                    if (ThumbnailClicked != null)
                    {
                        ThumbnailClicked(thumb, e);
                    }
                }
            };

            MouseMove += (sender, e) =>
            {
                var position = e.GetPosition(this);
                var i = ThumbnailCanvas.Children.Count;
                while (i-- > 0)
                {
                    var thumb = (ThumbnailBorder)ThumbnailCanvas.Children[i];
                    thumb.Highlight = thumb.TransformedThumbRect.Contains(position);
                }
            };
        }
Пример #3
0
 public bool InMonitor(Monitor monitor)
 {
     return monitor.Contains(SourceHandle);
 }
Пример #4
0
 private List<Thumbnail> GetWindowThumbnailsForMonitor(Monitor monitor)
 {
     return GetWindowThumbnails().FindAll(thumbnail => thumbnail.InMonitor(monitor));
 }