public void UpdateTerrain(TerrainUpdate update) { if (!BottomRight.Contains(update.Position)) { return; // We can ignore out of bound updates, as these are not accessible anyway. } (Int32 x, Int32 y) = update.Position; Terrain[x, y] = update.NewTerrain; }
public TerrainType this[CoordinatePair coords] { get { if (!BottomRight.Contains(coords)) { throw new ArgumentOutOfRangeException(nameof(coords)); } return(Terrain[coords.X, coords.Y]); } }
public override UIElement OnMouseAction(MouseActionEventArgs mouse) { UIElement intercept = base.OnMouseAction(mouse); if (intercept == null && FrameDimensions.Contains(mouse.Position)) { intercept = this; if (ResizeableByUser && mouse.Button == MouseButton.Left && mouse.Action == MouseAction.Pressed) { if (TopLeft.Contains(mouse.Position)) { EdgeCaught = Edge.TopLeft; } else if (Top.Contains(mouse.Position)) { EdgeCaught = Edge.Top; } else if (TopRight.Contains(mouse.Position)) { EdgeCaught = Edge.TopRight; } else if (MiddleLeft.Contains(mouse.Position)) { EdgeCaught = Edge.Left; } else if (MiddleRight.Contains(mouse.Position)) { EdgeCaught = Edge.Right; } else if (BottomLeft.Contains(mouse.Position)) { EdgeCaught = Edge.BottomLeft; } else if (Bottom.Contains(mouse.Position)) { EdgeCaught = Edge.Bottom; } else if (BottomRight.Contains(mouse.Position)) { EdgeCaught = Edge.BottomRight; } } } if (mouse.Button == MouseButton.Left && mouse.Action == MouseAction.Released) { EdgeCaught = Edge.None; } return(intercept); }
public void UpdateRoverPos(PositionUpdate update) { if (!BottomRight.Contains(update.Previous)) { throw new ArgumentOutOfRangeException(nameof(update), update.Previous, "Previous position must lie within bottom right position."); } if (!BottomRight.Contains(update.New)) { throw new ArgumentOutOfRangeException(nameof(update), update.New, "New position must lie within bottom right position."); } RoverPosition = update.New; }
protected override void WndProc(ref Message message) { base.WndProc(ref message); if (message.Msg == 0x84) { var cursor = this.PointToClient(Cursor.Position); if (TopLeft.Contains(cursor)) { message.Result = (IntPtr)HTTOPLEFT; } else if (TopRight.Contains(cursor)) { message.Result = (IntPtr)HTTOPRIGHT; } else if (BottomLeft.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOMLEFT; } else if (BottomRight.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOMRIGHT; } else if (Top.Contains(cursor)) { message.Result = (IntPtr)HTTOP; } else if (Left.Contains(cursor)) { message.Result = (IntPtr)HTLEFT; } else if (Right.Contains(cursor)) { message.Result = (IntPtr)HTRIGHT; } else if (Bottom.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOM; } } }
public TerrainType SampleSquare(Position position) { if (!BottomRight.Contains(position)) { throw new ArgumentOutOfRangeException(nameof(position), position, "Must be contained within this level."); } (Int32 x, Int32 y) = position; if (Terrain[x, y] == TerrainType.Rough) { Terrain[x, y] = TerrainType.SampledRough; } else if (Terrain[x, y] == TerrainType.Smooth) { Terrain[x, y] = TerrainType.SampledSmooth; } return(Terrain[x, y]); }
protected override void WndProc(ref Message message) { try { if (message.Msg == WM_SYSCOMMAND && (message.WParam.ToInt32() & 0xfff0) == SC_SIZE) { if (FormResizable) { GetSystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, out int isDragFullWindow, 0); if (isDragFullWindow != 0) { SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 0, 0, 0); } base.WndProc(ref message); if (isDragFullWindow != 0) { SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 1, 0, 0); } } } else { if (message.Msg == 0x84) // WM_NCHITTEST { if (FormResizable) { // Always add grid styles regardless of border type var cursor = PointToClient(Cursor.Position); if (TopLeft.Contains(cursor)) { message.Result = (IntPtr)HTTOPLEFT; } else if (TopRight.Contains(cursor)) { message.Result = (IntPtr)HTTOPRIGHT; } else if (BottomLeft.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOMLEFT; } else if (BottomRight.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOMRIGHT; } else if (Top.Contains(cursor)) { message.Result = (IntPtr)HTTOP; } else if (Left.Contains(cursor)) { message.Result = (IntPtr)HTLEFT; } else if (Right.Contains(cursor)) { message.Result = (IntPtr)HTRIGHT; } else if (Bottom.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOM; } } else { Cursor.Current = Cursors.Arrow; message.Result = (IntPtr)1; // Processed6 return; } } base.WndProc(ref message); } } catch (Exception e) { MessageBox.Show( "The application encountered a fatal error and must be restarted. Please contact the service desk with this message: " + e.Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected override void WndProc(ref Message message) { try { if (message.Msg == WM_SYSCOMMAND && (message.WParam.ToInt32() & 0xfff0) == SC_SIZE) { int isDragFullWindow; GetSystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, out isDragFullWindow, 0); if (isDragFullWindow != 0) { SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 0, 0, 0); } base.WndProc(ref message); if (isDragFullWindow != 0) { SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 1, 0, 0); } } else { base.WndProc(ref message); if (message.Msg == 0x84) // WM_NCHITTEST { var cursor = PointToClient(Cursor.Position); if (TopLeft.Contains(cursor)) { message.Result = (IntPtr)HTTOPLEFT; } else if (TopRight.Contains(cursor)) { message.Result = (IntPtr)HTTOPRIGHT; } else if (BottomLeft.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOMLEFT; } else if (BottomRight.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOMRIGHT; } else if (Top.Contains(cursor)) { message.Result = (IntPtr)HTTOP; } else if (Left.Contains(cursor)) { message.Result = (IntPtr)HTLEFT; } else if (Right.Contains(cursor)) { message.Result = (IntPtr)HTRIGHT; } else if (Bottom.Contains(cursor)) { message.Result = (IntPtr)HTBOTTOM; } } } } catch (Exception e) { MessageBox.Show( "Google Geolocation encountered a fatal error and must be restarted. Please contact support with this message: " + e.Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Checks if specified item is inside this collection. /// </summary> public bool Contains(T item) { var bounds = item.Bounds; return(TopRight != null && TopRight.Extent.IntersectsWith(bounds) && TopRight.Contains(item) || TopLeft != null && TopLeft.Extent.IntersectsWith(bounds) && TopLeft.Contains(item) || BottomRight != null && BottomRight.Extent.IntersectsWith(bounds) && BottomRight.Contains(item) || BottomLeft != null && BottomLeft.Extent.IntersectsWith(bounds) && BottomLeft.Contains(item) || ItemsInQuadrant.Contains(item)); }