Example #1
0
 private void Favorite(string key)
 {
     if (EditViewModel.CurrentItem != null)
     {
         var item = new FavoriteItem(EditViewModel.CurrentItem.Name, EditViewModel.CurrentItem.Url);
         if (IsAddFavorite)
         {
             if (Settings.Properties.Contains(key))
             {
                 Settings.Properties[key] = item;
             }
             else
             {
                 Settings.Properties.Add(key, item);
             }
             FavoriteButtonIconPath = Settings.ResourcePath + "white.png";
             IsAddFavorite          = false;
         }
         else
         {
             if (Settings.Properties.Contains(key))
             {
                 item = (FavoriteItem)Settings.Properties[key];
                 EditViewModel.CurrentItem.Name = item.Name;
                 EditViewModel.CurrentItem.Url  = item.Url;
             }
         }
         if (FindTreeNode(item.Url))
         {
             HasPlayed = false;
             Play(null);
         }
     }
 }
Example #2
0
 static Settings()
 {
     string[] tokens;
     Properties = new Hashtable();
     if (File.Exists(settingsPath))
     {
         foreach (string line in File.ReadAllLines(settingsPath))
         {
             tokens = line.Split('=');
             if (tokens.Length > 1)
             {
                 string key = tokens[0].TrimEnd();
                 string val = tokens[1].TrimStart();
                 if (key.StartsWith("Favorite"))
                 {
                     int idx = val.IndexOf(';');
                     if (idx != -1)
                     {
                         var fi = new FavoriteItem(val.Substring(0, idx), val.Substring(idx + 1));
                         readProps.Add(key, fi);
                         Properties.Add(key, fi);
                     }
                 }
                 else
                 {
                     readProps.Add(key, val);         // to avoid unnecessary write operations
                     Properties.Add(key, val);
                 }
             }
         }
     }
 }