예제 #1
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();
        }
예제 #2
0
        protected override void MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (Drawing != null)
            {
                Point ptPhy = Coordinates(e);

                Microsoft.Win32.OpenFileDialog ofDialog = new Microsoft.Win32.OpenFileDialog()
                {
                    Title  = "Insert Background",
                    Filter = Webb.Playbook.Data.Extensions.ImageFileFilter,
                };

                if (ofDialog.ShowDialog().Value)
                {
                    ImageBrush imgBrush = new ImageBrush()
                    {
                        Stretch     = Stretch.None,
                        AlignmentX  = AlignmentX.Center,
                        AlignmentY  = AlignmentY.Center,
                        ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(ofDialog.FileName, UriKind.RelativeOrAbsolute)),
                    };

                    System.Drawing.Image image = System.Drawing.Image.FromFile(ofDialog.FileName);

                    PBImage pbImg = new PBImage()
                    {
                        Coordinates = ptPhy,
                        File        = ofDialog.FileName,

                        Width  = ToLogical(image.Width),
                        Height = ToLogical(image.Height),
                    };

                    Drawing.Add(pbImg);
                    pbImg.MoveTo(pbImg.Coordinates);
                }

                Drawing.SetDefaultBehavior();
            }
        }
예제 #3
0
        protected override void MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            bool bSuccess = false;

            offsetFromFigureLeftTopCorner = Coordinates(e);
            oldCoordinates = offsetFromFigureLeftTopCorner;

            IFigure found = Drawing.Figures.HitTest(offsetFromFigureLeftTopCorner);

            if (found != null && found is Game.PBPlayer)
            {
                Game.PBPlayer targetPlayer = found as Game.PBPlayer;

                IEnumerable <IFigure> figures = Drawing.GetSelectedFigures();

                if (figures != null && figures.Count() > 0)
                {
                    IFigure source = figures.ElementAt(0);

                    if (source is Game.PBPlayer)
                    {
                        Game.PBPlayer sourcePlayer = source as Game.PBPlayer;

                        if (sourcePlayer.ScoutType != targetPlayer.ScoutType)
                        {
                            sourcePlayer.Assignment = targetPlayer.Name;

                            Drawing.SetDefaultBehavior();

                            bSuccess = true;
                        }
                    }
                }
            }

            if (!bSuccess)
            {
                MessageBox.Show("You must select a player of opposing team !");
            }
        }
예제 #4
0
        protected override void MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            bool bSuccess = false;

            var coordinates = Coordinates(e);
            IEnumerable <IFigure> selectedFigures = Drawing.GetSelectedFigures();

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

                if (player != null && player.ScoutType == 1)
                {
                    IFigure found = Drawing.Figures.HitTest(coordinates);

                    if (found != null && found is PBPlayer)
                    {
                        PBPlayer setPlayer = found as PBPlayer;

                        if (setPlayer.ScoutType == 0)
                        {
                            player.ManPress    = setPlayer.Name;
                            player.ManCoverage = string.Empty;

                            Drawing.SetDefaultBehavior();

                            bSuccess = true;
                        }
                    }
                }
            }

            if (!bSuccess)
            {
                MessageBox.Show("You must select a player of opposing team!");
            }
        }
예제 #5
0
        protected override void MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            bool bSuccess    = false;
            var  coordinates = Coordinates(e);
            IEnumerable <IFigure> selectedFigures = Drawing.GetSelectedFigures();

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

                if (qbPlayer != null && qbPlayer.Name == "QB")
                {
                    IFigure found = Drawing.Figures.HitTest(coordinates);

                    if (found != null && found is PBPlayer)
                    {
                        PBPlayer setPlayer = found as PBPlayer;

                        if (setPlayer.ScoutType == 0 && setPlayer != qbPlayer)
                        {
                            qbPlayer.AssignArray.Clear();
                            qbPlayer.SetArray.Clear();
                            qbPlayer.SetArray.Add(setPlayer.Name);

                            Drawing.SetDefaultBehavior();

                            bSuccess = true;
                        }
                    }
                }
            }

            if (!bSuccess)
            {
                MessageBox.Show("You must select a teammate !");
            }
        }
