-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProfileSelectionWindow.xaml.cs
More file actions
59 lines (53 loc) · 2 KB
/
ProfileSelectionWindow.xaml.cs
File metadata and controls
59 lines (53 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Windows;
using XColumn.Models;
namespace XColumn
{
public partial class ProfileSelectionWindow : Window
{
public string SelectedProfileName { get; private set; } = "";
/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="profiles">プロファイル一覧</param>
/// <param name="defaultProfileName">初期選択するプロファイル名</param>
/// <param name="title">ウィンドウのタイトル</param>
/// <param name="message">ユーザーへのメッセージ</param>
/// <param name="buttonText">実行ボタンのテキスト</param>
public ProfileSelectionWindow(
IEnumerable<object> profiles,
string defaultProfileName,
string title = "プロファイル選択",
string message = "プロファイルを選択してください:",
string buttonText = "OK")
{
InitializeComponent();
// UIテキストの反映
this.Title = title;
this.MessageText.Text = message;
this.ActionButton.Content = buttonText;
// プロファイル一覧を設定
ProfileCombo.ItemsSource = profiles;
// 初期選択
foreach (var item in ProfileCombo.Items)
{
if (item is ProfileItem p && p.Name == defaultProfileName)
{
ProfileCombo.SelectedItem = item;
break;
}
}
}
private void OkButton_Click(object sender, RoutedEventArgs e)
{
if (ProfileCombo.SelectedItem is ProfileItem item)
{
SelectedProfileName = item.Name;
DialogResult = true;
}
else
{
MessageWindow.Show("プロファイルを選択してください。", "確認", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
}
}