private async void RunePageItem_Apply(Json.Value value) { try { Json.Value currentPageJson = await Wrapper.GetCurrentRunePageAsync(); int order = 0; if (currentPageJson != null) { ulong selectedId = currentPageJson["id"]; if (currentPageJson["isDeletable"]) { await Wrapper.DeleteRunePageAsync(selectedId); } } value["order"] = order; if (!await Wrapper.AddRunePageAsync(value)) { Json.Value pages = await Wrapper.GetRunePagesAsync(); foreach (Json.Value pageJson in pages) { if (pageJson["isDeletable"]) { value["order"] = pageJson["order"]; await Wrapper.DeleteRunePageAsync(pageJson["id"]); await Wrapper.AddRunePageAsync(value); break; } } } } catch (RequestWrapper.NoClientException) { MessagePopup messagePopup = new MessagePopup("Service currently unavailable, try again?"); messagePopup.Decided += delegate(bool result) { if (result) { RunePageItem_Apply(value); } MainViewGrid.Children.Remove(messagePopup); }; MainViewGrid.Children.Add(messagePopup); } }
private void RunePageItem_Delete(RunePageItem runePageItem) { MessagePopup messagePopup = new MessagePopup("Are you sure you want to delete this page?"); messagePopup.Decided += delegate(bool result) { if (result) { RunePagePanel.Children.Remove(runePageItem); RunePagePanelDummy.Children.RemoveAt(RunePagePanelDummy.Children.Count - 1); UpdateConfig(); } MainViewGrid.Children.Remove(messagePopup); }; MainViewGrid.Children.Add(messagePopup); }
private async void NewRunePageItem_StoreNew() { try { Json.Value value = await Wrapper.GetCurrentRunePageAsync(); if (value != null) { value.Remove("current"); value.Remove("id"); value.Remove("isActive"); value.Remove("isDeletable"); value.Remove("isEditable"); value.Remove("isValid"); value.Remove("lastModified"); value.Remove("order"); AppendRunePage(value); UpdateConfig(); } else { MessagePopup messagePopup = new MessagePopup("Please select a page, try again?"); messagePopup.Decided += delegate(bool result) { if (result) { NewRunePageItem_StoreNew(); } MainViewGrid.Children.Remove(messagePopup); }; } } catch (RequestWrapper.NoClientException) { MessagePopup messagePopup = new MessagePopup("Service currently unavailable, try again?"); messagePopup.Decided += delegate(bool result) { if (result) { NewRunePageItem_StoreNew(); } MainViewGrid.Children.Remove(messagePopup); }; MainViewGrid.Children.Add(messagePopup); } }