public void CreatePlayers(Webb.Playbook.Geometry.Drawing drawing, Data.Personnel personnel, bool bCreateBall, double dLogicScrimmage) { // 03-16-2011 Scott double radius = Webb.Playbook.Data.GameSetting.Instance.PlayerSize; double angle = Webb.Playbook.Data.GameSetting.Instance.PlayerAngle; PlayerAppearance playerAppearance = (PlayerAppearance)Enum.Parse(typeof(PlayerAppearance), Webb.Playbook.Data.GameSetting.Instance.PlayerAppearance); double thickness = Webb.Playbook.Data.GameSetting.Instance.PlayerThickness; bool dash = Webb.Playbook.Data.GameSetting.Instance.PlayerDash; bool textVisibility = Webb.Playbook.Data.GameSetting.Instance.PlayerTextVisibility; IEnumerable <Webb.Playbook.Geometry.Game.PBPlayer> players = drawing.Figures.OfType <Webb.Playbook.Geometry.Game.PBPlayer>(); if (players != null && players.Count() > 0) { radius = players.First().Radius; } double scrimmage = dLogicScrimmage; int i = 0; double x = 0; double y = 0; double size = Webb.Playbook.Data.GameSetting.Instance.PlayerSize * 1.1; //Color colorOffense = Colors.OrangeRed; //Color colorDefense = Colors.SteelBlue; if (personnel.ScoutType == ScoutTypes.Offensive) { foreach (Position pos in personnel.Positions.FindAll(p => p.Name.StartsWith("QB"))) { PBPlayer player = new PBPlayer(playerAppearance, pos.Name) { Text = pos.Value, Coordinates = new Point(0, scrimmage - 2 * size), Stance = "TwoPointCenter", FillColor = ColorSetting.Instance.OffensivePlayerColor, Radius = radius, Angle = angle, StrokeThickness = thickness, TextVisible = textVisibility, Dash = dash, }; drawing.Add(player); } y = -0.5 * size; foreach (Position pos in personnel.Positions.FindAll(p => p.Name.StartsWith("OL"))) { i = pos.ID - 1; PBPlayer player = new PBPlayer(playerAppearance, pos.Name) { Text = pos.Value, Coordinates = new Point((i + 1) / 2 * System.Math.Pow(-1, i) * size, scrimmage + y), Stance = "ThreePointRight", FillColor = ColorSetting.Instance.OffensivePlayerColor, Radius = radius, Angle = angle, StrokeThickness = thickness, TextVisible = textVisibility, Dash = dash, }; drawing.Add(player); } x = -6 * size; y = -1 * size; foreach (Position pos in personnel.Positions.FindAll(p => p.Name.StartsWith("TE"))) { i = pos.ID - 1; PBPlayer player = new PBPlayer(playerAppearance, pos.Name) { Text = pos.Value, Coordinates = new Point(x, scrimmage + y - i * size), Stance = "ThreePointRight", FillColor = ColorSetting.Instance.OffensivePlayerColor, Radius = radius, Angle = angle, StrokeThickness = thickness, TextVisible = textVisibility, Dash = dash, }; drawing.Add(player); } x = 8 * size; y = -1 * size; foreach (Position pos in personnel.Positions.FindAll(p => p.Name.StartsWith("WR"))) { i = pos.ID - 1; PBPlayer player = new PBPlayer(playerAppearance, pos.Name) { Text = pos.Value, Coordinates = new Point(x, scrimmage + y - i * size), Stance = "TwoPointRight", FillColor = ColorSetting.Instance.OffensivePlayerColor, Radius = radius, Angle = angle, StrokeThickness = thickness, TextVisible = textVisibility, Dash = dash, }; drawing.Add(player); } x = 0 * size; y = -4 * size; foreach (Position pos in personnel.Positions.FindAll(p => p.Name.StartsWith("RB"))) { i = pos.ID - 1; PBPlayer player = new PBPlayer(playerAppearance, pos.Name) { Text = pos.Value, Coordinates = new Point(x, scrimmage + y - i * size), Stance = "TwoPointCenter", FillColor = ColorSetting.Instance.OffensivePlayerColor, Radius = radius, Angle = angle, StrokeThickness = thickness, TextVisible = textVisibility, Dash = dash, }; drawing.Add(player); } } else if (personnel.ScoutType == ScoutTypes.Defensive) { y = 0.5 * size; foreach (Position pos in personnel.Positions.FindAll(p => p.Name.StartsWith("DL"))) { i = pos.ID - 1; PBPlayer player = new PBPlayer(playerAppearance, pos.Name) { Text = pos.Value, Coordinates = new Point((i + 1) / 2 * System.Math.Pow(-1, i) * size, scrimmage + y), Stance = "ThreePointLeft", FillColor = ColorSetting.Instance.DefensivePlayerColor, Radius = radius, Angle = angle, StrokeThickness = thickness, TextVisible = textVisibility, Dash = dash, }; drawing.Add(player); } x = 8 * size; y = 1 * size; foreach (Position pos in personnel.Positions.FindAll(p => p.Name.StartsWith("CB"))) { i = pos.ID - 1; PBPlayer player = new PBPlayer(playerAppearance, pos.Name) { Text = pos.Value, Coordinates = new Point(x * System.Math.Pow(-1, i) * size, scrimmage + (i / 2) * size + y), Stance = "TwoPointCenter", FillColor = ColorSetting.Instance.DefensivePlayerColor, Radius = radius, Angle = angle, StrokeThickness = thickness, TextVisible = textVisibility, Dash = dash, }; drawing.Add(player); } y = 3 * size; foreach (Position pos in personnel.Positions.FindAll(p => p.Name.StartsWith("LB"))) { i = pos.ID - 1; PBPlayer player = new PBPlayer(playerAppearance, pos.Name) { Text = pos.Value, Coordinates = new Point((i + 1) / 2 * System.Math.Pow(-1, i) * size, scrimmage + y), Stance = "TwoPointCenter", FillColor = ColorSetting.Instance.DefensivePlayerColor, Radius = radius, Angle = angle, StrokeThickness = thickness, TextVisible = textVisibility, Dash = dash, }; drawing.Add(player); } y = 5.5 * size; foreach (Position pos in personnel.Positions.FindAll(p => p.Name.StartsWith("S"))) { i = pos.ID - 1; PBPlayer player = new PBPlayer(playerAppearance, pos.Name) { Text = pos.Value, Coordinates = new Point((i + 1) / 2 * System.Math.Pow(-1, i) * size, scrimmage + y), Stance = "TwoPointCenter", FillColor = ColorSetting.Instance.DefensivePlayerColor, Radius = radius, Angle = angle, StrokeThickness = thickness, TextVisible = textVisibility, Dash = dash, }; drawing.Add(player); } } if (bCreateBall) { Point ptBall = new Point(0, 0); bool bHasBall = false; foreach (PBPlayer player in drawing.Figures.OfType <PBPlayer>()) { if (personnel.ScoutType == ScoutTypes.Offensive) { if (player.Name == PersonnelEditor.OffHasBallPlayer) { ptBall = player.Coordinates; bHasBall = true; } } else if (personnel.ScoutType == ScoutTypes.Defensive) { if (player.Name == PersonnelEditor.DefHasBallPlayer) { ptBall = player.Coordinates; bHasBall = true; } } } if (bHasBall) { PBBall ball = new PBBall() { Center = new Point(ptBall.X, personnel.ScoutType == ScoutTypes.Defensive ? ptBall.Y - 0.5f : ptBall.Y + 0.5f), }; if (drawing.Figures.OfType <PBBall>().Count() == 0) { ball.Visible = Webb.Playbook.Data.GameSetting.Instance.ShowBall; drawing.Add(ball); } } } }
public DiagramBackgroundWindow(string filename, bool cropped, Size size, out Size retSize, bool background, bool autoImage) { InitializeComponent(); this.MinWidth = size.Width; this.MinHeight = size.Height; this.ShowInTaskbar = false; this.WindowStartupLocation = WindowStartupLocation.Manual; this.Left = -3000; this.Top = -3000; this.ResizeMode = ResizeMode.NoResize; Webb.Playbook.Geometry.Drawing drawing = null; if (System.IO.File.Exists(filename)) { drawing = Webb.Playbook.Geometry.Drawing.Load(filename, canvas); if (!background) { drawing.Canvas.Children.Remove(drawing.Playground.UCPlayground); } if (autoImage) { drawing.SetFiguresColor(Webb.Playbook.Data.GameSetting.Instance.ImageEnableSymbolColor); drawing.SetPlaygroundColor(Webb.Playbook.Data.GameSetting.Instance.ImageEnableColor ? Webb.Playbook.Data.PlaygroundColors.Color : Webb.Playbook.Data.PlaygroundColors.BlackAndWhite); } IEnumerable <FreePoint> fPoints = drawing.Figures.OfType <FreePoint>().Where(f => f.Visible); if (fPoints != null && fPoints.Count() > 0) { Point startPoint = fPoints.First().Coordinates; if (drawing.Figures.Any(f => f is PBBall)) { PBBall ball = drawing.Figures.OfType <PBBall>().First(); if (ball.Visible) { startPoint = ball.Coordinates; ball.Visible = false; } } Rect rectLogic = Rect.Empty; foreach (FreePoint fPoint in fPoints) { if (rectLogic == Rect.Empty) { rectLogic = new Rect(startPoint, fPoint.Coordinates); } else { rectLogic.Union(fPoint.Coordinates); } } double unitLength = size.Width / CoordinateSystem.LogicalPlaygroundWidth; Point origin = new Point(size.Width / 2, size.Height / 2); Rect rect = new Rect(new Point(origin.X + rectLogic.TopLeft.X * unitLength, origin.Y - rectLogic.TopLeft.Y * unitLength), new Point(origin.X + rectLogic.BottomRight.X * unitLength, origin.Y - rectLogic.BottomRight.Y * unitLength)); rect.Inflate(unitLength, unitLength); this.Clip = new System.Windows.Media.RectangleGeometry(rect); retSize = rect.Size; } else { retSize = Size.Empty; } } else { retSize = Size.Empty; } }