Example #1
0
 public QuadTreeNode(ulong location, RectangleShape boundingBox, string id)
 {
     this.location = location;
     this.boundingBox = boundingBox;
     this.id = id;
     this.children = new Collection<QuadCell>();
 }
Example #2
0
        public void Extent()
        {
            RectangleShape r = new RectangleShape();

              r.Extent = new Vector2F(1, 2);
              Assert.AreEqual(1, r.WidthX);
              Assert.AreEqual(2, r.WidthY);
        }
Example #3
0
		/// <summary>
		/// Fill the Background and draw a (Rectangle)Frame around the Control
		/// </summary>
		/// <param name="graphics"></param>
		
		protected virtual void Decorate (Graphics graphics)
		{
			if (graphics == null) {
				throw new ArgumentNullException("graphics");
			}
			RectangleShape shape = new RectangleShape();
			this.FillShape(graphics,shape);
			StandardPrinter.DrawBorder(graphics,this.StyleDecorator as BaseStyleDecorator);
		}
Example #4
0
		protected virtual void Decorate ()
		{
			RectangleShape shape = new RectangleShape();
			shape.DrawShape(this.pdfWriter.DirectContent,
			            null,
			            this.styleDecorator,
			            ConvertToPdfRectangle());
			this.DrawFrame();
		}
		/// <summary>
		/// Fill the Background and draw a (Rectangle)Frame around the Control
		/// </summary>
		/// <param name="graphics"></param>
		
		protected virtual void Decorate (Graphics graphics)
		{
			if (graphics == null) {
				throw new ArgumentNullException("graphics");
			}
			RectangleShape shape = new RectangleShape();
			this.FillShape(graphics,shape);
			this.DrawFrame(graphics);
		}
Example #6
0
 public void Clone()
 {
     RectangleShape rectangle = new RectangleShape(0.1234f, 2.345f);
       RectangleShape clone = rectangle.Clone() as RectangleShape;
       Assert.IsNotNull(clone);
       Assert.AreEqual(rectangle.WidthX, clone.WidthX);
       Assert.AreEqual(rectangle.WidthY, clone.WidthY);
       Assert.AreEqual(rectangle.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum);
       Assert.AreEqual(rectangle.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum);
 }
		public static void FillBackground (Graphics  graphics,BaseStyleDecorator decorator)
		{
			if (decorator.BackColor != GlobalValues.DefaultBackColor) {
				
				RectangleShape backgroundShape = new RectangleShape();
				
				backgroundShape.FillShape(graphics,
				                          new SolidFillPattern(decorator.BackColor),
				                          decorator.DisplayRectangle);
			}
		}
 void UpdateCoordinates(RectangleShape bounds)
 {
     _north = bounds.UpperLeftPoint.Y;
     OnPropertyChanged("North");
     _south = bounds.LowerRightPoint.Y;
     OnPropertyChanged("South");
     _east = bounds.LowerRightPoint.X;
     OnPropertyChanged("East");
     _west = bounds.UpperLeftPoint.X;
     OnPropertyChanged("West");
 }
        private void control_renklendir(RectangleShape atak_Rec, RectangleShape def_rec, Label atak_Ismi, Label atak_Asker, Label Def_Ismi, Label Def_Asker)
        {

            atak_Rec.FillColor = drm_atak.tutulanulke[0].sahip.renkoku();
            atak_Ismi.Text = drm_atak.tutulanulke[0].ismi;
            atak_Asker.Text = drm_atak.tutulanulke[0].asker_Adedi.ToString();
            // 
            def_rec.FillColor = drm_atak.tutulanulke[1].sahip.renkoku();
            Def_Ismi.Text = drm_atak.tutulanulke[1].ismi;
            Def_Asker.Text = drm_atak.tutulanulke[1].asker_Adedi.ToString();

        }
 protected override void DrawCore(RectangleShape targetExtent, OverlayRefreshType overlayRefreshType)
 {
     LayerTile tile = GetTile(targetExtent, MapArguments.ActualWidth, MapArguments.ActualHeight, 0, 0, MapArguments.GetSnappedZoomLevelIndex(targetExtent));
     if (overlayRefreshType == OverlayRefreshType.Pan)
     {
         isPanningMap = true;
         PanOverlay(targetExtent);
     }
     else
     {
         isPanningMap = false;
         RefreshHighlightLayerTileAndPopup(targetExtent, tile);
     }
 }
 protected void generateNode(RectangleShape rec,Point ourLocation, MouseEventArgs e)
 {
     outRec = rec;
     Node_Front newInputRect = new Node_Front();
     newRect = newInputRect;
     Form1.getInstance().Controls.Add(newInputRect);
     int xPosition = outRec.Location.X + ourLocation.X;
     int yPosition = outRec.Location.Y + ourLocation.Y;
     // Point p = rectangleShape4.Parent.PointToScreen(rectangleShape4.Location);
     //newInputRect.Location = new Point((Cursor.Position.X - xPosition), (Cursor.Position.Y - yPosition));
     newInputRect.Location = new Point(xPosition, yPosition);
     newInputRect.BringToFront();
     this.DrawConnection(e);
 }
Example #12
0
 /// <summary>
 /// Change back color of the contro to given value.
 /// </summary>
 /// <param name="control"></param>
 /// <param name="propertyValue"></param>
 public static void ChangeRectangleBackColor(RectangleShape control, Color propertyValue)
 {
     if (control.Parent.InvokeRequired)
     {
         control.Parent.Invoke((System.Action)(() =>
         {
             control.BackColor = propertyValue;
         }));
     }
     else
     {
        control.BackColor = propertyValue;
     }
 }
Example #13
0
        public void TestBranchIteration()
        {
            var a = new EllipseShape ();
            var b = new RectangleShape ();
            var c = new LineShape (0.0, 0.0, 32.0, 32.0);
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, a);
            op.AddChild (look, b).AddChild (look, c);

            // Iterate through each member of the branch.
            var list = new List<ShapeBase> ();
            foreach (var item in op) {
                list.Add (item);
            }

            Assert.True (list[0] == b);
            Assert.True (list[1] == c);
        }
        public void ResolveSlideCollissionOrthogonal()
        {
            var initPosition = new Vector2(0.5f,0f);
            var shape = new RectangleShape(initPosition, new Vector2(1,1));
            IForwardMovablePhysicalEntity pe = new ForwardMovablePhysicalEntity(initPosition, shape, 1, MathHelper.Pi / 2);
            pe.InelasticCollision = true;

            ICollisionChecker collisionChecker = new CollisionCheckerMock(new List<IPhysicalEntity>() {pe});
            var movementPhysics = new MovementPhysics();
            ICollisionResolver collisionResolver = new MomentumCollisionResolver(collisionChecker, movementPhysics);

            movementPhysics.Move(pe);

            collisionResolver.ResolveCollisions();

            Assert.Equal(pe.Position.X, 0, 2);
            Assert.Equal(pe.Position.Y, 0, 2);
        }
