Adjust project structure

This commit is contained in:
NaBian committed 2019-04-05 22:23:19 +08:00
1 parent d38912f5da
commit e3c436f939
2111 files changed
+14028 -47199

No files matched your search

@@ -0,0 +1,60 @@
using System.Windows;
using System.Windows.Media;
using HandyControl.Expression.Media;
namespace HandyControl.Expression.Shapes
{
public sealed class Arc : PrimitiveShape, IArcGeometrySourceParameters
{
public static readonly DependencyProperty ArcThicknessProperty =
DependencyProperty.Register("ArcThickness", typeof(double), typeof(Arc),
new DrawingPropertyMetadata(0.0, DrawingPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty ArcThicknessUnitProperty =
DependencyProperty.Register("ArcThicknessUnit", typeof(UnitType), typeof(Arc),
new DrawingPropertyMetadata(UnitType.Pixel, DrawingPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty EndAngleProperty = DependencyProperty.Register("EndAngle",
typeof(double), typeof(Arc),
new DrawingPropertyMetadata(90.0, DrawingPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty StartAngleProperty =
DependencyProperty.Register("StartAngle", typeof(double), typeof(Arc),
new DrawingPropertyMetadata(0.0, DrawingPropertyMetadataOptions.AffectsRender));
public double ArcThickness
{
get => (double) GetValue(ArcThicknessProperty);
set => SetValue(ArcThicknessProperty, value);
}
public UnitType ArcThicknessUnit
{
get => (UnitType) GetValue(ArcThicknessUnitProperty);
set => SetValue(ArcThicknessUnitProperty, value);
}
public double EndAngle
{
get => (double) GetValue(EndAngleProperty);
set => SetValue(EndAngleProperty, value);
}
Stretch IGeometrySourceParameters.Stretch => Stretch;
Brush IGeometrySourceParameters.Stroke => Stroke;
double IGeometrySourceParameters.StrokeThickness => StrokeThickness;
public double StartAngle
{
get => (double) GetValue(StartAngleProperty);
set => SetValue(StartAngleProperty, value);
}
protected override IGeometrySource CreateGeometrySource()
{
return new ArcGeometrySource();
}
}
}
@@ -0,0 +1,79 @@
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using HandyControl.Expression.Drawing;
using HandyControl.Expression.Media;
namespace HandyControl.Expression.Shapes
{
public abstract class PrimitiveShape : Shape, IGeometrySourceParameters, IShape
{
private IGeometrySource _geometrySource;
static PrimitiveShape()
{
StretchProperty.OverrideMetadata(typeof(PrimitiveShape),
new DrawingPropertyMetadata(Stretch.Fill, DrawingPropertyMetadataOptions.AffectsRender));
StrokeThicknessProperty.OverrideMetadata(typeof(PrimitiveShape),
new DrawingPropertyMetadata(1.0, DrawingPropertyMetadataOptions.AffectsRender));
}
protected sealed override Geometry DefiningGeometry =>
GeometrySource.Geometry ?? Geometry.Empty;
private IGeometrySource GeometrySource => _geometrySource ?? (_geometrySource = CreateGeometrySource());
Stretch IGeometrySourceParameters.Stretch => Stretch;
Brush IGeometrySourceParameters.Stroke => Stroke;
double IGeometrySourceParameters.StrokeThickness => StrokeThickness;
public event EventHandler RenderedGeometryChanged;
public void InvalidateGeometry(InvalidateGeometryReasons reasons)
{
if (GeometrySource.InvalidateGeometry(reasons)) InvalidateArrange();
}
public Thickness GeometryMargin => GeometrySource.LogicalBounds.Subtract(RenderedGeometry.Bounds);
Brush IShape.Fill
{
get => Fill;
set => Fill = value;
}
Stretch IShape.Stretch
{
get => Stretch;
set => Stretch = value;
}
Brush IShape.Stroke
{
get => Stroke;
set => Stroke = value;
}
double IShape.StrokeThickness
{
get => StrokeThickness;
set => StrokeThickness = value;
}
protected override Size ArrangeOverride(Size finalSize)
{
if (GeometrySource.UpdateGeometry(this, finalSize.Bounds())) RealizeGeometry();
base.ArrangeOverride(finalSize);
return finalSize;
}
protected abstract IGeometrySource CreateGeometrySource();
protected override Size MeasureOverride(Size availableSize) => new Size(base.StrokeThickness, base.StrokeThickness);
private void RealizeGeometry() => RenderedGeometryChanged?.Invoke(this, EventArgs.Empty);
}
}