private void VerticalButtonClickedEvents(object sender, EventArgs e) { try { EventHandler <CustomTapEventArgs> handler = VerticalButtonClickedEvent; CustomTapEventArgs customTapEventArgs = new CustomTapEventArgs(); var owner = (Button)sender; if (owner.Text == "+") { customTapEventArgs.ButtonOption = ButtonOption.Add; } else if (owner.Text == "-") { customTapEventArgs.ButtonOption = ButtonOption.Delete; } else { } if (handler != null) { handler(sender, customTapEventArgs); } } catch (Exception ex) { var msg = ex.Message + "\n" + ex.StackTrace; } }
private void AlterHorizontalCells(CustomTapEventArgs e) { try { if (e.ButtonOption == ButtonOption.Add) { grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); var rows = grid.RowDefinitions.Count; var columns = grid.ColumnDefinitions.Count; for (int column = 0; column < columns; column++) { var box = new BoxView() { BackgroundColor = Color.Teal, WidthRequest = 50, HeightRequest = 50 }; grid.Children.Add(box, column, rows - 1); } } else if (e.ButtonOption == ButtonOption.Delete) { var rows = grid.RowDefinitions.Count; var gridChildren = grid.Children; List <View> removableColumnViews = new List <View>(); foreach (var child in gridChildren) { var childRow = Grid.GetRow(child); if (childRow == rows) { removableColumnViews.Add(child); } } foreach (var viewItem in removableColumnViews) { grid.Children.Remove(viewItem); } grid.RowDefinitions.Remove(grid.RowDefinitions[grid.RowDefinitions.Count - 1]); } else { } } catch (Exception ex) { var msg = ex.Message + "\n" + ex.StackTrace; } }
public void AlterCells(EffectedSection section, CustomTapEventArgs args) { try { if (section == EffectedSection.Column) { AlterHorizontalCells(args); } else if (section == EffectedSection.Row) { AlterVerticalCells(args); } else { } } catch (Exception ex) { var msg = ex.Message + "\n" + ex.StackTrace; } }