Ejemplo n.º 1
0
        public ImageCaptureWindow(System.Drawing.Rectangle rect, AreaSelection areaSelection)
        {
            InitializeComponent();

            MouseUp   += OnMouseUp;
            MouseDown += OnMouseDown;
            MouseMove += OnMouseMove;
            Loaded    += OnMainWindowLoaded;
            _scalor    = DpiUtilities.GetVirtualPixelScale(this);

            _areaSelection   = areaSelection;
            _screenShotImage = new ScreenshotImage();

            _screenScalor = DpiUtilities.GetScreenScalingFactor();
            _screenShotImage.SnapShot(rect, _screenScalor);

            WindowStartupLocation = WindowStartupLocation.Manual;

            SourceInitialized += (sender, e) =>
            {
                IntPtr hWnd = new WindowInteropHelper(this).Handle;
                NativeMethods.SetWindowPos(hWnd, (IntPtr)NativeMethods.SetWindowPosInsertAfter.HWND_TOP, rect.Left, rect.Top, rect.Width, rect.Height, 0);
            };

            var bmDesktopSource = ScreenCapture.GetBitmapSource(_screenShotImage.ScreenSnapshotImage);

            BackgroundImage.Fill            = new ImageBrush(bmDesktopSource);
            MagnifierBackgroundImage.Source = bmDesktopSource;
        }
Ejemplo n.º 2
0
        private BitmapSource GetCapturedImage()
        {
            var rect = _areaSelection.GetSelectedArea();
            // decide which monitor the selected area belongs to by checking the mid point of the selected area
            var x = (rect.left + rect.width / 2);
            var y = (rect.top + rect.height / 2);

            var hMonitor = NativeMethods.MonitorFromPoint(new NativeMethods.POINT()
            {
                x = x, y = y
            }, 0);
            var curMon          = _areaSelection.ScreenProps.GetMonitorInformation(hMonitor);
            var monitorScalingX = curMon.dpiX / 96 / _screenScalor;
            var monitorScalingY = curMon.dpiY / 96 / _screenScalor;
            var dpiScaler       = new DpiScale(monitorScalingX, monitorScalingY);
            var capturedImage   = _screenShotImage.GetCaptureImage(rect, dpiScaler);

            // Copies to clipboard based on user setting
            if (UserSettings.CopyToClipboardAfterSnip)
            {
                System.Windows.Clipboard.SetImage(capturedImage);
            }

            return(capturedImage);
        }
