Skip to content

Commit

Permalink
Port ContentAlignmentEditor
Browse files Browse the repository at this point in the history
Closes #2018
  • Loading branch information
zsd4yr authored and RussKie committed Nov 5, 2019
1 parent e0d025c commit f93ffe5
Show file tree
Hide file tree
Showing 20 changed files with 1,350 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
* text=auto

# Collapse XLF files in PRs by default
*.xlf linguist-generated=true
23 changes: 23 additions & 0 deletions src/System.Windows.Forms.Design.Editors/src/Misc/DpiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ public static bool IsScalingRequired
}
}

/// <summary>
/// scale logical pixel to the factor
/// </summary>
public static int ConvertToGivenDpiPixel(int value, double pixelFactor)
{
var scaledValue = (int)Math.Round(value * pixelFactor);
return scaledValue == 0 ? 1 : scaledValue;
}

/// <summary>
/// Transforms a horizontal or vertical integer coordinate from logical to device units
/// by scaling it up for current DPI and rounding to nearest integer value
Expand All @@ -142,6 +151,20 @@ public static int LogicalToDeviceUnits(int value, int devicePixels = 0)
return (int)Math.Round(scalingFactor * (double)value);
}

/// <summary>
/// Transforms a horizontal or vertical integer coordinate from logical to device units
/// by scaling it up for current DPI and rounding to nearest integer value
/// </summary>
public static double LogicalToDeviceUnits(double value, int devicePixels = 0)
{
if (devicePixels == 0)
{
return LogicalToDeviceUnitsScalingFactor * value;
}
double scalingFactor = devicePixels / LogicalDpi;
return scalingFactor * value;
}

/// <summary>
/// Transforms a horizontal integer coordinate from logical to device units
/// by scaling it up for current DPI and rounding to nearest integer value
Expand Down
30 changes: 30 additions & 0 deletions src/System.Windows.Forms.Design.Editors/src/Resources/SR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,36 @@ Press Ctrl+Enter to accept Text.</value>
<data name="ImageCollectionEditorFormText" xml:space="preserve">
<value>Images Collection Editor</value>
</data>
<data name="ContentAlignmentEditorAccName" xml:space="preserve">
<value>Alignment Picker</value>
</data>
<data name="ContentAlignmentEditorBottomCenterAccName" xml:space="preserve">
<value>Bottom Middle</value>
</data>
<data name="ContentAlignmentEditorBottomLeftAccName" xml:space="preserve">
<value>Bottom Left</value>
</data>
<data name="ContentAlignmentEditorBottomRightAccName" xml:space="preserve">
<value>Bottom Right</value>
</data>
<data name="ContentAlignmentEditorMiddleCenterAccName" xml:space="preserve">
<value>Middle Center</value>
</data>
<data name="ContentAlignmentEditorMiddleLeftAccName" xml:space="preserve">
<value>Middle Left</value>
</data>
<data name="ContentAlignmentEditorMiddleRightAccName" xml:space="preserve">
<value>Middle Right</value>
</data>
<data name="ContentAlignmentEditorTopCenterAccName" xml:space="preserve">
<value>Top Center</value>
</data>
<data name="ContentAlignmentEditorTopLeftAccName" xml:space="preserve">
<value>Top Left</value>
</data>
<data name="ContentAlignmentEditorTopRightAccName" xml:space="preserve">
<value>Top Right</value>
</data>
<data name="iconFileDescription" xml:space="preserve">
<value>Icon files</value>
</data>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f93ffe5

Please sign in to comment.