public void DrawTriangle(Point corner, double width, double height, SelectionPosition position) { double x1, y1, x2, y2, x3, y3; x1 = corner.X; y1 = corner.Y; switch (position) { case SelectionPosition.Top: x2 = x1 + width / 2; y2 = y1 + height; x3 = x1 - width / 2; y3 = y1 + height; break; case SelectionPosition.Bottom: default: x2 = x1 + width / 2; y2 = y1 - height; x3 = x1 - width / 2; y3 = y1 - height; break; } SetColor(StrokeColor); CContext.MoveTo(x1, y1); CContext.LineTo(x2, y2); CContext.LineTo(x3, y3); CContext.ClosePath(); StrokeAndFill(); }
public void DrawRoundedRectangle(Point start, double width, double height, double radius, bool strokeAndFill) { double x, y; x = start.X + LineWidth / 2; y = start.Y + LineWidth / 2; height -= LineWidth; width -= LineWidth; if ((radius > height / 2) || (radius > width / 2)) { radius = Math.Min(height / 2, width / 2); } CContext.MoveTo(x, y + radius); CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); CContext.LineTo(x + width - radius, y); CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); CContext.LineTo(x + width, y + height - radius); CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); CContext.LineTo(x + radius, y + height); CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); CContext.ClosePath(); if (strokeAndFill) { StrokeAndFill(); } }
public void DrawImage(Point start, double width, double height, Image image, bool scale, bool masked = false) { double scaleX, scaleY; Point offset; if (scale) { image.ScaleFactor((int)width, (int)height, out scaleX, out scaleY, out offset); } else { offset = new Point(0, 0); scaleX = width / image.Width; scaleY = height / image.Height; } CContext.Save(); CContext.Translate(start.X + offset.X, start.Y + offset.Y); CContext.Scale(scaleX, scaleY); if (masked) { CContext.PushGroup(); Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.Paint(); var src = CContext.PopGroup(); SetColor(FillColor); CContext.Mask(src); src.Dispose(); } else { Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.Paint(); } CContext.Restore(); }
public void DrawLine(Point start, Point stop) { CContext.LineWidth = LineWidth; CContext.MoveTo(start.X, start.Y); CContext.LineTo(stop.X, stop.Y); StrokeAndFill(); }
public void DrawRectangle(Point start, double width, double height) { CContext.Rectangle(new global::Cairo.Rectangle(start.X + LineWidth / 2, start.Y + LineWidth / 2, width - LineWidth, height - LineWidth)); StrokeAndFill(false); }
public void TranslateAndScale(Point translation, Point scale) { if (!disableScalling) { CContext.Translate(translation.X, translation.Y); CContext.Scale(scale.X, scale.Y); } }
public void DrawEllipse(Point center, double axisX, double axisY) { double max = Math.Max(axisX, axisY); CContext.Save(); CContext.Translate(center.X, center.Y); CContext.Scale(axisX / max, axisY / max); CContext.Arc(0, 0, max, 0, 2 * Math.PI); StrokeAndFill(); CContext.Restore(); }
public void DrawText(Point point, double width, double height, string text, bool escape = false, bool ellipsize = false) { Layout layout = null; Pango.Rectangle inkRect, logRect; if (text == null) { return; } if (escape) { text = GLib.Markup.EscapeText(text); } if (context is CairoContext) { layout = (context as CairoContext).PangoLayout; } if (layout == null) { layout = Pango.CairoHelper.CreateLayout(CContext); } if (ellipsize) { layout.Ellipsize = EllipsizeMode.End; } else { layout.Ellipsize = EllipsizeMode.None; } layout.FontDescription = FontDescription.FromString( String.Format("{0} {1}px", FontFamily, FontSize)); layout.FontDescription.Weight = fWeight; layout.FontDescription.Style = fSlant; layout.Width = Pango.Units.FromPixels((int)width); layout.Alignment = fAlignment; layout.SetMarkup(GLib.Markup.EscapeText(text)); SetColor(StrokeColor); Pango.CairoHelper.UpdateLayout(CContext, layout); layout.GetPixelExtents(out inkRect, out logRect); CContext.MoveTo(point.X, point.Y + height / 2 - (double)logRect.Height / 2); Pango.CairoHelper.ShowLayout(CContext, layout); CContext.NewPath(); }
public void DrawSurface(ISurface surface, Point p = null) { ImageSurface image; image = surface.Value as ImageSurface; if (p == null) { CContext.SetSourceSurface(image, 0, 0); CContext.Paint(); } else { CContext.SetSourceSurface(image, (int)p.X, (int)p.Y); CContext.Rectangle(p.X, p.Y, image.Width, image.Height); CContext.Fill(); } }
public void DrawArrow(Point start, Point stop, int lenght, double radians, bool closed) { double vx1, vy1, vx2, vy2; double angle = Math.Atan2(stop.Y - start.Y, stop.X - start.X) + Math.PI; vx1 = stop.X + (lenght + LineWidth) * Math.Cos(angle - radians); vy1 = stop.Y + (lenght + LineWidth) * Math.Sin(angle - radians); vx2 = stop.X + (lenght + LineWidth) * Math.Cos(angle + radians); vy2 = stop.Y + (lenght + LineWidth) * Math.Sin(angle + radians); CContext.MoveTo(stop.X, stop.Y); CContext.LineTo(vx1, vy1); if (!closed) { CContext.MoveTo(stop.X, stop.Y); CContext.LineTo(vx2, vy2); } else { CContext.LineTo(vx2, vy2); CContext.ClosePath(); } StrokeAndFill(false); }
protected override void ShowMenu(Point coords) { List<PlayerLongoMatch> players = tagger.SelectedPlayers; if (players.Count == 0) { Selection sel = tagger.GetSelection (coords, 0, true); if (sel != null) { players = new List<PlayerLongoMatch> { (sel.Drawable as SportsPlayerObject).Player }; } } else { players = tagger.SelectedPlayers; } if (ShowMenuEvent != null) { ShowMenuEvent (players); } }
public Selection GetSelection(Point point, double precision, bool inMotion = false) { Point position = new Point (Position.X - Width / 2, Position.Y - Height / 2); if (point.X >= position.X && point.X <= position.X + Width) { if (point.Y >= position.Y && point.Y <= position.Y + Height) { return new Selection (this, SelectionPosition.All, 0); } } return null; }
protected override void ShowMenu(Point coords) { if (ShowTimerMenuEvent != null) { Timer t = null; if (Selections.Count > 0) { TimerTimeNodeObject to = Selections.Last ().Drawable as TimerTimeNodeObject; t = to.Timer; } ShowTimerMenuEvent (t, Utils.PosToTime (coords, SecondsPerPixel)); } }
public PlayerObject(Player player, Point position = null) { Player = player; Init (position); }
public void DrawCircle(Point center, double radius) { CContext.Arc(center.X, center.Y, radius, 0, 2 * Math.PI); StrokeAndFill(); }
public void DrawPoint(Point point) { DrawCircle(point, LineWidth); }
public void DrawRoundedRectangle(Point start, double width, double height, double radius) { DrawRoundedRectangle(start, width, height, radius, true); }
public Selection GetSelection(Point point, double precision, bool inMotion) { Selection selection = null; point = VASDrawing.Utils.ToUserCoords (point, Position, 1, 1); if (HomePlayingPlayers != null) { foreach (SportsPlayerObject po in HomePlayingPlayers) { selection = po.GetSelection (point, precision); if (selection != null) break; } } if (selection == null && AwayPlayingPlayers != null) { foreach (SportsPlayerObject po in AwayPlayingPlayers) { selection = po.GetSelection (point, precision); if (selection != null) break; } } return selection; }
public FieldObject() { Position = new Point (0, 0); }
public void Move(Selection s, Point p, Point start) { }
public override void Draw(IDrawingToolkit tk, Area area) { Point zero, start, p; double size, scale; ISurface arrowin, arrowout; if (Player == null) return; zero = new Point (0, 0); size = StyleConf.PlayerSize; scale = (double)Width / size; if (Team == TeamType.LOCAL) { arrowin = ArrowIn; arrowout = ArrowOut; } else { arrowin = ArrowOut; arrowout = ArrowIn; } tk.Begin (); start = new Point (Size / 2, Size / 2); tk.TranslateAndScale (Center - start, new Point (scale, scale)); if (!UpdateDrawArea (tk, area, new Area (zero, size, size))) { tk.End (); return; } /* Background */ tk.FillColor = App.Current.Style.PaletteBackgroundDark; tk.LineWidth = 0; tk.DrawRectangle (zero, StyleConf.PlayerSize, StyleConf.PlayerSize); /* Image */ if (Player.Photo != null) { tk.DrawImage (zero, size, size, Player.Photo, ScaleMode.AspectFit); } else { tk.DrawSurface (zero, StyleConf.PlayerSize, StyleConf.PlayerSize, PlayerObject.DefaultPhoto, ScaleMode.AspectFit); } /* Bottom line */ p = new Point (0, size - StyleConf.PlayerLineWidth); tk.FillColor = Color; tk.DrawRectangle (p, size, 3); /* Draw Arrow */ if (SubstitutionMode && (Highlighted || Active)) { ISurface arrow; Point ap; if (Playing) { arrow = arrowout; } else { arrow = arrowin; } ap = new Point (StyleConf.PlayerArrowX, StyleConf.PlayerArrowY); tk.DrawRectangle (ap, StyleConf.PlayerArrowSize, StyleConf.PlayerArrowSize); tk.DrawSurface (arrow, ap); } /* Draw number */ p = new Point (StyleConf.PlayerNumberX, StyleConf.PlayerNumberY); tk.FillColor = Color; tk.DrawRectangle (p, StyleConf.PlayerNumberSize, StyleConf.PlayerNumberSize); tk.FillColor = Color.White; tk.StrokeColor = Color.White; tk.FontAlignment = FontAlignment.Center; tk.FontWeight = FontWeight.Normal; if (Player.Number >= 100) { tk.FontSize = 12; } else { tk.FontSize = 16; } tk.DrawText (p, StyleConf.PlayerNumberSize, StyleConf.PlayerNumberSize, Player.Number.ToString ()); if (Active) { Color c = Color.Copy (); c.A = (byte)(c.A * 60 / 100); tk.FillColor = c; tk.DrawRectangle (zero, size, size); } tk.End (); }
protected override void ShowMenu(Point coords) { if (ShowMenuEvent != null) { List<TimelineEventLongoMatch> plays = Selections.Select (p => (p.Drawable as PositionObject).Play).ToList (); ShowMenuEvent (plays); } }
public override void ClickPressed(Point p, ButtonModifier modif) { cancelPressed = cancelRect.GetSelection (p) != null; }
public SportsPlayerObject(PlayerLongoMatch player, Point position = null) { // Set the base Player too, because it's a different Property base.Player = Player = player; Init (position); }
void Init(Point pos = null) { if (pos == null) { pos = new Point (0, 0); } Position = pos; DrawPhoto = true; Size = (int)PlayersIconSize.Medium; Toggle = true; LoadSurfaces (); }