Ejemplo n.º 3
0
        public Screen(ConsoleBuffer.Buffer buffer)
        {
            this.dpiInfo = VisualTreeHelper.GetDpi(this);
            this.cells   = new VisualCollection(this);
            this.Buffer  = buffer;

            this.cursorBlinkWatch.Start();

            CompositionTarget.Rendering += this.RenderFrame;
            this.MouseEnter             += (sender, args) =>
            {
                args.MouseDevice.OverrideCursor = Cursors.IBeam;
            };
            this.MouseLeave += (sender, args) =>
            {
                args.MouseDevice.OverrideCursor = Cursors.Arrow;
            };
            this.MouseWheel += (sender, args) =>
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    var factor = args.Delta > 0 ? 2 : -2;
                    this.SetFontSize(this.fontSizeEm + factor);
                    args.Handled = true;
                }
            };

            this.SetFontSize(14);
            this.Resize();
        }
        private IntPtr _HandleNCCalcSize(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled)
        {
            if (this._chromeInfo.NonClientFrameEdges != NonClientFrameEdges.None)
            {
                DpiScale  dpi       = this._window.GetDpi();
                Thickness thickness = DpiHelper.LogicalThicknessToDevice(SystemParameters.WindowResizeBorderThickness, dpi.DpiScaleX, dpi.DpiScaleY);
                RECT      rect      = (RECT)Marshal.PtrToStructure(lParam, typeof(RECT));
                if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 2))
                {
                    rect.Top += (int)thickness.Top;
                }
                if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 1))
                {
                    rect.Left += (int)thickness.Left;
                }
                if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 8))
                {
                    rect.Bottom -= (int)thickness.Bottom;
                }
                if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 4))
                {
                    rect.Right -= (int)thickness.Right;
                }
                Marshal.StructureToPtr(rect, lParam, false);
            }
            handled = true;
            IntPtr zero = IntPtr.Zero;

            if (wParam.ToInt32() != 0)
            {
                zero = new IntPtr(768);
            }
            return(zero);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 指定スクリーンにおけるDPIを取得する
        /// </summary>
        /// <param name="screen">スクリーン</param>
        /// <param name="dpiX">X値</param>
        /// <param name="dpiY">Y値</param>
        public static void    GetDpi(System.Windows.Forms.Screen screen, out float dpiX, out float dpiY)
        {
            DpiScale dpi = GetDpi(screen);

            dpiX = (float)dpi.PixelsPerInchX;
            dpiY = (float)dpi.PixelsPerInchY;
        }
 // Token: 0x06006D68 RID: 28008 RVA: 0x001F6988 File Offset: 0x001F4B88
 protected override Cursor GetCurrentCursor()
 {
     if (InkCanvasEditingMode.EraseByPoint == this._cachedEraseMode)
     {
         if (this._cachedPointEraserCursor == null)
         {
             this._cachedStylusShape = base.InkCanvas.EraserShape;
             Matrix tranform = base.GetElementTransformMatrix();
             if (!tranform.IsIdentity)
             {
                 if (tranform.HasInverse)
                 {
                     tranform.OffsetX = 0.0;
                     tranform.OffsetY = 0.0;
                 }
                 else
                 {
                     tranform = Matrix.Identity;
                 }
             }
             DpiScale dpi = base.InkCanvas.GetDpi();
             this._cachedPointEraserCursor = PenCursorManager.GetPointEraserCursor(this._cachedStylusShape, tranform, dpi.DpiScaleX, dpi.DpiScaleY);
         }
         return(this._cachedPointEraserCursor);
     }
     return(PenCursorManager.GetStrokeEraserCursor());
 }
