Sicherung
400
RadialMenu/.gitignore
vendored
@@ -1,400 +0,0 @@
|
||||
# ---> VisualStudio
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,279 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace RadialMenu.Converters
|
||||
{
|
||||
internal class RadialMenuItemToArrowPosition : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values.Length != 5)
|
||||
{
|
||||
throw new ArgumentException("RadialMenuItemToArrowPosition converter needs 7 values (double centerX, double centerY, double arrowWidth, double arrowHeight, double arrowRadius) !", "values");
|
||||
}
|
||||
if (parameter == null)
|
||||
{
|
||||
throw new ArgumentNullException("parameter", "RadialMenuItemToArrowPosition converter needs the parameter (string axis) !");
|
||||
}
|
||||
|
||||
string axis = (string)parameter;
|
||||
|
||||
if (axis != "X" && axis != "Y")
|
||||
{
|
||||
throw new ArgumentException("RadialMenuItemToArrowPosition parameter needs to be 'X' or 'Y' !", "parameter");
|
||||
}
|
||||
|
||||
double centerX = (double)values[0];
|
||||
double centerY = (double)values[1];
|
||||
double arrowWidth = (double)values[2];
|
||||
double arrowHeight = (double)values[3];
|
||||
double arrowRadius = (double)values[4];
|
||||
|
||||
if (axis == "X")
|
||||
{
|
||||
return centerX - (arrowWidth / 2);
|
||||
}
|
||||
|
||||
return centerY - arrowRadius - (arrowHeight / 2);
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new InvalidOperationException("RadialMenuItemToArrowPosition is a One-Way converter only !");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace RadialMenu.Converters
|
||||
{
|
||||
internal class RadialMenuItemToContentPosition : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values.Length != 6)
|
||||
{
|
||||
throw new ArgumentException("RadialMenuItemToContentPosition converter needs 6 values (double angle, double centerX, double centerY, double contentWidth, double contentHeight, double contentRadius) !", "values");
|
||||
}
|
||||
if (parameter == null)
|
||||
{
|
||||
throw new ArgumentNullException("parameter", "RadialMenuItemToContentPosition converter needs the parameter (string axis) !");
|
||||
}
|
||||
|
||||
string axis = (string)parameter;
|
||||
|
||||
if (axis != "X" && axis != "Y")
|
||||
{
|
||||
throw new ArgumentException("RadialMenuItemToContentPosition parameter needs to be 'X' or 'Y' !", "parameter");
|
||||
}
|
||||
|
||||
double angle = (double)values[0];
|
||||
double centerX = (double)values[1];
|
||||
double centerY = (double)values[2];
|
||||
double contentWidth = (double)values[3];
|
||||
double contentHeight = (double)values[4];
|
||||
double contentRadius = (double)values[5];
|
||||
|
||||
Point contentPosition = ComputeCartesianCoordinate(new Point(centerX, centerY), angle, contentRadius);
|
||||
|
||||
if (axis == "X")
|
||||
{
|
||||
return contentPosition.X - (contentWidth / 2);
|
||||
}
|
||||
|
||||
return contentPosition.Y - (contentHeight / 2);
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new InvalidOperationException("RadialMenuItemToContentPosition is a One-Way converter only !");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RadialMenu")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("RadialMenu")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly:ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,215 +0,0 @@
|
||||
RadialMenu
|
||||
===========
|
||||
Quelle : https://github.com/Julien-Marcou/RadialMenu#readme
|
||||
|
||||
A custom control to create radial-menu into your WPF application.
|
||||
|
||||

