Esempio n. 1
0
        public ColorSettingWindow(Draw drawing)
        {
            InitializeComponent();

            ColorSettingsVM = new ColorSettingsViewModel(ColorSetting.Instance);

            colorSettingControl.DataContext = ColorSettingsVM;

            Drawing = drawing;
        }
Esempio n. 2
0
        public AnimationWindow(Draw drawing)
            : this()
        {
            OriDrawing = drawing;

            OriDrawing.Stop();

            OriCanvas = drawing.Canvas;

            OriDrawing.Canvas = canvasDrawing;
        }
Esempio n. 3
0
        public DiagramBackgroundWindow(double width)
        {
            InitializeComponent();

            double scale = 8.4 / 10.0;

            Webb.Playbook.Geometry.Drawing drawing = new Webb.Playbook.Geometry.Drawing(canvas);

            this.Clip = new System.Windows.Media.RectangleGeometry(new Rect(0, 0, 720, 480));

            canvas.Margin = new Thickness((720 - (width * scale)) / 2, 0, (720 - (width * scale)) / 2, 0);
        }
Esempio n. 4
0
        public void CloseDrawing()
        {
            if (Drawing != null)
            {
                Drawing.Behavior = null;

                Drawing.Dispose();

                Drawing = null;
            }

            this.Canvas.Children.Clear();
        }
Esempio n. 5
0
        public DiagramBackgroundWindow(int width, Size size)
        {
            InitializeComponent();

            double scale = 8.4 / 10.0;

            this.Width  = size.Width;
            this.Height = size.Height;

            Webb.Playbook.Geometry.Drawing drawing = new Webb.Playbook.Geometry.Drawing(canvas);

            this.Clip = new System.Windows.Media.RectangleGeometry(new Rect(0, 0, size.Width, size.Height));

            canvas.Margin = new Thickness((size.Width - (width * scale)) / 2, 0, (size.Width - (width * scale)) / 2, 0);
        }
Esempio n. 6
0
        public void LoadDrawing(string strFile)
        {
            CloseDrawing();

            if (!System.IO.File.Exists(strFile))
            {
                Drawing = new Webb.Playbook.Geometry.Drawing(Canvas);
            }
            else
            {
                Drawing = Draw.Load(strFile, Canvas);
            }

            Drawing.Playground.UCPlayground.Visibility = Visibility.Hidden;
            Drawing.SetDefaultBehavior();
        }
Esempio n. 7
0
        public DiagramBackgroundWindow(string filename, int width, Size size)
        {
            InitializeComponent();

            double scale = 8.4 / 10.0;

            this.Width  = size.Width;
            this.Height = size.Height;

            if (System.IO.File.Exists(filename))
            {
                Webb.Playbook.Geometry.Drawing drawing = Webb.Playbook.Geometry.Drawing.Load(filename, canvas);
            }
            else
            {
                Webb.Playbook.Geometry.Drawing drawing = new Webb.Playbook.Geometry.Drawing(canvas);
            }

            this.Clip = new System.Windows.Media.RectangleGeometry(new Rect(0, 0, size.Width, size.Height));

            canvas.Margin = new Thickness((size.Width - (width * scale)) / 2, 0, (size.Width - (width * scale)) / 2, 0);
        }
Esempio n. 8
0
 public AnimationWindow(string path)
     : this()
 {
     OriDrawing          = Draw.Load(path, canvasDrawing);
     OriDrawing.Behavior = null;
 }
Esempio n. 9
0
        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);
                    }
                }
            }
        }
Esempio n. 10
0
        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;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Assumes coordinates are logical already
        /// </summary>
        /// <param name="coordinates">Logical coordinates of the click point</param>
        protected override void  MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (e.ClickCount > 1)
            {
                Drawing.SetDefaultBehavior();
                return;
            }

            IEnumerable <IFigure> selectedFigures = Drawing.GetSelectedFigures();
            PBPlayer player    = null;
            IFigure  endFigure = null;

            if (selectedFigures != null && selectedFigures.Count() > 0)
            {
                player = selectedFigures.ElementAt(0) as PBPlayer;
            }

            //Type expectedType = ExpectedDependency;
            System.Windows.Point coordinates = Coordinates(e);
            IFigure underMouse = null;

            underMouse = Drawing.Figures.HitTest(coordinates);
            if (underMouse is Game.PBPlayer)
            {
                if (underMouse == player)
                {
                    Drawing.SetDefaultBehavior();
                    return;
                }

                player = underMouse as Game.PBPlayer;

                Drawing.ClearSelectedFigures();
                player.Selected = true;
                Drawing.Figures.UpdateVisual();
                return;
            }
            else if (underMouse is IPoint && (underMouse as IPoint).Dependents.Count == 1)
            {
                Drawing.ClearSelectedFigures();
                underMouse.Selected = true;
                Drawing.Figures.UpdateVisual();
                return;
            }

            if (player == null)
            {
                if (selectedFigures != null && selectedFigures.Count() > 0)
                {
                    IFigure figure = selectedFigures.ElementAt(0);
                    if (figure is IPoint && (figure as IPoint).Dependents.Count == 1)
                    {
                        endFigure = figure;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {// 09-26-2011 Scott
                endFigure = null;
                //endFigure = player.GetEndFigure();
                //player.ChangeLineType(CapType.Arrow);

                //if (endFigure is Game.Zone)
                //{
                //    return;
                //}
            }

            FreePoint  pp = CreatePointAtCurrentPosition(coordinates, false);
            FigureList fl = new FigureList();

            if (endFigure != null)
            {
                if (endFigure is Game.PBPlayer)
                {
                    player.ClearEndPath();
                    endFigure = player.GetEndFigure();
                    if (endFigure != null)
                    {
                        fl.Add(endFigure);
                    }
                    else
                    {
                        fl.Add(player);
                    }
                }
                else
                {
                    fl.Add(endFigure);
                }
            }
            else
            {
                fl.Add(player);
            }
            fl.Add(pp);
            PBLine line = Factory.CreateArrowLine(Drawing, fl);

            if (!Drawing.DrawingMode)
            {
                line.StrokeColor = Webb.Playbook.Data.ColorSetting.Instance.RouteColor;
            }
            FigureList figureList = new FigureList();

            figureList.Add(line);
            figureList.Add(pp);

            Drawing.Add(figureList as IEnumerable <IFigure>);

            Drawing.ClearSelectedFigures();
            pp.Selected = true;

            Drawing.Figures.CheckConsistency();
            Drawing.Figures.UpdateVisual();
        }