Ejemplo n.º 7
0
        public bool Equals(BitmapLoadProperties other)
        {
            if (other is null)
            {
                return(false);
            }

            if (DpiScale?.Equals(other.DpiScale) == false)
            {
                return(false);
            }

            if (MaxDecodePixelWidth != other.MaxDecodePixelWidth)
            {
                return(false);
            }

            if (MaxDecodePixelHeight != other.MaxDecodePixelHeight)
            {
                return(false);
            }

            if (!string.Equals(Source, other.Source, StringComparison.Ordinal))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        // adjust zoom when DPI changes.
        protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
        {
            var ratio = newDpi.DpiScaleX / oldDpi.DpiScaleX;

            Zoom = (int)(Zoom * ratio);
            base.OnDpiChanged(oldDpi, newDpi);
        }
Ejemplo n.º 9
0
        private void MainWin_Loaded(object sender, RoutedEventArgs e)
        {
            if (App.ContextMenuWin == null)
            {
                App.ContextMenuWin = new ContextMenuWindow();
            }

            virWrapPanel = GetVisualChild <VirtualizingWrapPanel>(TV1);

            DpiScale = VisualTreeHelper.GetDpi(this);
            Setting.ThumbnailSize.PropertyChanged += ThumbnailSizeChanged;

            var view = (ListCollectionView)((CollectionViewSource)FindResource("ObjectListViewSource")).View;

            view.CustomSort = new Helpers.ObjectInfoSorter();

            //load last path or open dialog
            if (InitialPath?.Length > 0)
            {
                Task.Run(() => LoadPath(InitialPath));
            }
            else if (Setting.LastPath?.Length > 0)
            {
                Task.Run(() => LoadPath(Setting.LastPath));
            }
            else
            {
                openFolderPrompt();
            }
        }
Ejemplo n.º 10
0
        private void DrawFormattedText(DpiScale dpiInfo)
        {
            FormattedText formattedText = new FormattedText(
                "FABLE",
                new System.Globalization.CultureInfo("en-US"),
                FlowDirection.LeftToRight,
                new Typeface(
                    new System.Windows.Media.FontFamily("Segoe UI"),
                    FontStyles.Normal,
                    FontWeights.Bold,
                    FontStretches.Normal),
                120,
                System.Windows.Media.Brushes.Red,
                dpiInfo.PixelsPerDip);

            // Build a geometry out of the text.
            Geometry geometry = new PathGeometry();
            geometry = formattedText.BuildGeometry(new System.Windows.Point(0, 0));

            // Adjust the geometry to fit the aspect ration of the video by scaling it.
            ScaleTransform myScaleTransform = new ScaleTransform();
            myScaleTransform.ScaleX = .85;
            myScaleTransform.ScaleY = 2.0;
            geometry.Transform = myScaleTransform;

            // Flatten the geometry and create a PathGeometry out of it.
            PathGeometry pathGeometry = new PathGeometry();
            pathGeometry = geometry.GetFlattenedPathGeometry();

            // Use the PathGeometry for the empty placeholder Path element in XAML.
            path.Data = pathGeometry;

            // Use the PathGeometry for the animated ball that follows the path of the text outline.
            matrixAnimation.PathGeometry = pathGeometry;
        }
Ejemplo n.º 11
0
 protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
 {
     base.OnDpiChanged(oldDpi, newDpi);
     eventAggregator.SendMessage(new DpiChangedMessage {
         DpiScale = newDpi
     });
 }
Ejemplo n.º 12
0
        public static Rect ScaleRectDownFromDPI(Rect _sourceRect, DpiScale dpiScale)
        {
            double dpiX = dpiScale.DpiScaleX;
            double dpiY = dpiScale.DpiScaleY;

            return(new Rect(new Point(_sourceRect.X / dpiX, _sourceRect.Y / dpiY), new System.Windows.Size(_sourceRect.Width / dpiX, _sourceRect.Height / dpiY)));
        }
Ejemplo n.º 13
0
        public static Rect ScaleRectUpToDPI(Rect _toScaleUp, DpiScale dpiScale)
        {
            double dpiX = dpiScale.DpiScaleX;
            double dpiY = dpiScale.DpiScaleY;

            return(new Rect(new Point(_toScaleUp.X * dpiX, _toScaleUp.Y * dpiY), new System.Windows.Size(_toScaleUp.Width * dpiX, _toScaleUp.Height * dpiY)));
        }
        private void CompositionHostControl_Loaded(object sender, RoutedEventArgs e)
        {
            _currentDpi = WindowsMedia.VisualTreeHelper.GetDpi(this);

            _rectWidth  = CompositionHostElement.ActualWidth / 2;
            _rectHeight = CompositionHostElement.ActualHeight / 2;

            // Get graphics device.
            _compositionGraphicsDevice = CanvasComposition.CreateCompositionGraphicsDevice(_compositor, _canvasDevice);

            // Create surface.
            var noiseDrawingSurface = _compositionGraphicsDevice.CreateDrawingSurface(
                new Windows.Foundation.Size(_rectWidth, _rectHeight),
                DirectXPixelFormat.B8G8R8A8UIntNormalized,
                DirectXAlphaMode.Premultiplied);

            // Draw to surface and create surface brush.
            var noiseFilePath = AppDomain.CurrentDomain.BaseDirectory + "Assets\\NoiseAsset_256X256.png";

            LoadSurface(noiseDrawingSurface, noiseFilePath);
            _noiseSurfaceBrush = _compositor.CreateSurfaceBrush(noiseDrawingSurface);

            // Add composition content to tree.
            _compositionHost.SetChild(_containerVisual);
            AddCompositionContent();

            ToggleAcrylic();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Returns a string containing a list of numbers separated with newlines.
        /// </summary>
        private FormattedText GetFormattedLineNumbers(int firstIndex, int lastIndex, DpiScale dpi)
        {
            string text = "";

            for (int i = firstIndex + 1; i <= lastIndex + 1; i++)
            {
                text += i.ToString() + "\n";
            }
            text = text.Trim();

            FormattedText ft = new FormattedText(
                text,
                System.Globalization.CultureInfo.InvariantCulture,
                FlowDirection.LeftToRight,
                new Typeface(FontFamily, FontStyle, FontWeight, FontStretch),
                FontSize,
                new SolidColorBrush(Color.FromRgb(0x21, 0xA1, 0xD8)), dpi.PixelsPerDip)
            {
                Trimming      = TextTrimming.None,
                LineHeight    = lineHeight,
                TextAlignment = TextAlignment.Right
            };

            return(ft);
        }
Ejemplo n.º 16
0
        public BitmapSource RenderToImage(UIElement element)
        {
            element.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            element.Arrange(new Rect(new Point(), element.DesiredSize));

            // call to UpdateLayout is required to force children to be rendered too
            element.UpdateLayout();

            DpiScale dpiInfo = VisualTreeHelper.GetDpi(App.Current.MainWindow);

            var renderTarget = new RenderTargetBitmap(
                (int)(element.DesiredSize.Width * dpiInfo.DpiScaleX),
                (int)(element.DesiredSize.Height * dpiInfo.DpiScaleY),
                96.0, 96.0, PixelFormats.Pbgra32
                );

            var drawingVisual = new DrawingVisual();

            using (DrawingContext drawingContext = drawingVisual.RenderOpen())
            {
                var rect = new Rect(new Point(0, 0), new Point(renderTarget.Width, renderTarget.Height));

                drawingContext.DrawRectangle(Brushes.White, null, rect);
                drawingContext.DrawRectangle(new VisualBrush(element), null, rect);
            }

            renderTarget.Render(drawingVisual);

            return(renderTarget);
        }
Ejemplo n.º 17
0
        private void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
        {
            NativeMethods.MINMAXINFO mmi = (NativeMethods.MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(NativeMethods.MINMAXINFO));

            // Adjust the maximized size and position to fit the work area of the correct monitor
            System.IntPtr monitor = NativeMethods.GetMonitorFromWindow(hwnd);

            // MinHeight and MinWidth need to be scaled from Virtual Pixels back to Logical Pixels
            DpiScale dpiScale = VirtualPixelScale;

            if (monitor != System.IntPtr.Zero)
            {
                NativeMethods.MONITORINFO monitorInfo = new NativeMethods.MONITORINFO();
                NativeMethods.GetMonitorInfo(monitor, monitorInfo);
                NativeMethods.RECT rcWorkArea    = monitorInfo.rcWork;
                NativeMethods.RECT rcMonitorArea = monitorInfo.rcMonitor;
                mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
                mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
                mmi.ptMaxSize.x     = DoubleToInt32(Math.Abs(rcWorkArea.right - rcWorkArea.left));
                mmi.ptMaxSize.y     = DoubleToInt32(Math.Abs(rcWorkArea.bottom - rcWorkArea.top));
                // After much research, it appears that the MaxTrackSize is used for secondary monitors
                // while MaxSize is used for the primary monitor.
                mmi.ptMaxTrackSize.x = DoubleToInt32(Math.Abs(rcWorkArea.right - rcWorkArea.left));
                mmi.ptMaxTrackSize.y = DoubleToInt32(Math.Abs(rcWorkArea.bottom - rcWorkArea.top));
                mmi.ptMinTrackSize.x = GetMinWidthInScreenPixels(dpiScale);
                mmi.ptMinTrackSize.y = GetMinHeightInScreenPixels(dpiScale);
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Called when DPI of the monitor to which NotifyIcon belongs changed.
 /// </summary>
 /// <param name="oldDpi">Old DPI information</param>
 /// <param name="newDpi">New DPI information</param>
 protected virtual void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
 {
     if (_icon != null)
     {
         NotifyIcon.Icon = GetIcon(_icon, newDpi);
     }
 }
Ejemplo n.º 19
0
        private static T LogicalToDeviceUnits <T>(this IntPtr hwnd, T value) where T : IConvertible
        {
            var windowDpi      = hwnd.GetWindowDpi();
            var windowDpiScale = new DpiScale(windowDpi.X / 96.0, windowDpi.Y / 96.0);

            return((T)Convert.ChangeType((value.ToDouble(null) * windowDpiScale.DpiScaleX), typeof(T)));
        }
Ejemplo n.º 20
0
 protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
 {
     if (this.ActualWidth > 0 && currentGraph != null)
     {
         currentGraph.UpdateSize(newDpi, CompositionHostElement.ActualWidth, CompositionHostElement.ActualHeight);
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        ///     When implemented in a derived class, positions child elements and determines a
        ///     size for a FrameworkElement-derived class.
        /// </summary>
        /// <param name="finalSize"></param>
        /// <returns></returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (this.Visibility == Visibility.Collapsed || Child == null)
            {
                //Child takes up no space
                return(new Size(0, 0));
            }

            Vector originalScale = _currentScale;

            ScaleChild();
            DpiScale dpi    = GetDpi();
            bool     scaled = (_currentScale != originalScale);

            SD.Size targetSize = Convert.ConstraintToSystemDrawingSize(finalSize, _currentScale, dpi.DpiScaleX, dpi.DpiScaleY);
            if ((Child.Size != targetSize) && ((finalSize != _priorConstraint) || scaled))
            {
                _priorConstraint = finalSize;
                Child.Size       = targetSize;
            }
            Size returnSize = Convert.ToSystemWindowsSize(Child.Size, _currentScale, dpi.DpiScaleX, dpi.DpiScaleY);

            returnSize.Width  = Math.Min(returnSize.Width, finalSize.Width);
            returnSize.Height = Math.Min(returnSize.Height, finalSize.Height);
            if (HostContainerInternal.BackgroundImage != null)
            {
                _propertyMap.OnPropertyChanged(this, "Background", this.Background);
            }
            return(returnSize);
        }
Ejemplo n.º 22
0
        private static void SetWindowDpiImpl(Window window, double dpiScaleX, double dpiScaleY)
        {
            // Get window current dpi.
            DpiScale dpi = VisualTreeHelper.GetDpi(window);
            // Prepare new window position.
            double left   = window.Left * dpi.DpiScaleX;
            double top    = window.Top * dpi.DpiScaleY;
            double width  = window.ActualWidth * dpi.DpiScaleX;
            double height = window.ActualHeight * dpi.DpiScaleY;

            // Prepare an instance of HwndDpiChangedEventArgs.
            Type[]   paramTypes  = new Type[] { typeof(DpiScale), typeof(DpiScale), typeof(Rect) };
            object[] paramValues = new object[]
            {
                /* old dpi */ dpi,
                /* new dpi */ new DpiScale(dpiScaleX, dpiScaleY),
                /* position */ new Rect(left, top, width, height)
            };
            HwndDpiChangedEventArgs args = CreateInstance <HwndDpiChangedEventArgs>(paramTypes, paramValues);

            // Get window hosting HwndSource.
            PresentationSource source = PresentationSource.FromVisual(window);

            // Change DPI on the specified window.
            _onDpiChangedMethod.Invoke(source, new object[] { args });
            // Update Left and Top properties according to new DPI.
            _wmMoveChangedMethod.Invoke(window, null);
        }
Ejemplo n.º 23
0
        protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
        {
            base.OnDpiChanged(oldDpi, newDpi);

            dpi = VisualTreeHelper.GetDpi(this).DpiScaleX;
            log.Info($"Current screen dpi {dpi * 100}%");
        }
Ejemplo n.º 24
0
        /// <summary>Measures the child elements of a <see cref="T:System.Windows.Controls.Border" /> before they are arranged during the <see cref="M:System.Windows.Controls.Border.ArrangeOverride(System.Windows.Size)" /> pass.</summary>
        /// <param name="constraint">An upper <see cref="T:System.Windows.Size" /> limit that cannot be exceeded.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> that represents the upper size limit of the element.</returns>
        // Token: 0x06004264 RID: 16996 RVA: 0x0012F824 File Offset: 0x0012DA24
        protected override Size MeasureOverride(Size constraint)
        {
            UIElement child           = this.Child;
            Size      result          = default(Size);
            Thickness borderThickness = this.BorderThickness;

            if (base.UseLayoutRounding && !FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness)
            {
                DpiScale dpi = base.GetDpi();
                borderThickness = new Thickness(UIElement.RoundLayoutValue(borderThickness.Left, dpi.DpiScaleX), UIElement.RoundLayoutValue(borderThickness.Top, dpi.DpiScaleY), UIElement.RoundLayoutValue(borderThickness.Right, dpi.DpiScaleX), UIElement.RoundLayoutValue(borderThickness.Bottom, dpi.DpiScaleY));
            }
            Size size  = Border.HelperCollapseThickness(borderThickness);
            Size size2 = Border.HelperCollapseThickness(this.Padding);

            if (child != null)
            {
                Size size3         = new Size(size.Width + size2.Width, size.Height + size2.Height);
                Size availableSize = new Size(Math.Max(0.0, constraint.Width - size3.Width), Math.Max(0.0, constraint.Height - size3.Height));
                child.Measure(availableSize);
                Size desiredSize = child.DesiredSize;
                result.Width  = desiredSize.Width + size3.Width;
                result.Height = desiredSize.Height + size3.Height;
            }
            else
            {
                result = new Size(size.Width + size2.Width, size.Height + size2.Height);
            }
            return(result);
        }
Ejemplo n.º 25
0
        /// <overloads>
        /// Initializes a new instance of the <see cref="WpfDrawingSettings"/> class.
        /// </overloads>
        /// <summary>
        /// Initializes a new instance of the <see cref="WpfDrawingSettings"/> class
        /// with the default parameters and settings.
        /// </summary>
        public WpfDrawingSettings()
        {
            _defaultFontName = "Arial";
            _textAsGeometry  = false;
            _optimizePath    = true;
            _includeRuntime  = true;
            _neutralCulture  = CultureInfo.GetCultureInfo("en-us");
            _culture         = CultureInfo.GetCultureInfo("en-us");

            _pixelWidth  = -1;
            _pixelHeight = -1;

            _ensureViewboxSize     = false;
            _ensureViewboxPosition = true;
            _ignoreRootViewbox     = false;
            _wpfVisitors           = new WpfVisitors();
            _properties            = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);

            _fontSynch       = new object();
            _fontLocations   = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            _fontFamilyNames = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            _fontFamilyMap   = new Dictionary <string, IList <FontFamily> >(StringComparer.OrdinalIgnoreCase);
            _cssVariables    = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            _dpiScale = DpiUtilities.GetSystemScale();
        }
Ejemplo n.º 26
0
        private void ScaleRightImage(DpiScale newDpi)
        {
            // update bestScale
            bestScale = ImageDpiHelper.GetBestScale(newDpi.PixelsPerDip);

            string imageUrl = ImageDpiHelper.GetDesiredImageUrlForDpi(this);
            UpdateImageSource(this, imageUrl);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Rescaling the AppBar when Display DPI changes
 /// </summary>
 /// <param name="oldDpi">Old Display DPI</param>
 /// <param name="newDpi">New Display DPI</param>
 protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
 {
     base.OnDpiChanged(oldDpi, newDpi);
     if (IsAppBarRegistered)
     {
         OnDockLocationChanged();
     }
 }
Ejemplo n.º 28
0
        protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
        {
            base.OnDpiChanged(oldDpi, newDpi);

            Debug.WriteLine($"Image DpiChanged: {newDpi.PixelsPerDip}");

            SetSource(newDpi.PixelsPerDip);
        }
Ejemplo n.º 29
0
    internal static Pixel Pixel(this MouseEventArgs e, WpfPlot plot)
    {
        DpiScale dpiScale = VisualTreeHelper.GetDpi(plot);
        double   x        = e.GetPosition(plot).X *dpiScale.DpiScaleX;
        double   y        = e.GetPosition(plot).Y *dpiScale.DpiScaleY;

        return(new Pixel((float)x, (float)y));
    }
Ejemplo n.º 30
0
 public static Thickness RoundLayoutValue(Thickness value, DpiScale dpi)
 {
     return(new(
                RoundLayoutValue(value.Left, dpi.DpiScaleX),
                RoundLayoutValue(value.Top, dpi.DpiScaleY),
                RoundLayoutValue(value.Right, dpi.DpiScaleX),
                RoundLayoutValue(value.Bottom, dpi.DpiScaleY)));
 }
Ejemplo n.º 31
0
 protected override void OnDpiChanged(DpiScale oldDpiScaleInfo, DpiScale newDpiScaleInfo)
 {
     _dpiInfo = newDpiScaleInfo;
     if (_mouseAnimator != null)
     {
         _mouseAnimator.DpiInfo = newDpiScaleInfo;
     }
 }
 ///<summary>DPI改变时</summary>
 protected override void OnDpiChanged(DpiScale oldValueDpi, DpiScale newDpi)
 {
     base.OnDpiChanged(oldValueDpi, newDpi);
     if (Oscilloscopes != IntPtr.Zero)
     {
         Dll.RefreshDPI(Oscilloscopes);
     }
 }
Ejemplo n.º 33
0
 protected override void OnDpiChanged(DpiScale oldDpiScale, DpiScale newDpiScale)
 {
     _pixelsPerDip = newDpiScale.PixelsPerDip;
     UpdateFormattedText(_pixelsPerDip);
 }
Ejemplo n.º 34
0
        private void Attach()
        {
            if (attached)
                return;

            var hwndSource = GetHwndSource();
            if (hwndSource == null)
                return;
                
            var hwndParent = hwndSource.Handle;
            if (hwndParent == IntPtr.Zero)
                return;

            // Get current DPI
            dpiScale = VisualTreeHelper.GetDpi(this);

            var style = NativeHelper.GetWindowLong(Handle, NativeHelper.GWL_STYLE);
            // Removes Caption bar and the sizing border
            // Must be a child window to be hosted
            style |= NativeHelper.WS_CHILD;

            NativeHelper.SetWindowLong(Handle, NativeHelper.GWL_STYLE, style);
            NativeHelper.ShowWindow(Handle, NativeHelper.SW_HIDE);

            // Update the parent to be the parent of the host
            NativeHelper.SetParent(Handle, hwndParent);

            // Register keyboard sink to make shortcuts work
            ((IKeyboardInputSink)this).KeyboardInputSite = ((IKeyboardInputSink)hwndSource).RegisterKeyboardInputSink(this);
            attached = true;
        }
Ejemplo n.º 35
0
 /// <inheritdoc />
 protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
 {
     dpiScale = newDpi;
     UpdateWindowPosition();
 }
Ejemplo n.º 36
0
 protected override void OnDpiChanged(DpiScale oldDpiScaleInfo, DpiScale newDpiScaleInfo)
 {
     DrawFormattedText(newDpiScaleInfo);
 }
Ejemplo n.º 37
0
 // when DPI changes, ensure we are using the right scaled image, based on the DPI.
 protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
 {
     ScaleRightImage(newDpi);
 }