|
||||
|
||||
How to use
|
||||
-----------
|
||||
|
||||
Import the RadialMenu.dll into your project (do not forget to reference it),
|
||||
then into your Xaml View, import the custom control
|
||||
|
||||
xmlns:Controls="clr-namespace:RadialMenu.Controls;assembly=RadialMenu"
|
||||
|
||||
To create the **main component** of the RadialMenu, simply type
|
||||
|
||||
```xaml
|
||||
<Controls:RadialMenu>
|
||||
...
|
||||
</Controls:RadialMenu>
|
||||
```
|
||||
|
||||
To create the **central menu item** of the RadialMenu, simply type
|
||||
|
||||
```xaml
|
||||
<Controls:RadialMenuCentralItem>
|
||||
...
|
||||
</Controls:RadialMenuCentralItem>
|
||||
```
|
||||
|
||||
To create a **menu item** of the RadialMenu, simply type
|
||||
|
||||
```xaml
|
||||
<Controls:RadialMenuItem>
|
||||
...
|
||||
</Controls:RadialMenuItem>
|
||||
```
|
||||
|
||||
Full example
|
||||
-----------
|
||||
|
||||
A tipical example of what can be done
|
||||
|
||||
```xaml
|
||||
<RadialMenu:RadialMenu IsOpen="{Binding IsOpen}">
|
||||
|
||||
<!-- CentralMenuItem -->
|
||||
|
||||
<RadialMenu:RadialMenu.CentralItem>
|
||||
<RadialMenu:RadialMenuCentralItem Command="{Binding CloseRadialMenuCommand}">
|
||||
<TextBlock>Close</TextBlock>
|
||||
</RadialMenu:RadialMenuCentralItem>
|
||||
</RadialMenu:RadialMenu.CentralItem>
|
||||
|
||||
<!-- MenuItems Around -->
|
||||
|
||||
<RadialMenu:RadialMenuItem Command="{Binding NewFileCommand}">
|
||||
<TextBlock>New file</TextBlock>
|
||||
</RadialMenu:RadialMenuItem>
|
||||
|
||||
<RadialMenu:RadialMenuItem Command="{Binding EditCommand}">
|
||||
<TextBlock>Edit</TextBlock>
|
||||
</RadialMenu:RadialMenuItem>
|
||||
|
||||
<RadialMenu:RadialMenuItem Command="{Binding SaveCommand}">
|
||||
<TextBlock>Save</TextBlock>
|
||||
</RadialMenu:RadialMenuItem>
|
||||
|
||||
<RadialMenu:RadialMenuItem Command="{Binding DeleteCommand}">
|
||||
<TextBlock>Delete</TextBlock>
|
||||
</RadialMenu:RadialMenuItem>
|
||||
|
||||
<RadialMenu:RadialMenuItem Command="{Binding ExitCommand}">
|
||||
<TextBlock>Exit</TextBlock>
|
||||
</RadialMenu:RadialMenuItem>
|
||||
|
||||
<!-- Add items as you want... -->
|
||||
|
||||
</RadialMenu:RadialMenu>
|
||||
```
|
||||
|
||||
which results in
|
||||
|
||||

|
||||
|
||||
Customization
|
||||
-----------
|
||||
|
||||
You can even create your own style of RadialMenu (do not forget to add style for `disabled`, `hovered` and `pressed` item states if desired)
|
||||
|
||||
```xaml
|
||||
<Style x:Key="FancyRadialMenuCentralItem" TargetType="Controls:RadialMenuCentralItem" BasedOn="{StaticResource {x:Type Controls:RadialMenuCentralItem}}">
|
||||
|
||||
<Setter Property="Background" Value="AliceBlue"/>
|
||||
<Setter Property="BorderBrush" Value="DarkBlue"/>
|
||||
<Setter Property="BorderThickness" Value="4"/>
|
||||
<Setter Property="Width" Value="64"/>
|
||||
<Setter Property="Height" Value="64"/>
|
||||
|
||||
</Style>
|
||||
|
||||
<Style x:Key="FancyRadialMenuItem" TargetType="Controls:RadialMenuItem" BasedOn="{StaticResource {x:Type Controls:RadialMenuItem}}">
|
||||
|
||||
<Setter Property="Background" Value="AliceBlue"/>
|
||||
<Setter Property="Padding" Value="2"/>
|
||||
<Setter Property="InnerRadius" Value="40"/>
|
||||
<Setter Property="OuterRadius" Value="150"/>
|
||||
<Setter Property="ContentRadius" Value="85"/>
|
||||
|
||||
<Setter Property="EdgeBackground" Value="DarkBlue"/>
|
||||
<Setter Property="EdgePadding" Value="7"/>
|
||||
<Setter Property="EdgeInnerRadius" Value="130"/>
|
||||
<Setter Property="EdgeOuterRadius" Value="145"/>
|
||||
|
||||
<Setter Property="ArrowBackground" Value="Cyan"/>
|
||||
<Setter Property="ArrowRadius" Value="138"/>
|
||||
|
||||
</Style>
|
||||
```
|
||||
|
||||
which results in
|
||||
|
||||

