1
我需要創建一個自定義的滑塊,此刻我的滑塊看上去正是我想要的,它看起來像這樣(從VisualStudio的圖像):自定義滑塊的Windows 8.1
<Grid x:Name="mainGrid">
<Grid Height="240" Width="300" Canvas.ZIndex="2">
<Grid.RenderTransform>
<RotateTransform x:Name="rotateTransform"
Angle="-125"
CenterX="150"
CenterY="150" />
</Grid.RenderTransform>
<Ellipse Height="54" Width="54"
x:Name="knob"
Fill="Red"
PointerMoved="Image_PointerMoved"
VerticalAlignment="Top"
Margin="0,-7,0,0"/>
</Grid>
<Path x:Name="path"
Data="M269.01,233.229 C303.532,181.303 304.261,118.855 269.097,67.0139 C207.933,-15.2077 92.8603,-16.8742 31.2108,66.0937 C-3.68835,121.514 -3.36331,179.271 30.8461,232.917 C51.2571,253.282 74.8965,230.573 61.3585,209.167 C38.2919,172.761 36.0008,129.688 62.1396,90.2093 C106.398,28.022 194.916,29.4803 237.509,90.1399 C262.554,127.345 263.613,170.209 237.647,209.792 C227.355,233.49 250.474,250.782 269.01,233.229 z"
Stretch="Fill"
Fill="Gray" />
</Grid>
和C#代碼是這樣的:
private void Image_PointerMoved(object sender, PointerRoutedEventArgs e)
{
//Canculate the current rotation angle and set the value.
var newPos = e.GetCurrentPoint(path);
double angle = GetAngleR(newPos.Position);
rotateTransform.Angle = angle;
}
public double GetAngleR(Point pos)
{
var xDiff = 150 - pos.X;
var yDiff = 150 - pos.Y;
var r = Math.Sqrt((xDiff * xDiff) + (yDiff * yDiff));
var radians = Math.Acos((yDiff)/r);
var angle = radians * (180/Math.PI);
if(angle > 125)
{
angle = 125;
}
if(pos.X < 150)
{
angle = -angle;
}
return angle;
}
我的問題是我如何填充不同的顏色路徑作爲我動橢圓?
我需要才達到somethig這樣的:
什麼建議嗎?
哦,這看起來像一個整潔的一個!我可能會看direct2D的不透明面具。 –