private async void InputMCIDDIalogAsync(string title) { TextBox inputTextBox = new TextBox { AcceptsReturn = false, Height = 32, }; ContentDialog dialog = new ContentDialog { Content = inputTextBox, Title = title, IsSecondaryButtonEnabled = false, PrimaryButtonText = "OK", CloseButtonText = "Cancel" }; var result = await dialog.ShowAsync(); var OK = ContentDialogResult.Primary; if (result == OK) { if (inputTextBox.Text == null) { return; } ChangeStyle(mcid.Text, inputTextBox.Text); // データとmcidのテキストを入れ替える var playerdata = DictionaryManager.getDictionary(); Points data = playerdata[mcid.Text]; playerdata.Remove(mcid.Text); playerdata.Add(inputTextBox.Text, data); DictionaryManager.setPlayerData(mcid.Text, data); mcid.Text = inputTextBox.Text; if (EditOnce) { return; } EditOnce = true; } }
private void AddData(object sender, RoutedEventArgs e) { dataTotal += 1; buttonTotal += 1; Button NewButton = new Button() { Content = "Sample" + buttonTotal, FontSize = 60, FontFamily = new FontFamily("Arial"), Background = null, Width = 465, Height = 87, HorizontalAlignment = HorizontalAlignment.Center }; // ※補足 NewButton.Click += ShowPoints -> ボタンにクリックイベントを追加するやつ NewButton.Click += ShowPoints; NewButton.HorizontalAlignment = HorizontalAlignment.Center; RelativePanel.SetAlignHorizontalCenterWith(NewButton, sender); Button addbutton = Add; NameList.Children.Remove(Add); NameList.Children.Add(NewButton); NameList.Children.Add(addbutton); Points playerData = new Points(1, 1, dataTotal); string playername = NewButton.Content.ToString(); DictionaryManager.setPlayerData(playername, playerData); if (EditOnce == false) { EditOnce = true; } }
public MainPage() { this.InitializeComponent(); Points sample__ = new Points(0, 0, 0); DictionaryManager.setPlayerData("Sample", sample__); buttonTotal += 1; DatabaseInit(); LoadPlayerData(); createTestSampleWindow(); instance = this; }
private void LoadPlayerData() { ApplicationDataContainer database = ApplicationData.Current.LocalSettings; var playerContainer = database.Containers["key"]; // ※補足 foreach (string mcid in sortList()) -> データの中にある全てのMCIDを取得する foreach (string mcid in sortList()) { // なぜかデータからnullデータが出てしまうため、回避策としてreturnで返している if (mcid == null) { return; } bool mcidCondition = !mcid.Equals("Sample") && !mcid.Equals("Add"); if (mcidCondition) { try { Button button = new Button { Content = mcid, FontSize = 60, FontFamily = new FontFamily("Arial"), Background = null, Width = 465, Height = 87, HorizontalAlignment = HorizontalAlignment.Center }; // ※補足 button.Click += ShowPoints -> ボタンにクリックイベントを追加 button.Click += ShowPoints; dataTotal = countKeys() - 1; buttonTotal = countKeys(); Button addbutton = Add; // 一度Addボタンを付けなおして位置を直す NameList.Children.Remove(Add); NameList.Children.Add(button); NameList.Children.Add(addbutton); RelativePanel.SetAlignHorizontalCenterWith(button, addbutton); ApplicationDataCompositeValue playerdatafromdatabase = getPlayerData(mcid); int scpoint = (int)playerdatafromdatabase["SC"]; int contributionpoint = (int)playerdatafromdatabase["Contribution"]; int id = (int)playerdatafromdatabase["ID"]; Points data = new Points(scpoint, contributionpoint, id); DictionaryManager.setPlayerData(button.Content.ToString(), data); } catch (Exception e) { return; } } } }