private async void CreateProfile() { if (SyncProfileList.Count > 4) { MessageService.ShowMessageAsync("You have reached the maximum number of profiles."); return; } var result = await MessageService.ShowInput("Please enter profile name."); if (!string.IsNullOrEmpty(result)) { if (SyncProfileList.Any(t => !string.IsNullOrEmpty(t.Name) && t.Name.Equals(result))) { MessageService.ShowMessageAsync( string.Format("A Profile with name '{0}' already exists. Please try again.", result)); return; } var syncProfile = CalendarSyncProfile.GetDefaultSyncProfile(); syncProfile.Name = result; syncProfile.IsDefault = false; var viewModel = new ProfileViewModel(syncProfile, GoogleCalendarService, OutlookCalendarService, MessageService, ExchangeWebCalendarService, ApplicationLogger, AccountAuthenticationService); PropertyChangedEventManager.AddHandler(viewModel, ProfilePropertyChangedHandler, "IsLoading"); viewModel.Initialize(null); SyncProfileList.Add(viewModel); } }
private void MoveProfileDown(object parameter) { var profile = parameter as ProfileViewModel; if (profile != null) { var index = SyncProfileList.IndexOf(profile); if (index < SyncProfileList.Count - 1) { SyncProfileList.Move(index, index + 1); } } }
private void MoveProfileUp(object parameter) { var profile = parameter as ProfileViewModel; if (profile != null) { var index = SyncProfileList.IndexOf(profile); if (index > 0) { SyncProfileList.Move(index, index - 1); } } }
private async void DeleteProfile(object parameter) { var profile = parameter as ProfileViewModel; if (profile != null) { var task = await MessageService.ShowConfirmMessage("Are you sure you want to delete the profile?"); if (task == MessageDialogResult.Affirmative) { SyncProfileList.Remove(profile); PropertyChangedEventManager.RemoveHandler(profile, ProfilePropertyChangedHandler, "IsLoading"); SelectedProfile = SyncProfileList.FirstOrDefault(); } } }
private void LoadProfiles() { var profileList = new ObservableCollection <ProfileViewModel>(); foreach (var syncProfile in Settings.SyncProfiles) { var viewModel = new ProfileViewModel(syncProfile, GoogleCalendarService, OutlookCalendarService, MessageService, ExchangeWebCalendarService, ApplicationLogger, AccountAuthenticationService); PropertyChangedEventManager.AddHandler(viewModel, ProfilePropertyChangedHandler, "IsLoading"); var googleAccount = GetGoogleAccount(syncProfile); viewModel.Initialize(googleAccount); profileList.Add(viewModel); } SyncProfileList = profileList; SelectedProfile = SyncProfileList.FirstOrDefault(); }