Revision 0eea575a trunk/Pithos.Client.WPF/PreferencesViewModel.cs

b/trunk/Pithos.Client.WPF/PreferencesViewModel.cs
9 9
using System.Diagnostics;
10 10
using System.IO;
11 11
using System.IO.IsolatedStorage;
12
using System.Linq.Expressions;
12 13
using System.Net;
14
using System.Reflection;
13 15
using System.Runtime.Serialization;
14 16
using System.Windows;
15 17
using System.Windows.Forms;
......
56 58
            Settings=settings;
57 59
            Monitor=monitor;
58 60

  
59
            
60

  
61
            
62 61

  
63 62
            Taskbar.UsageMessage = "Using 15% of 50 GB";
64 63
            Taskbar.RecentFiles.AddRange(new[]
......
69 68
            Taskbar.StatusMessage = "In Synch";
70 69
            Taskbar.UpdateStatus();
71 70
        }
71

  
72 72
        protected override void OnViewAttached(object view, object context)
73 73
        {
74 74
            var window = (Window)view;
75
/*
76
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
77
            window.ShowInTaskbar = false;
78
*/
79 75

  
80 76
            base.OnViewAttached(view, context);
81 77
        }
......
133 129
        #region Commands
134 130
        
135 131

  
136
        /*public void ShowPreferences()
137
        {
138
            Settings.Reload();
139

  
140
            var window = (Window)this.GetView();
141
            window.Show();
142
        }*/
143

  
144

  
145
        /*public PithosCommand OpenPithosFolderCommand { get; private set; }
146

  
147
        public void OpenPithosFolder()
148
        {
149
            Process.Start(Settings.PithosPath);
150
        }
151

  
152
        public void GoToSite()
153
        {
154

  
155
        }
156

  
157
        public void ToggleSynching()
158
        {
159

  
160
        }
161
*/
132
    
162 133
        public void SaveChanges()
163 134
        {
164 135
            DoSave();
165
            /*var window = (Window)GetView();
166
            window.Hide();*/
136
           
167 137
        }
168 138

  
169 139
        public void RejectChanges()
170 140
        {
171 141
            Settings.Reload();
172
           /* var window = (Window)GetView();
173
            window.Hide();*/
142
           
174 143
        }
175 144

  
176 145
        public void ApplyChanges()
......
181 150
        private void DoSave()
182 151
        {
183 152
            Settings.Save();
153
            NotifyOfPropertyChange(()=>Settings);
184 154
            Monitor.Start();
185 155
        }
186 156

  
......
196 166
                Settings.PithosPath = newPath;
197 167
                Settings.Save();
198 168
                NotifyOfPropertyChange(() => Settings);
169

  
199 170
            }
200 171
        }
201 172

  
202
       /* public void ExitPithos()
203
        {
204
            Monitor.Stop();
205
            this.TryClose();            
206
        }
207
*/
208

  
209
        public void AddAccount()
173
       public void AddAccount()
210 174
        {
211 175
            var newAccount = new AccountSettings();
212 176
            Settings.Accounts.Add(newAccount);
213
            CurrentAccount = newAccount;
177
            SelectedAccountIndex= Settings.Accounts.Count-1;
214 178
            NotifyOfPropertyChange(()=>Settings);
215 179
        }
216 180

  
217 181
        public void RemoveAccount()
218 182
        {
219
//            var idx = Settings.Accounts.IndexOf(CurrentAccount);
220 183
            Settings.Accounts.RemoveAll(account => account.AccountName == CurrentAccount.AccountName);
221
//            Settings.Accounts.RemoveAt(idx);            
222
            CurrentAccount = null;
184
            
185
            NotifyOfPropertyChange(()=>CurrentAccount);
223 186
            NotifyOfPropertyChange(()=>Settings);
224
            NotifyOfPropertyChange("Settings.Accounts");
187
            //NotifyOfPropertyChange("Settings.Accounts");
225 188
        }
226 189

  
227 190
        public bool CanRemoveAccount
......
257 220
        }
258 221
        #endregion
259 222

  
260
        private AccountSettings _currentAccount;
261
        public AccountSettings CurrentAccount
223
        private int _selectedAccountIndex;
224
        public int SelectedAccountIndex
262 225
        {
263
            get { return _currentAccount; }
226
            get { return _selectedAccountIndex; }
264 227
            set
265 228
            {
266
                _currentAccount = value;
267
                NotifyOfPropertyChange(()=>CurrentAccount);
268
                NotifyOfPropertyChange(()=>CanRemoveAccount);
229
                _selectedAccountIndex = value;
230
                NotifyOfPropertyChange(() => CurrentAccount);
231
                NotifyOfPropertyChange(() => CanRemoveAccount);
232
                NotifyOfPropertyChange(()=>SelectedAccountIndex);
269 233
            }
270 234
        }
271 235

  
272

  
273

  
274
        /* private void UnregisterExtensions()
236
        private AccountSettings _currentAccount;
237
        public AccountSettings CurrentAccount
275 238
        {
276
            using (var installer = new ProjectInstaller())
239
            get { return Settings.Accounts[SelectedAccountIndex]; }
240
/*
241
            set
277 242
            {
278
                IDictionary state = ShellExtensionController.LoadState();
279
                installer.Uninstall(state);
243
                _currentAccount = value;
280 244
            }
245
*/
281 246
        }
282 247

  
283
        private void RegisterExtensions()
284
        {
285
            using (var installer = new ProjectInstaller())
286
            {
287
                IDictionary state = new Dictionary<object, object>();
288
                installer.Install(state);
289
                ShellExtensionController.SaveState(state);
290 248

  
291
            }
292
        }*/
293 249
    }
294 250
}

Also available in: Unified diff