예제 #6
0
        public void CancelEdit()
        {
            Drawing.Canvas.Children.Remove(Edit);

            Drawing.SetDefaultBehavior();

            Edit.KeyDown -= new System.Windows.Input.KeyEventHandler(tb_KeyDown);

            if (Label != null)
            {
                Label.Visible = true;

                Label.UpdateVisual();

                Label = null;
            }

            if (Edit != null)
            {
                Edit.FontSize   = 14;
                Edit.FontFamily = new FontFamily("Arial");
                Edit.Foreground = Brushes.Black;
            }
        }
예제 #7
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)
        {
            // 11-18-2010 Scott
            if (e.ClickCount == 2)
            {
                Drawing.SetDefaultBehavior();
                return;
            }

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

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

                if (player == null)
                {
                    return;
                }
            }
            else
            {
                return;
            }
            //Type expectedType = ExpectedDependency;
            System.Windows.Point coordinates = Coordinates(e);
            IFigure underMouse = null;

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

            IFigure endFigure = player.GetEndFigure();

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

            player.ChangeLineType(CapType.Arrow);

            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.Figures.CheckConsistency();
            Drawing.Figures.UpdateVisual();
            //if (TempPoint != null)
            //{
            //    underMouse = Drawing.Figures.HitTest(
            //        coordinates,
            //        typeof(IPoint));
            //}
            //else if (expectedType != null)
            //{
            //    underMouse = Drawing.Figures.HitTest(coordinates, expectedType);
            //}
            //else
            //{
            //    underMouse = Drawing.Figures.HitTest(coordinates);
            //}

            //if (underMouse != null
            //    && underMouse != TempPoint
            //    && ((FoundDependencies.Contains(underMouse) && !CanReuseDependency())
            //        || underMouse == TempResult))
            //{
            //    return;
            //}

            //IFigure endPointFigure = player.GetEndFigure();
            //if (TempPoint == null && underMouse != player && underMouse != endPointFigure)
            //{
            //    return;
            //}

            //if (ExpectingAPoint())
            //{
            //    if (underMouse == null)
            //    {
            //       underMouse = CreatePointAtCurrentPosition(coordinates, true);
            //       FigureList fl = new FigureList();
            //       fl.Add(player);
            //       if (underMouse != null)
            //       {
            //           fl.Add(underMouse);
            //       }
            //       PBLine line = Factory.CreateArrowLine(Drawing, fl);
            //       FigureList figureList = new FigureList();
            //       figureList.Add(line);
            //       figureList.Add(underMouse);
            //       Drawing.Add(figureList as IEnumerable<IFigure>);
            //       return;
            //    }
            //    else
            //    {
            //        // one branch only
            //        if (underMouse is Webb.Playbook.Geometry.Game.PBPlayer && underMouse.Dependents.Count > 0)
            //        {
            //            foreach (IFigure dep in underMouse.Dependents)
            //            {
            //                if (dep.Dependencies != null && dep.Dependencies.Count() > 1 && dep.Dependencies.ElementAt(0) == underMouse)
            //                {
            //                    return;
            //                }
            //            }

            //            if (underMouse != player)
            //            {
            //                return;
            //            }
            //        }
            //        // at most two branch
            //        else if (underMouse is IPoint && underMouse.Dependents.Count > 1)
            //        {
            //            return;
            //        }
            //        else if (underMouse is Zone)
            //        {
            //            return;
            //        }
            //    }
            //}

            //RemoveIntermediateFigureIfNecessary();

            //if (TempPoint != null)
            //{
            //    //if (underMouse == TempPoint || underMouse == TempResult || underMouse == null)
            //    //{
            //    underMouse = CreatePointAtCurrentPosition(coordinates, true);
            //    //}
            //    TempPoint.SubstituteWith(underMouse);
            //    FoundDependencies.Remove(TempPoint);
            //    Drawing.Figures.Remove(TempPoint);
            //    TempPoint = null;
            //}

            //if (ExpectedDependency != null)
            //{
            //    AddFoundDependency(underMouse);
            //}

            //if (ExpectedDependency != null)
            //{
            // if (ExpectingAPoint())
            //    {
            //        player.ChangeLineType(CapType.Arrow);   // 01-07-2010 Scott

            //        TempPoint = CreateTempPoint(coordinates);
            //        AddFoundDependency(TempPoint);
            //        if (ExpectedDependency == null)
            //        {
            //            CreateAndAddFigure();

            //            Drawing.Figures.UpdateVisual();
            //        }
            //    }
            //    AddIntermediateFigureIfNecessary();
            //    AdvertiseNextDependency();
            //}
            //else
            //{
            //    Finish();

            //    //07-22-2009 scott
            //    if (IsMouseButtonDown)
            //    {// click mode
            //        IFigure endFigure = Drawing.Figures.HitTest(coordinates, typeof(Webb.Playbook.Geometry.Game.PBPlayer));
            //        if (endFigure is Webb.Playbook.Geometry.Game.PBPlayer)
            //        {
            //            Drawing.ActionManager.Undo();
            //        }
            //        else
            //        {
            //            MouseLeftButtonDown(sender, e as System.Windows.Input.MouseButtonEventArgs);
            //        }
            //    }
            //    else
            //    {// drag mode

            //    }
            //}

            //Drawing.Figures.CheckConsistency();
            //Drawing.Figures.UpdateVisual();
        }