|
||||
|
||||
Advanced Usage
|
||||
-----------
|
||||
|
||||
- The radial menu will not scale by default (and transform controls will break it). To modify the size you want to adjust the Radius properties on the style. You will most likely need to adjust OuterRadius, ContentRadius, EdgeInnerRadius, EdgeOuterRadius, and ArrowRadius to resize the control
|
||||
- When creating RadialMenuItems try to stick the text in a TextBlock for the best formatting results
|
||||
- You can hide the arrow on a RadialMenuItem by setting its ArrowBackground to Transparent
|
||||
- To update the control from code behind after creation you cannot simply update the radialMenu.Items list, you must replace it with a new collection. For example:
|
||||
|
||||
```csharp
|
||||
MyRadialMenu.Items = new List<RadialMenuItem>
|
||||
{
|
||||
new RadialMenuItem
|
||||
{
|
||||
Content = new TextBlock { Text = "Hello" }
|
||||
},
|
||||
new RadialMenuItem
|
||||
{
|
||||
Content = new TextBlock { Text = "World" }
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Multi-level menu
|
||||
-----------
|
||||
|
||||
You can easily create multi-level radial menus by using the arrow as a visual queue and then replacing the items with an updated set. For example:
|
||||
|
||||
```xaml
|
||||
<RadialMenu:RadialMenu x:Name="MyRadialMenu" IsOpen="{Binding IsOpen}">
|
||||
...
|
||||
</RadialMenu:RadialMenu>
|
||||
```
|
||||
|
||||
```csharp
|
||||
// Main menu
|
||||
var MainMenuItems = new List<RadialMenuItem>
|
||||
{
|
||||
new RadialMenuItem
|
||||
{
|
||||
Content = new TextBlock { Text = "Item 1" },
|
||||
ArrowBackground = Brushes.Transparent
|
||||
},
|
||||
new RadialMenuItem
|
||||
{
|
||||
Content = new TextBlock { Text = "Item 2" },
|
||||
ArrowBackground = Brushes.Transparent
|
||||
},
|
||||
new RadialMenuItem
|
||||
{
|
||||
Content = new TextBlock { Text = "Sub Menu" }
|
||||
}
|
||||
};
|
||||
|
||||
// Sub menu
|
||||
var SubMenuItems = new List<RadialMenuItem>
|
||||
{
|
||||
new RadialMenuItem
|
||||
{
|
||||
Content = new TextBlock { Text = "Sub Item 1" },
|
||||
ArrowBackground = Brushes.Transparent
|
||||
},
|
||||
new RadialMenuItem
|
||||
{
|
||||
Content = new TextBlock { Text = "Sub Item 2" },
|
||||
ArrowBackground = Brushes.Transparent
|
||||
},
|
||||
new RadialMenuItem
|
||||
{
|
||||
Content = new TextBlock { Text = "Sub Item 3" },
|
||||
ArrowBackground = Brushes.Transparent
|
||||
}
|
||||
};
|
||||
|
||||
// Go to Sub menu when clicking on the third item
|
||||
MainMenuItems[2].Click += async (sender, args) =>
|
||||
{
|
||||
IsOpen = false;
|
||||
await Task.Delay(400);
|
||||
MyRadialMenu.Items = SubMenuItems;
|
||||
IsOpen = true;
|
||||
};
|
||||
|
||||
// Set default menu to Main menu
|
||||
MyRadialMenu.Items = MainMenuItems;
|
||||
```
|
||||
|
||||
Which results in
|
||||
|
||||
![RadialMenu Multi-Levels]/Resources/RadialMenuMultiLevels.gif)
|
||||
@@ -1,13 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows;net472</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Before Width: | Height: | Size: 299 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 139 KiB |
@@ -1,12 +0,0 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/RadialMenu;component/Themes/PieShape.xaml"/>
|
||||
<ResourceDictionary Source="/RadialMenu;component/Themes/RadialMenu.xaml"/>
|
||||
<ResourceDictionary Source="/RadialMenu;component/Themes/RadialMenuCentralItem.xaml"/>
|
||||
<ResourceDictionary Source="/RadialMenu;component/Themes/RadialMenuItem.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -1,10 +0,0 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Controls="clr-namespace:RadialMenu.Controls">
|
||||
|
||||
<Style TargetType="Controls:PieShape">
|
||||
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -1,110 +0,0 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Controls="clr-namespace:RadialMenu.Controls">
|
||||
|
||||
<Style TargetType="Controls:RadialMenu">
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsOpen" Value="True">
|
||||
|
||||
<!-- RadialMenu openning animation -->
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="1"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX">
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="1"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY">
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="1"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
Storyboard.TargetProperty="RenderTransform.Children[1].Angle">
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="0"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.EnterActions>
|
||||
|
||||
<!-- RadialMenu closing animation -->
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="0"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX">
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="0.5"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY">
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="0.5"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
Storyboard.TargetProperty="RenderTransform.Children[1].Angle">
|
||||
<SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="-50"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="0:0:0.4" Value="{x:Static Visibility.Collapsed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.ExitActions>
|
||||
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
|
||||
<!-- Default RadialMenu style (while closed) -->
|
||||
<Setter Property="Opacity" Value="0"/>
|
||||
<Setter Property="Visibility" Value="Collapsed"/>
|
||||
<Setter Property="Height" Value="300"/>
|
||||
<Setter Property="Width" Value="300"/>
|
||||
<Setter Property="RenderTransform">
|
||||
<Setter.Value>
|
||||
<TransformGroup>
|
||||
<ScaleTransform CenterX="150" CenterY="150" ScaleX="0.5" ScaleY="0.5"/>
|
||||
<RotateTransform CenterX="150" CenterY="150" Angle="-50"/>
|
||||
</TransformGroup>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
<!-- RadialMenu template -->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
|
||||
<ControlTemplate TargetType="Controls:RadialMenu">
|
||||
<Grid>
|
||||
|
||||
<!-- RadialMenu background -->
|
||||
<Ellipse Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/>
|
||||
|
||||
<!-- Content repitition (for items around) -->
|
||||
<ItemsControl ItemsSource="{TemplateBinding Content}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
|
||||
<!-- Content (for central item) -->
|
||||
<ContentPresenter Content="{TemplateBinding CentralItem}"/>
|
||||
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -1,68 +0,0 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Controls="clr-namespace:RadialMenu.Controls">
|
||||
|
||||
<Style TargetType="Controls:RadialMenuCentralItem">
|
||||
|
||||
<Style.Triggers>
|
||||
|
||||
<!-- RadialMenuCentralItem style when overed -->
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" Value="#999"/>
|
||||
<Setter Property="Panel.ZIndex" Value="10"/>
|
||||
</Trigger>
|
||||
|
||||
<!-- RadialMenuCentralItem style when pressed -->
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="BorderBrush" Value="#666"/>
|
||||
<Setter Property="Panel.ZIndex" Value="10"/>
|
||||
</Trigger>
|
||||
|
||||
<!-- RadialMenuCentralItem style when disabled -->
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="BorderBrush" Value="#F3F3F3"/>
|
||||
<Setter Property="Foreground" Value="#AFAFAF"/>
|
||||
</Trigger>
|
||||
|
||||
</Style.Triggers>
|
||||
|
||||
<!-- Default RadialMenuCentralItem style -->
|
||||
<Setter Property="Width" Value="60"/>
|
||||
<Setter Property="Height" Value="60"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#111"/>
|
||||
<Setter Property="BorderBrush" Value="#CCC"/>
|
||||
<Setter Property="BorderThickness" Value="2"/>
|
||||
<Setter Property="Panel.ZIndex" Value="0"/>
|
||||
|
||||
<!-- RadialMenuCentralItem template -->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
|
||||
<ControlTemplate TargetType="Controls:RadialMenuCentralItem">
|
||||
<Grid>
|
||||
|
||||
<!-- Rounded button -->
|
||||
<Ellipse
|
||||
Stroke="{TemplateBinding BorderBrush}"
|
||||
StrokeThickness="{Binding BorderThickness.Top, RelativeSource={RelativeSource AncestorType=Controls:RadialMenuCentralItem}}"
|
||||
Fill="{TemplateBinding Background}"/>
|
||||
|
||||
<!-- Content -->
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Content}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"/>
|
||||
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -1,182 +0,0 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Controls="clr-namespace:RadialMenu.Controls"
|
||||
xmlns:Converters="clr-namespace:RadialMenu.Converters">
|
||||
|
||||
<Converters:RadialMenuItemToContentPosition x:Key="RadialMenuItemToContentPosition"/>
|
||||
<Converters:RadialMenuItemToArrowPosition x:Key="RadialMenuItemToArrowPosition"/>
|
||||
|
||||
<Style x:Key="RoundedArrowPath" TargetType="Path">
|
||||
<Setter Property="Data" Value="m 5.427 222.9380 c 3.614 3.617 7.898 5.424 12.848 5.424 l 255.813 0 c 4.952 0 9.233 -1.807 12.85 -5.424 3.617 -3.621 5.424 -7.902 5.424 -12.851 0 -4.948 -1.807 -9.229 -5.424 -12.847 L 159.031 69.3330 c -3.621 -3.617 -7.902 -5.428 -12.85 -5.428 -4.948 0 -9.233 1.811 -12.847 5.428 L 5.427 197.2410 C 1.814 200.8580 0 205.1390 0 210.0880 c 0 4.948 1.814 9.229 5.427 12.85 z"/>
|
||||
<Setter Property="Width" Value="76"/>
|
||||
<Setter Property="Height" Value="42.75"/>
|
||||
<Setter Property="Stretch" Value="Fill"/>
|
||||
<Setter Property="Canvas.Left" Value="0"/>
|
||||
<Setter Property="Canvas.Top" Value="16.125"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Controls:RadialMenuItem">
|
||||
|
||||
<Style.Triggers>
|
||||
|
||||
<!-- RadialMenuItem style when overed -->
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="EdgeBackground" Value="#999"/>
|
||||
<Setter Property="Panel.ZIndex" Value="10"/>
|
||||
</Trigger>
|
||||
|
||||
<!-- RadialMenuItem style when pressed -->
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="EdgeBackground" Value="#666"/>
|
||||
<Setter Property="Panel.ZIndex" Value="10"/>
|
||||
</Trigger>
|
||||
|
||||
<!-- RadialMenuItem style when disabled -->
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="EdgeBackground" Value="#F3F3F3"/>
|
||||
<Setter Property="Foreground" Value="#AFAFAF"/>
|
||||
</Trigger>
|
||||
|
||||
</Style.Triggers>
|
||||
|
||||
<!-- Default RadialMenuItem style -->
|
||||
<Setter Property="Width" Value="300"/>
|
||||
<Setter Property="Height" Value="300"/>
|
||||
<Setter Property="CenterX" Value="150"/>
|
||||
<Setter Property="CenterY" Value="150"/>
|
||||
<Setter Property="InnerRadius" Value="30"/>
|
||||
<Setter Property="OuterRadius" Value="150"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#111"/>
|
||||
<Setter Property="EdgeInnerRadius" Value="135"/>
|
||||
<Setter Property="EdgeOuterRadius" Value="150"/>
|
||||
<Setter Property="EdgeBackground" Value="#CCC"/>
|
||||
<Setter Property="EdgePadding" Value="2"/>
|
||||
<Setter Property="ContentRadius" Value="82.5"/>
|
||||
<Setter Property="ArrowBackground" Value="#FFF"/>
|
||||
<Setter Property="ArrowRadius" Value="142.5"/>
|
||||
<Setter Property="ArrowWidth" Value="14"/>
|
||||
<Setter Property="ArrowHeight" Value="14"/>
|
||||
<Setter Property="Panel.ZIndex" Value="0"/>
|
||||
|
||||
<!-- RadialMenuItem template -->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
|
||||
<ControlTemplate TargetType="Controls:RadialMenuItem">
|
||||
<Canvas Panel.ZIndex="{TemplateBinding Panel.ZIndex}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
|
||||
|
||||
<!-- Main pie piece -->
|
||||
<Controls:PieShape
|
||||
CenterX="{TemplateBinding CenterX}"
|
||||
CenterY="{TemplateBinding CenterY}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
OuterRadius="{TemplateBinding OuterRadius}"
|
||||
InnerRadius="{TemplateBinding InnerRadius}"
|
||||
Fill="{TemplateBinding Background}"
|
||||
StrokeThickness="{Binding BorderThickness.Top, RelativeSource={RelativeSource AncestorType=Controls:RadialMenuItem}}"
|
||||
Stroke="{TemplateBinding BorderBrush}"
|
||||
StartAngle="{TemplateBinding StartAngle}"
|
||||
AngleDelta="{TemplateBinding AngleDelta}"/>
|
||||
|
||||
<!-- Edge pie piece -->
|
||||
<Controls:PieShape
|
||||
CenterX="{TemplateBinding CenterX}"
|
||||
CenterY="{TemplateBinding CenterY}"
|
||||
Padding="{TemplateBinding EdgePadding}"
|
||||
OuterRadius="{TemplateBinding EdgeOuterRadius}"
|
||||
InnerRadius="{TemplateBinding EdgeInnerRadius}"
|
||||
Fill="{TemplateBinding EdgeBackground}"
|
||||
StrokeThickness="{TemplateBinding EdgeBorderThickness}"
|
||||
Stroke="{TemplateBinding EdgeBorderBrush}"
|
||||
StartAngle="{TemplateBinding StartAngle}"
|
||||
AngleDelta="{TemplateBinding AngleDelta}"/>
|
||||
|
||||
<!-- Edge content (arrow) -->
|
||||
<Canvas>
|
||||
|
||||
<Canvas.RenderTransform>
|
||||
<!-- See : http://stackoverflow.com/a/3190907/2837434 -->
|
||||
<RotateTransform
|
||||
x:Name="BindingErrorFix"
|
||||
Angle="{Binding Rotation, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
CenterX="{Binding CenterX, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
CenterY="{Binding CenterY, RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</Canvas.RenderTransform>
|
||||
|
||||
<Rectangle Width="{TemplateBinding ArrowWidth}" Height="{TemplateBinding ArrowHeight}">
|
||||
|
||||
<Canvas.Left>
|
||||
<MultiBinding Converter="{StaticResource RadialMenuItemToArrowPosition}" ConverterParameter="X">
|
||||
<Binding Path="CenterX" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="CenterY" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="ArrowWidth" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="ArrowHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="ArrowRadius" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
</MultiBinding>
|
||||
</Canvas.Left>
|
||||
|
||||
<Canvas.Top>
|
||||
<MultiBinding Converter="{StaticResource RadialMenuItemToArrowPosition}" ConverterParameter="Y">
|
||||
<Binding Path="CenterX" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="CenterY" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="ArrowWidth" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="ArrowHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="ArrowRadius" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
</MultiBinding>
|
||||
</Canvas.Top>
|
||||
|
||||
<Rectangle.Fill>
|
||||
<VisualBrush>
|
||||
<VisualBrush.Visual>
|
||||
<Canvas Width="76" Height="76" Background="Transparent">
|
||||
<Path
|
||||
Style="{StaticResource RoundedArrowPath}"
|
||||
Stroke="{TemplateBinding ArrowBorderBrush}"
|
||||
StrokeThickness="{TemplateBinding ArrowBorderThickness}"
|
||||
Fill="{TemplateBinding ArrowBackground}"/>
|
||||
</Canvas>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Rectangle.Fill>
|
||||
|
||||
</Rectangle>
|
||||
</Canvas>
|
||||
|
||||
<!-- Main content -->
|
||||
<ContentControl Content="{TemplateBinding Content}">
|
||||
|
||||
<Canvas.Left>
|
||||
<MultiBinding Converter="{StaticResource RadialMenuItemToContentPosition}" ConverterParameter="X">
|
||||
<Binding Path="Rotation" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="CenterX" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="CenterY" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="Content.ActualWidth" RelativeSource="{RelativeSource TemplatedParent}" FallbackValue="0"/>
|
||||
<Binding Path="Content.ActualHeight" RelativeSource="{RelativeSource TemplatedParent}" FallbackValue="0"/>
|
||||
<Binding Path="ContentRadius" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
</MultiBinding>
|
||||
</Canvas.Left>
|
||||
|
||||
<Canvas.Top>
|
||||
<MultiBinding Converter="{StaticResource RadialMenuItemToContentPosition}" ConverterParameter="Y">
|
||||
<Binding Path="Rotation" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="CenterX" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="CenterY" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
<Binding Path="Content.ActualWidth" RelativeSource="{RelativeSource TemplatedParent}" FallbackValue="0"/>
|
||||
<Binding Path="Content.ActualHeight" RelativeSource="{RelativeSource TemplatedParent}" FallbackValue="0"/>
|
||||
<Binding Path="ContentRadius" RelativeSource="{RelativeSource TemplatedParent}"/>
|
||||
</MultiBinding>
|
||||
</Canvas.Top>
|
||||
|
||||
</ContentControl>
|
||||
|
||||
</Canvas>
|
||||
</ControlTemplate>
|
||||
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||