private void OnCustomSave(object sender, EventArgs e) { if (ProfileName.Text is null || FolderName.Text is null || RollName.Text is null || Roll.Text is null) { Error.Text = "Missing Field"; return; } Error.Text = ""; RollItem rollItem = new RollItem { RollName = RollName.Text, RollDice = Roll.Text, CanSave = CanSaveToggle.IsToggled, CanCrit = CanCritToggle.IsToggled, Folder = FolderName.Text, Profile = ProfileName.Text }; HasLevels hasLevels = new HasLevels { BaseRoll = null }; if (Save.CommandParameter != null) { rollItem.RollID = Convert.ToInt32(Save.CommandParameter); } App.Database.SaveItemAsync(rollItem); Navigation.PopAsync(); }
private void OnCustomRoll(object sender, EventArgs e) { RollItem tempItem = new RollItem { RollDice = CustomRollInput.Text }; roll.CustomRoll(tempItem, false); }
public SaveView(RollItem item) { InitializeComponent(); RollName.Keyboard = Keyboard.Create(KeyboardFlags.CapitalizeWord); Roll.Text = item.RollDice; RollName.Text = item.RollName; CanSaveToggle.IsToggled = item.CanSave; CanCritToggle.IsToggled = item.CanCrit; Save.CommandParameter = item.RollID; }
public Task SaveItemAsync(RollItem item) { if (item.RollID != 0) { return(database.UpdateWithChildrenAsync(item)); } else { return(database.InsertWithChildrenAsync(item)); } }
private async void ViewCell_Tapped(object sender, EventArgs e) { bool isCrit = false; ViewCell view = (ViewCell)sender; RollItem item = (RollItem)view.View.BindingContext; if (item.CanCrit) { isCrit = await DisplayAlert(null, "Is this a critical hit?", "Yes", "No"); } roll.CustomRoll(item, isCrit); }
public async void EditRoll(int id) { RollItem item = await App.Database.GetItemAsync(id); await Navigation.PushAsync(new SaveView(item)); }
private async void CustomRolls() { List <object> listRolls = new List <object>(); var profiles = await App.Database.GetProfliesAsync(); for (int p = 0; p < profiles.Count; p++) { RollItem profile = profiles[p]; listRolls.Add(new ContainerItem { Container = profile.Profile }); var folders = await App.Database.GetFoldersAsync(profile.Profile); for (int f = 0; f < folders.Count; f++) { RollItem folder = folders[f]; listRolls.Add(new ContainerItem { Container = folder.Folder }); var rolls = await App.Database.GetItemsAsync(profile.Profile, folder.Folder); foreach (var roll in rolls) { listRolls.Add(roll); } } } var listView = new ListView { ItemsSource = listRolls, ItemTemplate = new RollsTemplateSelector { RollTemplate = RollTemplate(), LabelTemplate = LabelTemplate() }, SelectionMode = ListViewSelectionMode.None, RowHeight = 70, HasUnevenRows = true }; var floatButton = new MyFloatButton { Margin = new Thickness(0, 0, 0, 0), HeightRequest = 56, WidthRequest = 56, HorizontalOptions = LayoutOptions.End }; var layout = new StackLayout { Children = { new Label { Text = "zDice", FontSize = 40, HorizontalOptions = LayoutOptions.Center }, listView, floatButton } }; Content = layout; }
public Task <int> DeleteItemAsync(RollItem item) { return(database.DeleteAsync(item)); }