[longomatch/newui: 25/157] Rename namespace CanvasObjects and fix players selections
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/newui: 25/157] Rename namespace CanvasObjects and fix players selections
- Date: Mon, 1 Sep 2014 09:43:27 +0000 (UTC)
commit 8dc484315620586068faa564ff0e7ecdc4e300c8
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Aug 19 01:47:53 2014 +0200
Rename namespace CanvasObjects and fix players selections
LongoMatch.Core/Handlers/Handlers.cs | 5 +
LongoMatch.Core/Interfaces/Drawing/ICanvas.cs | 2 +-
LongoMatch.Core/StyleConf.cs | 1 +
LongoMatch.Drawing/Canvas.cs | 4 +-
.../CanvasObject/PlayersTaggerObject.cs | 202 -----------
.../{CanvasObject => CanvasObjects}/BenchObject.cs | 2 +-
.../CanvasObject.cs | 40 ++-
.../{CanvasObject => CanvasObjects}/CardObject.cs | 2 +-
.../CategoryLabel.cs | 2 +-
.../CategoryObject.cs | 4 +-
.../CategoryTagger.cs | 0
.../CounterObject.cs | 2 +-
.../{CanvasObject => CanvasObjects}/CrossObject.cs | 2 +-
.../EllipseObject.cs | 2 +-
.../{CanvasObject => CanvasObjects}/FieldObject.cs | 2 +-
.../{CanvasObject => CanvasObjects}/LineObject.cs | 2 +-
.../{CanvasObject => CanvasObjects}/PlayObject.cs | 2 +-
.../PlayerObject.cs | 17 +-
.../CanvasObjects/PlayersTaggerObject.cs | 372 ++++++++++++++++++++
.../PositionObject.cs | 2 +-
.../QuadrilateralObject.cs | 2 +-
.../RectangleObject.cs | 2 +-
.../{CanvasObject => CanvasObjects}/ScoreObject.cs | 2 +-
.../{CanvasObject => CanvasObjects}/TagObject.cs | 2 +-
.../TaggerObject.cs | 37 +--
.../{CanvasObject => CanvasObjects}/TextObject.cs | 2 +-
.../TimeNodeObject.cs | 2 +-
.../TimelineObject.cs | 2 +-
.../{CanvasObject => CanvasObjects}/TimerObject.cs | 2 +-
LongoMatch.Drawing/LongoMatch.Drawing.mdp | 52 ++--
LongoMatch.Drawing/Makefile.am | 46 ++--
LongoMatch.Drawing/Widgets/Blackboard.cs | 2 +-
LongoMatch.Drawing/Widgets/CategoriesLabels.cs | 2 +-
LongoMatch.Drawing/Widgets/PlaysTagger.cs | 16 +-
LongoMatch.Drawing/Widgets/PlaysTimeline.cs | 2 +-
LongoMatch.Drawing/Widgets/PositionTagger.cs | 2 +-
LongoMatch.Drawing/Widgets/TeamTagger.cs | 39 ++-
LongoMatch.Drawing/Widgets/TimersTimeline.cs | 2 +-
LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs | 5 +-
LongoMatch.GUI/Makefile.am | 2 +
LongoMatch.GUI/gtk-gui/gui.stetic | 2 +-
41 files changed, 553 insertions(+), 339 deletions(-)
---
diff --git a/LongoMatch.Core/Handlers/Handlers.cs b/LongoMatch.Core/Handlers/Handlers.cs
index d3cfaba..ddefa86 100644
--- a/LongoMatch.Core/Handlers/Handlers.cs
+++ b/LongoMatch.Core/Handlers/Handlers.cs
@@ -26,6 +26,7 @@ using LongoMatch.Interfaces.Drawing;
using LongoMatch.Interfaces.GUI;
using LongoMatch.Store;
using LongoMatch.Store.Playlists;
+using LongoMatch.Store.Templates;
namespace LongoMatch.Handlers
{
@@ -117,6 +118,10 @@ namespace LongoMatch.Handlers
public delegate void PlayerPropertiesHandler(Player player);
public delegate void PlayersPropertiesHandler(List<Player> players);
+ /* Players selection */
+ public delegate void PlayersSubstitutionHandler (Player p1, Player p2, TeamTemplate team);
+ public delegate void PlayersSelectionChangedHandler (List<Player> players);
+
/* A list of projects have been selected */
public delegate void ProjectsSelectedHandler(List<ProjectDescription> projects);
public delegate void ProjectSelectedHandler(ProjectDescription project);
diff --git a/LongoMatch.Core/Interfaces/Drawing/ICanvas.cs b/LongoMatch.Core/Interfaces/Drawing/ICanvas.cs
index a3431e6..86d84d7 100644
--- a/LongoMatch.Core/Interfaces/Drawing/ICanvas.cs
+++ b/LongoMatch.Core/Interfaces/Drawing/ICanvas.cs
@@ -34,7 +34,7 @@ namespace LongoMatch.Interfaces.Drawing
void Draw (IDrawingToolkit tk, Area area);
bool Visible {set; get;}
string Description {set; get;}
- void ClickPressed (Point p);
+ void ClickPressed (Point p, ButtonModifier modif);
void ClickReleased ();
}
diff --git a/LongoMatch.Core/StyleConf.cs b/LongoMatch.Core/StyleConf.cs
index 21b69ae..2fad2b4 100644
--- a/LongoMatch.Core/StyleConf.cs
+++ b/LongoMatch.Core/StyleConf.cs
@@ -32,6 +32,7 @@ namespace LongoMatch.Common
public const int WelcomeIconsPerRow = 3;
public const int WelcomeTextHeight = 20;
public const int WelcomeMinWidthBorder = 30;
+
public const int NewHeaderHeight = 60;
public const int NewHeaderSpacing = 10;
public const int NewEntryWidth = 150;
diff --git a/LongoMatch.Drawing/Canvas.cs b/LongoMatch.Drawing/Canvas.cs
index 33a2d17..1133448 100644
--- a/LongoMatch.Drawing/Canvas.cs
+++ b/LongoMatch.Drawing/Canvas.cs
@@ -22,7 +22,7 @@ using LongoMatch.Interfaces.Drawing;
using LongoMatch.Interfaces;
using LongoMatch.Common;
using LongoMatch.Store.Drawables;
-using LongoMatch.Drawing.CanvasObject;
+using LongoMatch.Drawing.CanvasObjects;
namespace LongoMatch.Drawing
{
@@ -238,7 +238,7 @@ namespace LongoMatch.Drawing
clickedSel = sel;
if (sel != null) {
- (sel.Drawable as ICanvasSelectableObject).ClickPressed (coords);
+ (sel.Drawable as ICanvasObject).ClickPressed (coords, modif);
}
if ((SelectionMode == MultiSelectionMode.Multiple) ||
diff --git a/LongoMatch.Drawing/CanvasObject/BenchObject.cs b/LongoMatch.Drawing/CanvasObjects/BenchObject.cs
similarity index 98%
rename from LongoMatch.Drawing/CanvasObject/BenchObject.cs
rename to LongoMatch.Drawing/CanvasObjects/BenchObject.cs
index 6f2ea21..d485f7c 100644
--- a/LongoMatch.Drawing/CanvasObject/BenchObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/BenchObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Common;
using System.Collections.Generic;
using LongoMatch.Store.Drawables;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class BenchObject: CanvasObject, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/CanvasObject.cs
b/LongoMatch.Drawing/CanvasObjects/CanvasObject.cs
similarity index 81%
rename from LongoMatch.Drawing/CanvasObject/CanvasObject.cs
rename to LongoMatch.Drawing/CanvasObjects/CanvasObject.cs
index a1b1b4b..0b5012b 100644
--- a/LongoMatch.Drawing/CanvasObject/CanvasObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CanvasObject.cs
@@ -19,10 +19,13 @@ using LongoMatch.Interfaces.Drawing;
using LongoMatch.Common;
using LongoMatch.Store.Drawables;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public abstract class CanvasObject: ICanvasObject
{
+ public delegate void CanvasHandler (CanvasObject co);
+ public event CanvasHandler ClickedEvent;
+
protected CanvasObject ()
{
Visible = true;
@@ -43,7 +46,7 @@ namespace LongoMatch.Drawing.CanvasObject
get;
}
- public virtual void ClickPressed (Point p)
+ public virtual void ClickPressed (Point p, ButtonModifier modif)
{
}
@@ -51,9 +54,42 @@ namespace LongoMatch.Drawing.CanvasObject
{
}
+ protected void EmitClickEvent ()
+ {
+ if (ClickedEvent != null) {
+ ClickedEvent (this);
+ }
+ }
+
public abstract void Draw (IDrawingToolkit tk, Area area);
}
+ public abstract class CanvasButtonObject: CanvasObject {
+
+ public bool Toggle {
+ get;
+ set;
+ }
+
+ public bool Active {
+ get;
+ set;
+ }
+
+ public override void ClickPressed (Point p, ButtonModifier modif)
+ {
+ Active = !Active;
+ }
+
+ public override void ClickReleased ()
+ {
+ if (!Toggle) {
+ Active = !Active;
+ }
+ EmitClickEvent ();
+ }
+ }
+
public abstract class CanvasDrawableObject<T>: CanvasObject, ICanvasDrawableObject where T:
IBlackboardObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/CardObject.cs b/LongoMatch.Drawing/CanvasObjects/CardObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/CardObject.cs
rename to LongoMatch.Drawing/CanvasObjects/CardObject.cs
index 3aed21e..223244e 100644
--- a/LongoMatch.Drawing/CanvasObject/CardObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CardObject.cs
@@ -20,7 +20,7 @@ using LongoMatch.Common;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Store;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class CardObject: TaggerObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
b/LongoMatch.Drawing/CanvasObjects/CategoryLabel.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
rename to LongoMatch.Drawing/CanvasObjects/CategoryLabel.cs
index 98ec7a2..a2175ec 100644
--- a/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CategoryLabel.cs
@@ -19,7 +19,7 @@ using LongoMatch.Store;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Common;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class CategoryLabel: CanvasObject, ICanvasObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/CategoryObject.cs
b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
similarity index 98%
rename from LongoMatch.Drawing/CanvasObject/CategoryObject.cs
rename to LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
index ebb63d4..c225638 100644
--- a/LongoMatch.Drawing/CanvasObject/CategoryObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
@@ -22,7 +22,7 @@ using LongoMatch.Interfaces.Drawing;
using LongoMatch.Store;
using LongoMatch.Store.Drawables;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class CategoryObject: TaggerObject
{
@@ -97,7 +97,7 @@ namespace LongoMatch.Drawing.CanvasObject
}
}
- public override void ClickPressed (Point p)
+ public override void ClickPressed (Point p, ButtonModifier modif)
{
foreach (Rectangle rect in rects.Keys) {
Selection subsel = rect.GetSelection (p, 0);
diff --git a/LongoMatch.Drawing/CanvasObject/CategoryTagger.cs
b/LongoMatch.Drawing/CanvasObjects/CategoryTagger.cs
similarity index 100%
rename from LongoMatch.Drawing/CanvasObject/CategoryTagger.cs
rename to LongoMatch.Drawing/CanvasObjects/CategoryTagger.cs
diff --git a/LongoMatch.Drawing/CanvasObject/CounterObject.cs
b/LongoMatch.Drawing/CanvasObjects/CounterObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/CounterObject.cs
rename to LongoMatch.Drawing/CanvasObjects/CounterObject.cs
index c69a217..daa2500 100644
--- a/LongoMatch.Drawing/CanvasObject/CounterObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CounterObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Interfaces.Drawing;
using LongoMatch.Interfaces;
using LongoMatch.Common;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class CounterObject: CanvasDrawableObject<Counter>, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/CrossObject.cs b/LongoMatch.Drawing/CanvasObjects/CrossObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/CrossObject.cs
rename to LongoMatch.Drawing/CanvasObjects/CrossObject.cs
index 1d6fcf1..7392dbc 100644
--- a/LongoMatch.Drawing/CanvasObject/CrossObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CrossObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Interfaces.Drawing;
using LongoMatch.Interfaces;
using LongoMatch.Common;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class CrossObject: CanvasDrawableObject<Cross>, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/EllipseObject.cs
b/LongoMatch.Drawing/CanvasObjects/EllipseObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/EllipseObject.cs
rename to LongoMatch.Drawing/CanvasObjects/EllipseObject.cs
index e4975a9..4ba690c 100644
--- a/LongoMatch.Drawing/CanvasObject/EllipseObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/EllipseObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Store.Drawables;
using LongoMatch.Common;
using LongoMatch.Interfaces;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class EllipseObject: CanvasDrawableObject<Ellipse>, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/FieldObject.cs b/LongoMatch.Drawing/CanvasObjects/FieldObject.cs
similarity index 98%
rename from LongoMatch.Drawing/CanvasObject/FieldObject.cs
rename to LongoMatch.Drawing/CanvasObjects/FieldObject.cs
index bf51bc0..b54292f 100644
--- a/LongoMatch.Drawing/CanvasObject/FieldObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/FieldObject.cs
@@ -22,7 +22,7 @@ using System.Collections.Generic;
using LongoMatch.Common;
using LongoMatch.Store.Drawables;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class FieldObject: CanvasObject, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/LineObject.cs b/LongoMatch.Drawing/CanvasObjects/LineObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/LineObject.cs
rename to LongoMatch.Drawing/CanvasObjects/LineObject.cs
index 04e79fb..1c5cf37 100644
--- a/LongoMatch.Drawing/CanvasObject/LineObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/LineObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Store.Drawables;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Interfaces;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class LineObject: CanvasDrawableObject<Line>, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/PlayObject.cs b/LongoMatch.Drawing/CanvasObjects/PlayObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/PlayObject.cs
rename to LongoMatch.Drawing/CanvasObjects/PlayObject.cs
index 1f3bb59..c7b22a9 100644
--- a/LongoMatch.Drawing/CanvasObject/PlayObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/PlayObject.cs
@@ -22,7 +22,7 @@ using LongoMatch.Interfaces;
using LongoMatch.Common;
using LongoMatch.Store.Drawables;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class PlayObject: TimeNodeObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/PlayerObject.cs
b/LongoMatch.Drawing/CanvasObjects/PlayerObject.cs
similarity index 94%
rename from LongoMatch.Drawing/CanvasObject/PlayerObject.cs
rename to LongoMatch.Drawing/CanvasObjects/PlayerObject.cs
index 9f12bd2..cd29374 100644
--- a/LongoMatch.Drawing/CanvasObject/PlayerObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/PlayerObject.cs
@@ -23,9 +23,9 @@ using LongoMatch.Common;
using LongoMatch.Store.Drawables;
using LongoMatch.Drawing.Widgets;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
- public class PlayerObject: CanvasObject, ICanvasSelectableObject
+ public class PlayerObject: CanvasButtonObject, ICanvasSelectableObject
{
public PlayerObject ()
{
@@ -46,6 +46,7 @@ namespace LongoMatch.Drawing.CanvasObject
DrawPhoto = true;
Color = Constants.PLAYER_SELECTED_COLOR;
Size = (int)PlayersIconSize.Medium;
+ Toggle = true;
}
public Player Player {
@@ -84,6 +85,11 @@ namespace LongoMatch.Drawing.CanvasObject
return Size;
}
}
+
+ public Team Team {
+ get;
+ set;
+ }
public Selection GetSelection (Point point, double precision)
{
@@ -107,11 +113,6 @@ namespace LongoMatch.Drawing.CanvasObject
double numberWidth, numberHeight;
double size, scale;
- if (Position == null) {
- Console.WriteLine (Player.Name + Player.Number);
- return;
- }
-
zero = new Point (0, 0);
size = Config.Style.PlayerSize;
scale = Width / size;
@@ -164,7 +165,7 @@ namespace LongoMatch.Drawing.CanvasObject
tk.DrawText (p, numberWidth, numberHeight, Player.Number.ToString ());
/* Selection line */
- if (Selected) {
+ if (Active) {
tk.LineStyle = LineStyle.Normal;
tk.LineWidth = Config.Style.PlayerBorder;
tk.FillColor = null;
diff --git a/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
b/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
new file mode 100644
index 0000000..a551624
--- /dev/null
+++ b/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
@@ -0,0 +1,372 @@
+//
+// 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 System.Linq;
+using LongoMatch.Interfaces.Drawing;
+using LongoMatch.Store.Templates;
+using System.Collections.Generic;
+using LongoMatch.Common;
+using LongoMatch.Store.Drawables;
+using LongoMatch.Store;
+using LongoMatch.Handlers;
+
+namespace LongoMatch.Drawing.CanvasObjects
+{
+ public class PlayersTaggerObject: CanvasObject, ICanvasSelectableObject
+ {
+
+ /* This object can be used like single object filling a canvas or embedded
+ * in a canvas with more objects, like in the analysis template.
+ * For this reason we can't use the canvas selection logic and we have
+ * to handle it internally
+ */
+
+ public event PlayersSubstitutionHandler PlayersSubstitutionEvent;
+ public event PlayersSelectionChangedHandler PlayersSelectionChangedEvent;
+
+ TeamTemplate homeTeam, awayTeam;
+ Image background;
+ List<PlayerObject> homePlayingPlayers, awayPlayingPlayers;
+ List<PlayerObject> homeBenchPlayers, awayBenchPlayers;
+ List <PlayerObject> homePlayers, awayPlayers;
+ BenchObject homeBench, awayBench;
+ PlayerObject clickedPlayer, substitutionPlayer;
+ FieldObject field;
+ int NTeams;
+ Point offset;
+ double scaleX, scaleY;
+
+ public PlayersTaggerObject ()
+ {
+ Position = new Point (0, 0);
+ homeBench = new BenchObject ();
+ awayBench = new BenchObject ();
+ field = new FieldObject ();
+ SelectedPlayers = new List<Player> ();
+ }
+
+ public Point Position {
+ get;
+ set;
+ }
+
+ public double Width {
+ get;
+ set;
+ }
+
+ public double Height {
+ get;
+ set;
+ }
+
+ public bool SubstitutionMode {
+ get;
+ set;
+ }
+
+ public List<Player> SelectedPlayers {
+ get;
+ set;
+ }
+
+ public void Reload () {
+ LoadTeams (homeTeam, awayTeam, background);
+ }
+
+ public void Update ()
+ {
+ homeBench.Update ();
+ awayBench.Update ();
+ field.Update ();
+ }
+
+ public void ResetSelection ()
+ {
+ SelectedPlayers.Clear ();
+ substitutionPlayer = null;
+ foreach (PlayerObject player in homePlayers) {
+ player.Active = false;
+ }
+ foreach (PlayerObject player in awayPlayers) {
+ player.Active = false;
+ }
+ }
+
+ public void Substitute (Player p1, Player p2, TeamTemplate team)
+ {
+ if (team == homeTeam) {
+ Substitute (homePlayers.FirstOrDefault (p => p.Player == p1),
+ homePlayers.FirstOrDefault (p => p.Player == p2),
+ homePlayingPlayers, homeBenchPlayers);
+ } else {
+ Substitute (awayPlayers.FirstOrDefault (p => p.Player == p1),
+ awayPlayers.FirstOrDefault (p => p.Player == p2),
+ awayPlayingPlayers, awayBenchPlayers);
+ }
+ }
+
+ public void LoadTeams (TeamTemplate homeTeam, TeamTemplate awayTeam, Image background)
+ {
+ int[] homeF = null, awayF = null;
+ int playerSize, colSize, border;
+
+ this.homeTeam = homeTeam;
+ this.awayTeam = awayTeam;
+ this.background = background;
+ NTeams = 0;
+
+
+ if (background != null) {
+ field.Height = background.Height;
+ field.Width = background.Width;
+ } else {
+ field.Width = 300;
+ field.Height = 250;
+ }
+ homePlayingPlayers = awayPlayingPlayers = null;
+
+ homePlayers = new List<PlayerObject> ();
+ awayPlayers = new List<PlayerObject> ();
+
+ if (homeTeam != null) {
+ homePlayingPlayers = GetPlayers (homeTeam.StartingPlayersList, Team.LOCAL);
+ homeBenchPlayers = GetPlayers (homeTeam.BenchPlayersList, Team.LOCAL);
+ homePlayers.AddRange (homePlayingPlayers);
+ homePlayers.AddRange (homeBenchPlayers);
+ homeF = homeTeam.Formation;
+ NTeams ++;
+ }
+ if (awayTeam != null) {
+ awayPlayingPlayers = GetPlayers (awayTeam.StartingPlayersList, Team.VISITOR);
+ awayBenchPlayers = GetPlayers (awayTeam.BenchPlayersList, Team.VISITOR);
+ awayPlayers.AddRange (awayPlayingPlayers);
+ awayPlayers.AddRange (awayBenchPlayers);
+ awayF = awayTeam.Formation;
+ NTeams ++;
+ }
+
+ colSize = ColumnSize;
+ playerSize = colSize * 80 / 100;
+
+ field.LoadTeams (background, homeF, awayF, homePlayingPlayers,
+ awayPlayingPlayers, playerSize, NTeams);
+ homeBench.BenchPlayers = homeBenchPlayers;
+ awayBench.BenchPlayers = awayBenchPlayers;
+ homeBench.PlayersSize = awayBench.PlayersSize = playerSize;
+ homeBench.PlayersPerRow = awayBench.PlayersPerRow = 2;
+ homeBench.Width = awayBench.Width = colSize * 2;
+ homeBench.Height = awayBench.Height = field.Height;
+
+ border = Config.Style.TeamTaggerBenchBorder;
+ homeBench.Position = new Point (border, 0);
+ field.Position = new Point (awayBench.Width + 2 * border, 0);
+ awayBench.Position = new Point (awayBench.Width + field.Width + 3 * border, 0);
+
+ Update ();
+ }
+
+
+ void Substitute (PlayerObject p1, PlayerObject p2,
+ List<PlayerObject> playingPlayers,
+ List<PlayerObject> benchPlayers)
+ {
+ Point tmpPos;
+ List<PlayerObject> p1List, p2List;
+
+ if (playingPlayers.Contains (p1)) {
+ p1List = playingPlayers;
+ } else {
+ p1List = benchPlayers;
+ }
+ if (playingPlayers.Contains (p2)) {
+ p2List = playingPlayers;
+ } else {
+ p2List = benchPlayers;
+ }
+
+ if (p1List == p2List) {
+ p1List.Swap (p1, p2);
+ } else {
+ int p1Index, p2Index;
+
+ p1Index = p1List.IndexOf (p1);
+ p2Index = p2List.IndexOf (p2);
+ p1List.Remove (p1);
+ p2List.Remove (p2);
+ p1List.Insert (p1Index, p2);
+ p2List.Insert (p2Index, p1);
+ }
+ tmpPos = p2.Position;
+ p2.Position = p1.Position;
+ p1.Position = tmpPos;
+ ResetSelection ();
+ }
+
+ int ColumnSize {
+ get {
+ int width, optWidth, optHeight, count = 0, max = 0;
+
+ width = field.Width / NTeams;
+ if (homeTeam != null && awayTeam != null) {
+ count = Math.Max (homeTeam.Formation.Count (),
+ awayTeam.Formation.Count ());
+ max = Math.Max (homeTeam.Formation.Max (),
+ awayTeam.Formation.Max ());
+ } else if (homeTeam != null) {
+ count = homeTeam.Formation.Count ();
+ max = homeTeam.Formation.Max ();
+ } else if (awayTeam != null) {
+ count = awayTeam.Formation.Count ();
+ max = awayTeam.Formation.Max ();
+ }
+ optWidth = width / count;
+ optHeight = field.Height / max;
+ return Math.Min (optWidth, optHeight);
+ }
+ }
+
+ List<PlayerObject> GetPlayers (List<Player> players, Team team)
+ {
+ List<PlayerObject> playerObjects;
+ Color color = null;
+
+ if (team == Team.LOCAL) {
+ color = Config.Style.HomeTeamColor;
+ } else {
+ color = Config.Style.AwayTeamColor;
+ }
+
+ playerObjects = new List<PlayerObject> ();
+ foreach (Player p in players) {
+ PlayerObject po = new PlayerObject { Player = p, Color = color, Team = team };
+ po.ClickedEvent += HandleClickedEvent;
+ playerObjects.Add (po);
+ }
+ return playerObjects;
+ }
+
+ void HandleClickedEvent (CanvasObject co)
+ {
+ PlayerObject player = co as PlayerObject;
+
+ if (SubstitutionMode) {
+ if (substitutionPlayer == null) {
+ substitutionPlayer = player;
+ } else {
+ if (substitutionPlayer.Team == player.Team) {
+ TeamTemplate team;
+ if (substitutionPlayer.Team == Team.LOCAL) {
+ team = homeTeam;
+ } else {
+ team = awayTeam;
+ }
+ if (PlayersSubstitutionEvent != null) {
+ PlayersSubstitutionEvent (substitutionPlayer.Player,
+ player.Player, team);
+ }
+ }
+ }
+ } else {
+ if (player.Active) {
+ SelectedPlayers.Add (player.Player);
+ } else {
+ SelectedPlayers.Remove (player.Player);
+ }
+ if (PlayersSelectionChangedEvent != null) {
+ PlayersSelectionChangedEvent (SelectedPlayers);
+ }
+ }
+ }
+
+ public override void ClickPressed (Point point, ButtonModifier modif)
+ {
+ Selection selection = null;
+
+ if (modif == ButtonModifier.None && !SubstitutionMode) {
+ ResetSelection ();
+ }
+
+ point = Utils.ToUserCoords (point, offset, scaleX, scaleY);
+ selection = homeBench.GetSelection (point, 0);
+ if (selection == null) {
+ selection = awayBench.GetSelection (point, 0);
+ if (selection == null) {
+ selection = field.GetSelection (point, 0);
+ }
+ }
+ if (selection != null) {
+ clickedPlayer = selection.Drawable as PlayerObject;
+ if (SubstitutionMode && substitutionPlayer != null &&
+ clickedPlayer.Team != substitutionPlayer.Team) {
+ clickedPlayer= null;
+ } else {
+ (selection.Drawable as ICanvasObject).ClickPressed (point, modif);
+ }
+ } else {
+ clickedPlayer = null;
+ }
+ }
+
+ public override void ClickReleased ()
+ {
+ if (clickedPlayer != null) {
+ clickedPlayer.ClickReleased ();
+ } else {
+ ResetSelection ();
+ if (PlayersSelectionChangedEvent != null) {
+ PlayersSelectionChangedEvent (SelectedPlayers);
+ }
+ }
+ }
+
+ public override void Draw (IDrawingToolkit tk, Area area)
+ {
+ double width, height;
+
+ /* Compute how we should scale and translate to fit the widget
+ * in the designated area */
+ width = homeBench.Width * NTeams + field.Width +
+ 2 * NTeams * Config.Style.TeamTaggerBenchBorder;
+ height = field.Height;
+ Image.ScaleFactor ((int)width, (int)height, (int)Width, (int)Height,
+ out scaleX, out scaleY, out offset);
+ tk.Begin ();
+ tk.TranslateAndScale (Position + offset, new Point (scaleX, scaleY));
+ homeBench.Draw (tk, area);
+ awayBench.Draw (tk, area);
+ field.Draw (tk, area);
+ tk.End ();
+ }
+
+ public Selection GetSelection (Point point, double precision)
+ {
+ if (point.X < Position.X || point.X > Position.X + Width ||
+ point.Y < Position.Y || point.Y > Position.Y + Height) {
+ return null;
+ }
+ return new Selection (this, SelectionPosition.All, 0);
+ }
+
+ public void Move (Selection s, Point p, Point start)
+ {
+ throw new NotImplementedException ("Unsupported move for PlayersTaggerObject: " +
s.Position);
+ }
+ }
+}
+
diff --git a/LongoMatch.Drawing/CanvasObject/PositionObject.cs
b/LongoMatch.Drawing/CanvasObjects/PositionObject.cs
similarity index 98%
rename from LongoMatch.Drawing/CanvasObject/PositionObject.cs
rename to LongoMatch.Drawing/CanvasObjects/PositionObject.cs
index be11be3..ba16578 100644
--- a/LongoMatch.Drawing/CanvasObject/PositionObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/PositionObject.cs
@@ -23,7 +23,7 @@ using LongoMatch.Store;
using LongoMatch.Interfaces;
using System.Collections.Generic;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class PositionObject: CanvasObject, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/QuadrilateralObject.cs
b/LongoMatch.Drawing/CanvasObjects/QuadrilateralObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/QuadrilateralObject.cs
rename to LongoMatch.Drawing/CanvasObjects/QuadrilateralObject.cs
index 78c544d..c630feb 100644
--- a/LongoMatch.Drawing/CanvasObject/QuadrilateralObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/QuadrilateralObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Store.Drawables;
using LongoMatch.Common;
using LongoMatch.Interfaces;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class QuadrilateralObject: CanvasDrawableObject<Quadrilateral>, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/RectangleObject.cs
b/LongoMatch.Drawing/CanvasObjects/RectangleObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/RectangleObject.cs
rename to LongoMatch.Drawing/CanvasObjects/RectangleObject.cs
index 1606f77..23a8d69 100644
--- a/LongoMatch.Drawing/CanvasObject/RectangleObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/RectangleObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Interfaces.Drawing;
using LongoMatch.Interfaces;
using LongoMatch.Common;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class RectangleObject: CanvasDrawableObject<Rectangle>, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/ScoreObject.cs b/LongoMatch.Drawing/CanvasObjects/ScoreObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/ScoreObject.cs
rename to LongoMatch.Drawing/CanvasObjects/ScoreObject.cs
index 8da051e..d75a567 100644
--- a/LongoMatch.Drawing/CanvasObject/ScoreObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/ScoreObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Common;
using LongoMatch.Interfaces;
using LongoMatch.Store;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class ScoreObject: TaggerObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/TagObject.cs b/LongoMatch.Drawing/CanvasObjects/TagObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/TagObject.cs
rename to LongoMatch.Drawing/CanvasObjects/TagObject.cs
index 0a12148..a4acc37 100644
--- a/LongoMatch.Drawing/CanvasObject/TagObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TagObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Common;
using LongoMatch.Interfaces;
using LongoMatch.Store;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class TagObject: TaggerObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/TaggerObject.cs
b/LongoMatch.Drawing/CanvasObjects/TaggerObject.cs
similarity index 86%
rename from LongoMatch.Drawing/CanvasObject/TaggerObject.cs
rename to LongoMatch.Drawing/CanvasObjects/TaggerObject.cs
index f9b2904..bc7d7bd 100644
--- a/LongoMatch.Drawing/CanvasObject/TaggerObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TaggerObject.cs
@@ -23,17 +23,14 @@ using LongoMatch.Store.Drawables;
using LongoMatch.Store;
using LongoMatch.Handlers;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
- public delegate void TaggerObjectHandler (TaggerObject to);
- public abstract class TaggerObject: CanvasObject, ICanvasSelectableObject
+ public abstract class TaggerObject: CanvasButtonObject, ICanvasSelectableObject
{
- public event TaggerObjectHandler TaggerClickedEvent;
public TaggerObject (TaggerButton tagger)
{
Tagger = tagger;
- Toggle = false;
}
public TaggerButton Tagger {
@@ -72,41 +69,11 @@ namespace LongoMatch.Drawing.CanvasObject
}
}
- public bool Toggle {
- get;
- set;
- }
-
- public bool Active {
- get;
- set;
- }
-
public Time Start {
get;
set;
}
- public override void ClickPressed (Point p)
- {
- Active = !Active;
- }
-
- protected void EmitClickEvent ()
- {
- if (TaggerClickedEvent != null) {
- TaggerClickedEvent (this);
- }
- }
-
- public override void ClickReleased ()
- {
- if (!Toggle) {
- Active = !Active;
- }
- EmitClickEvent ();
- }
-
public virtual Selection GetSelection (Point p, double precision)
{
Selection s;
diff --git a/LongoMatch.Drawing/CanvasObject/TextObject.cs b/LongoMatch.Drawing/CanvasObjects/TextObject.cs
similarity index 97%
rename from LongoMatch.Drawing/CanvasObject/TextObject.cs
rename to LongoMatch.Drawing/CanvasObjects/TextObject.cs
index 8fb8996..e2ea161 100644
--- a/LongoMatch.Drawing/CanvasObject/TextObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TextObject.cs
@@ -21,7 +21,7 @@ using LongoMatch.Interfaces.Drawing;
using LongoMatch.Interfaces;
using LongoMatch.Common;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class TextObject: CanvasDrawableObject<Text>, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/TimeNodeObject.cs
b/LongoMatch.Drawing/CanvasObjects/TimeNodeObject.cs
similarity index 98%
rename from LongoMatch.Drawing/CanvasObject/TimeNodeObject.cs
rename to LongoMatch.Drawing/CanvasObjects/TimeNodeObject.cs
index 0dcd049..87a6996 100644
--- a/LongoMatch.Drawing/CanvasObject/TimeNodeObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TimeNodeObject.cs
@@ -22,7 +22,7 @@ using LongoMatch.Interfaces;
using LongoMatch.Common;
using LongoMatch.Store.Drawables;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class TimeNodeObject: CanvasObject, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/TimelineObject.cs
b/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
similarity index 99%
rename from LongoMatch.Drawing/CanvasObject/TimelineObject.cs
rename to LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
index a5c5d85..f2e2daa 100644
--- a/LongoMatch.Drawing/CanvasObject/TimelineObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
@@ -23,7 +23,7 @@ using LongoMatch.Interfaces;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Store.Drawables;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public abstract class TimelineObject: CanvasObject, ICanvasSelectableObject
{
diff --git a/LongoMatch.Drawing/CanvasObject/TimerObject.cs b/LongoMatch.Drawing/CanvasObjects/TimerObject.cs
similarity index 98%
rename from LongoMatch.Drawing/CanvasObject/TimerObject.cs
rename to LongoMatch.Drawing/CanvasObjects/TimerObject.cs
index 197ab6d..a74b9bd 100644
--- a/LongoMatch.Drawing/CanvasObject/TimerObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TimerObject.cs
@@ -22,7 +22,7 @@ using LongoMatch.Interfaces;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Store;
-namespace LongoMatch.Drawing.CanvasObject
+namespace LongoMatch.Drawing.CanvasObjects
{
public class TimerObject: TaggerObject
{
diff --git a/LongoMatch.Drawing/LongoMatch.Drawing.mdp b/LongoMatch.Drawing/LongoMatch.Drawing.mdp
index d8dad1a..6f97b9d 100644
--- a/LongoMatch.Drawing/LongoMatch.Drawing.mdp
+++ b/LongoMatch.Drawing/LongoMatch.Drawing.mdp
@@ -14,44 +14,44 @@
</Configuration>
</Configurations>
<Contents>
- <File subtype="Directory" buildaction="Compile" name="CanvasObject" />
+ <File subtype="Directory" buildaction="Compile" name="CanvasObjects" />
<File subtype="Code" buildaction="Compile" name="Canvas.cs" />
- <File subtype="Directory" buildaction="Compile" name="CanvasObject" />
+ <File subtype="Directory" buildaction="Compile" name="CanvasObjects" />
<File subtype="Directory" buildaction="Compile" name="Widgets" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/CategoryLabel.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/CategoryLabel.cs" />
<File subtype="Code" buildaction="Compile" name="Widgets/Timerule.cs" />
<File subtype="Code" buildaction="Compile" name="Widgets/CategoriesLabels.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/PlayObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/PlayObject.cs" />
<File subtype="Code" buildaction="Compile" name="Constants.cs" />
<File subtype="Code" buildaction="Compile" name="Widgets/PlaysTimeline.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/TimelineObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/CanvasObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/PlayerObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/TimelineObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/CanvasObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/PlayerObject.cs" />
<File subtype="Code" buildaction="Compile" name="Widgets/TeamTagger.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/TimeNodeObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/TimeNodeObject.cs" />
<File subtype="Code" buildaction="Compile" name="Widgets/TimersTimeline.cs" />
<File subtype="Code" buildaction="Compile" name="Widgets/PositionTagger.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/PositionObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/LineObject.cs" />
- <File subtype="Directory" buildaction="Compile" name="CanvasObject" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/CrossObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/RectangleObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/QuadrilateralObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/PositionObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/LineObject.cs" />
+ <File subtype="Directory" buildaction="Compile" name="CanvasObjects" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/CrossObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/RectangleObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/QuadrilateralObject.cs" />
<File subtype="Code" buildaction="Compile" name="Widgets/Blackboard.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/EllipseObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/TextObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/CounterObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/EllipseObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/TextObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/CounterObject.cs" />
<File subtype="Code" buildaction="Compile" name="Utils.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/CategoryObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/CategoryObject.cs" />
<File subtype="Code" buildaction="Compile" name="Widgets/PlaysTagger.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/TaggerObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/ScoreObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/CardObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/TimerObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/TagObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/BenchObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/FieldObject.cs" />
- <File subtype="Code" buildaction="Compile" name="CanvasObject/PlayersTaggerObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/TaggerObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/ScoreObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/CardObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/TimerObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/TagObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/BenchObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/FieldObject.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObjects/PlayersTaggerObject.cs" />
</Contents>
<References>
<ProjectReference type="Package" localcopy="True" refto="System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
diff --git a/LongoMatch.Drawing/Makefile.am b/LongoMatch.Drawing/Makefile.am
index 80dbc64..202dc7a 100644
--- a/LongoMatch.Drawing/Makefile.am
+++ b/LongoMatch.Drawing/Makefile.am
@@ -5,29 +5,29 @@ TARGET = library
LINK = $(REF_DEP_LONGOMATCH_DRAWING)
SOURCES = Canvas.cs \
- CanvasObject/BenchObject.cs \
- CanvasObject/CanvasObject.cs \
- CanvasObject/CardObject.cs \
- CanvasObject/CategoryLabel.cs \
- CanvasObject/CategoryObject.cs \
- CanvasObject/CounterObject.cs \
- CanvasObject/CrossObject.cs \
- CanvasObject/EllipseObject.cs \
- CanvasObject/FieldObject.cs \
- CanvasObject/LineObject.cs \
- CanvasObject/PlayObject.cs \
- CanvasObject/PlayerObject.cs \
- CanvasObject/PlayersTaggerObject.cs \
- CanvasObject/PositionObject.cs \
- CanvasObject/QuadrilateralObject.cs \
- CanvasObject/RectangleObject.cs \
- CanvasObject/ScoreObject.cs \
- CanvasObject/TagObject.cs \
- CanvasObject/TaggerObject.cs \
- CanvasObject/TextObject.cs \
- CanvasObject/TimeNodeObject.cs \
- CanvasObject/TimelineObject.cs \
- CanvasObject/TimerObject.cs \
+ CanvasObjects/BenchObject.cs \
+ CanvasObjects/CanvasObject.cs \
+ CanvasObjects/CardObject.cs \
+ CanvasObjects/CategoryLabel.cs \
+ CanvasObjects/CategoryObject.cs \
+ CanvasObjects/CounterObject.cs \
+ CanvasObjects/CrossObject.cs \
+ CanvasObjects/EllipseObject.cs \
+ CanvasObjects/FieldObject.cs \
+ CanvasObjects/LineObject.cs \
+ CanvasObjects/PlayObject.cs \
+ CanvasObjects/PlayerObject.cs \
+ CanvasObjects/PlayersTaggerObject.cs \
+ CanvasObjects/PositionObject.cs \
+ CanvasObjects/QuadrilateralObject.cs \
+ CanvasObjects/RectangleObject.cs \
+ CanvasObjects/ScoreObject.cs \
+ CanvasObjects/TagObject.cs \
+ CanvasObjects/TaggerObject.cs \
+ CanvasObjects/TextObject.cs \
+ CanvasObjects/TimeNodeObject.cs \
+ CanvasObjects/TimelineObject.cs \
+ CanvasObjects/TimerObject.cs \
Constants.cs \
Utils.cs \
Widgets/Blackboard.cs \
diff --git a/LongoMatch.Drawing/Widgets/Blackboard.cs b/LongoMatch.Drawing/Widgets/Blackboard.cs
index f6f0695..1a96b10 100644
--- a/LongoMatch.Drawing/Widgets/Blackboard.cs
+++ b/LongoMatch.Drawing/Widgets/Blackboard.cs
@@ -21,7 +21,7 @@ using System.Runtime.Remoting;
using LongoMatch.Common;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Store;
-using LongoMatch.Drawing.CanvasObject;
+using LongoMatch.Drawing.CanvasObjects;
using LongoMatch.Store.Drawables;
using LongoMatch.Handlers;
using LongoMatch.Interfaces;
diff --git a/LongoMatch.Drawing/Widgets/CategoriesLabels.cs b/LongoMatch.Drawing/Widgets/CategoriesLabels.cs
index cc40798..f7f2058 100644
--- a/LongoMatch.Drawing/Widgets/CategoriesLabels.cs
+++ b/LongoMatch.Drawing/Widgets/CategoriesLabels.cs
@@ -20,7 +20,7 @@ using System.Collections.Generic;
using LongoMatch.Store;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Common;
-using LongoMatch.Drawing.CanvasObject;
+using LongoMatch.Drawing.CanvasObjects;
namespace LongoMatch.Drawing.Widgets
{
diff --git a/LongoMatch.Drawing/Widgets/PlaysTagger.cs b/LongoMatch.Drawing/Widgets/PlaysTagger.cs
index b1b5fa5..41a3e4e 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTagger.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTagger.cs
@@ -20,7 +20,7 @@ using System.Linq;
using LongoMatch.Store.Templates;
using System.Collections.Generic;
using LongoMatch.Common;
-using LongoMatch.Drawing.CanvasObject;
+using LongoMatch.Drawing.CanvasObjects;
using LongoMatch.Handlers;
using LongoMatch.Store;
using LongoMatch.Store.Drawables;
@@ -190,14 +190,14 @@ namespace LongoMatch.Drawing.Widgets
Objects.Clear ();
foreach (TagButton tag in template.CommonTags) {
TagObject to = new TagObject (tag);
- to.TaggerClickedEvent += HandleTaggerClickedEvent;
+ to.ClickedEvent += HandleTaggerClickedEvent;
to.Mode = TagMode;
Objects.Add (to);
}
foreach (Category cat in template.CategoriesList) {
CategoryObject co = new CategoryObject (cat);
- co.TaggerClickedEvent += HandleTaggerClickedEvent;
+ co.ClickedEvent += HandleTaggerClickedEvent;
co.Mode = TagMode;
co.AddTag = AddTag;
Objects.Add (co);
@@ -205,20 +205,20 @@ namespace LongoMatch.Drawing.Widgets
foreach (PenaltyCard c in template.PenaltyCards) {
CardObject co = new CardObject (c);
- co.TaggerClickedEvent += HandleTaggerClickedEvent;
+ co.ClickedEvent += HandleTaggerClickedEvent;
co.Mode = TagMode;
Objects.Add (co);
}
foreach (Score s in template.Scores) {
ScoreObject co = new ScoreObject (s);
- co.TaggerClickedEvent += HandleTaggerClickedEvent;
+ co.ClickedEvent += HandleTaggerClickedEvent;
co.Mode = TagMode;
Objects.Add (co);
}
foreach (Timer t in template.Timers) {
TimerObject to = new TimerObject (t);
- to.TaggerClickedEvent += HandleTaggerClickedEvent;
+ to.ClickedEvent += HandleTaggerClickedEvent;
to.Mode = TagMode;
Objects.Add (to);
}
@@ -244,11 +244,13 @@ namespace LongoMatch.Drawing.Widgets
}
}
- void HandleTaggerClickedEvent (TaggerObject tagger)
+ void HandleTaggerClickedEvent (CanvasObject co)
{
+ TaggerObject tagger;
Time start = null, stop = null;
List<Tag> tags = null;
+ tagger = co as TaggerObject;
if (NewTagEvent == null || tagger is TimerObject ||
tagger is TagObject) {
return;
diff --git a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
index 45a3f03..e3b2f9f 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
@@ -19,7 +19,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using LongoMatch.Store;
-using LongoMatch.Drawing.CanvasObject;
+using LongoMatch.Drawing.CanvasObjects;
using LongoMatch.Common;
using LongoMatch.Handlers;
using LongoMatch.Interfaces.Drawing;
diff --git a/LongoMatch.Drawing/Widgets/PositionTagger.cs b/LongoMatch.Drawing/Widgets/PositionTagger.cs
index cab1e47..4a64393 100644
--- a/LongoMatch.Drawing/Widgets/PositionTagger.cs
+++ b/LongoMatch.Drawing/Widgets/PositionTagger.cs
@@ -20,7 +20,7 @@ using System.Linq;
using LongoMatch.Common;
using System.Collections.Generic;
using LongoMatch.Store;
-using LongoMatch.Drawing.CanvasObject;
+using LongoMatch.Drawing.CanvasObjects;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Store.Drawables;
using LongoMatch.Handlers;
diff --git a/LongoMatch.Drawing/Widgets/TeamTagger.cs b/LongoMatch.Drawing/Widgets/TeamTagger.cs
index 8eb6686..5b18493 100644
--- a/LongoMatch.Drawing/Widgets/TeamTagger.cs
+++ b/LongoMatch.Drawing/Widgets/TeamTagger.cs
@@ -22,7 +22,7 @@ using LongoMatch.Common;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Store.Drawables;
using LongoMatch.Store.Templates;
-using LongoMatch.Drawing.CanvasObject;
+using LongoMatch.Drawing.CanvasObjects;
using LongoMatch.Store;
using LongoMatch.Handlers;
@@ -31,7 +31,7 @@ namespace LongoMatch.Drawing.Widgets
public class TeamTagger: SelectionCanvas
{
- public event PlayersPropertiesHandler PlayersSelectionChangedEvent;
+ public event PlayersSelectionChangedHandler PlayersSelectionChangedEvent;
public event PlayersPropertiesHandler ShowMenuEvent;
PlayersTaggerObject tagger;
@@ -45,6 +45,9 @@ namespace LongoMatch.Drawing.Widgets
SelectionMode = MultiSelectionMode.MultipleWithModifier;
widget.SizeChangedEvent += HandleSizeChangedEvent;
tagger = new PlayersTaggerObject ();
+ tagger.PlayersSubstitutionEvent += HandlePlayersSubstitutionEvent;
+ tagger.PlayersSelectionChangedEvent += HandlePlayersSelectionChangedEvent;
+ ObjectsCanMove = false;
Objects.Add (tagger);
}
@@ -53,16 +56,28 @@ namespace LongoMatch.Drawing.Widgets
tagger.LoadTeams (homeTeam, awayTeam, background);
widget.ReDraw ();
}
-
- public void Reload ()
- {
+
+ public void Reload () {
+ tagger.Reload ();
}
+ public bool SubstitutionMode {
+ set {
+ tagger.SubstitutionMode = value;
+ }
+ }
+
public void Select (Player p) {
}
protected override void ShowMenu (Point coords)
{
+ Selection sel = tagger.GetSelection (coords, 0);
+
+ if (sel != null && ShowMenuEvent != null) {
+ PlayerObject po = sel.Drawable as PlayerObject;
+ ShowMenuEvent (new List<Player> {po.Player});
+ }
}
void HandleSizeChangedEvent ()
@@ -70,6 +85,20 @@ namespace LongoMatch.Drawing.Widgets
tagger.Width = widget.Width;
tagger.Height = widget.Height;
}
+
+ void HandlePlayersSubstitutionEvent (Player p1, Player p2, TeamTemplate team)
+ {
+ team.List.Swap (p1, p2);
+ tagger.Substitute (p1, p2, team);
+ widget.ReDraw ();
+ }
+
+ void HandlePlayersSelectionChangedEvent (List<Player> players)
+ {
+ if (PlayersSelectionChangedEvent != null) {
+ PlayersSelectionChangedEvent (players);
+ }
+ }
}
}
diff --git a/LongoMatch.Drawing/Widgets/TimersTimeline.cs b/LongoMatch.Drawing/Widgets/TimersTimeline.cs
index 4441a16..ae0780e 100644
--- a/LongoMatch.Drawing/Widgets/TimersTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/TimersTimeline.cs
@@ -1,6 +1,6 @@
using System.Linq;
using LongoMatch.Store;
-using LongoMatch.Drawing.CanvasObject;
+using LongoMatch.Drawing.CanvasObjects;
using LongoMatch.Common;
using LongoMatch.Handlers;
using LongoMatch.Interfaces.Drawing;
diff --git a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
index b5e0083..9f377a8 100644
--- a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
@@ -119,6 +119,7 @@ namespace LongoMatch.Gui.Panel
drawingarea.HeightRequest = 200;
teamtagger = new TeamTagger (new WidgetWrapper (drawingarea));
+ teamtagger.SubstitutionMode = true;
teams = Config.TeamTemplatesProvider.Templates;
hometeamscombobox.Load (teams, false);
hometeamscombobox.Changed += (sender, e) => {
@@ -231,9 +232,9 @@ namespace LongoMatch.Gui.Panel
void LoadTemplate (TeamTemplate template, Team team) {
if (team == Team.LOCAL) {
- hometemplate = template;
+ hometemplate = Cloner.Clone (template);
} else {
- awaytemplate = template;
+ awaytemplate = Cloner.Clone (template);
}
teamtagger.LoadTeams (hometemplate, awaytemplate,
analysisTemplate.FieldBackground);
diff --git a/LongoMatch.GUI/Makefile.am b/LongoMatch.GUI/Makefile.am
index ea2ef64..0cae19f 100644
--- a/LongoMatch.GUI/Makefile.am
+++ b/LongoMatch.GUI/Makefile.am
@@ -10,6 +10,7 @@ SOURCES = Gui/Cairo.cs \
Gui/Component/CategoryProperties.cs \
Gui/Component/CodingWidget.cs \
Gui/Component/CoordinatesTagger.cs \
+ Gui/Component/DatePicker.cs \
Gui/Component/GeneralPreferencesPanel.cs \
Gui/Component/LiveAnalysisPreferences.cs \
Gui/Component/MediaFileChooser.cs \
@@ -83,6 +84,7 @@ SOURCES = Gui/Cairo.cs \
gtk-gui/LongoMatch.Gui.Component.CategoryProperties.cs \
gtk-gui/LongoMatch.Gui.Component.CodingWidget.cs \
gtk-gui/LongoMatch.Gui.Component.CoordinatesTagger.cs \
+ gtk-gui/LongoMatch.Gui.Component.DatePicker.cs \
gtk-gui/LongoMatch.Gui.Component.GameViewer.cs \
gtk-gui/LongoMatch.Gui.Component.GeneralPreferencesPanel.cs \
gtk-gui/LongoMatch.Gui.Component.LiveAnalysisPreferences.cs \
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 212dc0b..3a7d6cd 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -6273,7 +6273,7 @@ You can continue with the current capture, cancel it or save your project.
</widget>
</child>
</widget>
- <widget class="Gtk.Bin" id="LongoMatch.Gui.Panel.NewProjectPanel" design-size="1182 340">
+ <widget class="Gtk.Bin" id="LongoMatch.Gui.Panel.NewProjectPanel" design-size="1182 438">
<property name="MemberName" />
<property name="Visible">False</property>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]