mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 03:07:56 +01:00
* [Mouse Jump] - move code shared with FancyMouse into "Common" folder (#25482) * [Mouse Jump] - updates to NativeMethods (#25482) * [Mouse Jump] - added new drawing / layout / style classes (#25482) * [Mouse Jump] - new style-based preview rendering (actual preview visual style unchanged) (#25482) * [Mouse Jump] - add words to spell checker (#25482) * [Mouse Jump] - small tweak to error handling (#25482) * [Mouse Jump] - fixed failing test (#25482)
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Drawing;
|
|
using MouseJumpUI.Common.Models.Drawing;
|
|
|
|
namespace MouseJumpUI.Common.Imaging;
|
|
|
|
/// <summary>
|
|
/// Implements an IImageRegionCopyService that uses the specified image as the copy source.
|
|
/// This is used for testing the DrawingHelper rather than as part of the main application.
|
|
/// </summary>
|
|
internal sealed class StaticImageRegionCopyService : IImageRegionCopyService
|
|
{
|
|
public StaticImageRegionCopyService(Image sourceImage)
|
|
{
|
|
this.SourceImage = sourceImage ?? throw new ArgumentNullException(nameof(sourceImage));
|
|
}
|
|
|
|
private Image SourceImage
|
|
{
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copies the source region from the static source image
|
|
/// to the target region on the specified Graphics object.
|
|
/// </summary>
|
|
public void CopyImageRegion(
|
|
Graphics targetGraphics,
|
|
RectangleInfo sourceBounds,
|
|
RectangleInfo targetBounds)
|
|
{
|
|
targetGraphics.DrawImage(
|
|
image: this.SourceImage,
|
|
destRect: targetBounds.ToRectangle(),
|
|
srcRect: sourceBounds.ToRectangle(),
|
|
srcUnit: GraphicsUnit.Pixel);
|
|
}
|
|
}
|