Example #15
0
        public static int GetAppropriateLevel(RectangleShape extent, BaseShape shape)
        {
            RectangleShape currentBoundingBox = SquaredExtent(extent);
            RectangleShape shapeBoundingBox = shape.GetBoundingBox();

            int level = 0;

            if (shapeBoundingBox.IsWithin(currentBoundingBox))
            {
                while (true)
                {
                    level++;
                    RectangleShape upperLeft = GetUpperLeftQuater(currentBoundingBox);
                    RectangleShape uppperRight = GetUpperRightQuater(currentBoundingBox);
                    RectangleShape lowerLeft = GetLowerLeftQuater(currentBoundingBox);
                    RectangleShape lowerRight = GetLowerRightQuater(currentBoundingBox);

                    if (shapeBoundingBox.IsWithin(upperLeft))
                    {
                        currentBoundingBox = upperLeft;
                    }
                    else if (shapeBoundingBox.IsWithin(uppperRight))
                    {
                        currentBoundingBox = uppperRight;
                    }
                    else if (shapeBoundingBox.IsWithin(lowerLeft))
                    {
                        currentBoundingBox = lowerLeft;
                    }
                    else if (shapeBoundingBox.IsWithin(lowerRight))
                    {
                        currentBoundingBox = lowerRight;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return level;
        }
Example #16
0
        public void InitializeLightbulbs(int rows, int columns)
        {
            this.shapeContainer1 = new ShapeContainer();
            this.SuspendLayout();

            this.shapeContainer1.Location = new System.Drawing.Point(0, 0);
            this.shapeContainer1.Margin = new System.Windows.Forms.Padding(0);
            this.shapeContainer1.Name = "shapeContainer1";

            int numberOfBulbs = rows * columns;
            _lightbulbs = new RectangleShape[numberOfBulbs];
            int index = 0;
            for (int rowNumber = 0; rowNumber < rows; rowNumber++)
            {
                for (int columNumber = 0; columNumber < columns; columNumber++)
                {
                    int left = (columNumber * PADDING) + (columNumber * BULB_SIZE);
                    int top = (rowNumber * PADDING) + (rowNumber * BULB_SIZE);
                    var bulb = new RectangleShape(left, top, BULB_SIZE, BULB_SIZE)
                    {
                        BackStyle = BackStyle.Opaque,
                        BackColor = COLOR_OFF,
                    };
                    _lightbulbs[index++] = bulb;
                    this.shapeContainer1.Shapes.Add(bulb);
                }
            }

            this.shapeContainer1.Size = new System.Drawing.Size(64, 73);
            this.shapeContainer1.TabIndex = 0;
            this.shapeContainer1.TabStop = false;

            this.Controls.Add(this.shapeContainer1);

            int totalWidth = (columns * PADDING) + (columns * BULB_SIZE);
            int totalHeight = (rows * PADDING) + (rows * BULB_SIZE);
            this.Size = new System.Drawing.Size(totalWidth, totalHeight);

            this.ResumeLayout(false);
            this.PerformLayout();
        }
Example #17
0
        public void RectangleCoverTiles(float x, float y, float size)
        {
            var rectangle = new RectangleShape(new Vector2(x + size/2, y + size/2), new Vector2(size, size));
            List<Vector2I> coverTiles = rectangle.CoverTiles();

            if (TestUtils.FloatEq(x, 0.2f) && TestUtils.FloatEq(y, 0.2f) && TestUtils.FloatEq(size, 0.5f))
            {
                Assert.True(coverTiles.Count == 1);
                Assert.Contains(Vector2I.Zero, coverTiles);
            }

            if (TestUtils.FloatEq(x, 0f) && TestUtils.FloatEq(y, 0f) && TestUtils.FloatEq(size, 1.5f))
            {
                Assert.True(coverTiles.Count == 4);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
                return;
            }

            if (TestUtils.FloatEq(x, 0f) && TestUtils.FloatEq(y, 0f) && TestUtils.FloatEq(size, 2f))
            {
                Assert.True(coverTiles.Count == 4);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
                return;
            }

            if (TestUtils.FloatEq(x, 0.1f) && TestUtils.FloatEq(y, 0.1f) && TestUtils.FloatEq(size, 1.5f))
            {
                Assert.True(coverTiles.Count == 4);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
            }
        }
Example #18
0
        public void TestDrawRectangle()
        {
            var bytes = new byte[1024 * 4];
            var format = Cairo.Format.ARGB32;
            var image = new Cairo.ImageSurface (bytes, format, 32, 32, 32 * 4);
            var shape = new RectangleShape ();
            shape.Rectangle = new Rectangle () {
                X = 10.0,
                Y = 10.0,
                Width = 12.0,
                Height = 12.0
            };
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, shape);
            using (var context = new Cairo.Context (image)) {
                op.Draw (context);
            }

            image.WriteToPng ("testimages/rectangle.png");
            image.Dispose ();
        }
        protected override void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent)
        {
            base.DrawSampleCore(canvas, drawingExtent);
            PointShape upperLeftPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingExtent.CenterX - drawingExtent.Width / 2, drawingExtent.CenterY - drawingExtent.Height / 2, canvas.Width, canvas.Height);
            PointShape lowerRightPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingExtent.CenterX + drawingExtent.Width / 2, drawingExtent.CenterY + drawingExtent.Height / 2, canvas.Width, canvas.Height);
            RectangleShape rectangle = new RectangleShape(upperLeftPoint, lowerRightPoint);
            rectangle.ScaleDown(10);

            // Here draw the points on Legend Image
            Random random = new Random(DateTime.Now.Millisecond);
            Collection<BaseShape> drawingPoints = new Collection<BaseShape>();
            for (int i = 0; i < DrawingPointsNumber; i++)
            {
                double x = rectangle.LowerLeftPoint.X + random.NextDouble() * (rectangle.Width);
                double y = rectangle.LowerLeftPoint.Y + random.NextDouble() * (rectangle.Height);
                drawingPoints.Add(new PointShape(x, y));
            }
            TextStyle textStyle = new TextStyle(DrawingPointsNumber.ToString(), new GeoFont("Arial", 20, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.FromArgb(180, GeoColor.FromHtml("#d3d3d3"))));
            textStyle.DrawSample(canvas, drawingExtent);
            CustomPointStyle.Draw(drawingPoints, canvas, new Collection<SimpleCandidate>(), new Collection<SimpleCandidate>());
        }
        public void ResolveSlideCollission45()
        {
            var initPosition = new Vector2(0.5f, 0f);
            var shape = new RectangleShape(initPosition, new Vector2(1, 1));

            float angle = 135f;

            var angleRads = MathHelper.ToRadians(angle);
            IForwardMovablePhysicalEntity pe = new ForwardMovablePhysicalEntity(initPosition, shape, 1, angleRads)
                {InelasticCollision = true};

            ICollisionChecker collisionChecker = new CollisionCheckerMock(new List<IPhysicalEntity>() {pe});
            var movementPhysics = new MovementPhysics();
            ICollisionResolver collisionResolver = new MomentumCollisionResolver(collisionChecker, movementPhysics);

            movementPhysics.Move(pe);

            collisionResolver.ResolveCollisions();

            Assert.Equal(pe.Position.X, 0f, 2);
            Assert.Equal(pe.Position.Y, -0.71f, 2);
        }
        private LayerTile DrawHighlightTile(RectangleShape targetExtent, LayerTile tile)
        {
            tile.DrawingLayers.Clear();
            if (highlightFeatureLayer.InternalFeatures.Count > 0)
            {
                tile.DrawingLayers.Add(highlightFeatureLayer);
            }

            GeoCanvas geoCanvas = new GdiPlusGeoCanvas()
            {
                CompositingQuality = CompositingQuality.HighSpeed,
                DrawingQuality = DrawingQuality.HighSpeed,
                SmoothingMode = SmoothingMode.HighSpeed
            };
            Bitmap bitmap = new Bitmap((int)tile.Width, (int)tile.Height);
            geoCanvas.BeginDrawing(bitmap, targetExtent, MapArguments.MapUnit);
            tile.Draw(geoCanvas);
            geoCanvas.EndDrawing();
            tile.CommitDrawing(geoCanvas, MapSuiteSampleHelper.GetImageSourceFromNativeImage(bitmap));

            return tile;
        }
Example #22
0
        public static int GetLevelByCellWidth(RectangleShape extent, GeographyUnit extentMapUnit, double cellWidth, DistanceUnit widthDistanceUnit)
        {
            PointShape centerPoint = extent.GetCenterPoint();

            PointShape centerLeft = new PointShape(extent.LowerLeftPoint.X, centerPoint.Y);
            PointShape centerRight = new PointShape(extent.UpperRightPoint.X, centerPoint.Y);
            PointShape centerUpper = new PointShape(centerPoint.X, extent.UpperLeftPoint.Y);
            PointShape centerLower = new PointShape(centerPoint.X, extent.LowerLeftPoint.Y);

            double centerWidth = centerLeft.GetDistanceTo(centerRight, extentMapUnit, widthDistanceUnit);
            double centerHeight = centerUpper.GetDistanceTo(centerLower, extentMapUnit, widthDistanceUnit);

            double longestEdge = Math.Max(centerWidth, centerHeight);

            double level = Math.Round(2 * Math.Log((longestEdge / cellWidth), 4) + 1);

            return (int)level;
        }
Example #23
0
        public static Collection<QuadCell> GetIntersectingCells(RectangleShape extent, BaseShape shape, int startLevel, int endLevel)
        {
            RectangleShape extentBoundingBox = SquaredExtent(extent);
            RectangleShape shapeBoundingBox = shape.GetBoundingBox();

            Collection<QuadCell> result = new Collection<QuadCell>();

            if (shapeBoundingBox.Intersects(extentBoundingBox))
            {
                ulong location = GetLocation(extentBoundingBox, shape, int.MaxValue);
                ulong reversedResult = Reverse(location);
                ulong temporaryValue = reversedResult;
                temporaryValue >>= 1;

                int locationLength = GetLevelsCount(temporaryValue);
                if (startLevel <= locationLength)
                {
                    int index = startLevel;
                    while (index <= endLevel)
                    {
                        ulong temporaryLocation = temporaryValue;
                        if (index <= locationLength)
                        {
                            MovePositionByIndex(ref temporaryLocation, index);
                            if (locationLength > 1)
                            {
                                result.Add(GetCellByLocation(extentBoundingBox, temporaryLocation));
                            }
                            else
                            {
                                result.Add(GetCellByLocation(extentBoundingBox, 0));
                            }
                        }
                        index++;
                    }
                }
                if (endLevel > locationLength)
                {
                    Queue<ulong> locationsToProcess = new Queue<ulong>();
                    locationsToProcess.Enqueue(location);

                    while (locationsToProcess.Count > 0)
                    {
                        ulong currentLocation = locationsToProcess.Dequeue();

                        for (int k = 1; k <= 4; k++)
                        {
                            ulong newLocation = (currentLocation << k) | 1;
                            result.Add(GetCellByLocation(extentBoundingBox, newLocation));
                            int newLocationsCount = GetLevelsCount(newLocation);
                            if (newLocationsCount < endLevel)
                            {
                                locationsToProcess.Enqueue(newLocation);
                            }
                        }
                    }
                }
            }
            //if (result.Count == 0)
            //{
            //    result.Add(GetCellByLocation(extentBoundingBox, "01"));
            //    result.Add(GetCellByLocation(extentBoundingBox, "02"));
            //    result.Add(GetCellByLocation(extentBoundingBox, "03"));
            //    result.Add(GetCellByLocation(extentBoundingBox, "04"));
            //}
            return result;
        }
Example #24
0
        public void MouseMoved(object sender, EventArgs e)
        {
            Vector2i pixelPos = Mouse.GetPosition(_window);
            Vector2f worldPos = _window.MapPixelToCoords(pixelPos, View);

            RectangleShape rec = new RectangleShape();

            rec.OutlineColor     = new Color(Color.Transparent);
            rec.OutlineThickness = 3.0f;
            rec.FillColor        = new Color(253, 254, 254);
            rec.Size             = new Vector2f(32 * 8, 32 * 4);

            int posX = Mouse.GetPosition(_window).X;
            int posY = Mouse.GetPosition(_window).Y;

            if (_ctx.MenuState == 1)
            {
                _xMax = _mapUI._x2y2.X;
                _yMax = _mapUI._x2y2.Y;
                if (!Equals(_ui.mouseSprite, null))
                {
                    _ui.mouseSprite.Position = new Vector2f(Mouse.GetPosition(_window).X, Mouse.GetPosition(_window).Y);
                }
            }

            // Right side
            if (posX == (_resolution.X - 1))
            {
                if (CheckCamera(new Vector2f(50, 0)))
                {
                    _x1 += 50;
                    _x2 += 50;
                    _view.Move(new Vector2f(50, 0));
                }
            }
            // Left side
            else if (posX == 0)
            {
                if (CheckCamera(new Vector2f(-50, 0)))
                {
                    _x1 += -50;
                    _x2 += -50;
                    _view.Move(new Vector2f(-50, 0));
                }
            }
            // Up side
            else if (posY == 0)
            {
                if (CheckCamera(new Vector2f(0, -50)))
                {
                    _y1 += -50;
                    _y2 += -50;
                    _view.Move(new Vector2f(0, -50));
                }
            }
            // Bottom side
            else if (posY == (_resolution.Y - 1))
            {
                Console.WriteLine("X = {0}, Y = {1}", _view.Viewport.Height, _view.Viewport.Width);

                if (CheckCamera(new Vector2f(0, 50)))
                {
                    _y1 += 50;
                    _y2 += 50;
                    _view.Move(new Vector2f(0, 50));
                }
            }
        }
Example #25
0
 public GroupShape(RectangleShape rectangle) : base(rectangle)
 {
 }
        private static void Main(string[] args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            const int width  = 800;
            const int height = 800;

            RenderWindow window = new RenderWindow(new VideoMode(width, height), "Space Invaders");

            //window.SetFramerateLimit(30);
            window.Closed      += OnClose;
            window.KeyReleased += OnKeyReleased;

            Color windowColor = Color.Black;

            const int   playerWidth  = width / 10;
            const int   playerHeight = height / 20;
            const float playerSpeed  = 1;
            var         player       = new RectangleShape(new Vector2f(playerWidth, playerHeight))
            {
                //Position = new SFML.System.Vector2f(, 50),
                FillColor = Color.Green,
                Origin    = new Vector2f(playerWidth / 2, playerHeight / 2),
                Position  = new Vector2f(width / 2, height - (playerHeight / 2) - (height / 10))
            };

            const int   bulletWidth  = 5;
            const int   bulletHeight = 20;
            const float bulletSpeed  = 1.5f;
            var         bullet       = new RectangleShape(new Vector2f(bulletWidth, bulletHeight))
            {
                FillColor = Color.Green,
                Origin    = new Vector2f(bulletWidth / 2, bulletHeight / 2),
                Position  = player.Position
            };

            var clock                 = new Clock();
            var playerElapsed         = clock.ElapsedTime;
            var playerPreviousElapsed = playerElapsed;
            var bulletElapsed         = clock.ElapsedTime;
            var bulletPreviousElapsed = playerElapsed;

            var fpsCounter = 0;
            var fps        = 0;
            //var fps = new Text(fpsCounter.ToString(), );
            var fpsElapsed         = clock.ElapsedTime;
            var fpsPreviousElapsed = fpsElapsed;

            while (window.IsOpen)
            {
                fpsCounter++;
                window.DispatchEvents();

                playerElapsed = clock.ElapsedTime;
                if (playerElapsed.AsMilliseconds() > playerPreviousElapsed.AsMilliseconds())
                {
                    playerPreviousElapsed = playerElapsed;
                    if (Keyboard.IsKeyPressed(Keyboard.Key.Left))
                    {
                        player.Position += new Vector2f(-playerSpeed, 0);
                    }
                    else if (Keyboard.IsKeyPressed(Keyboard.Key.Right))
                    {
                        player.Position += new Vector2f(playerSpeed, 0);
                    }
                    var playerBounds = player.GetGlobalBounds();
                    if (playerBounds.Left < 0)
                    {
                        player.Position = new Vector2f(playerWidth / 2, player.Position.Y);
                    }
                    if (playerBounds.Left + playerBounds.Width > width)
                    {
                        player.Position = new Vector2f(width - (playerWidth / 2), player.Position.Y);
                    }
                }
                bulletElapsed = clock.ElapsedTime;
                if (bulletElapsed.AsMilliseconds() > bulletPreviousElapsed.AsMilliseconds())
                {
                    bulletPreviousElapsed = bulletElapsed;
                    if (Shooting)
                    {
                        bullet.Position += new Vector2f(0, -bulletSpeed);
                        if (bullet.Position.Y + bulletHeight < 0)
                        {
                            Shooting = false;
                        }
                    }
                    else
                    {
                        bullet.Position = player.Position;
                    }
                }
                fpsElapsed = clock.ElapsedTime;
                if (fpsElapsed > fpsPreviousElapsed + Time.FromSeconds(1))
                {
                    fps = fpsCounter;
                    Console.WriteLine(fps);
                    fpsCounter         = 0;
                    fpsPreviousElapsed = fpsElapsed;
                }

                window.Clear(windowColor);

                window.Draw(bullet);
                window.Draw(player);

                window.Display();
            }
        }
Example #27
0
 protected override GeoImage GetImageCore(RectangleShape worldExtent, int canvasWidth, int canvasHeight)
 {
     return(null);
 }
