root / trunk / Pithos.Client.WPF / Preferences / ProxyAccountViewModel.cs @ 65282d58
History | View | Annotate | Download (3.4 kB)
1 |
// ----------------------------------------------------------------------- |
---|---|
2 |
// <copyright file="ProxyAccountViewModel.cs" company="Microsoft"> |
3 |
// TODO: Update copyright text. |
4 |
// </copyright> |
5 |
// ----------------------------------------------------------------------- |
6 |
|
7 |
using System.ComponentModel.Composition; |
8 |
using System.Diagnostics.Contracts; |
9 |
using System.Net; |
10 |
using Caliburn.Micro; |
11 |
using Pithos.Client.WPF.Configuration; |
12 |
|
13 |
namespace Pithos.Client.WPF.Preferences |
14 |
{ |
15 |
using System; |
16 |
using System.Collections.Generic; |
17 |
using System.Linq; |
18 |
using System.Text; |
19 |
|
20 |
[Export(typeof(ProxyAccountViewModel))] |
21 |
public class ProxyAccountViewModel:Screen |
22 |
{ |
23 |
public override string DisplayName |
24 |
{ |
25 |
get { return "Proxy Settings"; } |
26 |
set |
27 |
{ |
28 |
base.DisplayName = value; |
29 |
} |
30 |
} |
31 |
private string _userName; |
32 |
public string UserName |
33 |
{ |
34 |
get { return _userName; } |
35 |
set |
36 |
{ |
37 |
if (String.IsNullOrWhiteSpace(value)) |
38 |
throw new ArgumentNullException(); |
39 |
_userName = value; |
40 |
NotifyOfPropertyChange(()=>UserName); |
41 |
} |
42 |
} |
43 |
|
44 |
private string _password; |
45 |
public string Password |
46 |
{ |
47 |
get { return _password; } |
48 |
set |
49 |
{ |
50 |
if (String.IsNullOrWhiteSpace(value)) |
51 |
throw new ArgumentNullException(); |
52 |
_password = value; |
53 |
NotifyOfPropertyChange(()=>Password); |
54 |
} |
55 |
} |
56 |
|
57 |
private string _domain; |
58 |
public string Domain |
59 |
{ |
60 |
get { return _domain; } |
61 |
set |
62 |
{ |
63 |
_domain = value; |
64 |
NotifyOfPropertyChange(()=>Domain); |
65 |
} |
66 |
} |
67 |
|
68 |
public PithosSettings Settings |
69 |
{ |
70 |
get { return _settings; } |
71 |
set |
72 |
{ |
73 |
_settings = value; |
74 |
NotifyOfPropertyChange(()=>Settings); |
75 |
} |
76 |
} |
77 |
|
78 |
private PithosSettings _settings; |
79 |
|
80 |
public ProxyAccountViewModel(PithosSettings settings) |
81 |
{ |
82 |
if (settings == null) |
83 |
throw new ArgumentNullException("settings"); |
84 |
Contract.EndContractBlock(); |
85 |
|
86 |
Settings = settings; |
87 |
UserName = Settings.ProxyUsername; |
88 |
Password = Settings.ProxyPassword; |
89 |
Domain = Settings.ProxyDomain; |
90 |
} |
91 |
|
92 |
public void SaveChanges() |
93 |
{ |
94 |
/* |
95 |
Settings.ProxyUsername = UserName; |
96 |
Settings.ProxyPassword = Password; |
97 |
Settings.ProxyDomain = Domain; |
98 |
Settings.UseManualProxy = true; |
99 |
Settings.UseDefaultProxy = false; |
100 |
Settings.UseNoProxy = false; |
101 |
Settings.ProxyAuthentication = true; |
102 |
*/ |
103 |
Settings.Save(); |
104 |
CredentialCache.DefaultNetworkCredentials.Password = Settings.ProxyPassword; |
105 |
CredentialCache.DefaultNetworkCredentials.UserName = Settings.ProxyUsername; |
106 |
CredentialCache.DefaultNetworkCredentials.Domain= Settings.ProxyDomain; |
107 |
this.TryClose(true); |
108 |
} |
109 |
|
110 |
public void RejectChanges() |
111 |
{ |
112 |
this.TryClose(); |
113 |
} |
114 |
} |
115 |
} |