-
Notifications
You must be signed in to change notification settings - Fork 15
/
CustomHeadersDialog.xaml.cs
53 lines (45 loc) · 1.23 KB
/
CustomHeadersDialog.xaml.cs
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
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
namespace OData4.LINQPadDriver
{
/// <summary>
/// Interaction logic for CustomHeadersDialog.xaml
/// </summary>
public partial class CustomHeadersDialog : Window
{
public ObservableCollection<CustomHeader> CustomHeaders { get; set; } = new ObservableCollection<CustomHeader>();
public CustomHeadersDialog(IEnumerable<KeyValuePair<string, string>> customHeaders)
{
foreach (var item in customHeaders)
{
CustomHeaders.Add(new CustomHeader { Name = item.Key, Value = item.Value });
}
InitializeComponent();
DataContext = this;
}
public CustomHeader SelectedCustomHeader { get; set; }
private void OK_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
this.Close();
}
private void Cancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
this.Close();
}
private void Remove_Click(object sender, RoutedEventArgs e)
{
if (SelectedCustomHeader != null && CustomHeaders.Contains(SelectedCustomHeader))
{
CustomHeaders.Remove(SelectedCustomHeader);
}
}
}
public class CustomHeader
{
public string Name { get; set; }
public string Value { get; set; }
}
}