private void SaveChanges() { string user = UserBox.Text; if (string.IsNullOrEmpty(user)) { MessageBoxResult result = MessageBox.Show("No ha indicado ningún nombre de usuario.\n\n" + "Mientras no lo haga, no podrá acceder a ningún disco de red de la UPV.\n\n" + "¿Desea continuar?", "Ningún nombre de usuario", MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (result != MessageBoxResult.OK) { throw new OperationCanceledException(); } user = null; // Avoids the user being an empty string (it causes problems) } Service.User = user; VPNToUPVPrefs.Save(); VPNToDSICPrefs.Save(); DiscoWPrefs.Save(); AsigDSICPrefs.Save(); DiscoDSICPrefs.Save(); Service.Asig_DSIC.Password = Service.Disco_DSIC.Password; foreach (RadioButton domain in DomainsUPV.Children) { if (domain.IsChecked ?? false) { Service.Disco_W.Domain = (UPVDomain)domain.Tag; break; } } Service.NotifyIcon = NotifyIconCheckBox.IsChecked ?? false; Service.StartMinimized = StartMinimizedCheckBox.IsChecked ?? false; Service.SaveChanges(); }
private void Load() { UserBox.Text = Service.User; VPNToUPVPrefs.Load(); VPNToDSICPrefs.Load(); DiscoWPrefs.Load(); AsigDSICPrefs.Load(); DiscoDSICPrefs.Load(); foreach (RadioButton domain in DomainsUPV.Children) { if (Service.Disco_W.Domain.Equals((UPVDomain)domain.Tag)) { domain.IsChecked = true; break; } } NotifyIconCheckBox.IsChecked = Service.NotifyIcon; }