Neuerstellung
This commit is contained in:
219
RadialMenu/Controls/PieShape.cs
Normal file
219
RadialMenu/Controls/PieShape.cs
Normal file
@@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace RadialMenu.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for PieShape.xaml
|
||||
/// </summary>
|
||||
internal class PieShape : Shape
|
||||
{
|
||||
public static readonly DependencyProperty InnerRadiusProperty =
|
||||
DependencyProperty.Register("InnerRadius", typeof(double), typeof(PieShape),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The inner radius of this pie piece
|
||||
/// </summary>
|
||||
public double InnerRadius
|
||||
{
|
||||
get { return (double)GetValue(InnerRadiusProperty); }
|
||||
set { SetValue(InnerRadiusProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OuterRadiusProperty =
|
||||
DependencyProperty.Register("OuterRadius", typeof(double), typeof(PieShape),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The outer radius of this pie piece
|
||||
/// </summary>
|
||||
public double OuterRadius
|
||||
{
|
||||
get { return (double)GetValue(OuterRadiusProperty); }
|
||||
set { SetValue(OuterRadiusProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty PaddingProperty =
|
||||
DependencyProperty.Register("Padding", typeof(double), typeof(PieShape),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The padding arround this pie piece
|
||||
/// </summary>
|
||||
public double Padding
|
||||
{
|
||||
get { return (double)GetValue(PaddingProperty); }
|
||||
set { SetValue(PaddingProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty PushOutProperty =
|
||||
DependencyProperty.Register("PushOut", typeof(double), typeof(PieShape),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The distance to 'push' this pie piece out from the center
|
||||
/// </summary>
|
||||
public double PushOut
|
||||
{
|
||||
get { return (double)GetValue(PushOutProperty); }
|
||||
set { SetValue(PushOutProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AngleDeltaProperty =
|
||||
DependencyProperty.Register("AngleDelta", typeof(double), typeof(PieShape),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The angle delta of this pie piece in degrees
|
||||
/// </summary>
|
||||
public double AngleDelta
|
||||
{
|
||||
get { return (double)GetValue(AngleDeltaProperty); }
|
||||
set { SetValue(AngleDeltaProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty StartAngleProperty =
|
||||
DependencyProperty.Register("StartAngle", typeof(double), typeof(PieShape),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The start angle from the Y axis vector of this pie piece in degrees
|
||||
/// </summary>
|
||||
public double StartAngle
|
||||
{
|
||||
get { return (double)GetValue(StartAngleProperty); }
|
||||
set { SetValue(StartAngleProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty CenterXProperty =
|
||||
DependencyProperty.Register("CenterX", typeof(double), typeof(PieShape),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The X coordinate of center of the circle from which this pie piece is cut
|
||||
/// </summary>
|
||||
public double CenterX
|
||||
{
|
||||
get { return (double)GetValue(CenterXProperty); }
|
||||
set { SetValue(CenterXProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty CenterYProperty =
|
||||
DependencyProperty.Register("CenterY", typeof(double), typeof(PieShape),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
/// <summary>
|
||||
/// The Y coordinate of center of the circle from which this pie piece is cut
|
||||
/// </summary>
|
||||
public double CenterY
|
||||
{
|
||||
get { return (double)GetValue(CenterYProperty); }
|
||||
set { SetValue(CenterYProperty, value); }
|
||||
}
|
||||
|
||||
static PieShape()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(PieShape), new FrameworkPropertyMetadata(typeof(PieShape)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the shape
|
||||
/// </summary>
|
||||
protected override Geometry DefiningGeometry
|
||||
{
|
||||
get
|
||||
{
|
||||
// Creates a StreamGeometry for describing the shape
|
||||
StreamGeometry geometry = new StreamGeometry();
|
||||
geometry.FillRule = FillRule.EvenOdd;
|
||||
|
||||
using (StreamGeometryContext context = geometry.Open())
|
||||
{
|
||||
DrawGeometry(context);
|
||||
}
|
||||
|
||||
// Freezes the geometry for performance benefits
|
||||
geometry.Freeze();
|
||||
|
||||
return geometry;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the pie piece
|
||||
/// </summary>
|
||||
private void DrawGeometry(StreamGeometryContext context)
|
||||
{
|
||||
if (AngleDelta <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double outerStartAngle = StartAngle;
|
||||
double outerAngleDelta = AngleDelta;
|
||||
double innerStartAngle = StartAngle;
|
||||
double innerAngleDelta = AngleDelta;
|
||||
Point arcCenter = new Point(CenterX, CenterY);
|
||||
Size outerArcSize = new Size(OuterRadius, OuterRadius);
|
||||
Size innerArcSize = new Size(InnerRadius, InnerRadius);
|
||||
|
||||
// If have to draw a full-circle, draws two semi-circles, because 'ArcTo()' can not draw a full-circle
|
||||
if (AngleDelta >= 360 && Padding <= 0)
|
||||
{
|
||||
Point outerArcTopPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle, OuterRadius + PushOut);
|
||||
Point outerArcBottomPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle + 180, OuterRadius + PushOut);
|
||||
Point innerArcTopPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle, InnerRadius + PushOut);
|
||||
Point innerArcBottomPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle + 180, InnerRadius + PushOut);
|
||||
|
||||
context.BeginFigure(innerArcTopPoint, true, true);
|
||||
context.LineTo(outerArcTopPoint, true, true);
|
||||
context.ArcTo(outerArcBottomPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true);
|
||||
context.ArcTo(outerArcTopPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true);
|
||||
context.LineTo(innerArcTopPoint, true, true);
|
||||
context.ArcTo(innerArcBottomPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
|
||||
context.ArcTo(innerArcTopPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
|
||||
}
|
||||
// Else draws as always
|
||||
else
|
||||
{
|
||||
if (Padding > 0)
|
||||
{
|
||||
// Offsets the angle by the padding
|
||||
double outerAngleVariation = (180 * (Padding / OuterRadius)) / Math.PI;
|
||||
double innerAngleVariation = (180 * (Padding / InnerRadius)) / Math.PI;
|
||||
|
||||
outerStartAngle += outerAngleVariation;
|
||||
outerAngleDelta -= outerAngleVariation * 2;
|
||||
innerStartAngle += innerAngleVariation;
|
||||
innerAngleDelta -= innerAngleVariation * 2;
|
||||
}
|
||||
|
||||
Point outerArcStartPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle, OuterRadius + PushOut);
|
||||
Point outerArcEndPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle + outerAngleDelta, OuterRadius + PushOut);
|
||||
Point innerArcStartPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle, InnerRadius + PushOut);
|
||||
Point innerArcEndPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle + innerAngleDelta, InnerRadius + PushOut);
|
||||
|
||||
bool largeArcOuter = outerAngleDelta > 180.0;
|
||||
bool largeArcInner = innerAngleDelta > 180.0;
|
||||
|
||||
context.BeginFigure(innerArcStartPoint, true, true);
|
||||
context.LineTo(outerArcStartPoint, true, true);
|
||||
context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArcOuter, SweepDirection.Clockwise, true, true);
|
||||
context.LineTo(innerArcEndPoint, true, true);
|
||||
context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArcInner, SweepDirection.Counterclockwise, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static Point ComputeCartesianCoordinate(Point center, double angle, double radius)
|
||||
{
|
||||
// Converts to radians
|
||||
double radiansAngle = (Math.PI / 180.0) * (angle - 90);
|
||||
double x = radius * Math.Cos(radiansAngle);
|
||||
double y = radius * Math.Sin(radiansAngle);
|
||||
return new Point(x + center.X, y + center.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
80
RadialMenu/Controls/RadialMenu.cs
Normal file
80
RadialMenu/Controls/RadialMenu.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace RadialMenu.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for RadialMenu.xaml
|
||||
/// </summary>
|
||||
public class RadialMenu : ContentControl
|
||||
{
|
||||
public static readonly DependencyProperty IsOpenProperty =
|
||||
DependencyProperty.Register("IsOpen", typeof(bool), typeof(RadialMenu),
|
||||
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public bool IsOpen
|
||||
{
|
||||
get { return (bool)GetValue(IsOpenProperty); }
|
||||
set { SetValue(IsOpenProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HalfShiftedItemsProperty =
|
||||
DependencyProperty.Register("HalfShiftedItems", typeof(bool), typeof(RadialMenu),
|
||||
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public bool HalfShiftedItems
|
||||
{
|
||||
get { return (bool)GetValue(HalfShiftedItemsProperty); }
|
||||
set { SetValue(HalfShiftedItemsProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty CentralItemProperty =
|
||||
DependencyProperty.Register("CentralItem", typeof(RadialMenuCentralItem), typeof(RadialMenu),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public RadialMenuCentralItem CentralItem
|
||||
{
|
||||
get { return (RadialMenuCentralItem)GetValue(CentralItemProperty); }
|
||||
set { SetValue(CentralItemProperty, value); }
|
||||
}
|
||||
|
||||
public new static readonly DependencyProperty ContentProperty =
|
||||
DependencyProperty.Register("Content", typeof(List<RadialMenuItem>), typeof(RadialMenu),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public new List<RadialMenuItem> Content
|
||||
{
|
||||
get { return (List<RadialMenuItem>)GetValue(ContentProperty); }
|
||||
set { SetValue(ContentProperty, value); }
|
||||
}
|
||||
|
||||
public List<RadialMenuItem> Items
|
||||
{
|
||||
get { return Content; }
|
||||
set { Content = value; }
|
||||
}
|
||||
|
||||
static RadialMenu()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(RadialMenu), new FrameworkPropertyMetadata(typeof(RadialMenu)));
|
||||
}
|
||||
|
||||
public override void BeginInit()
|
||||
{
|
||||
Content = new List<RadialMenuItem>();
|
||||
base.BeginInit();
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size arrangeSize)
|
||||
{
|
||||
for (int i = 0, count = Items.Count; i < count; i++)
|
||||
{
|
||||
Items[i].Index = i;
|
||||
Items[i].Count = count;
|
||||
Items[i].HalfShifted = HalfShiftedItems;
|
||||
}
|
||||
return base.ArrangeOverride(arrangeSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
RadialMenu/Controls/RadialMenuCentralItem.cs
Normal file
16
RadialMenu/Controls/RadialMenuCentralItem.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace RadialMenu.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for RadialMenuCentralItem.xaml
|
||||
/// </summary>
|
||||
public class RadialMenuCentralItem : Button
|
||||
{
|
||||
static RadialMenuCentralItem()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(RadialMenuCentralItem), new FrameworkPropertyMetadata(typeof(RadialMenuCentralItem)));
|
||||
}
|
||||
}
|
||||
}
|
||||
279
RadialMenu/Controls/RadialMenuItem.cs
Normal file
279
RadialMenu/Controls/RadialMenuItem.cs
Normal file
@@ -0,0 +1,279 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace RadialMenu.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for RadialMenuItem.xaml
|
||||
/// </summary>
|
||||
public class RadialMenuItem : Button
|
||||
{
|
||||
public static readonly DependencyProperty IndexProperty =
|
||||
DependencyProperty.Register("Index", typeof(int), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure, UpdateItemRendering));
|
||||
|
||||
public int Index
|
||||
{
|
||||
get { return (int)GetValue(IndexProperty); }
|
||||
set { SetValue(IndexProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty CountProperty =
|
||||
DependencyProperty.Register("Count", typeof(int), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(1, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure, UpdateItemRendering));
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return (int)GetValue(CountProperty); }
|
||||
set { SetValue(CountProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HalfShiftedProperty =
|
||||
DependencyProperty.Register("HalfShifted", typeof(bool), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure, UpdateItemRendering));
|
||||
|
||||
public bool HalfShifted
|
||||
{
|
||||
get { return (bool)GetValue(HalfShiftedProperty); }
|
||||
set { SetValue(HalfShiftedProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty CenterXProperty =
|
||||
DependencyProperty.Register("CenterX", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double CenterX
|
||||
{
|
||||
get { return (double)GetValue(CenterXProperty); }
|
||||
set { SetValue(CenterXProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty CenterYProperty =
|
||||
DependencyProperty.Register("CenterY", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double CenterY
|
||||
{
|
||||
get { return (double)GetValue(CenterYProperty); }
|
||||
set { SetValue(CenterYProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OuterRadiusProperty =
|
||||
DependencyProperty.Register("OuterRadius", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double OuterRadius
|
||||
{
|
||||
get { return (double)GetValue(OuterRadiusProperty); }
|
||||
set { SetValue(OuterRadiusProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty InnerRadiusProperty =
|
||||
DependencyProperty.Register("InnerRadius", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double InnerRadius
|
||||
{
|
||||
get { return (double)GetValue(InnerRadiusProperty); }
|
||||
set { SetValue(InnerRadiusProperty, value); }
|
||||
}
|
||||
|
||||
public new static readonly DependencyProperty PaddingProperty =
|
||||
DependencyProperty.Register("Padding", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public new double Padding
|
||||
{
|
||||
get { return (double)GetValue(PaddingProperty); }
|
||||
set { SetValue(PaddingProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ContentRadiusProperty =
|
||||
DependencyProperty.Register("ContentRadius", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double ContentRadius
|
||||
{
|
||||
get { return (double)GetValue(ContentRadiusProperty); }
|
||||
set { SetValue(ContentRadiusProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty EdgeOuterRadiusProperty =
|
||||
DependencyProperty.Register("EdgeOuterRadius", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double EdgeOuterRadius
|
||||
{
|
||||
get { return (double)GetValue(EdgeOuterRadiusProperty); }
|
||||
set { SetValue(EdgeOuterRadiusProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty EdgeInnerRadiusProperty =
|
||||
DependencyProperty.Register("EdgeInnerRadius", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double EdgeInnerRadius
|
||||
{
|
||||
get { return (double)GetValue(EdgeInnerRadiusProperty); }
|
||||
set { SetValue(EdgeInnerRadiusProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty EdgePaddingProperty =
|
||||
DependencyProperty.Register("EdgePadding", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double EdgePadding
|
||||
{
|
||||
get { return (double)GetValue(EdgePaddingProperty); }
|
||||
set { SetValue(EdgePaddingProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty EdgeBackgroundProperty =
|
||||
DependencyProperty.Register("EdgeBackground", typeof(Brush), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public Brush EdgeBackground
|
||||
{
|
||||
get { return (Brush)GetValue(EdgeBackgroundProperty); }
|
||||
set { SetValue(EdgeBackgroundProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty EdgeBorderThicknessProperty =
|
||||
DependencyProperty.Register("EdgeBorderThickness", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double EdgeBorderThickness
|
||||
{
|
||||
get { return (double)GetValue(EdgeBorderThicknessProperty); }
|
||||
set { SetValue(EdgeBorderThicknessProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty EdgeBorderBrushProperty =
|
||||
DependencyProperty.Register("EdgeBorderBrush", typeof(Brush), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public Brush EdgeBorderBrush
|
||||
{
|
||||
get { return (Brush)GetValue(EdgeBorderBrushProperty); }
|
||||
set { SetValue(EdgeBorderBrushProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ArrowBackgroundProperty =
|
||||
DependencyProperty.Register("ArrowBackground", typeof(Brush), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public Brush ArrowBackground
|
||||
{
|
||||
get { return (Brush)GetValue(ArrowBackgroundProperty); }
|
||||
set { SetValue(ArrowBackgroundProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ArrowBorderThicknessProperty =
|
||||
DependencyProperty.Register("ArrowBorderThickness", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double ArrowBorderThickness
|
||||
{
|
||||
get { return (double)GetValue(ArrowBorderThicknessProperty); }
|
||||
set { SetValue(ArrowBorderThicknessProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ArrowBorderBrushProperty =
|
||||
DependencyProperty.Register("ArrowBorderBrush", typeof(Brush), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public Brush ArrowBorderBrush
|
||||
{
|
||||
get { return (Brush)GetValue(ArrowBorderBrushProperty); }
|
||||
set { SetValue(ArrowBorderBrushProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ArrowWidthProperty =
|
||||
DependencyProperty.Register("ArrowWidth", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double ArrowWidth
|
||||
{
|
||||
get { return (double)GetValue(ArrowWidthProperty); }
|
||||
set { SetValue(ArrowWidthProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ArrowHeightProperty =
|
||||
DependencyProperty.Register("ArrowHeight", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double ArrowHeight
|
||||
{
|
||||
get { return (double)GetValue(ArrowHeightProperty); }
|
||||
set { SetValue(ArrowHeightProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ArrowRadiusProperty =
|
||||
DependencyProperty.Register("ArrowRadius", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public double ArrowRadius
|
||||
{
|
||||
get { return (double)GetValue(ArrowRadiusProperty); }
|
||||
set { SetValue(ArrowRadiusProperty, value); }
|
||||
}
|
||||
|
||||
protected static readonly DependencyPropertyKey AngleDeltaPropertyKey =
|
||||
DependencyProperty.RegisterReadOnly("AngleDelta", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(200.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public static readonly DependencyProperty AngleDeltaProperty = AngleDeltaPropertyKey.DependencyProperty;
|
||||
|
||||
public double AngleDelta
|
||||
{
|
||||
get { return (double)GetValue(AngleDeltaProperty); }
|
||||
protected set { SetValue(AngleDeltaPropertyKey, value); }
|
||||
}
|
||||
|
||||
protected static readonly DependencyPropertyKey StartAnglePropertyKey =
|
||||
DependencyProperty.RegisterReadOnly("StartAngle", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public static readonly DependencyProperty StartAngleProperty = StartAnglePropertyKey.DependencyProperty;
|
||||
|
||||
public double StartAngle
|
||||
{
|
||||
get { return (double)GetValue(StartAngleProperty); }
|
||||
protected set { SetValue(StartAnglePropertyKey, value); }
|
||||
}
|
||||
|
||||
protected static readonly DependencyPropertyKey RotationPropertyKey =
|
||||
DependencyProperty.RegisterReadOnly("Rotation", typeof(double), typeof(RadialMenuItem),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||
|
||||
public static readonly DependencyProperty RotationProperty = RotationPropertyKey.DependencyProperty;
|
||||
|
||||
public double Rotation
|
||||
{
|
||||
get { return (double)GetValue(RotationProperty); }
|
||||
protected set { SetValue(RotationPropertyKey, value); }
|
||||
}
|
||||
|
||||
static RadialMenuItem()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(RadialMenuItem), new FrameworkPropertyMetadata(typeof(RadialMenuItem)));
|
||||
}
|
||||
|
||||
private static void UpdateItemRendering(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
RadialMenuItem item = d as RadialMenuItem;
|
||||
if (item != null)
|
||||
{
|
||||
var angleDelta = 360.0 / item.Count;
|
||||
var angleShift = item.HalfShifted ? -angleDelta / 2 : 0;
|
||||
var startAngle = angleDelta * item.Index + angleShift;
|
||||
var rotation = startAngle + angleDelta / 2;
|
||||
|
||||
item.AngleDelta = angleDelta;
|
||||
item.StartAngle = startAngle;
|
||||
item.Rotation = rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user