Files
PowerToys/src/modules/MouseUtils/MouseJumpUI/Common/Imaging/StaticImageRegionCopyService.cs
Michael Clayton 651f2e4bd8 [MouseJump]Refactor code to allow later introduction of customizable appearance (#32838)
* [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)
2024-06-12 16:30:18 +01:00

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);
}
}