Example #1
0
        private IObservable<Tuple<Settings, IList<string>>> GetRepositoriesObservable(object _)
        {
            var user = UserName;
            var pass = Password;
            if (string.IsNullOrWhiteSpace(user) || string.IsNullOrWhiteSpace(pass))
            {
                // Invalid Argument
                return Observable.Empty<Tuple<Settings, IList<string>>>();
            }

            var settings = new Settings()
            {
                UserName = user,
                Password = pass
            };

            return Repository.GetRepositories(settings.ToCreds())
                .Select(repos => repos.ToList() as IList<string>)
                .Do(list => list.Insert(0, NoRepo))
                .Select(list => Tuple.Create(settings, list));
        }
Example #2
0
 public void SaveSettingsToFile(string filePath, Settings s)
 {
     using (var iso = IsolatedStorageFile.GetUserStoreForApplication())
     {
         if (s == null)
         {
             if (iso.FileExists(filePath))
             {
                 iso.DeleteFile(filePath);
             }
         }
         else
         {
             using (var settingsFile = iso.OpenFile(filePath, FileMode.Create))
             {
                 SettingsSerializer.Serialize(settingsFile, s);
             }
         }
     }
 }
Example #3
0
 public void SaveSettings(Settings settings)
 {
     _SettingsIn.OnNext(settings);
 }
Example #4
0
        private Settings PersistSettings(Settings s)
        {
            var settingsPath = GetSettingsPath();

            SaveSettingsToFile(settingsPath, s);

            return s;
        }
Example #5
0
 private void SetLogin(Settings settings)
 {
     if (settings != null)
     {
         this.UserName = settings.UserName;
         this.Password = settings.Password;
     }
 }
Example #6
0
        public SettingsVM(
            ISettingsService Settings,
            ICleanupData Cleanup,
            IConnectivityService Connectivity
            )
        {
            this.Cleanup = Cleanup;
            this.Settings = Settings;
            this.Connectivity = Connectivity;

            this.WhenAny(x => x.Model, x => x.Value)
                .Where(x => x != null)
                .Select(m => m.UseGPS)
                .Subscribe(x => UseGPS = x);

            Reset = new ReactiveAsyncCommand(Connectivity.WifiAvailable());

            Reset.RegisterAsyncTask(OnReset);

            var setting_changed =
                this.WhenAny(x => x.UseGPS, x => x.Model,
                    (gps, model) => (model.Value != null) ? model.Value.UseGPS != gps.Value : false);

            Save = new ReactiveCommand(setting_changed);
            Messenger.RegisterMessageSource(
                Save
                .Do(_ => saveModel())
                .Select(_ => Page.Previous)
                );

            RefreshVocabulary = new ReactiveCommand(Connectivity.WifiAvailable());
            RefreshVocabulary
                .Subscribe(_ =>
                {
                    Messenger.SendMessage(Page.SetupVocabulary);
                });

            ManageTaxa = new ReactiveCommand();
            Messenger.RegisterMessageSource(
                ManageTaxa
                .Select(_ => Page.TaxonManagement)
                );

            UploadData = new ReactiveCommand();
            Messenger.RegisterMessageSource(
                UploadData
                .Select(_ => Page.Upload)
                );

            DownloadData = new ReactiveCommand();
            Messenger.RegisterMessageSource(
                DownloadData
                .Select(_ => Page.Download)
                );

            Info = new ReactiveCommand();
            Messenger.RegisterMessageSource(
                Info
                .Select(_ => Page.Info)
                );

            ImportExport = new ReactiveCommand();
            Messenger.RegisterMessageSource(
                ImportExport
                .Select(_ => Page.ImportExport)
                );

            Settings
                .SettingsObservable()
                .Subscribe(x => Model = x);
        }
Example #7
0
 private string GetSnapshotPath(Settings Settings)
 {
     return string.Format("{0}/{1}-{2}", SNAPSHOTS_DIRECTORY, Settings.UserName, DateTime.Now.ToFileTimeStamp());
 }
Example #8
0
 private Snapshot SnapshotFromSettingsAndTime(Settings Settings, DateTime TimeTaken, string SnapshotDir)
 {
     return new Snapshot()
     {
         UserName = Settings.UserName,
         ProjectName = Settings.CurrentProjectName,
         TimeTaken = TimeTaken,
         FolderPath = SnapshotDir
     };
 }