Statistics
| Branch: | Revision:

root / trunk / Pithos.Client.WPF / Preferences / ProxyAccountViewModel.cs @ 34bdb91d

History | View | Annotate | Download (3 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
                UserName = _settings.ProxyUsername;
75
                Password = _settings.ProxyPassword;
76
                Domain = _settings.ProxyDomain;
77
                NotifyOfPropertyChange(() => Settings);
78
            }
79
        }
80

    
81
        private PithosSettings _settings;
82

    
83

    
84
        public ProxyAccountViewModel()
85
        {
86
            
87
        }
88

    
89
        public void SaveChanges()
90
        {
91
/*
92
            Settings.ProxyUsername = UserName;
93
            Settings.ProxyPassword = Password;
94
            Settings.ProxyDomain = Domain;
95
            Settings.UseManualProxy = true;
96
            Settings.UseDefaultProxy = false;
97
            Settings.UseNoProxy = false;
98
            Settings.ProxyAuthentication = true;
99
*/
100
            Proxy.SetCredentials(Settings.ProxyUsername, Settings.ProxyPassword, Settings.ProxyDomain);
101
            this.TryClose(true);            
102
        }
103

    
104
        public void RejectChanges()
105
        {
106
            this.TryClose();
107
        }
108
    }
109
}