Esempio n. 1
0
        private void CancelSettingsHandler(object o)
        {
            Settings = LastSavedSettings.DeepClone();

            foreach (var syncProfile in Settings.CalendarSyncProfiles)
            {
                syncProfile.IsLoaded = false;
            }

            foreach (var syncProfile in Settings.TaskSyncProfiles)
            {
                syncProfile.IsLoaded = false;
            }

            foreach (var syncProfile in Settings.ContactSyncProfiles)
            {
                syncProfile.IsLoaded = false;
            }

            Init = true;
            MessageService.ShowMessage("Settings cancelled.",
                                       "Settings");
        }
Esempio n. 2
0
        private async void SaveSettings()
        {
            IsLoading     = true;
            SettingsSaved = false;

            Settings.SettingsVersion = ApplicationInfo.Version;

            ApplyProxySettings();
            if (Settings.AppSettings.RunApplicationAtSystemStartup)
            {
                WindowsStartupService.RunAtWindowsStartup();
            }
            else
            {
                WindowsStartupService.RemoveFromWindowsStartup();
            }

            try
            {
                foreach (var calendarSyncProfile in Settings.CalendarSyncProfiles)
                {
                    calendarSyncProfile.SetSourceDestTypes();
                }

                foreach (var calendarSyncProfile in Settings.TaskSyncProfiles)
                {
                    calendarSyncProfile.SetSourceDestTypes();
                }

                foreach (var calendarSyncProfile in Settings.ContactSyncProfiles)
                {
                    calendarSyncProfile.SetSourceDestTypes();
                }

                var result = await SettingsSerializationService.SerializeSettingsAsync(Settings);

                if (result)
                {
                    LastSavedSettings = Settings;
                    Settings          = LastSavedSettings.DeepClone();
                }
                Init = true;
                await MessageService.ShowMessage(result? "Settings Saved Successfully" : "Error Saving Settings",
                                                 "Settings");

                SettingsSaved = true;
            }
            catch (AggregateException exception)
            {
                SettingsSaved = false;
                var flattenException = exception.Flatten();
                MessageService.ShowMessageAsync(flattenException.Message);
            }
            catch (Exception exception)
            {
                SettingsSaved = false;
                MessageService.ShowMessageAsync(exception.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }