Exemple #1
0
        private void RectangleSheetAction(TNode node, SheetActionType actionType)
        {
            var blockViewLevel = NextTileLevel;

            var rect = new ScreenRectangle(node.Rectangle, blockViewLevel).BlockView;

            var deltaX = (rect.Left <= rect.Right) ? 1 : -1;
            var deltaY = (rect.Top <= rect.Bottom) ? 1 : -1;

            //rectangle search in daughter sheet
            for (var x = rect.Left; (deltaX == 1 && x <= rect.Right) || (deltaX == -1 && x >= rect.Right); x += deltaX)
            {
                for (var y = rect.Top; (deltaY == 1 && y <= rect.Bottom) || (deltaY == -1 && y >= rect.Bottom); y += deltaY)
                {
                    var block = new TileBlock(x, y, blockViewLevel);
                    lock (this)
                    {
                        var sheet = Sheets[block];

                        sheet.SheetAction(node, actionType);

                        PostSheetAction(block, sheet, actionType);
                    }
                }
            }
        }
Exemple #2
0
        private void LineSheetAction(TNode node, SheetActionType actionType)
        {
            var blockViewLevel = NextTileLevel;

            var line = node.Rectangle;
            var rect = new ScreenRectangle(line, blockViewLevel).BlockView;

            var deltaX = (rect.Left <= rect.Right) ? 1 : -1;
            var deltaY = (rect.Top <= rect.Bottom) ? 1 : -1;

            //line search in daughter sheet
            for (var x = rect.Left; (deltaX == 1 && x <= rect.Right) || (deltaX == -1 && x >= rect.Right); x += deltaX)
            {
                for (var y = rect.Top; (deltaY == 1 && y <= rect.Bottom) || (deltaY == -1 && y >= rect.Bottom); y += deltaY)
                {
                    var block    = new TileBlock(x, y, blockViewLevel);
                    var TileRect = (ScreenRectangle)block;

                    if (TileRect.LineContains(line) != IntersectResult.None)
                    {
                        lock (this)
                        {
                            var sheet = Sheets[block];

                            sheet.SheetAction(node, actionType);

                            PostSheetAction(block, sheet, actionType);
                        }
                    }
                }
            }
        }
Exemple #3
0
        private bool DrawImages(Rectangle localBlockView, ScreenRectangle localScreenView)
        {
            for (var x = localBlockView.Left; x <= localBlockView.Right; x++)
            {
                for (var y = localBlockView.Top; y <= localBlockView.Bottom; y++)
                {
                    var block = new TileBlock(x, y, Level);
                    var pt    = ((ScreenCoordinate)block).GetScreenPoint(localScreenView);

                    var bmp = FindImage(block);
                    if (bmp != null)
                    {
                        DrawBitmap(bmp, pt);
                    }
                    else
                    {
                        DrawBitmap(_emptyBlock, pt);
                        PutMapThreadEvent(WorkerEventType.DownloadImage, block, EventPriorityType.Idle);
                    }

                    if (Terminating)
                    {
                        return(true);
                    }

                    if (localScreenView.CompareTo(ScreenView) != 0)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Draw(GameTime gameTime)
        {
            if (Rectangle.Intersect(ScreenRectangle.ToRectangle(), Container.ScreenRectangle.ToRectangle()).IsEmpty)
            {
                return;
            }

            base.Draw(gameTime);
        }
    public static void Main()
    {
        ScreenRectangle r =
            new ScreenRectangle(2, 2, 20, 5);

        r.Draw();

        Console.WriteLine();
        Console.WriteLine();

        Console.WriteLine(r.GetSize());
    }
Exemple #6
0
    public static void Main()
    {
        ScreenRectangle r1 = new ScreenRectangle(1, 1, 4, 2);

        r1.Draw();
        Console.SetCursorPosition(1, 3);
        Console.WriteLine("Size = " + r1.GetSize());


        ScreenRectangle r2 = new ScreenRectangle(10, 4, 20, 8);

        r2.Draw();
        Console.SetCursorPosition(1, 9);
        Console.WriteLine("Size = " + r2.GetSize());
    }
Exemple #7
0
        /// <summary>
        /// Add or update screen rectangle for the view.
        /// </summary>
        private void AddOrUpdateViewRectangle()
        {
            if (Rectangles == null)
            {
                return;
            }
            var screenRectangle = Rectangles.FirstOrDefault(item => ScreenNames.View.Equals(item.Name));

            if (screenRectangle == null)
            {
                screenRectangle = new ScreenRectangle(ScreenNames.View, ViewWidth, ViewHeight);
                Rectangles.Add(screenRectangle);
            }
            else
            {
                screenRectangle.SetSize(ViewWidth, ViewHeight);
            }
        }
Exemple #8
0
        private void RedrawCables(ScreenRectangle localScreenView)
        {
            try
            {
                _lockCr.EnterReadLock();

                if (_rCableTree.NodeCount == 0)
                {
                    return;
                }

                var res = _rCableTree.Query(localScreenView);
                foreach (var node in res)
                {
                    var row = (MapDb.CablesRow)node.Row;

                    var cabRect = new CoordinateRectangle(row.Longitude1, row.Latitude1, row.Longitude2, row.Latitude2);
                    var rect    = cabRect.GetScreenRect(localScreenView);

                    DrawLine(rect, 2, Color.Blue);

                    if (Level >= 14)
                    {
                        var caption = row.Caption;
                        if (!String.IsNullOrEmpty(caption))
                        {
                            var coordinate = cabRect.LineMiddlePoint;
                            var point      = coordinate.GetScreenPoint(localScreenView);
                            DrawString(caption, HalfVertexSize.Height, Point.Add(point, HalfVertexSize));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //do nothing
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                _lockCr.ExitReadLock();
            }
        }
Exemple #9
0
        private void RedrawVertexes(ScreenRectangle localScreenView)
        {
            try
            {
                _lockVr.EnterReadLock();
                if (_rVertexTree.NodeCount == 0)
                {
                    return;
                }

                var res = _rVertexTree.Query(localScreenView);

                foreach (var node in res)
                {
                    var row = (MapDb.VertexesRow)node.Row;

                    var coordinate = new GeomCoordinate(row.Longitude, row.Latitude);
                    var pt         = coordinate.GetScreenPoint(localScreenView);

                    DrawBitmap(Vertex, Point.Subtract(pt, HalfVertexSize));

                    if (Level >= 14)
                    {
                        var caption = row.Caption;
                        if (!String.IsNullOrEmpty(caption))
                        {
                            DrawString(caption, HalfVertexSize.Height, Point.Add(pt, HalfVertexSize));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //do nothing
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                _lockVr.ExitReadLock();
            }
        }
        public RaysAndBoundingRectangleElementHighlighter(AutomationElementTreeControl treeControl) : base(treeControl)
        {
            _topLeftVerticalRay       = new ScreenRectangle();
            _topLeftHorizontalRay     = new ScreenRectangle();
            _topRightVerticalRay      = new ScreenRectangle();
            _topRightHorizontalRay    = new ScreenRectangle();
            _bottomLeftVerticalRay    = new ScreenRectangle();
            _bottomLeftHorizontalRay  = new ScreenRectangle();
            _bottomRightVerticalRay   = new ScreenRectangle();
            _bottomRightHorizontalRay = new ScreenRectangle();

            this._rays = new ScreenRectangle[] { _topLeftVerticalRay, _topLeftHorizontalRay,
                                                 _topRightVerticalRay, _topRightHorizontalRay,
                                                 _bottomLeftVerticalRay, _bottomLeftHorizontalRay,
                                                 _bottomRightVerticalRay, _bottomRightHorizontalRay };

            double boundingRectOpacity = base._rectangle.Opacity;

            foreach (ScreenRectangle ray in this._rays)
            {
                ray.Color   = Drawing.Color.Blue;
                ray.Opacity = boundingRectOpacity;
            }
        }
 /// <summary>
 ///     Determines if the HitObject is hovered.
 /// </summary>
 /// <param name="mousePos"></param>
 /// <returns></returns>
 public virtual bool IsHovered(Vector2 mousePos) => ScreenRectangle.Contains(mousePos);
Exemple #12
0
 public Rectangle GetScreenRect(ScreenRectangle screenView)
 {
     return(new ScreenRectangle(this, screenView.Level).GetScreenRect(screenView));
 }
Exemple #13
0
 public static GeomCoordinate GetCoordinateFromScreen(ScreenRectangle screenView, Point point)
 {
     return(screenView.LeftTop + new ScreenCoordinate(point.X, point.Y, screenView.Level));
 }
Exemple #14
0
 public Point GetScreenPoint(ScreenRectangle screenView)
 {
     return(new ScreenCoordinate(this, screenView.Level).GetScreenPoint(screenView));
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="direction"></param>
        private void HandlePoolShifting(Direction direction)
        {
            if (CurrentMapset == null)
            {
                return;
            }

            switch (direction)
            {
            case Direction.Forward:
                // If there are no available maps then there's no need to do anything.
                if (CurrentMapset.Maps.ElementAtOrDefault(PoolStartingIndex) == null ||
                    CurrentMapset.Maps.ElementAtOrDefault(PoolStartingIndex + MAX_BUFFER_SIZE) == null)
                {
                    return;
                }

                var firstDifficulty = DifficultyBuffer.First();

                // Check if the object is in the rect of the ScrollContainer.
                // If it is, then there's no updating that needs to happen.
                if (!Rectangle.Intersect(firstDifficulty.ScreenRectangle.ToRectangle(), ScreenRectangle.ToRectangle()).IsEmpty)
                {
                    return;
                }

                // Update the mapset's information and y position.
                firstDifficulty.Y = (PoolStartingIndex + MAX_BUFFER_SIZE) * DrawableDifficulty.HEIGHT +
                                    (PoolStartingIndex + MAX_BUFFER_SIZE) * YSpacing + YSpaceBeforeFirstDifficulty;

                lock (CurrentMapset.Maps)
                {
                    firstDifficulty.UpdateWithNewMap(CurrentMapset.Maps[PoolStartingIndex + MAX_BUFFER_SIZE]);
                }

                // Circuluarly Shift the list forward one.
                DifficultyBuffer.Remove(firstDifficulty);
                DifficultyBuffer.Add(firstDifficulty);

                // Make sure the set is corrected selected/deselected
                if (PoolStartingIndex + MAX_BUFFER_SIZE == SelectedMapIndex)
                {
                    firstDifficulty.DisplayAsSelected();
                }
                else
                {
                    firstDifficulty.DisplayAsDeselected();
                }

                PoolStartingIndex++;
                break;

            case Direction.Backward:
                // If there are no previous available map then there's no need to shift.
                if (CurrentMapset.Maps.ElementAtOrDefault(PoolStartingIndex - 1) == null)
                {
                    return;
                }

                var lastDifficulty = DifficultyBuffer.Last();

                // Check if the object is in the rect of the ScrollContainer.
                // If it is, then there's no updating that needs to happen.
                if (!Rectangle.Intersect(lastDifficulty.ScreenRectangle.ToRectangle(), ScreenRectangle.ToRectangle()).IsEmpty)
                {
                    return;
                }

                lastDifficulty.Y = (PoolStartingIndex - 1) * DrawableDifficulty.HEIGHT + (PoolStartingIndex - 1)
                                   * YSpacing + YSpaceBeforeFirstDifficulty;

                lock (CurrentMapset.Maps)
                {
                    lastDifficulty.UpdateWithNewMap(CurrentMapset.Maps[PoolStartingIndex - 1]);
                }

                DifficultyBuffer.Remove(lastDifficulty);
                DifficultyBuffer.Insert(0, lastDifficulty);

                // Make sure the set is correctly selected/deselected.
                if (PoolStartingIndex - 1 == SelectedMapIndex)
                {
                    lastDifficulty.DisplayAsSelected();
                }
                else
                {
                    lastDifficulty.DisplayAsDeselected();
                }

                PoolStartingIndex--;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
            }
        }
    static void Main()
    {
        ScreenRectangle r = new ScreenRectangle(3, 7, 2, 6);

        r.Draw();
    }
Exemple #17
0
        /// <summary>
        ///     Handles shifting of the pool when scrolling.
        /// </summary>
        /// <param name="direction"></param>
        private void HandlePoolShifting(Direction direction)
        {
            switch (direction)
            {
            case Direction.Forward:
                // If there are no available mapsets then there's no need to do anything.
                if (Screen.AvailableMapsets.ElementAtOrDefault(PoolStartingIndex) == null ||
                    Screen.AvailableMapsets.ElementAtOrDefault(PoolStartingIndex + MAX_MAPSETS_SHOWN) == null)
                {
                    return;
                }

                var firstMapset = MapsetBuffer.First();

                // Check if the object is in the rect of the ScrollContainer.
                // If it is, then there's no updating that needs to happen.
                if (!Rectangle.Intersect(firstMapset.ScreenRectangle.ToRectangle(), ScreenRectangle.ToRectangle()).IsEmpty)
                {
                    return;
                }

                // Update the mapset's information and y position.
                firstMapset.Y = (PoolStartingIndex + MAX_MAPSETS_SHOWN) * DrawableMapset.HEIGHT +
                                (PoolStartingIndex + MAX_MAPSETS_SHOWN) * YSpacing + YSpaceBeforeFirstSet;

                lock (Screen.AvailableMapsets)
                    firstMapset.UpdateWithNewMapset(Screen.AvailableMapsets[PoolStartingIndex + MAX_MAPSETS_SHOWN],
                                                    PoolStartingIndex + MAX_MAPSETS_SHOWN);

                // Circuluarly Shift the list forward one.
                MapsetBuffer.Remove(firstMapset);
                MapsetBuffer.Add(firstMapset);

                // Make sure the set is corrected selected/deselected
                if (PoolStartingIndex + MAX_MAPSETS_SHOWN == SelectedMapsetIndex)
                {
                    firstMapset.DisplayAsSelected(MapManager.Selected.Value);
                }
                else
                {
                    firstMapset.DisplayAsDeselected();
                }

                PoolStartingIndex++;
                break;

            case Direction.Backward:
                // If there are no previous available user then there's no need to shift.
                if (Screen.AvailableMapsets.ElementAtOrDefault(PoolStartingIndex - 1) == null)
                {
                    return;
                }

                var lastMapset = MapsetBuffer.Last();

                // Check if the object is in the rect of the ScrollContainer.
                // If it is, then there's no updating that needs to happen.
                if (!Rectangle.Intersect(lastMapset.ScreenRectangle.ToRectangle(), ScreenRectangle.ToRectangle()).IsEmpty)
                {
                    return;
                }

                lastMapset.Y = (PoolStartingIndex - 1) * DrawableMapset.HEIGHT + (PoolStartingIndex - 1) * YSpacing + YSpaceBeforeFirstSet;

                lock (Screen.AvailableMapsets)
                    lastMapset.UpdateWithNewMapset(Screen.AvailableMapsets[PoolStartingIndex - 1], PoolStartingIndex - 1);

                MapsetBuffer.Remove(lastMapset);
                MapsetBuffer.Insert(0, lastMapset);

                // Make sure the set is correctly selected/deselected.
                if (PoolStartingIndex - 1 == SelectedMapsetIndex)
                {
                    lastMapset.DisplayAsSelected(MapManager.Selected.Value);
                }
                else
                {
                    lastMapset.DisplayAsDeselected();
                }

                PoolStartingIndex--;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
            }
        }
Exemple #18
0
 virtual protected void TranslateCoords()
 {
     _screenView     = _centerCoordinate.GetScreenViewFromCenter(Width, Height, _level);
     _coordinateView = ScreenView;
 }
Exemple #19
0
 public static bool ObjectOnScreenBounds(Rectangle bounds)
 {
     return(ScreenRectangle.Intersects(bounds));
 }
Exemple #20
0
        /// <summary>
        ///     Handles shifting of the pool based on the way the user has scrolled.
        /// </summary>
        private void HandlePoolShifting(Direction direction)
        {
            DrawableChatMessage message;

            switch (direction)
            {
            case Direction.Forward:
                // First run a check to see if we even have a message in this position.
                if (DrawableChatMessages.ElementAtOrDefault(PoolStartingIndex) == null ||
                    DrawableChatMessages.ElementAtOrDefault(PoolStartingIndex + MAX_MESSAGES_SHOWN) == null)
                {
                    return;
                }

                // Check the top message at the pool starting index to see if it is still in range
                message = DrawableChatMessages[PoolStartingIndex];

                var newRect = Rectangle.Intersect(message.ScreenRectangle.ToRectangle(), ScreenRectangle.ToRectangle());

                if (!newRect.IsEmpty)
                {
                    return;
                }

                // Since we're shifting forward, we can safely remove the button that has gone off-screen.
                RemoveContainedDrawable(DrawableChatMessages[PoolStartingIndex]);

                // Now add the button that is forward.
                AddContainedDrawable(DrawableChatMessages[PoolStartingIndex + MAX_MESSAGES_SHOWN]);

                // Increment the starting index to shift it.
                PoolStartingIndex++;
                break;

            case Direction.Backward:
                // First run a check to see if we even have a message in this position.
                if (DrawableChatMessages.ElementAtOrDefault(PoolStartingIndex - 1) == null ||
                    DrawableChatMessages.ElementAtOrDefault(PoolStartingIndex + MAX_MESSAGES_SHOWN - 1) == null)
                {
                    return;
                }

                message = DrawableChatMessages[PoolStartingIndex + MAX_MESSAGES_SHOWN - 1];

                var rect = Rectangle.Intersect(message.ScreenRectangle.ToRectangle(), ScreenRectangle.ToRectangle());

                if (!rect.IsEmpty)
                {
                    return;
                }

                // Since we're scrolling up, we need to shift backwards.
                // Remove the drawable from the bottom one.
                RemoveContainedDrawable(DrawableChatMessages[PoolStartingIndex + MAX_MESSAGES_SHOWN - 1]);
                AddContainedDrawable(DrawableChatMessages[PoolStartingIndex - 1]);

                PoolStartingIndex--;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
            }
        }
Exemple #21
0
        /// <inheritdoc />
        /// <summary>
        ///     In this case, we only want buttons to be clickable if they're in the bounds of the scroll container.
        /// </summary>
        /// <returns></returns>
        protected override bool IsMouseInClickArea()
        {
            var newRect = Rectangle.Intersect(ScreenRectangle.ToRectangle(), Container.ScreenRectangle.ToRectangle());

            return(GraphicsHelper.RectangleContains(newRect, MouseManager.CurrentState.Position));
        }
Exemple #22
0
 public DeskScreen(ScreenRectangle prect)
 {
     _metrics = prect;
 }
Exemple #23
0
        /// <summary>
        ///     Handles shifting the pool whenever the container is scrolled.
        ///     Also initializing any new objects that need it.
        /// </summary>
        /// <param name="direction"></param>
        private void HandlePoolShifting(Direction direction)
        {
            switch (direction)
            {
            case Direction.Forward:
                // If there are no available users then there's no need to do anything.
                if (AvailableUsers.ElementAtOrDefault(PoolStartingIndex) == null ||
                    AvailableUsers.ElementAtOrDefault(PoolStartingIndex + MAX_USERS_SHOWN) == null)
                {
                    return;
                }

                var firstUser = UserBuffer.First();

                // Check if the object is in the rect of the ScrollContainer.
                // If it is, then there's no updating that needs to happen.
                if (!Rectangle.Intersect(firstUser.ScreenRectangle.ToRectangle(), ScreenRectangle.ToRectangle()).IsEmpty)
                {
                    return;
                }

                // Update the user's information and y position.
                firstUser.Y = (PoolStartingIndex + MAX_USERS_SHOWN) * DrawableOnlineUser.HEIGHT;

                lock (AvailableUsers)
                    firstUser.UpdateUser(AvailableUsers[PoolStartingIndex + MAX_USERS_SHOWN]);

                // Circuluarly Shift the list forward one.
                UserBuffer.RemoveFirst();
                UserBuffer.AddLast(firstUser);

                // Take this user, and place them at the bottom.
                PoolStartingIndex++;
                break;

            case Direction.Backward:
                // If there are no previous available user then there's no need to shift.
                if (AvailableUsers.ElementAtOrDefault(PoolStartingIndex - 1) == null)
                {
                    return;
                }

                var lastUser = UserBuffer.Last();

                // Check if the object is in the rect of the ScrollContainer.
                // If it is, then there's no updating that needs to happen.
                if (!Rectangle.Intersect(lastUser.ScreenRectangle.ToRectangle(), ScreenRectangle.ToRectangle()).IsEmpty)
                {
                    return;
                }

                lastUser.Y = (PoolStartingIndex - 1) * DrawableOnlineUser.HEIGHT;

                lock (AvailableUsers)
                    lastUser.UpdateUser(AvailableUsers[PoolStartingIndex - 1]);

                UserBuffer.RemoveLast();
                UserBuffer.AddFirst(lastUser);

                PoolStartingIndex--;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
            }
        }