private async void ScrollView_Scrolled(object sender, ScrolledEventArgs e) { if (translating) { return; } uint mills = 100; translating = true; if (e.ScrollY > lastScrollPoint) { // hide if (isVisible) { await PanelGrid.TranslateTo(PanelGrid.TranslationX, PanelGrid.TranslationY + PanelGrid.HeightRequest, mills); isVisible = false; } } else { // show if (!isVisible) { await PanelGrid.TranslateTo(PanelGrid.TranslationX, PanelGrid.TranslationY - PanelGrid.HeightRequest, mills); isVisible = true; } } lastScrollPoint = e.ScrollY; translating = false; }
private void UpdateResource() { var index = 0; foreach (var item in _itemui.Data.Inventorys.Resource.Resources) { if (item.Value.numver > 0) { if (PanelGrid.GetChild(index).ChildPanel.Count == 0) { var currentpanel = new ImagePanel(PanelGrid.GetChild(index), GetItemPath(item.Key)) { Position = PanelGrid.GetChild(index).Bounds.Center.ToVector2(), Origin = new Vector2(17, 15), Scale = 11, PanelCode = item.Key, }; currentpanel.UpdateEvent += Currentpanel_UpdateEvent; new TextPanel(PanelGrid.GetChild(index).GetChild(item.Key), _itemui.ParantMenu.StandardFont, item.Value.numver.ToString(), TextSortMode.MIDDLE) { Position = PanelGrid.GetChild(index).Bounds.Center.ToVector2() + new Vector2(25, 25), Color = Color.White }; } else { PanelExt.GetPanel <TextPanel>(PanelGrid.GetChild(index).GetChild(item.Key).GetChild(0)).Text = item.Value.numver.ToString(); } index++; } } }
private string Part2Returner(int paintedPanels, PanelGrid grid) { var builder = new StringBuilder(); for (int y = 0; y < gridSize; y++) { for (int x = 0; x < gridSize; x++) { builder.Append(grid[x, y] == PanelColor.White ? '#' : '.'); } builder.AppendLine(); } return(builder.ToString()); }
private void InitializeGridMaze() { var ctx = new PanelGridContext { GridSize = 15, Height = board.Height, Width = board.Width, CellClickEventHandler = OnCellClickEvent, IsWall = CheckIfCellIsWall, }; gridMaze = new PanelGrid(ctx); board.Controls.Clear(); board.Controls.Add(gridMaze); }
public DBPanelGridController(PanelGrid <Type> grid, bool newRowIsVisible) { table_ = null; new_row_ = null; sql_ = ""; ShowInvalidColumnValueMessage = true; grid_ = grid; grid_.UpdateRowsAction += (begin, end) => RefreshRows(begin, end, false); grid_.NewRowIsVisible = newRowIsVisible; foreach (var row in grid_.AllRowControls()) { row.Column_BeforeChangeValueAction += Column_BeforeChangeValue; row.Column_UpdateValueAction += Column_UpdateValue; row.Column_LostFocusAction += Column_LostFocus; row.RemoveAction += Row_Remove; row.Leave += Row_LostFocus; row.Enter += Row_GotFocus; row.SetStatusMessageAction += delegate(string msg) { if (SetStatusMessage != null) { SetStatusMessage(msg); } }; row.RowClicked += delegate(AbstractPanelGridRow sender) { if (RowClicked != null) { RowClicked(sender as Type); } }; } delayTimerController = new misc.DelayTimerController(); }
private T General <T>(GeneralFunction beforeOperation, Returner <T> returner) { var grid = new PanelGrid(gridSize); for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { grid[x, y] = PanelColor.Untouched; } } var currentLocation = new Location2D(gridSize / 2, gridSize / 2); var currentDirection = Direction.Up; int currentDirectionIndex = 0; int paintedPanels = 0; bool givenFirstOutput = false; beforeOperation(grid, currentLocation); var computer = new IntcodeComputer(FileContents); computer.InputRequested += InputRequested; computer.OutputWritten += OutputWritten; computer.RunToHalt(); return(returner(paintedPanels, grid)); BigInteger InputRequested() { givenFirstOutput = false; var(x, y) = currentLocation; return((int)grid[x, y] & 1); } void OutputWritten(BigInteger output) { if (givenFirstOutput) { AddDirectionIndex(GetDirectionIndexOffset((int)output)); currentLocation.Forward(currentDirection, true, true); } else { PaintPanel(currentLocation, (PanelColor)(int)output); } givenFirstOutput = true; } int GetDirectionIndexOffset(int output) => output == 0 ? 1 : -1; void AddDirectionIndex(int offset) { currentDirectionIndex = (currentDirectionIndex + offset + 4) % 4; currentDirection = orderedDirections[currentDirectionIndex]; } void PaintPanel(Location2D location, PanelColor color) { var(x, y) = location; if (grid[x, y].HasFlag(PanelColor.Untouched)) { paintedPanels++; } grid[x, y] = color; } }
private int Part1Returner(int paintedPanels, PanelGrid grid) => paintedPanels;
private void Part2GeneralFunction(PanelGrid grid, Location2D startingLocation) { var(x, y) = startingLocation; grid[x, y] = PanelColor.White; }
private void Part1GeneralFunction(PanelGrid grid, Location2D startingLocation) { }