public void CheckCorrectAdd()
        {
            var list = new FigureList();

            for (int i = 0; i < 4; i++)
            {
                list.Add(new Figure(1, 1, 1, 1, 1, 1), 0);
            }
            Assert.AreEqual(1, list.Count());
        }
示例#2
0
        public FigureList GetOffFigures()
        {
            FigureList            offfigurelist = new FigureList();
            List <IFigure>        pathFigures;
            IEnumerable <IFigure> PbFigure = this.GetPBplayer();

            foreach (Game.PBPlayer pbplayer in PbFigure)
            {
                if (pbplayer.ScoutType == 0)
                {
                    pathFigures = pbplayer.GetPatheExceptEndPlayer(pbplayer, null, 0).ToList();
                    offfigurelist.Add(pbplayer as IFigure);
                    foreach (IFigure ifigure in pathFigures)
                    {
                        offfigurelist.Add(ifigure);
                    }
                }
            }
            return(offfigurelist);
        }
示例#3
0
        public void openVHDLFile(string filename)
        {
            My_FileAnalyzer analyzer = new My_FileAnalyzer(filename, core);

            analyzer.Analyze();
            foreach (My_Figure fig in analyzer.figures)
            {
                FigureList.Add(fig);
            }
            Sort();
        }
示例#4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

            var figure = new Figure();

            FigureControl.Ball = figure;
            FigureList.Add(FigureControl.Figure);
        }
示例#5
0
        private void canv_MouseUp(object sender, MouseEventArgs e)
        {
            isDrawn     = false;
            endpoint.X  = e.X;
            endpoint.Y  = e.Y;
            figBuff.end = endpoint;

            figureList.Add(figBuff);

            figBuff = (Figure)Activator.CreateInstance(figBuff.GetType(), pen, startpoint, endpoint);
            figureList.Draw(canvas);
        }
        public void CheckRemove()
        {
            var myList = new FigureList();
            var rnd    = new Random();

            for (int i = 0; i < 7; i++)
            {
                myList.Add(new Figure(1, i, 0, 0, 0, 0), 0);
            }
            myList.Remove(new Figure(1, 0, 0, 0, 0, 0));
            Assert.AreEqual(6, myList.Count());
        }
示例#7
0
        public void AddPassBlockArea(Geometry.Drawing drawing, Geometry.Game.PBPlayer player)
        {
            IEnumerable <IFigure> figures = player.GetPathPointFigure(player, null, 0);

            if (figures.Count() > 0)
            {// have path
                IFigure figure = player.GetEndFigure();

                if (figure is Game.PBPlayer)
                {
                    IEnumerable <IFigure> allFigures = player.GetPathFigure(player, null, 0);
                    IFigure lineFigure = allFigures.Last();
                    drawing.Remove(lineFigure);
                }
                player.ChangeLineType(CapType.BlockArea);
            }
            else
            {// no path
                player.ClearPath();

                IFigure    source       = player as IFigure;
                var        result       = Factory.CreateSubPoint(drawing, new Point(player.Coordinates.X, player.Coordinates.Y - 0.8));
                FigureList dependencies = new FigureList();
                dependencies.Add(source);
                dependencies.Add(result);
                PBLine         line             = Factory.CreateLine(drawing, dependencies);
                List <IFigure> figuresPassBlock = new List <IFigure>();
                figuresPassBlock.Add(line);
                figuresPassBlock.Add(result);
                drawing.Add(figuresPassBlock);
                if (!drawing.DrawingMode)
                {
                    line.CapType     = CapType.BlockArea;
                    line.StrokeColor = Webb.Playbook.Data.ColorSetting.Instance.BlockColor;
                }
                //player.Assignment = "Pass Block Area";
            }

            drawing.Figures.UpdateVisual();
        }
示例#8
0
 private static IFigureList ReadDependencies(XElement figureNode, Dictionary<string, IFigure> dictionary)
 {
     FigureList result = new FigureList();
     foreach (var node in figureNode.Elements("Dependency"))
     {
         var name = node.ReadString("Name");
         IFigure figure = null;
         if (dictionary.TryGetValue(name, out figure))
         {
             result.Add(figure);
         }
     }
     return result;
 }
示例#9
0
        public FigureList GetOffPBPlayer()
        {
            FigureList            defpbplayer = new FigureList();
            IEnumerable <IFigure> PbFigure    = this.GetPBplayer();

            foreach (Game.PBPlayer pbplayer in PbFigure)
            {
                if (pbplayer.ScoutType == 0)
                {
                    defpbplayer.Add(pbplayer);
                }
            }
            Point point = new Point(0, 0);

            foreach (IFigure figure in Figures)
            {
                if (figure is Game.PBBall)
                {
                    defpbplayer.Add(figure);
                    break;
                }
            }
            return(defpbplayer);
        }
示例#10
0
        public void openVHDLFile(string filename, string EntityName)
        {
            if (System.IO.File.Exists(filename) == false)
            {
                return;
            }
            My_FileAnalyzer analyzer = new My_FileAnalyzer(filename, core);

            analyzer.Analyze(EntityName);
            info.Entity = analyzer.SelectedEntity;
            foreach (My_Figure fig in analyzer.figures)
            {
                FigureList.Add(fig);
            }
            Sort();
        }
        public void CheckDecode()
        {
            var myList = new FigureList();
            var list   = new Do();

            list.MyList = myList;
            var rnd = new Random();

            for (int i = 0; i < 7; i++)
            {
                myList.Add(new Figure(rnd.Next(1, 4), rnd.Next(0, 6), rnd.Next(0, 6),
                                      rnd.Next(0, 4), rnd.Next(0, 4), rnd.Next(0, 4)), i);
            }
            list.Decode();
            Assert.AreEqual(0, myList.Count());
        }
示例#12
0
        private void Init()
        {
            Bitmap     bmp     = new Bitmap(this.Width, this.Height);
            Graphics   graph   = Graphics.FromImage(bmp);
            FigureList Figures = new FigureList();

            Figures.Add(new Line(new Pen(Color.Red), 100, 100, 200, 200));
            Figures.Add(new Triangle(new Pen(Color.Blue), 250, 200, 300, 50, 350, 200));
            Figures.Add(new Rectangle(new Pen(Color.Black), 300, 300, 100, 200));
            Figures.Add(new Ellipse(new Pen(Color.Purple), 300, 300, 100, 200));
            Figures.Add(new Square(new Pen(Color.Green), 450, 300, 100));
            Figures.Add(new Circle(new Pen(Color.Brown), 450, 300, 100));
            for (int i = 0; i < Figures.Count; i++)
            {
                Figures[i].Draw(graph);
            }
            this.BackgroundImage = bmp;
        }
示例#13
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();
        }
示例#14
0
文件: Form1.cs 项目: ItramariN/lab
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     List<Figure> list;
     flist = new FigureList();
     XmlSerializer formatter = new XmlSerializer(typeof(List<Figure>), TypeList.ToArray());
     openFileDialog1.InitialDirectory = "C:\tmp";
     openFileDialog1.Filter = "XML files (*.xml)|*.xml";
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         try
         {
             using (FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate))
                 list = (List<Figure>)formatter.Deserialize(fs);
         }
         catch (InvalidOperationException)
         {
             MessageBox.Show("Ошибка загрузки файла - отсутствуют требуемые классы");
             return;
         }
         foreach (Figure f in list)
         {
             flist.Add(f);
         }
         g.Clear(Color.White);
         Form1_Paint(this,null);
     }
 }
示例#15
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();
        }