Example #28
0
        private DrawingGroup LoadGroup(IList <Shape> elements, Rect?viewBox)
        {
            List <ControlLine> debugPoints = new List <ControlLine>();
            DrawingGroup       grp         = new DrawingGroup();

            if (viewBox.HasValue)
            {
                grp.ClipGeometry = new RectangleGeometry(viewBox.Value);
            }

            foreach (Shape shape in elements)
            {
                if (shape is UseShape)
                {
                    UseShape useshape = shape as UseShape;
                    Group    group    = this.SVG.GetShape(useshape.hRef) as Group;
                    if (group != null)
                    {
                        Shape oldparent = group.Parent;
                        group.Parent = useshape; // this to get proper style propagated
                        DrawingGroup subgroup = this.LoadGroup(group.Elements, null);
                        if (group.Clip != null)
                        {
                            subgroup.ClipGeometry = group.Clip.ClipGeometry;
                        }
                        subgroup.Transform = new TranslateTransform(useshape.X, useshape.Y);
                        grp.Children.Add(subgroup);
                        group.Parent = oldparent;
                    }
                    continue;
                }
                if (shape is Clip)
                {
                    DrawingGroup subgroup = this.LoadGroup((shape as Clip).Elements, null);
                    if (shape.Transform != null)
                    {
                        subgroup.Transform = shape.Transform;
                    }
                    grp.Children.Add(subgroup);
                    continue;
                }
                if (shape is Group)
                {
                    DrawingGroup subgroup = this.LoadGroup((shape as Group).Elements, null);
                    if (shape.Clip != null)
                    {
                        subgroup.ClipGeometry = shape.Clip.ClipGeometry;
                    }
                    if (shape.Transform != null)
                    {
                        subgroup.Transform = shape.Transform;
                    }
                    grp.Children.Add(subgroup);
                    continue;
                }
                if (shape is RectangleShape)
                {
                    RectangleShape    r    = shape as RectangleShape;
                    RectangleGeometry rect = new RectangleGeometry(new Rect(r.X, r.Y, r.Width, r.Height));
                    rect.RadiusX = r.RX;
                    rect.RadiusY = r.RY;
                    if (rect.RadiusX == 0 && rect.RadiusY > 0)
                    {
                        rect.RadiusX = rect.RadiusY;
                    }
                    grp.Children.Add(this.NewDrawingItem(shape, rect));
                }
                if (shape is LineShape)
                {
                    LineShape    r    = shape as LineShape;
                    LineGeometry line = new LineGeometry(r.P1, r.P2);
                    grp.Children.Add(this.NewDrawingItem(shape, line));
                }
                if (shape is PolylineShape)
                {
                    PolylineShape r    = shape as PolylineShape;
                    PathGeometry  path = new PathGeometry();
                    PathFigure    p    = new PathFigure();
                    path.Figures.Add(p);
                    p.IsClosed   = false;
                    p.StartPoint = r.Points[0];
                    for (int index = 1; index < r.Points.Length; index++)
                    {
                        p.Segments.Add(new LineSegment(r.Points[index], true));
                    }
                    grp.Children.Add(this.NewDrawingItem(shape, path));
                }
                if (shape is PolygonShape)
                {
                    PolygonShape r    = shape as PolygonShape;
                    PathGeometry path = new PathGeometry();
                    PathFigure   p    = new PathFigure();
                    path.Figures.Add(p);
                    p.IsClosed   = true;
                    p.StartPoint = r.Points[0];
                    for (int index = 1; index < r.Points.Length; index++)
                    {
                        p.Segments.Add(new LineSegment(r.Points[index], true));
                    }
                    grp.Children.Add(this.NewDrawingItem(shape, path));
                }
                if (shape is CircleShape)
                {
                    CircleShape     r = shape as CircleShape;
                    EllipseGeometry c = new EllipseGeometry(new Point(r.CX, r.CY), r.R, r.R);
                    grp.Children.Add(this.NewDrawingItem(shape, c));
                }
                if (shape is EllipseShape)
                {
                    EllipseShape    r = shape as EllipseShape;
                    EllipseGeometry c = new EllipseGeometry(new Point(r.CX, r.CY), r.RX, r.RY);
                    grp.Children.Add(this.NewDrawingItem(shape, c));
                }
                if (shape is ImageShape)
                {
                    ImageShape   image = shape as ImageShape;
                    ImageDrawing i     = new ImageDrawing(image.ImageSource, new Rect(image.X, image.Y, image.Width, image.Height));
                    grp.Children.Add(i);
                }
                if (shape is TextShape)
                {
                    GeometryGroup gp = TextRender.BuildTextGeometry(shape as TextShape);
                    if (gp != null)
                    {
                        foreach (Geometry gm in gp.Children)
                        {
                            TextShape.TSpan.Element tspan = TextRender.GetElement(gm);
                            if (tspan != null)
                            {
                                grp.Children.Add(this.NewDrawingItem(tspan, gm));
                            }
                            else
                            {
                                grp.Children.Add(this.NewDrawingItem(shape, gm));
                            }
                        }
                    }
                }
                if (shape is PathShape)
                {
                    PathShape  r         = shape as PathShape;
                    PathFigure p         = null;
                    Point      lastPoint = new Point(0, 0);

                    PathShape.CurveTo lastc        = null;
                    Point             lastcirPoint = new Point(0, 0);

                    PathGeometry path = new PathGeometry();
                    foreach (PathShape.PathElement element in r.Elements)
                    {
                        bool isRelative = element.IsRelative;
                        if (element is PathShape.MoveTo)
                        {
                            p          = new PathFigure();
                            p.IsClosed = r.ClosePath;
                            if (isRelative)
                            {
                                p.StartPoint = lastPoint + (Vector)((PathShape.MoveTo)element).Point;
                            }
                            else
                            {
                                p.StartPoint = ((PathShape.MoveTo)element).Point;
                            }
                            lastPoint = p.StartPoint;
                            path.Figures.Add(p);
                            continue;
                        }
                        if (element is PathShape.LineTo)
                        {
                            PathShape.LineTo lineto = element as PathShape.LineTo;
                            foreach (Point point in lineto.Points)
                            {
                                if (isRelative)
                                {
                                    Point newpoint = lastPoint + (Vector)point;
                                    lastPoint = newpoint;
                                    p.Segments.Add(new LineSegment(newpoint, true));
                                }
                                else
                                {
                                    if (lineto.PositionType == PathShape.LineTo.eType.Point)
                                    {
                                        lastPoint = point;
                                    }
                                    if (lineto.PositionType == PathShape.LineTo.eType.Horizontal)
                                    {
                                        lastPoint = new Point(point.X, lastPoint.Y);
                                    }
                                    if (lineto.PositionType == PathShape.LineTo.eType.Vertical)
                                    {
                                        lastPoint = new Point(lastPoint.X, point.Y);
                                    }
                                    p.Segments.Add(new LineSegment(lastPoint, true));
                                }
                            }
                            continue;
                        }
                        if (element is PathShape.CurveTo)
                        {
                            PathShape.CurveTo c          = element as PathShape.CurveTo;
                            Point             startPoint = lastPoint;
                            BezierSegment     s          = new BezierSegment();
                            if (isRelative)
                            {
                                s.Point1 = lastPoint + (Vector)c.CtrlPoint1;

                                if (c.Command == 's')
                                {
                                    // first control point is a mirrored point of last end control point
                                    //s.Point1 = lastPoint + new Vector(lastc.Point.X - dx, lastc.Point.Y - dy);
                                    //s.Point1 = new Point(lastctrlpoint.X+2, lastctrlpoint.Y+2);

                                    double dx = lastc.CtrlPoint2.X - lastc.Point.X;
                                    double dy = lastc.CtrlPoint2.Y - lastc.Point.Y;
                                    s.Point1 = new Point(lastcirPoint.X - dx, lastcirPoint.Y - dy);
                                    //s.Point1 = lastctrlpoint;
                                }

                                s.Point2 = lastPoint + (Vector)c.CtrlPoint2;
                                s.Point3 = lastPoint + (Vector)c.Point;
                            }
                            else
                            {
                                if (c.Command == 'S')
                                {
                                    // first control point is a mirrored point of last end control point
                                    //s.Point1 = lastPoint + new Vector(lastc.Point.X - dx, lastc.Point.Y - dy);
                                    //s.Point1 = new Point(lastctrlpoint.X+2, lastctrlpoint.Y+2);

                                    double dx = lastc.CtrlPoint2.X - lastc.Point.X;
                                    double dy = lastc.CtrlPoint2.Y - lastc.Point.Y;
                                    s.Point1 = new Point(lastcirPoint.X - dx, lastcirPoint.Y - dy);
                                }
                                else
                                {
                                    s.Point1 = c.CtrlPoint1;
                                }
                                s.Point2 = c.CtrlPoint2;
                                s.Point3 = c.Point;
                            }
                            lastPoint = s.Point3;
                            p.Segments.Add(s);

                            lastc        = c;
                            lastcirPoint = s.Point3;

                            //debugPoints.Add(new ControlLine(startPoint, s.Point1));
                            //debugPoints.Add(new ControlLine(s.Point3, s.Point2));
                            continue;
                        }
                        if (element is PathShape.EllipticalArcTo)
                        {
                            PathShape.EllipticalArcTo c = element as PathShape.EllipticalArcTo;
                            ArcSegment s = new ArcSegment();
                            if (isRelative)
                            {
                                s.Point = lastPoint + new Vector(c.X, c.Y);
                            }
                            else
                            {
                                s.Point = new Point(c.X, c.Y);
                            }

                            s.Size           = new Size(c.RX, c.RY);
                            s.RotationAngle  = c.AxisRotation;
                            s.SweepDirection = SweepDirection.Counterclockwise;
                            if (c.Clockwise)
                            {
                                s.SweepDirection = SweepDirection.Clockwise;
                            }
                            s.IsLargeArc = c.LargeArc;
                            lastPoint    = s.Point;
                            p.Segments.Add(s);
                            continue;
                        }
                    }

                    /*
                     * if (r.Transform != null)
                     *  path.Transform = r.Transform;
                     */
                    grp.Children.Add(this.NewDrawingItem(shape, path));
                    //}
                }
            }


            if (debugPoints != null)
            {
                foreach (ControlLine line in debugPoints)
                {
                    grp.Children.Add(line.Draw());
                }
            }
            return(grp);
        }
        public void ExtentXException()
        {
            RectangleShape r = new RectangleShape();

            r.Extent = new Vector2F(-1, 1);
        }
        public void WidthYException()
        {
            RectangleShape b = new RectangleShape();

            b.WidthY = -1;
        }
Example #31
0
 private void CalculateAreaPressed(object sender, EventArgs e)
 {
     _rectangleShape = _rectangleShapeView.RectangleShape;
     _rectangleShape.CalculateArea();
     _rectangleShapeView.RectangleShape = _rectangleShape;
 }
        private void HandleLoadChartMessage(ChartMessage message)
        {
            LayerOverlay overlay = null;

            if (message.Charts != null)
            {
                if (map.Overlays.Contains(chartsOverlayName))
                {
                    overlay = ((LayerOverlay)map.Overlays[chartsOverlayName]);
                }
                else
                {
                    overlay = new LayerOverlay()
                    {
                        TileType = TileType.SingleTile,
                    };
                    map.Overlays.Insert(1, chartsOverlayName, overlay);
                }

                overlay.Layers.Clear();
                ChartSelectedItem = new ChartSelectedItem(string.Empty, null);
                IEnumerable <ChartItem> charts      = message.Charts;
                RectangleShape          boundingBox = null;
                foreach (ChartItem item in charts)
                {
                    if (!File.Exists(item.IndexFileName))
                    {
                        NauticalChartsFeatureSource.BuildIndexFile(item.FileName, BuildIndexMode.DoNotRebuild);
                    }
                    NauticalChartsFeatureLayer layer = new NauticalChartsFeatureLayer(item.FileName);

                    layer.DrawingFeatures += hydrographyLayer_DrawingFeatures;

                    layer.IsDepthContourTextVisible = Globals.IsDepthContourTextVisible;
                    layer.IsLightDescriptionVisible = Globals.IsLightDescriptionVisible;
                    layer.IsSoundingTextVisible     = Globals.IsSoundingTextVisible;
                    layer.SymbolTextDisplayMode     = Globals.SymbolTextDisplayMode;
                    layer.DisplayCategory           = Globals.DisplayMode;
                    layer.DefaultColorSchema        = Globals.CurrentColorSchema;
                    layer.SymbolDisplayMode         = Globals.CurrentSymbolDisplayMode;
                    layer.BoundaryDisplayMode       = Globals.CurrentBoundaryDisplayMode;

                    layer.SafetyDepthInMeter        = NauticalChartsFeatureLayer.ConvertDistanceToMeters(Globals.SafetyDepth, Globals.CurrentDepthUnit);
                    layer.ShallowDepthInMeter       = NauticalChartsFeatureLayer.ConvertDistanceToMeters(Globals.ShallowDepth, Globals.CurrentDepthUnit);
                    layer.DeepDepthInMeter          = NauticalChartsFeatureLayer.ConvertDistanceToMeters(Globals.DeepDepth, Globals.CurrentDepthUnit);
                    layer.SafetyContourDepthInMeter = NauticalChartsFeatureLayer.ConvertDistanceToMeters(Globals.SafetyContour, Globals.CurrentDepthUnit);

                    layer.DrawingMode            = Globals.CurrentDrawingMode;
                    layer.IsFullLightLineVisible = Globals.IsFullLightLineVisible;
                    layer.IsMetaObjectsVisible   = Globals.IsMetaObjectsVisible;
                    layer.Name = item.FileName;
                    layer.Open();
                    if (boundingBox == null)
                    {
                        boundingBox = layer.GetBoundingBox();
                    }
                    else
                    {
                        boundingBox.ExpandToInclude(layer.GetBoundingBox());
                    }

                    boundingBoxPreviewLayer.InternalFeatures.Add(layer.GetHashCode().ToString(), new Feature(layer.GetBoundingBox()));

                    layer.Close();
                    overlay.Layers.Add(item.FileName, layer);
                }
                if (boundingBox != null)
                {
                    map.CurrentExtent = boundingBox;
                }

                //SetupAnimationForOverlay(overlay);

                ApplyOverlayOpacity();

                map.Refresh();
            }
        }
        private float GetFontSizeByBoundingBox(GeoCanvas canvas, GeoFont font, string drawingText, RectangleShape boundingBox)
        {
            float rtn = font.Size;

            ScreenPointF boundingBoxPointFUL = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, boundingBox.UpperLeftPoint, canvas.Width, canvas.Height);
            ScreenPointF boundingBoxPointFUR = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, boundingBox.UpperRightPoint, canvas.Width, canvas.Height);
            ScreenPointF boundingBoxPointFLL = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, boundingBox.LowerLeftPoint, canvas.Width, canvas.Height);

            double widthInScreen  = boundingBoxPointFUR.X - boundingBoxPointFUL.X;
            double heightInScreen = boundingBoxPointFLL.Y - boundingBoxPointFUL.Y;

            DrawingRectangleF textRectInScreen = canvas.MeasureText(drawingText, font);

            if (textRectInScreen.Width > widthInScreen || textRectInScreen.Height > heightInScreen)
            {
                while (textRectInScreen.Width > widthInScreen || textRectInScreen.Height > heightInScreen)
                {
                    rtn = rtn * 9 / 10;
                    textRectInScreen = canvas.MeasureText(drawingText, new GeoFont(font.FontName, rtn, font.Style));
                }
            }
            else
            {
                while (textRectInScreen.Width < widthInScreen && textRectInScreen.Height < heightInScreen)
                {
                    rtn = rtn * 10 / 9;
                    textRectInScreen = canvas.MeasureText(drawingText, new GeoFont(font.FontName, rtn, font.Style));
                }
                rtn = rtn * 9 / 10;
            }
            if (rtn > maxFontSize)
            {
                rtn = maxFontSize;
            }

            return(rtn);
        }
