public void TestSerialization() { Point o = new Point (10, 10); Text t = new Text (o, 10, 10, "TEST"); Utils.CheckSerialization (t); Text nt = Utils.SerializeDeserialize (t); Assert.AreEqual ("TEST", nt.Value); Rectangle r = new Rectangle (o, 10, 10); Assert.AreEqual (r.TopLeft, t.TopLeft); Assert.AreEqual (r.TopRight, t.TopRight); Assert.AreEqual (r.BottomLeft, t.BottomLeft); Assert.AreEqual (r.BottomRight, t.BottomRight); }
public void TestSerialization() { Point o = new Point(10, 10); Text t = new Text(o, 10, 10, "TEST"); Utils.CheckSerialization(t); Text nt = Utils.SerializeDeserialize(t); Assert.AreEqual("TEST", nt.Value); Rectangle r = new Rectangle(o, 10, 10); Assert.AreEqual(r.TopLeft, t.TopLeft); Assert.AreEqual(r.TopRight, t.TopRight); Assert.AreEqual(r.BottomLeft, t.BottomLeft); Assert.AreEqual(r.BottomRight, t.BottomRight); }
void EditText(Text text) { text.Value = MessagesHelpers.QueryMessage (this, Catalog.GetString ("Text"), null, text.Value); QueueDraw (); }
void EditPlayer(Text text) { playerText = text; if (playerDialog == null) { Gtk.Dialog d = new Gtk.Dialog (Catalog.GetString ("Select player"), this, DialogFlags.Modal | DialogFlags.DestroyWithParent, Stock.Cancel, ResponseType.Cancel); d.WidthRequest = 600; d.HeightRequest = 400; DrawingArea da = new DrawingArea (); TeamTagger tagger = new TeamTagger (new WidgetWrapper (da)); tagger.ShowSubstitutionButtons = false; tagger.LoadTeams (project.LocalTeamTemplate, project.VisitorTeamTemplate, project.Dashboard.FieldBackground); tagger.PlayersSelectionChangedEvent += players => { if (players.Count == 1) { Player p = players [0]; playerText.Value = p.ToString (); d.Respond (ResponseType.Ok); } tagger.ResetSelection (); }; d.VBox.PackStart (da, true, true, 0); d.ShowAll (); playerDialog = d; } if (playerDialog.Run () != (int)ResponseType.Ok) { text.Value = null; } playerDialog.Hide (); }
protected override void StartMove(Selection sel) { Drawable drawable = null; SelectionPosition pos = SelectionPosition.BottomRight; bool resize = true, copycolor = true, sele = true; if (Tool == DrawTool.Selection) { if (Selections.Count == 0 && currentZoom != 1) { widget.SetCursorForTool (DrawTool.Move); inZooming = true; } return; } if (sel != null) { ClearSelection (); } switch (Tool) { case DrawTool.Line: drawable = new Line (MoveStart, new Point (MoveStart.X + 1, MoveStart.Y + 1), LineType, LineStyle); drawable.FillColor = Color; pos = SelectionPosition.LineStop; break; case DrawTool.Cross: drawable = new Cross (MoveStart, new Point (MoveStart.X + 1, MoveStart.Y + 1), LineStyle); break; case DrawTool.Ellipse: drawable = new Ellipse (MoveStart, 2, 2); break; case DrawTool.Rectangle: drawable = new Rectangle (MoveStart, 2, 2); break; case DrawTool.CircleArea: drawable = new Ellipse (MoveStart, 2, 2); drawable.FillColor = Color.Copy (); drawable.FillColor.A = byte.MaxValue / 2; break; case DrawTool.RectangleArea: drawable = new Rectangle (MoveStart, 2, 2); drawable.FillColor = Color.Copy (); drawable.FillColor.A = byte.MaxValue / 2; break; case DrawTool.Counter: drawable = new Counter (MoveStart, 3 * LineWidth, 0); drawable.FillColor = Color.Copy (); (drawable as Counter).TextColor = Color.Grey2; resize = false; break; case DrawTool.Text: case DrawTool.Player: { int width, heigth; Text text = new Text (MoveStart, 1, 1, ""); if (ConfigureObjectEvent != null) { ConfigureObjectEvent (text, Tool); } if (text.Value == null) { return; } Config.DrawingToolkit.MeasureText (text.Value, out width, out heigth, Config.Style.Font, FontSize, FontWeight.Normal); text.Update (new Point (MoveStart.X - width / 2, MoveStart.Y - heigth / 2), width, heigth); text.TextColor = TextColor.Copy (); text.FillColor = text.StrokeColor = TextBackgroundColor.Copy (); text.TextSize = FontSize; resize = copycolor = sele = false; drawable = text; break; } case DrawTool.Pen: case DrawTool.Eraser: handdrawing = true; break; case DrawTool.Zoom: { double newZoom = currentZoom; if (modifier == ButtonModifier.Shift) { newZoom -= 0.1; } else { newZoom += 0.1; } newZoom = Math.Max (newZoom, MinZoom); newZoom = Math.Min (newZoom, MaxZoom); Zoom (newZoom, MoveStart); break; } } if (drawable != null) { if (copycolor) { drawable.StrokeColor = Color.Copy (); } drawable.LineWidth = LineWidth; drawable.Style = LineStyle; var selo = Add (drawable); drawing.Drawables.Add (drawable); if (Tool == DrawTool.Counter) { UpdateCounters (); } if (sele) { if (resize) { UpdateSelection (new Selection (selo, pos, 5)); } else { UpdateSelection (new Selection (selo, SelectionPosition.All, 5)); } inObjectCreation = true; } widget.ReDraw (); } }