Example #1
0
        private void RootContainer_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (_locatorTcs != null)
            {
                var rootContainer = (FrameworkElement)sender;
                var pos           = e.GetPosition(rootContainer);
                var pixelSize     = WpfUnitsConversion.ToPixels(rootContainer as Visual, pos);

                var result = LocatorResult.CreateClicked((int)pixelSize.X, (int)pixelSize.Y);
                EndLocatorMode(result);
            }
        }
Example #2
0
        private void PlotWindowPane_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
        {
            var unadjustedPixelSize = WpfUnitsConversion.ToPixels(Content as Visual, e.NewSize);

            // If the window gets below a certain minimum size, plot to the minimum size
            // and user will be able to use scrollbars to see the whole thing
            int pixelWidth  = Math.Max((int)unadjustedPixelSize.Width, MinPixelWidth);
            int pixelHeight = Math.Max((int)unadjustedPixelSize.Height, MinPixelHeight);

            // Throttle resize requests since we get a lot of size changed events when the tool window is undocked
            IdleTimeAction.Cancel(this);
            IdleTimeAction.Create(() => {
                PlotContentProvider.DoNotWait(_plotHistory.PlotContentProvider.ResizePlotAsync(pixelWidth, pixelHeight));
            }, 100, this);
        }
Example #3
0
        protected override Size MeasureOverride(Size constraint)
        {
            BitmapImage bmp = this.Source as BitmapImage;

            if (bmp != null)
            {
                // WPF assumes that your code doesn't have special dpi handling
                // and automatically sizes bitmaps to avoid them being too
                // small when running at high dpi.
                // We prevent that scaling by calculating a size based on
                // pixel size and dpi setting.
                Size bitmapSize = new Size(bmp.PixelWidth, bmp.PixelHeight);
                return(WpfUnitsConversion.FromPixels(this, bitmapSize));
            }
            return(base.MeasureOverride(constraint));
        }