fix(ui): inset main surface to keep content inside rounded frame
This commit is contained in:
@@ -355,7 +355,8 @@
|
||||
<Grid x:Name="MainGrid"
|
||||
Background="Transparent">
|
||||
<Border x:Name="MainWindowSurface"
|
||||
CornerRadius="20"
|
||||
CornerRadius="19"
|
||||
Margin="1"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource backgroundColor}"
|
||||
SnapsToDevicePixels="True"
|
||||
|
||||
@@ -2175,23 +2175,23 @@ namespace C4IT_CustomerPanel
|
||||
if (MainWindowSurface == null || MainGrid == null)
|
||||
return;
|
||||
|
||||
double width = MainGrid.ActualWidth;
|
||||
double height = MainGrid.ActualHeight;
|
||||
if (width <= 0 || height <= 0)
|
||||
double gridWidth = MainGrid.ActualWidth;
|
||||
double gridHeight = MainGrid.ActualHeight;
|
||||
if (gridWidth <= 0 || gridHeight <= 0)
|
||||
return;
|
||||
|
||||
const double outerRadius = 20d;
|
||||
const double clipInset = 0d;
|
||||
double clipWidth = Math.Max(0d, width - (clipInset * 2d));
|
||||
double clipHeight = Math.Max(0d, height - (clipInset * 2d));
|
||||
double clipRadius = Math.Max(0d, outerRadius - clipInset);
|
||||
RectangleGeometry clipGeometry = new RectangleGeometry(
|
||||
new Rect(clipInset, clipInset, clipWidth, clipHeight),
|
||||
clipRadius,
|
||||
clipRadius);
|
||||
const double surfaceInset = 1d;
|
||||
double surfaceRadius = Math.Max(0d, outerRadius - surfaceInset);
|
||||
|
||||
MainGrid.Clip = clipGeometry;
|
||||
MainWindowSurface.Clip = clipGeometry.Clone();
|
||||
MainGrid.Clip = new RectangleGeometry(new Rect(0d, 0d, gridWidth, gridHeight), outerRadius, outerRadius);
|
||||
|
||||
double surfaceWidth = MainWindowSurface.ActualWidth;
|
||||
double surfaceHeight = MainWindowSurface.ActualHeight;
|
||||
if (surfaceWidth > 0 && surfaceHeight > 0)
|
||||
{
|
||||
MainWindowSurface.Clip = new RectangleGeometry(new Rect(0d, 0d, surfaceWidth, surfaceHeight), surfaceRadius, surfaceRadius);
|
||||
}
|
||||
|
||||
_mainSurfaceClipInitialized = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user