Example #34
0
 public Brick(RectangleShape rect)
 {
     Rect = rect;
 }
        public void TestCircleRectangleCollision()
        {
            // Circles params: center coordiantes x,y ; radius, turn
            Vector2[][] circles =
            {
                new[] { new Vector2(5.0f,   5.0f), new Vector2(2.0f,   34.098f) },
                new[] { new Vector2(-6.0f,  6.0f), new Vector2(3.0f,  324.081f) },
                new[] { new Vector2(-8.0f, -7.0f), new Vector2(4.0f,  7.00098f) },
                new[] { new Vector2(10.0f, -8.0f), new Vector2(5.0f, 104.3398f) }
            };
            //Not intersect rectangle coordinates
            Vector2[][] freeRec =
            {
                new[] { new Vector2(2.023f,   3.00009f), new Vector2(130.0099f, 9900.019f) },
                new[] { new Vector2(102.999f, 60.0017f), new Vector2(-210.012f, 109.0002f) },
                new[] { new Vector2(534.001f, 12.0001f), new Vector2(-1024.99f, -634.091f) },
                new[] { new Vector2(2.09343f, 2.02321f), new Vector2(99.99f,       100.1f) }
            };
            // Intersect rectangle coordinates
            Vector2[][] intrRec =
            {
                new[] { new Vector2(6.0123f,   6.0321f), new Vector2(5.0001f,    5.0001f) },
                new[] { new Vector2(2.0009f,  2.00192f), new Vector2(-6.012f,    6.2202f) },
                new[] { new Vector2(7.013f,  1.980001f), new Vector2(-6.007f,   -7.1230f) },
                new[] { new Vector2(4.0012f,   4.1001f), new Vector2(6.034f,  -8.000009f) }
            };
            // Turns for first/second rect's
            Vector2[] turnRec =
            {
                new Vector2(27.304f,   0.0001f),
                new Vector2(124.303f,    66.6f),
                new Vector2(322.022f, 132.546f),
                new Vector2(66.6666f, 12.012f)
            };
            //Create circles and check collisions
            for (var obj = 0; obj < circles.Length; obj++)
            {
                //Work vals
                CollisionResult result;

                // Circle objects: circles[obj][0] - coords, circles[obj][1][0] - radius, circles[obj][1][1] - turn
                CircleShape         circleShape     = new CircleShape(Vector2.Zero, circles[obj][1].X);
                Collision.Transform circleTransform =
                    new Collision.Transform(circles[obj][0], circles[obj][1].Y * Mathf.Deg2Rad);

                //Create free rectangle objects: freeRec[obj][0] - width/heigth, freeRec[obj][1] - coordinates
                //Create intersect rectangle objects: intrRec[obj][0] - width/heigth, intrRec[obj][1] - coordinates
                // Turns for Shapes turnRec[obj][0-1]

                // Free Rect
                RectangleShape freeRectShape =
                    new RectangleShape(Vector2.Zero, freeRec[obj][0].X, freeRec[obj][0].Y);
                Collision.Transform freeRectTransform =
                    new Collision.Transform(freeRec[obj][1], turnRec[obj].X * Mathf.Deg2Rad);

                //Intersection Rect
                RectangleShape intrRectShape =
                    new RectangleShape(Vector2.Zero, intrRec[obj][0].X, intrRec[obj][0].Y);
                Collision.Transform intrdRectTransform =
                    new Collision.Transform(intrRec[obj][1], turnRec[obj].Y * Mathf.Deg2Rad);

                // Make free test
                var freeResult = circleShape.IntersectsWith(circleTransform, freeRectShape,
                                                            freeRectTransform, out result);
                // Make Intersection test
                var intrResult = circleShape.IntersectsWith(circleTransform, intrRectShape,
                                                            intrdRectTransform, out result);
                // Generate error messages

                string freeErr =
                    String.Format(
                        "Circle to Rectangle test failed; Circle({0})R:({1}) {2}° and freeRect({3} : {4}){5}°",
                        circles[obj][0], circles[obj][1].X, circles[obj][1].Y, freeRec[obj][0], freeRec[obj][1],
                        turnRec[obj].X);


                string intrErr = String.Format(
                    "Circle to Rectangle Interssept failed; Circle({0})R:({1}) {2}° and intrRect({3} : {4}){5}°",
                    circles[obj][0], circles[obj][1].X, circles[obj][1].Y, intrRec[obj][0], intrRec[obj][1],
                    turnRec[obj].Y);
                // Assert results
                Assert.That(freeResult == false, freeErr);
                Assert.That(intrResult, intrErr);
            }
        }
