コード例 #1
0
 /// <summary>
 /// Creates an instance of HwndDpiChangedEventArgs
 /// </summary>
 /// <param name="oldDpi">X-Axis DPI value before DPI changed</param>
 /// <param name="newDpi">Y-Axis DPI value before DPI changed</param>
 /// <param name="suggestedRect">Suggested client rectangle, scaled for the new DPI</param>
 /// <remarks>
 /// If <paramref name="suggestedRect"/> is <see cref="Rect.Empty"/>, this constructor will act as if
 /// no suggestion for the new client rectangle has been provided.
 /// When this happens, DPI-change processing logic in <see cref="HwndTarget.OnMonitorDPIChanged"/> will
 /// not attempt to resize the window. It will assume that the top-level WM_DPICHANGED resulted
 /// in a cascaded set of changes that adjusted the client areas for all child-windows appropriately
 /// in response to DPI changes. <see cref="HwndTarget.OnMonitorDPIChanged"/> will simply
 /// invalidate and repaint the window if this happens.
 /// </remarks>
 internal HwndDpiChangedEventArgs(DpiScale oldDpi, DpiScale newDpi, Rect suggestedRect) :
     base(false)
 {
     OldDpi        = oldDpi;
     NewDpi        = newDpi;
     SuggestedRect = suggestedRect;
 }
コード例 #2
0
        public static void ShowSystemMenu(Window window, Point screenLocation)
        {
            Verify.IsNotNull <Window>(window, "window");
            DpiScale dpi = window.GetDpi();

            SystemCommands.ShowSystemMenuPhysicalCoordinates(window, DpiHelper.LogicalPixelsToDevice(screenLocation, dpi.DpiScaleX, dpi.DpiScaleY));
        }
コード例 #3
0
 internal HwndDpiChangedEventArgs(double oldDpiX, double oldDpiY, double newDpiX, double newDpiY, IntPtr lParam) : base(false)
 {
     OldDpi = new DpiScale(oldDpiX / DpiUtil.DefaultPixelsPerInch, oldDpiY / DpiUtil.DefaultPixelsPerInch);
     NewDpi = new DpiScale(newDpiX / DpiUtil.DefaultPixelsPerInch, newDpiY / DpiUtil.DefaultPixelsPerInch);
     NativeMethods.RECT suggestedRect = Marshal.PtrToStructure <NativeMethods.RECT>(lParam);
     this.SuggestedRect = new Rect((double)suggestedRect.left, (double)suggestedRect.top, (double)suggestedRect.Width, (double)suggestedRect.Height);
 }
コード例 #4
0
 internal DpiRecursiveChangeArgs(DpiFlags dpiFlags, DpiScale oldDpiScale,
                                 DpiScale newDpiScale)
 {
     DpiScaleFlag1 = dpiFlags.DpiScaleFlag1;
     DpiScaleFlag2 = dpiFlags.DpiScaleFlag2;
     Index         = dpiFlags.Index;
     OldDpiScale   = oldDpiScale;
     NewDpiScale   = newDpiScale;
 }
コード例 #5
0
        public void UpdateSize(SysWin.DpiScale dpi, double newWidth, double newHeight)
        {
            var newDpiX = dpi.PixelsPerInchX;
            var newDpiY = dpi.PixelsPerInchY;

            var oldHeight = graphHeight;
            var oldWidth  = graphWidth;

            graphHeight = (float)(newWidth * newDpiY / 96.0);
            graphWidth  = (float)(newHeight * newDpiX / 96.0);

            UpdateSizeAndPositions();

            // Update bars.
            for (int i = 0; i < barValueMap.Count; i++)
            {
                var bar = (Bar)barValueMap[i];

                var xOffset = shapeGraphOffsetX + barSpacing + (barWidth + barSpacing) * i;
                var height  = bar.Height;
                if (oldHeight != newHeight)
                {
                    height = GetAdjustedBarHeight(maxBarValue, graphData[i]);
                }

                bar.UpdateSize(barWidth, height);
                bar.Root.Offset        = new System.Numerics.Vector3(xOffset, shapeGraphContainerHeight, 0);
                bar.OutlineRoot.Offset = new System.Numerics.Vector3(xOffset, shapeGraphContainerHeight, 0);
            }

            // Scale text size.
            textSize = textSize * graphHeight / oldHeight;
            // Update text render target and redraw text.
            textRenderTarget.DotsPerInch = new Size2F((float)newDpiX, (float)newDpiY);
            textRenderTarget.Resize(new Size2((int)(newWidth * newDpiX / 96.0), (int)(newWidth * newDpiY / 96.0)));
            DrawText(textRenderTarget, Title, XAxisLabel, YAxisLabel, textSize);
        }
コード例 #6
0
        public void UpdateSize(SysWin.DpiScale dpi, double newWidth, double newHeight)
        {
            var newDpiX = dpi.PixelsPerInchX;
            var newDpiY = dpi.PixelsPerInchY;

            var oldHeight = _graphHeight;
            var oldWidth  = _graphWidth;

            _graphHeight = (float)(newWidth * newDpiY / 96.0);
            _graphWidth  = (float)(newHeight * newDpiX / 96.0);

            UpdateSizeAndPositions();

            // Update bars.
            for (var i = 0; i < _graphData.Length; i++)
            {
                var bar = _bars[i];

                var xOffset = _shapeGraphOffsetX + _barSpacing + (_barWidth + _barSpacing) * i;
                var height  = bar.Height;
                if (oldHeight != newHeight)
                {
                    height = (float)GetAdjustedBarHeight(_maxBarValue, _graphData[i]);
                }

                bar.UpdateSize(_barWidth, height);
                bar.Root.Offset        = new SnVector3(xOffset, _shapeGraphContainerHeight, 0);
                bar.OutlineRoot.Offset = new SnVector3(xOffset, _shapeGraphContainerHeight, 0);
            }

            // Scale text size.
            _textSize = _textSize * _graphHeight / oldHeight;
            // Update text render target and redraw text.
            _textRenderTarget.DotsPerInch = new Size2F((float)newDpiX, (float)newDpiY);
            _textRenderTarget.Resize(new Size2((int)(newWidth * newDpiX / 96.0), (int)(newWidth * newDpiY / 96.0)));
            DrawText(_textRenderTarget, _graphTitle, _xAxisLabel, _yAxisLabel, _textSize);
        }
コード例 #7
0
 /// <summary>
 /// Constructs a DpiChangedEventArgs instance.
 /// </summary>
 internal DpiChangedEventArgs(DpiScale oldDpi, DpiScale newDpi, RoutedEvent routedEvent, object source) : base(routedEvent, source)
 {
     OldDpi = oldDpi;
     NewDpi = newDpi;
 }