Esempio n. 1
0
        private void Thumbnail_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (e.Delta == 0)
            {
                return;
            }

            Thumbnail thumbnail = sender as Thumbnail;

            if (thumbnail == null)
            {
                return;
            }

            if (e.Delta > 0)
            {
                thumbnail.Scale += ScaleDelta;
            }
            else
            {
                thumbnail.Scale = Math.Max(ScaleDelta, thumbnail.Scale - ScaleDelta);
            }
        }
Esempio n. 2
0
        private void SetContextMenu(Thumbnail thumbnail)
        {
            ContextMenu contextMenu = new ContextMenu();

            MenuItem toggleItem = new MenuItem()
            {
                Header      = Globalization.UIMessages.ToggleClientOnlyMenuItem,
                IsCheckable = true,
            };
            Binding checkedBinding = new Binding("IsChecked")
            {
                Source = toggleItem,
            };

            thumbnail.SetBinding(Thumbnail.ClientAreaOnlyProperty, checkedBinding);
            contextMenu.Items.Add(toggleItem);

            MenuItem selectorItem = new MenuItem()
            {
                Header = Globalization.UIMessages.SelectRegionMenuItem,
            };
            Binding enabledBinding = new Binding("IsEnabled")
            {
                Source    = selectorItem,
                Converter = Converters.BooleanToggleConverter.Instance,
                Mode      = BindingMode.OneWayToSource,
            };

            toggleItem.SetBinding(MenuItem.IsCheckedProperty, enabledBinding);
            selectorItem.Click += (sender, e) =>
            {
                Rect           region   = thumbnail.DrawnRegion;
                RegionSelector selector = new RegionSelector();
                selector.thumbnail.Scale          = Math.Min(RegionSelector.ViewerWidth / region.Width, RegionSelector.ViewerHeight / region.Height);
                selector.thumbnail.ClientAreaOnly = thumbnail.ClientAreaOnly;
                selector.Loaded += (a, b) =>
                {
                    selector.Background = Brushes.Transparent;
                    selector.ExtendFrame(RegionSelector.AeroRegion, Colors.Transparent);
                    selector.thumbnail.SetWindow(thumbnail.Target);
                    selector.SourceX      = region.X;
                    selector.SourceY      = region.Y;
                    selector.SourceWidth  = region.Width;
                    selector.SourceHeight = region.Height;
                };
                selector.ContentRendered += (a, b) =>
                {
                    selector.thumbnail.DrawnRegion = region;
                };
                if (selector.ShowDialog().GetValueOrDefault(false) == true)
                {
                    thumbnail.DrawnRegion = selector.thumbnail.DrawnRegion;
                }
            };
            contextMenu.Items.Add(selectorItem);

            contextMenu.Items.Add(new Separator());

            MenuItem removeItem = new MenuItem()
            {
                Header = Globalization.UIMessages.RemoveMenuItem,
            };

            removeItem.Click += (sender, e) =>
            {
                thumbnail.Dispose();
                canvas.Children.Remove(thumbnail);
            };
            contextMenu.Items.Add(removeItem);

            thumbnail.ContextMenu = contextMenu;
        }
Esempio n. 3
0
 private void BringToFront(Thumbnail thumbnail)
 {
     thumbnail.BringToFront();
     canvas.Children.Remove(thumbnail);
     canvas.Children.Add(thumbnail);
 }