/// <summary> /// ユーザー名が記載されたスタックパネルの要素を削除、与えられたパス(SettingFileDirectoryTextBox.Text)を元にユーザー名を新規追加する /// </summary> private void UpdateUserDataField() { if (this.UserDataStackPanel.Children.Count > 0) { this.UserDataStackPanel.Children.Clear(); } var dir = this.SettingFileDirectoryTextBox.Text; var userNames = FileController.GetUserNames(dir); foreach (var item in userNames) { var rb = new RadioButton { Style = this.ToggleStyledRadioButton.Style, Template = this.ToggleStyledRadioButton.Template, Tag = item, // 画像サイズ:200*160 Width = this.UserDataStackPanel.ActualWidth / 4, Height = this.UserDataStackPanel.ActualWidth / 5, FontSize = this.UserDataStackPanel.ActualWidth / 40 }; if (this.UserData[item][this.UserDataPropertyName[0]] != string.Empty) { rb.Content = this.UserData[item][this.UserDataPropertyName[0]]; } else { rb.Content = item.Substring(0, 12) + "..."; } rb.Checked += this.RbChecked; rb.MouseRightButtonDown += this.RbRightButtonDown; this.UserDataStackPanel.Children.Add(rb); } }
/// <summary> /// メインウィンドウのロード完了時に実行されるメソッド /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void MainWindowLoaded(object sender, RoutedEventArgs e) { // アプリの設定ファイルを読み込み、以前設定したパスがあるなら読み込む var pathData = FileController.ReadApplicationDirectoryInfo(this.ItemPropertyName); // game setting path if (Directory.Exists(pathData[this.ItemPropertyName[0]])) { this.SettingFileDirectoryTextBox.Text = pathData[this.ItemPropertyName[0]]; } else { var dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\My Games\Rainbow Six - Siege"; if (Directory.Exists(dir)) { this.SettingFileDirectoryTextBox.Text = dir; } } // R6S path if (File.Exists(pathData[this.ItemPropertyName[1]])) { this.AppFileDirectoryTextBox.Text = pathData[this.ItemPropertyName[1]]; } else { var dir = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); if (Directory.Exists(dir)) { this.AppFileDirectoryTextBox.Text = dir; } } // uplay path if (File.Exists(pathData[this.ItemPropertyName[2]])) { this.UplayAppFileDirectoryTextBox.Text = pathData[this.ItemPropertyName[2]]; } else { var dir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\Ubisoft\Ubisoft Game Launcher"; if (Directory.Exists(dir)) { this.UplayAppFileDirectoryTextBox.Text = dir; if (File.Exists(dir + @"\Uplay.exe")) { this.UplayAppFileDirectoryTextBox.Text += @"\Uplay.exe"; } } } // アプリの設定ファイルを読み込み、以前設定したユーザーデータが存在するなら読み込む var settingFileDir = this.SettingFileDirectoryTextBox.Text; var userNames = FileController.GetUserNames(settingFileDir); foreach (var userName in userNames) { var data = FileController.ReadUserInfo(userName, this.UserDataPropertyName); this.UserData.Add(userName, data); } this.UpdateUserDataField(); this.InitializeServerList(); var ls = FileController.ReadApplicationDirectoryInfo(this.LastSelectionPropertyName); foreach (var item in this.UserDataStackPanel.Children) { if (((RadioButton)item).Tag.ToString() != ls[this.LastSelectionPropertyName[0]]) { continue; } ((RadioButton)item).IsChecked = true; break; } foreach (var item in this.ServerListBox.Items) { if (((TextBlock)item).Tag.ToString() != ls[this.LastSelectionPropertyName[1]]) { continue; } this.ServerListBox.SelectedItem = item; break; } this.UpdateUserNavigationText(false); }