示例#1
0
 /// <summary>
 /// Uploads profiles from local store.
 /// </summary>
 static public void LoadProfiles()
 {
     LoadEmptyProfiles();
     if (File.Exists(syncProfilesStore))
     {
         string[] syncProfilesArray = File.ReadAllLines(syncProfilesStore);
         foreach (var profile in syncProfilesArray)
         {
             string[] substrings = profile.Split('|');
             AvailableProfilesList.Add(new SyncProfile(substrings[0], substrings[1], substrings[2]));
         }
     }
 }
示例#2
0
        /// <summary>
        /// Deletes profile with entered name and saves changes in local store.
        /// </summary>
        static public void DeleteProfile(string name)
        {
            for (int i = 0; i < AvailableProfilesList.Count; i++)
            {
                if (AvailableProfilesList[i].ProfileName == name)
                {
                    AvailableProfilesList.RemoveAt(i);
                }
            }

            File.Delete(syncProfilesStore);
            foreach (var item in AvailableProfilesList)
            {
                SaveProfile(item);
            }
        }
示例#3
0
 /// <summary>
 /// Validates input name and folder to avoid the similar profiles.
 /// </summary>
 static bool CheckInputData(SyncProfile newProfile, Activity currentActivity)
 {
     if (newProfile.ProfileName == "" || newProfile.ProfileSyncFolderPath == "")
     {
         MessageDisplayer.ShowAlertMessage(currentActivity, "Ошибка добавления профиля",
                                           "Попытка создать профиль с пустым именем и/или пустым каталогом.");
         return(false);
     }
     else
     {
         if (AvailableProfilesList.Count != 0)
         {
             if (AvailableProfilesList.Any(profile => profile.ProfileName == newProfile.ProfileName))
             {
                 MessageDisplayer.ShowAlertMessage(currentActivity, "Ошибка добавления профиля",
                                                   "Профиль с введеным именем уже существует.Пожалуйста, введите другое имя.");
                 return(false);
             }
             else if (AvailableProfilesList.Any(profile => profile.ProfileSyncFolderPath == newProfile.ProfileSyncFolderPath))
             {
                 MessageDisplayer.ShowAlertMessage(currentActivity, "Ошибка добавления профиля",
                                                   "Профиль с выбранным каталогом уже существует.Пожалуйста, выберите другой каталог.");
                 return(false);
             }
             else
             {
                 SaveProfile(newProfile);
                 return(true);
             }
         }
         else
         {
             SaveProfile(newProfile);
             return(true);
         }
     }
 }