Exemplo n.º 1
0
        private Rect[] AssignCells(Thumbnail[] thumbs, Rect[] cells)
        {
            var scale = GetScale(thumbs);
            var count = cells.Length;
            var assigned = new Rect[count];
            var cellList = new List<Rect>(cells);
            var thumbList = new List<Thumbnail>(thumbs);
            Array.Sort(thumbs, (a,b) => {
                return (int) a.SourceHandle - (int) b.SourceHandle;
            });
            foreach (var thumb in thumbs)
            {
                // note: GetClosestCell sorts cellList
                var cell = GetClosestCell(cellList, GetScaledRect(scale, thumb.WindowRect));
                cellList.Remove(cell);

                var index = thumbList.IndexOf(thumb);
                assigned[index] = cell;
            }
            return assigned;
        }
Exemplo n.º 2
0
        public ThumbnailBorder(Thumbnail thumb)
        {
            Thumb = thumb;
            ShowStoryboard = new Storyboard();
            HighlightStoryBoard = new Storyboard();

            IsVisibleChanged += (sender, e) => thumb.Visible = IsVisible;

            TitleBlock = new TextBlock();
            TitleBlock.Foreground = Brushes.White;
            TitleBlock.TextAlignment = TextAlignment.Center;
            TitleBlock.TextWrapping = TextWrapping.WrapWithOverflow;
            TitleBlock.Opacity = 0;
            Children.Add(TitleBlock);

            BorderElement = new Border();
            BorderElement.BorderBrush = Brushes.Black;
            BorderElement.CornerRadius = new CornerRadius(5);
            BorderElement.BorderThickness = new Thickness(10);
            BorderElement.Opacity = 0;
            Children.Add(BorderElement);
        }
Exemplo n.º 3
0
 public void AddThumbnail(Thumbnail thumb)
 {
     var border = new ThumbnailBorder(thumb);
     ThumbnailCanvas.Children.Add(border);
 }
Exemplo n.º 4
0
 public Rect[] Layout(Thumbnail[] thumbs)
 {
     var cells = GetCells(thumbs.Count());
     return AssignCells(thumbs, cells);
 }
Exemplo n.º 5
0
        private double GetScale(Thumbnail[] thumbs)
        {
            var total = new Rect();
            foreach (var thumb in thumbs)
            {
                total = Rect.Union(total, thumb.WindowRect);
            }

            return Math.Min(total.Width / Area.Width, total.Height / Area.Height);
        }
Exemplo n.º 6
0
 private void AddThumbnail(IntPtr winHandle)
 {
     var thumb = new Thumbnail(Handle, winHandle);
     var count = MainCanvas.Children.Count;
     for (var i = 0; i < count; i++)
     {
         var screen = (Screen)MainCanvas.Children[i];
         if (thumb.InMonitor(screen.TargetMonitor))
         {
             screen.AddThumbnail(thumb);
             screen.Update();
         }
     }
 }