aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/TEMP/Tango.Graphics2D/VisualBinders/PathBinder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/TEMP/Tango.Graphics2D/VisualBinders/PathBinder.cs')
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Graphics2D/VisualBinders/PathBinder.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/Software/Visual_Studio/TEMP/Tango.Graphics2D/VisualBinders/PathBinder.cs b/Software/Visual_Studio/TEMP/Tango.Graphics2D/VisualBinders/PathBinder.cs
new file mode 100644
index 000000000..903d62010
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Graphics2D/VisualBinders/PathBinder.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Shapes;
+
+namespace Tango.Graphics2D.VisualBinders
+{
+ public class PathBinder : IVisualBinder
+ {
+ public void DrawVisual(FrameworkElement element, Drawing2DHost host, DrawingContext context)
+ {
+ Path path = element as Path;
+
+ var location = host.GetElementLocation(path);
+ var size = host.GetElementSize(path);
+
+ Pen pen = null;
+
+ if (path.Stroke != null)
+ {
+ pen = new Pen(path.Stroke, path.StrokeThickness);
+ pen.DashCap = path.StrokeDashCap;
+ //TODO: add some stroke features...
+ }
+
+ var geo = path.Data.Clone();
+
+
+ if (path.Stretch == Stretch.Fill)
+ {
+ TransformGroup group = new TransformGroup();
+
+ TranslateTransform translateTransform = new TranslateTransform();
+ translateTransform.X = -geo.Bounds.Left;
+ translateTransform.Y = -geo.Bounds.Top;
+
+ ScaleTransform scaleTransform = new ScaleTransform();
+ scaleTransform.ScaleX = size.Width / geo.Bounds.Width;
+ scaleTransform.ScaleY = size.Height / geo.Bounds.Height;
+
+ group.Children.Add(translateTransform);
+ group.Children.Add(scaleTransform);
+
+ context.PushTransform(group);
+ }
+
+ context.DrawGeometry(path.Fill, pen, geo);
+ }
+
+ public List<DependencyProperty> GetRenderProperties()
+ {
+ return new List<DependencyProperty>()
+ {
+ Path.OpacityProperty,
+ Path.VisibilityProperty,
+ Path.FillProperty,
+ Path.StrokeProperty,
+ Path.StrokeThicknessProperty,
+ Path.StretchProperty
+ };
+ }
+ }
+}