-
Notifications
You must be signed in to change notification settings - Fork 15
/
ConnectionDialog.xaml.cs
53 lines (46 loc) · 1.41 KB
/
ConnectionDialog.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;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace OData4.LINQPadDriver
{
public partial class ConnectionDialog
{
private readonly ConnectionProperties _connectionProperties;
public ConnectionDialog(ConnectionProperties connectionProperties)
{
DataContext = _connectionProperties = connectionProperties;
InitializeComponent();
PasswordBox.Password = _connectionProperties.Password;
}
private void OnOkClick(object sender, RoutedEventArgs e)
{
DialogResult = true;
}
private void PasswordBox_OnPasswordChanged(object sender, RoutedEventArgs e)
{
_connectionProperties.Password = PasswordBox.Password;
}
private void Hyperlink_Click(object sender, RoutedEventArgs e)
{
try
{
CustomHeadersDialog customHeadersDialog = new CustomHeadersDialog(_connectionProperties.CustomHeaders);
var dialogResult = customHeadersDialog.ShowDialog();
if (dialogResult == true)
{
var customeHeaders = new List<KeyValuePair<string, string>>();
foreach (var item in customHeadersDialog.CustomHeaders.Where(s => !string.IsNullOrEmpty(s.Name)))
{
customeHeaders.Add(new KeyValuePair<string, string>(item.Name, item.Value));
}
_connectionProperties.CustomHeaders = customeHeaders;
}
}
catch (Exception ex)
{
MessageBox.Show($"Something went wrong \n{ex.Message}. Please try again!");
}
}
}
}