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