예제 #8
0
        protected override void MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            bool bSuccess = false;

            offsetFromFigureLeftTopCorner = Coordinates(e);
            oldCoordinates = offsetFromFigureLeftTopCorner;

            IFigure found = Drawing.Figures.HitTest(offsetFromFigureLeftTopCorner, typeof(Game.PBPlayer));

            if (found != null && found is Game.PBPlayer)
            {
                Game.PBPlayer targetPlayer = found as Game.PBPlayer;

                IEnumerable <IFigure> figures = Drawing.GetSelectedFigures();

                if (figures != null && figures.Count() > 0)
                {
                    IFigure source = figures.ElementAt(0);

                    if (source is Game.PBPlayer)
                    {
                        Game.PBPlayer sourcePlayer = source as Game.PBPlayer;

                        if (sourcePlayer.ScoutType != targetPlayer.ScoutType)
                        {
                            IFigure endfigure = sourcePlayer.GetEndFigure();

                            if (endfigure == null)
                            {
                                endfigure = source;
                            }

                            if (!(endfigure is Game.PBPlayer) && !(endfigure is Game.Zone) && (endfigure is FreePoint))
                            {
                                if (endfigure.Dependents.Count > 0)
                                {
                                    PBLine endline = endfigure.Dependents.ElementAt(0) as PBLine;

                                    if (endline != null /*&& endline.CapType == CapType.Arrow*/)
                                    {
                                        PBLine line = new PBLine();

                                        List <IFigure> dependencies = new List <IFigure>();
                                        dependencies.Add(endfigure);
                                        dependencies.Add(found);
                                        line.Dependencies = dependencies;

                                        sourcePlayer.ChangeLineType(CapType.Arrow);

                                        Drawing.Add(line);

                                        if (!Drawing.DrawingMode)
                                        {
                                            line.CapType = CapType.Block;

                                            line.StrokeColor = Webb.Playbook.Data.ColorSetting.Instance.BlockColor;
                                        }

                                        Drawing.Figures.UpdateVisual();

                                        Drawing.SetDefaultBehavior();

                                        bSuccess = true;
                                    }
                                }
                            }
                            else if (endfigure == source)
                            {
                                PBLine line = new PBLine();

                                List <IFigure> dependencies = new List <IFigure>();
                                dependencies.Add(endfigure);
                                dependencies.Add(found);
                                line.Dependencies = dependencies;

                                sourcePlayer.ChangeLineType(CapType.Arrow);

                                Drawing.Add(line);

                                if (!Drawing.DrawingMode)
                                {
                                    line.CapType = CapType.Block;

                                    line.StrokeColor = Webb.Playbook.Data.ColorSetting.Instance.BlockColor;
                                }

                                Drawing.Figures.UpdateVisual();

                                Drawing.SetDefaultBehavior();

                                bSuccess = true;
                            }
                        }
                    }
                }
            }

            if (!bSuccess)
            {
                MessageBox.Show("You must select a player of opposing team !");
            }
        }
예제 #9
0
파일: Pen.cs 프로젝트: WittyOrator/Playbook
        /// <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();
        }