Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add Size Extensions #3317

Closed
michael-hawker opened this issue May 30, 2020 · 1 comment · Fixed by #3489
Closed

[Feature] Add Size Extensions #3317

michael-hawker opened this issue May 30, 2020 · 1 comment · Fixed by #3489
Labels
Completed 🔥 feature request 📬 A request for new changes to improve functionality good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities
Milestone

Comments

@michael-hawker
Copy link
Member

Describe the problem this feature would solve

We have a lot of this pattern in the toolkit:

new Rect(0, 0, size.Width, size.Height)

Describe the solution

It'd be great to have some extensions for size:

size.ToRect() // Defaults to 0, 0
size.ToRect(point);
size.ToRect(x, y);

Thoughts?

@michael-hawker michael-hawker added the feature request 📬 A request for new changes to improve functionality label May 30, 2020
@ghost
Copy link

ghost commented May 30, 2020

Hello, 'michael-hawker! Thanks for submitting a new feature request. I've automatically added a vote 👍 reaction to help get things started. Other community members can vote to help us prioritize this feature in the future!

@ghost ghost added the needs triage 🔍 label May 30, 2020
@ghost ghost added the needs attention 👋 label Jun 14, 2020
@michael-hawker michael-hawker added good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities and removed needs attention 👋 needs triage 🔍 labels Sep 14, 2020
@michael-hawker michael-hawker added this to the 7.0 milestone Sep 14, 2020
@CommunityToolkit CommunityToolkit deleted a comment Sep 14, 2020
@CommunityToolkit CommunityToolkit deleted a comment Sep 14, 2020
@CommunityToolkit CommunityToolkit deleted a comment Sep 14, 2020
@CommunityToolkit CommunityToolkit deleted a comment Sep 14, 2020
@CommunityToolkit CommunityToolkit deleted a comment Sep 14, 2020
@CommunityToolkit CommunityToolkit deleted a comment Sep 14, 2020
@CommunityToolkit CommunityToolkit deleted a comment Sep 14, 2020
@ghost ghost added the In-PR 🚀 label Sep 21, 2020
@ghost ghost closed this as completed in #3489 Sep 24, 2020
ghost pushed a commit that referenced this issue Sep 24, 2020
## Closes #3317
<!-- Add the relevant issue number after the "#" mentioned above (for ex: Fixes #1234) which will automatically close the issue once the PR is merged. -->

<!-- Add a brief overview here of the feature/bug & fix. -->

## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one or more that apply to this PR. -->

<!-- - Bugfix -->
- Feature
<!-- - Code style update (formatting) -->
<!-- - Refactoring (no functional changes, no api changes) -->
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->


## What is the new behavior?
<!-- Describe how was this issue resolved or changed? -->
This PR adds new extensions to easily convert `Windows.Foundation.Size` and `Point` values to `Rect`:

```csharp
namespace Microsoft.Toolkit.Uwp.Extensions
{
    public static class SizeExtensions
    {
        public static Rect ToRect(this Size size);
        public static Rect ToRect(this Size size, double x, double y);
        public static Rect ToRect(this Size size, Point point);
    }

    public static class PointExtensions
    {
        public static Rect ToRect(this Point point, double width, double height);
        public static Rect ToRect(this Point point, Point end);
        public static Rect ToRect(this Point point, Size size);
    }
}
```

## PR Checklist

Please check if your PR fulfills the following requirements:

- [X] Tested code with current [supported SDKs](../readme.md#supported)
- [ ] ~~Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->~~
- [ ] ~~Sample in sample app has been added / updated (for bug fixes / features)~~
    - [ ] ~~Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)~~
- [X] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [X] Header has been added to all new source files (run *build/UpdateHeaders.bat*)
- [X] Contains **NO** breaking changes
@ghost ghost added Completed 🔥 and removed In-PR 🚀 labels Sep 24, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Nov 23, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Completed 🔥 feature request 📬 A request for new changes to improve functionality good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant