[longomatch] Start with Drawables implementation with Line and Circle



commit 86f924103f8abd3403fb5762450e1d9ba0a25f69
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Jun 17 18:53:33 2014 +0200

    Start with Drawables implementation with Line and Circle

 .../CanvasObject/BaseCanvasObject.cs               |   25 +++++++++-
 LongoMatch.Drawing/CanvasObject/CircleObject.cs    |   45 ++++++++++++++++++
 LongoMatch.Drawing/CanvasObject/LineObject.cs      |   48 ++++++++++++++++++++
 LongoMatch.Drawing/LongoMatch.Drawing.mdp          |    3 +
 4 files changed, 119 insertions(+), 2 deletions(-)
---
diff --git a/LongoMatch.Drawing/CanvasObject/BaseCanvasObject.cs 
b/LongoMatch.Drawing/CanvasObject/BaseCanvasObject.cs
index 958a473..cb7bfe0 100644
--- a/LongoMatch.Drawing/CanvasObject/BaseCanvasObject.cs
+++ b/LongoMatch.Drawing/CanvasObject/BaseCanvasObject.cs
@@ -19,6 +19,7 @@ using System;
 using LongoMatch.Interfaces.Drawing;
 using LongoMatch.Interfaces;
 using LongoMatch.Common;
+using LongoMatch.Store.Drawables;
 
 namespace LongoMatch.Drawing.CanvasObject
 {
@@ -41,5 +42,25 @@ namespace LongoMatch.Drawing.CanvasObject
                
                public abstract void Draw (IDrawingToolkit tk, Area area);
        }
-}
-
+       
+       public abstract class BaseCanvasDrawableObject<T>: BaseCanvasObject where T:Drawable
+       {
+               public T Drawable {
+                       get;
+                       set;
+               }
+               
+               public Canvas Parent {
+                       get;
+                       set;
+               }
+               
+               public Selection GetSelection (Point point, double precision) {
+                       return Drawable.GetSelection (point, precision);
+               }
+               
+               public void Move (Selection s, Point p, Point start) {
+                       Drawable.Move (s, p, start);
+               }
+       }
+}
\ No newline at end of file
diff --git a/LongoMatch.Drawing/CanvasObject/CircleObject.cs b/LongoMatch.Drawing/CanvasObject/CircleObject.cs
new file mode 100644
index 0000000..f697cf3
--- /dev/null
+++ b/LongoMatch.Drawing/CanvasObject/CircleObject.cs
@@ -0,0 +1,45 @@
+//
+//  Copyright (C) 2014 Andoni Morales Alastruey
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using LongoMatch.Interfaces.Drawing;
+using LongoMatch.Store.Drawables;
+using LongoMatch.Common;
+using LongoMatch.Interfaces;
+
+namespace LongoMatch.Drawing.CanvasObject
+{
+       public class PointObject: BaseCanvasDrawableObject<Circle>, ICanvasSelectableObject
+       {
+
+               public PointObject (Point center, double radius, Color color)
+               {
+                       Drawable = new Circle (center, radius);
+                       Drawable.FillColor = color;
+                       Drawable.StrokeColor = color;
+                       Drawable.LineWidth = 1;
+               }
+               
+               public override void Draw (IDrawingToolkit tk, Area area) {
+                       tk.FillColor = Drawable.FillColor;
+                       tk.StrokeColor = Drawable.StrokeColor;
+                       tk.LineWidth = Drawable.LineWidth;
+                       tk.DrawCircle (Drawable.Center, Drawable.Radius);
+               }
+       }
+}
+
diff --git a/LongoMatch.Drawing/CanvasObject/LineObject.cs b/LongoMatch.Drawing/CanvasObject/LineObject.cs
new file mode 100644
index 0000000..ac19d69
--- /dev/null
+++ b/LongoMatch.Drawing/CanvasObject/LineObject.cs
@@ -0,0 +1,48 @@
+//
+//  Copyright (C) 2014 Andoni Morales Alastruey
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using LongoMatch.Common;
+using LongoMatch.Store.Drawables;
+using LongoMatch.Interfaces.Drawing;
+using LongoMatch.Interfaces;
+
+namespace LongoMatch.Drawing.CanvasObject
+{
+       public class LineObject: BaseCanvasDrawableObject<Line>, ICanvasSelectableObject
+       {
+               public LineObject (Point start, Point stop, LineType type, LineStyle stile,
+                                  Color color, int width)
+               {
+                       Drawable = new Line (start, stop, type, stile);
+                       Drawable.FillColor = color;
+                       Drawable.StrokeColor = color;
+                       Drawable.LineWidth = width;
+               }
+               
+               public override void Draw (IDrawingToolkit tk, Area area) {
+                       tk.Begin ();
+                       tk.FillColor = Drawable.FillColor;
+                       tk.StrokeColor = Drawable.StrokeColor;
+                       tk.LineWidth = Drawable.LineWidth;
+                       tk.DrawLine (Drawable.Start, Drawable.Stop);
+                       tk.End ();
+               }
+
+       }
+}
+
diff --git a/LongoMatch.Drawing/LongoMatch.Drawing.mdp b/LongoMatch.Drawing/LongoMatch.Drawing.mdp
index 774f834..201d25c 100644
--- a/LongoMatch.Drawing/LongoMatch.Drawing.mdp
+++ b/LongoMatch.Drawing/LongoMatch.Drawing.mdp
@@ -31,6 +31,9 @@
     <File subtype="Code" buildaction="Compile" name="Widgets/TeamTagger.cs" />
     <File subtype="Code" buildaction="Compile" name="CanvasObject/TimeNodeObject.cs" />
     <File subtype="Code" buildaction="Compile" name="Widgets/TimersTimeline.cs" />
+    <File subtype="Code" buildaction="Compile" name="CanvasObject/CircleObject.cs" />
+    <File subtype="Code" buildaction="Compile" name="CanvasObject/LineObject.cs" />
+    <File subtype="Directory" buildaction="Compile" name="CanvasObject" />
   </Contents>
   <References>
     <ProjectReference type="Package" localcopy="True" refto="System, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089" />


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]