我试图在WPF中建模旧规模。因此我需要添加一个椭圆和一个矩形,我需要的只是切割量。 我尝试了Combined Geometry:
<Grid>
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF" Grid.ColumnSpan="3">
<Path.Data>
<CombinedGeometry GeometryCombineMode="Intersect">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="50,50" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<RectangleGeometry Rect="{Binding ElementName=recForm, Path=RenderedGeometry}" >
<RectangleGeometry.Transform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="45"/>
<TranslateTransform X="1" Y="1"/>
</TransformGroup>
</RectangleGeometry.Transform>
</RectangleGeometry>
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
<Rectangle x:Name="recForm" Visibility="Hidden" Fill="#000000" Stroke="Black" StrokeThickness="1" RenderTransformOrigin="0.5,0.5" Margin="25,-11,25,11">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="45"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
但我什么也看不见。任何想法?
答案 0 :(得分:0)
我修好了。我的代码看起来像:
<Path>
<Path.Fill>
<RadialGradientBrush>
<GradientStop Color="#FF252525" Offset="1"/>
<GradientStop Color="White"/>
<GradientStop Color="#FF474747" Offset="0.965"/>
<GradientStop Color="#FFA6A5A5" Offset="0.829"/>
</RadialGradientBrush>
</Path.Fill>
<Path.Data>
<EllipseGeometry Center="50,51" RadiusX="50" RadiusY="50" ></EllipseGeometry>
</Path.Data>
<Path.Clip>
<CombinedGeometry GeometryCombineMode="Intersect">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="50,51" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<RectangleGeometry Rect="50,0,50,50">
<RectangleGeometry.Transform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform CenterX="85" CenterY="-15" Angle="45"/>
<TranslateTransform X="1" Y="1"/>
</TransformGroup>
</RectangleGeometry.Transform>
</RectangleGeometry>
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Clip>
</Path>
<Canvas>
<Canvas x:Name="ScaleBody" RenderTransformOrigin="0.5,0.5" Width="100" Height="100" >
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform x:Name="scaleBodyTransform" Angle="-24"/>
<TranslateTransform/>
</TransformGroup>
</Canvas.RenderTransform>
<Label Content="-9" FontSize="10" RenderTransformOrigin="0.5,0.5" Canvas.Left="41" Canvas.Top="1" />
<Label Content="5" FontSize="10" Canvas.Left="28" Canvas.Top="5" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-24.505"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label Content="4" FontSize="10" Canvas.Left="15" Canvas.Top="13" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-47.684"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label Content="3" FontSize="10" Canvas.Left="6" Canvas.Top="26" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-72.35"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label Content="2" FontSize="10" Canvas.Left="4" Canvas.Top="42" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-97.669"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label Content="1" FontSize="10" Canvas.Left="9" Canvas.Top="58" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-120.409"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label FontSize="10" Content="0" Canvas.Left="19" Canvas.Top="70" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="216.695"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label FontSize="10" Content="-1" Canvas.Left="34" Canvas.Top="77" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-167.488"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label FontSize="10" Content="-2" Canvas.Left="50" Canvas.Top="77" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="169.538"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label FontSize="10" Content="-3" Canvas.Left="64" Canvas.Top="70" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="144.36"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label FontSize="10" Content="-4" Canvas.Left="75" Canvas.Top="56" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="120.457"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label FontSize="10" Content="-5" Canvas.Left="79" Canvas.Top="41" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="96.966"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label FontSize="10" Content="-6" Canvas.Left="77" Canvas.Top="25" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="71.036"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label FontSize="10" Content="-7" Canvas.Left="68" Canvas.Top="12" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="48.161"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Label FontSize="10" Content="-8" Canvas.Left="55" Canvas.Top="3" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="24.467"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
</Canvas>
<Canvas.Clip>
<CombinedGeometry GeometryCombineMode="Intersect">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="50,51" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<RectangleGeometry Rect="50,0,50,50">
<RectangleGeometry.Transform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform CenterX="85" CenterY="-15" Angle="45"/>
<TranslateTransform X="1" Y="1"/>
</TransformGroup>
</RectangleGeometry.Transform>
</RectangleGeometry>
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Canvas.Clip>
</Canvas>
<Rectangle Visibility="Hidden" Width="50" Height="50" Fill="Black" RenderTransformOrigin="0.5,0.5" Margin="25.5,-17,24.5,17">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="45"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="Red" Width="3" Height="5" Margin="49,2,48,0" VerticalAlignment="Top" RadiusX="5" RadiusY="5"/>
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<CombinedGeometry x:Name="Scale" GeometryCombineMode="Intersect">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="50,51" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<RectangleGeometry Rect="50,0,50,50">
<RectangleGeometry.Transform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform CenterX="85" CenterY="-15" Angle="45"/>
<TranslateTransform X="1" Y="1"/>
</TransformGroup>
</RectangleGeometry.Transform>
</RectangleGeometry>
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
<Label x:Name="lblFillBalance" Content="00:00" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="36,15,0,0" VerticalAlignment="Top" FontSize="9"/>
输出看起来像: Output
唯一不行的是设置锁定Canvas.Clip的角度到Canvas的角度
修改强>
现在一切正常。对于所有人来说,我编辑了上面的XAML代码,这是我的旋转方法。
private int setScaleBodyToBalance()
{
int balance = Program.TodayPresence.balanceWhenLeave();
int angle = 0;
if (balance >= 0) angle = 144 - balance / 150;
if (balance >= -5400 && balance < 0 ) angle = 144 + Math.Abs(balance) / 150;
if (balance < -5400) angle = -180 + (Math.Abs(balance) - 5400 )/ 150;
return angle;
}
public void updateShownInformation()
{
scaleBodyTransform.Angle = setScaleBodyToBalance();
}
余额是一个给我们时间的整数。当余额为3600时,时间是1:00 ......