Example #36
0
        public static ulong GetLocation(RectangleShape extent, BaseShape shape, int level)
        {
            RectangleShape extentBoundingBox = SquaredExtent(extent);
            RectangleShape shapeBoundingBox = shape.GetBoundingBox();

            ulong location = 1;

            if (shapeBoundingBox.IsWithin(extentBoundingBox))
            {
                int currentlevel = 1;

                while (currentlevel < level)
                {
                    RectangleShape upperLeft = GetUpperLeftQuater(extentBoundingBox);
                    RectangleShape uppperRight = GetUpperRightQuater(extentBoundingBox);
                    RectangleShape lowerLeft = GetLowerLeftQuater(extentBoundingBox);
                    RectangleShape lowerRight = GetLowerRightQuater(extentBoundingBox);

                    if (shapeBoundingBox.IsWithin(upperLeft))
                    {
                        location = (location << 1) | 1;
                        currentlevel++;
                        extentBoundingBox = upperLeft;
                    }
                    else if (shapeBoundingBox.IsWithin(uppperRight))
                    {
                        location = (location << 2) | 1;
                        currentlevel++;
                        extentBoundingBox = uppperRight;
                    }
                    else if (shapeBoundingBox.IsWithin(lowerLeft))
                    {
                        location = (location << 3) | 1;
                        currentlevel++;
                        extentBoundingBox = lowerLeft;
                    }
                    else if (shapeBoundingBox.IsWithin(lowerRight))
                    {
                        location = (location << 4) | 1;
                        currentlevel++;
                        extentBoundingBox = lowerRight;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return location;
        }
Example #37
0
 public TileSquare(RectangleShape square, TileState state = TileState.Known)
 {
     Text   = null;
     Square = square;
     State  = state;
 }
Example #38
0
        public static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");

            //byte[] loadedCode = File.ReadAllBytes("pong.rom");
            byte[] loadedCode = File.ReadAllBytes("INVADERS");
            //byte[] loadedCode = File.ReadAllBytes("test_opcode.ch8");
            //byte[] loadedCode = File.ReadAllBytes("BC_test.ch8");
            chip8 = new Chip8(loadedCode);
            RenderWindow app = new RenderWindow(new VideoMode(800, 600), "chip8 emu");

            app.Closed += new EventHandler(OnClose);

            float          TILESIZEX = (float)app.Size.X / 64;
            float          TILESIZEY = (float)app.Size.Y / 32;
            RectangleShape shape     = new RectangleShape(new Vector2f(TILESIZEX, TILESIZEY));

            app.KeyPressed  += OnKeyPressed;
            app.KeyReleased += OnKeyReleased;

            Font font = new Font("Arial.ttf");
            Text text = new Text("", font);

            //app.KeyReleased +=
            // Start the game loop
            //app.SetFramerateLimit(60);
            //app.SetVerticalSyncEnabled(true);
            while (app.IsOpen)
            {
                chip8.Execute();
                // Process events
                app.DispatchEvents();

                //if (chip8.displayUpdated)
                {
                    // Clear screen
                    app.Clear();

                    for (int y = 0; y < 32; y++)
                    {
                        for (int x = 0; x < 64; x++)
                        {
                            shape.Position = new Vector2f(x * TILESIZEX, y * TILESIZEY);
                            if (chip8.display[x, y] == 1)
                            {
                                shape.FillColor = Color.Blue;
                            }
                            else
                            {
                                shape.FillColor = Color.Black;
                            }
                            app.Draw(shape);
                        }
                        //Console.WriteLine();
                    }

                    List <string> lines = chip8.GetCurrentLine();
                    for (int i = 0; i < lines.Count; i++)
                    {
                        text.DisplayedString = lines[i];
                        text.Position        = new Vector2f(0, i * 25);
                        app.Draw(text);
                    }

                    for (int i = 0; i < 16; i++)
                    {
                        text.DisplayedString = chip8.inputs[i] ? "1" : "0";
                        text.Position        = new Vector2f((i % 4) * 25 + 200, (i / 4) * 25);
                        app.Draw(text);
                    }
                    app.Display();
                    chip8.displayUpdated = false;
                }

                //for (int i = 0; i < 16; i++)
                //  chip8.inputs[i] = false;

                // Draw the sprite


                // Draw the string

                // Sleep to slow down emulation speed
            }
        }
Example #39
0
        static void Main(string[] args)
        {
            RectangleShape rect  = new RectangleShape(0, 0, 100, 100);
            RectangleShape rect1 = new RectangleShape(0, 0, 50, 50);
            RectangleShape rect2 = new RectangleShape(0, 0, 25, 25);

            Console.WriteLine($"rectangle created: {rect}");



            CircleShape circ = new OOPFinalProject.BL.CircleShape(0, 0, 80, 80);


            DrawingShapes drawingShapes1 = new DrawingShapes();



            drawingShapes1.AddToList(rect1);
            rect1 = new RectangleShape(10, 10, 666, 999);

            drawingShapes1.AddToList(rect1);

            drawingShapes1.AddToList(circ);
            circ = new CircleShape(333, 333, 1000, 1000);
            drawingShapes1.AddToList(circ);

            foreach (var rec in drawingShapes1.GetListofRectangles)
            {
                Console.WriteLine("Rectangle: " + rec.Height.ToString());
            }

            foreach (var rec in drawingShapes1.GetListofCircles)
            {
                Console.WriteLine("Circle: " + rec.Radius1.ToString());
            }



            Console.WriteLine("Number of Entities in DrawingShapes List of Rectangles =" + drawingShapes1.GetListofRectangles.Count);
            Console.WriteLine("Number of Entities in DrawingShapes List of Circles =" + drawingShapes1.GetListofCircles.Count);


            DataList dataList = new DataList(drawingShapes1);


            dataList.SerializeIt();

            dataList.listOfObjects = null;

            Console.WriteLine("lalalala");



            //Console.WriteLine("Antes do Deserialize >>> " + dataList.listOfObjects.ElementAt(0));

            dataList.DeserializeIt();

            foreach (var item in dataList.listOfObjects)
            {
                if (item is RectangleShape rec)
                {
                    Console.WriteLine($"This Rectangle Shape has Width =  {rec.Width}");
                }
                if (item is CircleShape cU)
                {
                    Console.WriteLine($"This Circle Shape has Radius =  {cU.Radius1}");
                }
            }

            rect2 = new RectangleShape(0, 0, 2222, 2222);

            drawingShapes1.AddToList(rect2);
            dataList = new DataList(drawingShapes1);

            dataList.SerializeIt();



            //Console.WriteLine("Depois do Deserialize >>> " + dataList.listOfObjects.ElementAt(0));

            //Console.WriteLine($"The Rectangle info is: {rect2.X}, {rect2.Y}, {rect2.Width}, {rect2.Height}");

            Console.ReadLine();
        }
Example #40
0
        /// <summary>
        /// Set up main menu
        /// </summary>
        private void SetupMenu()
        {
            uint screenSizeX = WinInstance.Size.X, screenSizeY = WinInstance.Size.Y;
            var  fillColor = new Color(128, 128, 128);
            var  font      = AssetManager.LoadFont("OrangeJuice");
            var  newGame   = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 6))
            };
            var newGameText = new Text()
            {
                Position = new Vector2f(newGame.Position.X + 21, newGame.Position.Y + 10), DisplayedString = AssetManager.GetMessage("NewGame"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var loadGame = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 4) - 40)
            };
            var loadGameText = new Text()
            {
                Position = new Vector2f(loadGame.Position.X + 14, loadGame.Position.Y + 10), DisplayedString = AssetManager.GetMessage("LoadGame"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var stats = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 2) - 80)
            };
            var statsText = new Text()
            {
                Position = new Vector2f(stats.Position.X + 80, stats.Position.Y + 10), DisplayedString = AssetManager.GetMessage("Stats"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var exit = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 1) - 40)
            };
            var exitText = new Text()
            {
                Position = new Vector2f(exit.Position.X + 100, exit.Position.Y + 10), DisplayedString = AssetManager.GetMessage("Exit"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var pointerSpite = AssetManager.LoadSprite("OldTimeyPointer");
            var renderWindow = WinInstance;

            Pointer = new MenuPointer(ref renderWindow, pointerSpite);
            var loadGameItem = new MenuItem(ref renderWindow, loadGameText, loadGame);
            var statsItem    = new MenuItem(ref renderWindow, statsText, stats);
            var newGameItem  = new MenuItem(ref renderWindow, newGameText, newGame);
            var exitItem     = new MenuItem(ref renderWindow, exitText, exit);

            newGameItem.AddAction(NewGameFunc);
            loadGameItem.AddAction(LoadGameFunc);
            statsItem.AddAction(DisplayStats);
            exitItem.AddAction(ExitGameFunc);
            MenuItems.Add(newGameItem);
            MenuItems.Add(loadGameItem);
            MenuItems.Add(statsItem);
            MenuItems.Add(exitItem);
            _originalMenuItems = new List <MenuItem> {
                newGameItem, loadGameItem, statsItem, exitItem
            };
            Pointer.SetPosition(new Vector2f((newGame.Position.X - Pointer.Size.X / 2f), newGame.Position.Y));
            Pointer.SetScale(new Vector2f(0.5f, 0.5f));
            var vector2F = Pointer.GetPosition();

            if (vector2F == null)
            {
                return;
            }
            _pointerPositions = new LinkedList <Vector2f>(new[]
            {
                vector2F.Value,
                new Vector2f((loadGame.Position.X - Pointer.Size.X / 2f), loadGame.Position.Y),
                new Vector2f((stats.Position.X - Pointer.Size.X / 2f), stats.Position.Y),
                new Vector2f((exit.Position.X - Pointer.Size.X / 2f), exit.Position.Y)
            });
            _originalPointerPos = new LinkedList <Vector2f>(new[]
            {
                vector2F.Value,
                new Vector2f((loadGame.Position.X - Pointer.Size.X / 2f), loadGame.Position.Y),
                new Vector2f((stats.Position.X - Pointer.Size.X / 2f), stats.Position.Y),
                new Vector2f((exit.Position.X - Pointer.Size.X / 2f), exit.Position.Y)
            });
        }
Example #41
0
 public MercedesShape(RectangleShape mercedes) : base(mercedes)
 {
 }
Example #42
0
        public void ShowMap()
        {
            if (!_window.IsOpen)
            {
                _context.Close = true;
            }

            _window.Clear();
            // Background Player 1
            _window.Draw(_background);

            // Load map
            foreach (KeyValuePair <SFML.System.Vector2f, Sprite> s in _spritesDisplayed)
            {
                s.Value.GetSprite.Position  = s.Key;
                s.Value.GetSprite.Position -= _moveTheMapOf;
                _window.Draw(s.Value.GetSprite);
            }
            foreach (KeyValuePair <SFML.System.Vector2f, Sprite> s in _spritesDisplayed2)
            {
                s.Value.GetSprite2.Position  = s.Key;
                s.Value.GetSprite2.Position -= _moveTheMapOf2;
                _window.Draw(s.Value.GetSprite2);
            }

            // Lifebar
            _hpBar.TextureRect = new IntRect(0, 0, (int)(_lifebarTexture.Size.X * _context.GetGame.GetPlayer.GetLife.PerCent), (int)_lifebarTexture.Size.Y);
            // HP Text
            _window.Draw(_hpBar);
            Text hp = new Text(Convert.ToString(_context.GetGame.GetPlayer.GetLife.CurrentPoint), _context.GetFont, 28);

            hp.Position = new SFML.System.Vector2f(_lifebarTexture.Size.X / 2 - hp.GetGlobalBounds().Width / 2, _lifebarTexture.Size.Y / 2 - hp.GetGlobalBounds().Height / 2 - 5);
            _window.Draw(hp);


            // Player
            if (_context.GetGame.GetPlayer.IsAlive)
            {
                //_context.GetGame.GetPlayer.GetPlayerSprite.GetSprite.Position = new SFML.System.Vector2f((_context.GetGame.GetPlayer.Position.X + 0.5f) * 128, _window.Size.Y + _context.GetGame.GetPlayer.Position.Y * -128 - 65);
                _context.GetGame.GetPlayer.GetPlayerSprite.GetSprite.Position  = new SFML.System.Vector2f((_context.GetGame.GetPlayer.RealPosition.X) * 128, _window.Size.Y + _context.GetGame.GetPlayer.Position.Y * -128 - 65);
                _context.GetGame.GetPlayer.GetPlayerSprite.GetSprite.Position -= _moveTheMapOf;
                _window.Draw(_context.GetGame.GetPlayer.GetPlayerSprite.GetSprite);
            }

            // Monsters
            foreach (Monster m in _context.GetGame.GetMonsters)
            {
                //Orientation
                if (m.Orientation == "right" && m.GetMonsterSprite.GetSprite.Scale != new SFML.System.Vector2f(1.0f, 1.0f)) //Right
                {
                    m.GetMonsterSprite.GetSprite.Origin = new SFML.System.Vector2f(0, 0);
                    m.GetMonsterSprite.GetSprite.Scale  = new SFML.System.Vector2f(1.0f, 1.0f);
                }
                else if (m.Orientation == "left" && m.GetMonsterSprite.GetSprite.Scale != new SFML.System.Vector2f(-1.0f, 1.0f))//Left
                {
                    m.GetMonsterSprite.GetSprite.Origin = new SFML.System.Vector2f(m.GetMonsterSprite.GetSprite.Texture.Size.X / 2, 0);
                    m.GetMonsterSprite.GetSprite.Scale  = new SFML.System.Vector2f(-1.0f, 1.0f);
                }

                m.GetMonsterSprite.GetSprite.Position  = new SFML.System.Vector2f(m.Position.X * 128, _window.Size.Y + m.Position.Y * -128 - 40);
                m.GetMonsterSprite.GetSprite.Position -= _moveTheMapOf;

                _window.Draw(m.GetMonsterSprite.GetSprite);
            }

            // Boss
            if (_context.GetGame.GetBoss != null)
            {
                _context.GetGame.GetBoss.GetBossSprite.GetSprite.Position  = new SFML.System.Vector2f(_context.GetGame.GetBoss.Position.X * 128 - 150, _window.Size.Y + _context.GetGame.GetBoss.Position.Y * -128 - 205);
                _context.GetGame.GetBoss.GetBossSprite.GetSprite.Position -= _moveTheMapOf;
                _window.Draw(_context.GetGame.GetBoss.GetBossSprite.GetSprite);
            }

            // Show degats
            for (int i = 0; i < _context.GetGame.GetPlayer.DegatsToShow.Count; i++)
            {
                if (_context.GetGame.GetPlayer.DegatsToShow[i] != 0)
                {
                    if (_spDegats.Count == i)
                    {
                        _spDegats.Add(new Stopwatch());
                        _spDegats[i].Start();
                    }
                    else if (_spDegats.Count > i)
                    {
                        if (_spDegats[i].ElapsedMilliseconds >= 1500)
                        {
                            // Delete
                            _context.GetGame.GetPlayer.DegatsToShow.RemoveAt(i);
                            _spDegats.RemoveAt(i);
                        }
                        else
                        {
                            Text t = new Text(Convert.ToString(_context.GetGame.GetPlayer.DegatsToShow[i]), _context.GetFont, 48);

                            if (_context.GetGame.GetPlayer.DegatsToShow[i] > 0) // Attack
                            {
                                t.FillColor = Color.Blue;
                                t.Position  = new Vector2f(_context.GetGame.GetPlayer.GetPlayerSprite.GetSprite.Position.X + 128, _context.GetGame.GetPlayer.GetPlayerSprite.GetSprite.Position.Y - _spDegats[i].ElapsedMilliseconds / 10);
                            }
                            else // Hurt
                            {
                                t.FillColor = Color.Red;
                                t.Position  = new Vector2f(_context.GetGame.GetPlayer.GetPlayerSprite.GetSprite.Position.X + 20, _context.GetGame.GetPlayer.GetPlayerSprite.GetSprite.Position.Y - _spDegats[i].ElapsedMilliseconds / 10);
                            }

                            RectangleShape r = new RectangleShape(new Vector2f(t.GetGlobalBounds().Width + 15, t.GetGlobalBounds().Height + 15));
                            r.FillColor = new Color(0, 0, 0, 128);
                            r.Position  = new Vector2f(t.Position.X - 5, t.Position.Y - 5);
                            _window.Draw(r);
                            _window.Draw(t);
                        }
                    }
                }
            }


            // Display
            _window.Display();
        }
Example #43
0
 public Cell(Cell cell)
 {
     State = cell.State;
     _cell = cell._cell;
 }
Example #44
0
 public static void InsertRectangle(RectangleShape shape)
 {
 }
Example #45
0
        /// <summary>
        /// Display the possible characters to choose from
        /// </summary>
        private void DisplayCharacters()
        {
            var screenSize = WinInstance.Size;

            _charMenuItems = new List <MenuItem>();
            var names = new[]
            {
                AssetManager.GetMessage("Mack"), AssetManager.GetMessage("Sergei"),
                AssetManager.GetMessage("Trent"), AssetManager.GetMessage("Jaun")
            };
            var font = AssetManager.LoadFont("OrangeJuice");

            for (var i = 0; i < 5; i++)
            {
                Shape shape;
                Text  text;
                if (i <= 3)
                {
                    if (i == 0)
                    {
                        shape = new CircleShape(64.0f)
                        {
                            OutlineThickness = 2,
                            FillColor        = Color.Transparent,
                            Position         = new Vector2f(((float)screenSize.X / 4) + 50, ((float)screenSize.Y / 16))
                        }
                    }
                    ;
                    else
                    {
                        shape = new CircleShape(64.0f)
                        {
                            OutlineThickness = 3,
                            FillColor        = Color.Transparent,
                            Position         = new Vector2f(((float)screenSize.X / 4) + 50, ((float)screenSize.Y / 16) + (i * 128) + (i * 32))
                        }
                    };
                    text = new Text(names[i], font)
                    {
                        CharacterSize = 60,
                        Color         = Color.Black,
                        Position      = new Vector2f(shape.Position.X + 200, shape.Position.Y + 32)
                    };
                }
                else
                {
                    shape = new RectangleShape(new Vector2f(ButtonX, ButtonY))
                    {
                        FillColor = new Color(128, 128, 128),
                        Position  = new Vector2f(screenSize.X / 1.5f + 50, ((float)screenSize.Y / 12) + (i * 128) + 20)
                    };
                    text = new Text(AssetManager.GetMessage("Back"), font)
                    {
                        Color         = Color.Black,
                        CharacterSize = 60,
                        Position      = new Vector2f(shape.Position.X + 90, shape.Position.Y + 15)
                    };
                }
                var renderWindow = WinInstance;
                _charMenuItems.Add(new MenuItem(ref renderWindow, text, shape, DisplayCharMenuItemFunc));
            }
            _displayChars = true;
            var newPos = new LinkedList <Vector2f>();

            foreach (var t in _charMenuItems)
            {
                var pos = t.Position;
                newPos.AddLast(new Vector2f((pos.X - Pointer.Size.X / 2f), pos.Y));
            }
            var scale = new Vector2f(2.5f, 2.5f);

            try
            {
                var mack = AssetManager.LoadSprite("MackStill");
                mack.Scale    = scale;
                mack.Position = new Vector2f(_charMenuItems[0].Position.X + 24, _charMenuItems[0].Position.Y + 24);
                var sergei = AssetManager.LoadSprite("SergeiStill");
                sergei.Scale    = scale;
                sergei.Position = new Vector2f(_charMenuItems[1].Position.X + 24, _charMenuItems[1].Position.Y + 24);
                var lou = AssetManager.LoadSprite("TrentStill");
                lou.Scale    = scale;
                lou.Position = new Vector2f(_charMenuItems[2].Position.X + 24, _charMenuItems[2].Position.Y + 24);
                var rob = AssetManager.LoadSprite("JaunStill");
                rob.Scale        = scale;
                rob.Position     = new Vector2f(_charMenuItems[3].Position.X + 24, _charMenuItems[3].Position.Y + 24);
                _characterStills = new List <Sprite>(new[] {
                    mack, sergei, lou, rob
                });
            }
            catch (NullReferenceException)
            {
                LogManager.LogError("Could not load character stills.");
            }
            _pointerPositions = newPos;
            Pointer.Move(_pointerPositions.First.Value);
            _currentNode = _pointerPositions.First;
            _itemIndex   = 0;
        }
Example #46
0
 public static void UpdateRectangle(RectangleShape shape)
 {
 }
 public DataTable GetDataTableInCurrentExtent(RectangleShape currentExtent)
 {
     InitializeSelectedFeatures();
     return(GetDataTableInCurrentExtentCore(currentExtent));
 }
Example #48
0
 public static void DeleteRectangle(RectangleShape shape)
 {
 }
 public EllipseShape(RectangleShape rectangle)
     : base(rectangle)
 {
 }
Example #50
0
        private static Dictionary<int, Collection<QuadCell>> GetCells(ulong location, RectangleShape boudingBox, Dictionary<int, Collection<QuadCell>> currentLevelCellsSet, int currentLevel, int endLevel)
        {
            QuadCell newQTreeCell = new QuadCell(location, boudingBox);
            if (!currentLevelCellsSet.Keys.Contains(currentLevel))
            {
                Collection<QuadCell> qTreeCells = new Collection<QuadCell> { newQTreeCell };
                currentLevelCellsSet.Add(currentLevel, qTreeCells);
            }
            else
            {
                currentLevelCellsSet[currentLevel].Add(newQTreeCell);
            }
            if (currentLevel < endLevel)
            {
                currentLevel++;
                GetCells((location << 1) | 1, GetUpperLeftQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
                GetCells((location << 2) | 1, GetUpperRightQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
                GetCells((location << 3) | 1, GetLowerLeftQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
                GetCells((location << 4) | 1, GetLowerRightQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
            }

            return currentLevelCellsSet;
        }
Example #51
0
 public static int GetLevelByCellWidth(RectangleShape extent, double cellWidth)
 {
     return GetLevelByCellWidth(extent, GeographyUnit.Meter, cellWidth, DistanceUnit.Meter);
 }
Example #52
0
 //public static string GetLocation(RectangleShape extent, BaseShape shape, int level)
 //{
 //    RectangleShape extentBoundingBox = SquaredExtent(extent);
 //    RectangleShape shapeBoundingBox = shape.GetBoundingBox();
 //    string location = string.Empty;
 //    if (shapeBoundingBox.IsWithin(extentBoundingBox))
 //    {
 //        location += "0";
 //        int currentlevel = 1;
 //        while (currentlevel < level)
 //        {
 //            RectangleShape upperLeft = GetUpperLeftQuater(extentBoundingBox);
 //            RectangleShape uppperRight = GetUpperRightQuater(extentBoundingBox);
 //            RectangleShape lowerLeft = GetLowerLeftQuater(extentBoundingBox);
 //            RectangleShape lowerRight = GetLowerRightQuater(extentBoundingBox);
 //            if (shapeBoundingBox.IsWithin(upperLeft))
 //            {
 //                location += "1";
 //                currentlevel++;
 //                extentBoundingBox = upperLeft;
 //            }
 //            else if (shapeBoundingBox.IsWithin(uppperRight))
 //            {
 //                location += "2";
 //                currentlevel++;
 //                extentBoundingBox = uppperRight;
 //            }
 //            else if (shapeBoundingBox.IsWithin(lowerLeft))
 //            {
 //                location += "3";
 //                currentlevel++;
 //                extentBoundingBox = lowerLeft;
 //            }
 //            else if (shapeBoundingBox.IsWithin(lowerRight))
 //            {
 //                location += "4";
 //                currentlevel++;
 //                extentBoundingBox = lowerRight;
 //            }
 //            else
 //            {
 //                break;
 //            }
 //        }
 //    }
 //    return location;
 //}
 public static int GetAppropriateLevel(RectangleShape extent, Feature feature)
 {
     return GetAppropriateLevel(extent, feature.GetShape());
 }
Example #53
0
 public static ulong GetLocation(RectangleShape extent, Feature feature, int level)
 {
     return GetLocation(extent, feature.GetShape(), level);
 }
Example #54
0
        protected override Collection <string> GetFeatureIdsIntersectingBoundingBoxCore(RectangleShape boundingBox)
        {
            int level = QTreeHelper.GetAppropriateLevel(maxExtent, boundingBox);

            Collection <QuadTreeNode> intersectedNodes = GetIntersectedCells(boundingBox, level + 1);

            Collection <string> featureIds = new Collection <string>();

            foreach (QuadTreeNode node in intersectedNodes)
            {
                featureIds.Add(node.Id);
            }

            return(featureIds);
        }
Example #55
0
 public static RectangleShape GetUpperRightQuater(RectangleShape boundingBox)
 {
     PointShape uppperLeft = new PointShape((boundingBox.UpperLeftPoint.X + boundingBox.UpperRightPoint.X) / 2, boundingBox.UpperLeftPoint.Y);
     PointShape lowerRight = new PointShape(boundingBox.UpperRightPoint.X, (boundingBox.UpperRightPoint.Y + boundingBox.LowerRightPoint.Y) / 2);
     return new RectangleShape(uppperLeft, lowerRight);
 }
        //internal static void ActiveMap_MapClick(object sender, MapClickWpfMapEventArgs e)
        internal static void ActiveMap_MapClick(object sender, MapMouseClickInteractiveOverlayEventArgs e)
        {
            if (ViewModel.IsInModifyMode)
            {
                ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.Open();
                RectangleShape clickBuffer = GetClickBuffer(e.InteractionArguments.WorldX, e.InteractionArguments.WorldY);

                #region save feature ids to exclude temporary.

                var tmpFeatureIdsToExclude = new Collection <string>();
                foreach (var id in ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude)
                {
                    tmpFeatureIdsToExclude.Add(id);
                }
                ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Clear();

                #endregion save feature ids to exclude temporary.

                var foundFeature = ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.QueryTools
                                   .GetFeaturesIntersecting(clickBuffer, ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.GetDistinctColumnNames()).FirstOrDefault(tmpFeature => !tmpFeatureIdsToExclude.Contains(tmpFeature.Id));

                if (foundFeature == default(Feature))
                {
                    PlatformGeoCanvas geoCanvas = new PlatformGeoCanvas();
                    foundFeature = ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.InternalFeatures
                                   .Where(tmpFeature => tmpFeature.ColumnValues.ContainsKey(AnnotationTrackInteractiveOverlay.AnnotationTextColumnName) &&
                                          !String.IsNullOrEmpty(tmpFeature.ColumnValues[AnnotationTrackInteractiveOverlay.AnnotationTextColumnName]))
                                   .FirstOrDefault(textFeature =>
                    {
                        if (tmpFeatureIdsToExclude.Contains(textFeature.Id))
                        {
                            return(false);
                        }

                        TextStyle textStyle = ViewModel.CurrentAnnotationOverlay
                                              .GetSpecificTextStyle(textFeature.ColumnValues[AnnotationTrackInteractiveOverlay.ValueStyleMatchColumnName]);

                        DrawingRectangleF textArea = geoCanvas.MeasureText(textFeature.ColumnValues[AnnotationTrackInteractiveOverlay.AnnotationTextColumnName]
                                                                           , textStyle.Font);

                        PointShape textScreenPoint = GisEditor.ActiveMap.ToScreenCoordinate((PointShape)textFeature.GetShape());

                        double left   = textScreenPoint.X;
                        double top    = textScreenPoint.Y;
                        double right  = textScreenPoint.X + textArea.Width;
                        double bottom = textScreenPoint.Y + textArea.Height;

                        string placementString = textStyle.PointPlacement.ToString();
                        if (placementString.Contains("Left"))
                        {
                            left = textScreenPoint.X - textArea.Width;
                        }

                        if (placementString.Contains("Upper"))
                        {
                            top = textScreenPoint.Y - textArea.Height;
                        }

                        PointShape upperLeft  = GisEditor.ActiveMap.ToWorldCoordinate(new PointShape(left, top));
                        PointShape lowerRight = GisEditor.ActiveMap.ToWorldCoordinate(new PointShape(right, bottom));

                        RectangleShape textWorldArea = new RectangleShape(upperLeft, lowerRight);
                        return(textWorldArea.Intersects(new PointShape(e.InteractionArguments.WorldX, e.InteractionArguments.WorldY)));
                    });
                }

                #region restore feature ids to exclude

                foreach (var id in tmpFeatureIdsToExclude)
                {
                    ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Add(id);
                }

                #endregion restore feature ids to exclude

                ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.Close();

                if (foundFeature != default(Feature))
                {
                    var isShiftDown = Keyboard.Modifiers == ModifierKeys.Shift;
                    if (!isShiftDown)
                    {
                        CommitEdit(false);
                    }

                    bool isEditing = true;
                    if (!ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Contains(foundFeature.Id))
                    {
                        ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Add(foundFeature.Id);
                    }
                    else
                    {
                        isEditing = false;
                        if (isShiftDown)
                        {
                            ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Remove(foundFeature.Id);
                            if (ViewModel.CurrentEditOverlay.EditShapesLayer.InternalFeatures.Contains(foundFeature.Id))
                            {
                                ViewModel.CurrentEditOverlay.EditShapesLayer.InternalFeatures.Remove(foundFeature.Id);
                            }
                        }
                    }

                    if (isEditing)
                    {
                        SetAnnotationToEditMode(foundFeature);
                    }

                    ViewModel.CurrentEditOverlay.CalculateAllControlPoints();
                    ViewModel.CurrentAnnotationOverlay.Refresh();
                    ViewModel.CurrentEditOverlay.Refresh();
                    ViewModel.SyncUIState();
                    ViewModel.TakeSnapshot();
                }
                else
                {
                    if (ViewModel.CurrentEditOverlay.EditShapesLayer.InternalFeatures.Count > 0 ||
                        (MarkerHelper.CurrentMarkerOverlay != null && MarkerHelper.CurrentMarkerOverlay.Markers.Count > 0))
                    {
                        System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => CommitEdit()));
                    }
                }
            }
        }
Example #57
0
        private static RectangleShape SquaredExtent(RectangleShape extent)
        {
            PointShape center = extent.GetCenterPoint();

            double extentWidth = extent.LowerRightPoint.X - extent.LowerLeftPoint.X;
            double extentHeight = extent.UpperLeftPoint.Y - extent.LowerLeftPoint.Y;

            double halfEdgeLength = (extentWidth > extentHeight) ? extentWidth / 2 : extentHeight / 2;

            PointShape upperLeft = new PointShape(center.X - halfEdgeLength, center.Y + halfEdgeLength);
            PointShape lowerRight = new PointShape(center.X + halfEdgeLength, center.Y - halfEdgeLength);

            return new RectangleShape(upperLeft, lowerRight);
        }
        private void Refresh()
        {
            Dictionary <string, object> information = new Dictionary <string, object>();

            targetFeatureLayer.SafeProcess(() =>
            {
                string fileName = targetFeatureLayer.ShapePathFilename.Replace('/', '\\');
                information.Add("File Name", fileName);
                information.Add("File Size", string.Format("{0} bytes", new FileInfo(targetFeatureLayer.ShapePathFilename).Length));

                string indexPathFileName = targetFeatureLayer.IndexPathFilename.Replace('/', '\\');
                information.Add("Index File", indexPathFileName);
                information.Add("ShapeFile Type", targetFeatureLayer.GetShapeFileType().ToString());
                information.Add("Layer Name", targetFeatureLayer.Name);
                information.Add("Columns Count", targetFeatureLayer.QueryTools.GetColumns().Count.ToString());
                information.Add("Rows Count", targetFeatureLayer.GetRecordCount().ToString());


                if (targetFeatureLayer.HasBoundingBox)
                {
                    RectangleShape boundingBox = targetFeatureLayer.GetBoundingBox();
                    information.Add("Upper Left X:", boundingBox.UpperLeftPoint.X.ToString("N4"));
                    information.Add("Upper Left Y:", boundingBox.UpperLeftPoint.Y.ToString("N4"));
                    information.Add("Lower Right X:", boundingBox.LowerRightPoint.X.ToString("N4"));
                    information.Add("Lower Right Y:", boundingBox.LowerRightPoint.Y.ToString("N4"));
                }
                else
                {
                    information.Add("Upper Left X:", double.NaN.ToString());
                    information.Add("Upper Left Y:", double.NaN.ToString());
                    information.Add("Lower Right X:", double.NaN.ToString());
                    information.Add("Lower Right Y:", double.NaN.ToString());
                }

                if (!targetFeatureLayer.Name.Equals("TempLayer"))
                {
                    information.Add("Encoding", GetAllEncodings());
                    selectedEncoding = targetFeatureLayer.Encoding;
                    targetFeatureLayer.SafeProcess(() =>
                    {
                        columns.Add(PleaseSelectText, PleaseSelectText);
                        foreach (var item in targetFeatureLayer.FeatureSource.GetColumns())
                        {
                            columns.Add(item.ColumnName, targetFeatureLayer.FeatureSource.GetColumnAlias(item.ColumnName));
                        }

                        information.Add("Feature ID Column", columns);
                        if (string.IsNullOrEmpty(FeatureIDColumn) && columns.Count > 0)
                        {
                            FeatureIDColumnAlias = columns.FirstOrDefault();
                        }

                        if (!string.IsNullOrEmpty(FeatureIDColumn) && columns.Count > 0)
                        {
                            FeatureIDColumnAlias = columns.FirstOrDefault(c => c.Key == FeatureIDColumn);
                        }
                    });
                }
            });

            LayerInformation = information;
        }
Example #59
0
 public abstract void DrawRectangle(object dc, RectangleShape rectangle, ShapeStyle style, double dx, double dy);
Example #60
0
 public QTreeSpatialIndex(RectangleShape maxExtent)
 {
     this.qtree     = new Dictionary <ulong, QuadTreeNode>();
     this.maxExtent = maxExtent;
     this.maxLevel  = 0;
 }