private void RemoveRow(AttackRow row) { if (row == null) { return; } Attacks.Children.Remove(row.title); Attacks.Children.Remove(row.frame); rows.Remove(row); rowsPool.Add(row); }
private void UpdateRow(AttackRow row, CharacterSheet.ValueWithIntModifiers bab) { if (row == null) { return; } if (bab == null) { return; } var sheet = CharacterSheetStorage.Instance.selectedCharacter; if (sheet == null) { return; } var value = bab.GetTotal(sheet); UpdateValue(row.value, value >= 0 ? "+" + value : value.ToString()); MainPage.SetTapHandler(row.frame, (s, e) => EditBonus(bab), 1); }
private void CreateRow(CharacterSheet.ValueWithIntModifiers bab) { var sheet = CharacterSheetStorage.Instance.selectedCharacter; if (sheet == null) { return; } if (rowsPool.Count > 0) { var row = rowsPool[0]; rowsPool.RemoveAt(0); var rowIndex = rows.Count; rows.Add(row); UpdateRow(row, bab); Attacks.Children.Add(row.title, 0, rowIndex); Attacks.Children.Add(row.frame, 1, rowIndex); return; } var title = CreateLabel("Attack " + (rows.Count + 1) + " Bonus:"); var bonus = bab.GetTotal(sheet); var frame = CreateFrame(bonus >= 0 ? "+" + bonus : bonus.ToString()); var value = frame.Content as Label; value.TextDecorations = TextDecorations.Underline; var newRow = new AttackRow() { title = title, frame = frame, value = value, }; var newRowIndex = rows.Count; rows.Add(newRow); MainPage.SetTapHandler(frame, (s, e) => EditBonus(bab), 1); Attacks.Children.Add(newRow.title, 0, newRowIndex); Attacks.Children.Add(newRow.frame, 1, newRowIndex); }