示例#1
0
        public static void Move(FavoriteHolder rel, FavoriteHolder moved, FavoriteHolder newCopy, int d)
        {
            var items = LoadGroup(rel.Group);

            int idx    = items.IndexOfIf(h => String.Compare(h.Name, rel.Name, true) == 0);
            int movidx = items.IndexOfIf(h => String.Compare(h.Name, moved.Name, true) == 0);

            if (idx < 0)
            {
                items.RemoveAt(movidx);
                items.Insert(0, newCopy);
            }
            else if (idx + d >= items.Count)
            {
                items.RemoveAt(movidx);
                items.Add(newCopy);
            }
            else
            {
                items.RemoveAt(movidx);
                if (idx >= movidx)
                {
                    idx--;
                }
                items.Insert(idx + d, newCopy);
            }

            SaveGroup(items);
        }
示例#2
0
 public FavoriteItemTreeNode(ITreeNode parent, IFileHandler fhandler, FavoriteHolder favorite)
     : base(parent, fhandler)
 {
     m_favorite = favorite;
     SetAppObject(new FavoriteAppObject {
         FileName = favorite.File
     });
 }
示例#3
0
        //public void LoadFrom(IFavorite favorite)
        //{
        //    tbxName.Text = favorite.Name;
        //    if (!String.IsNullOrEmpty(favorite.Group))
        //    {
        //        var grp = Favorites.Instance.Groups.Find(g => g.Name == favorite.Name);
        //        if (grp != null) cbxCategory.SelectedIndex = cbxCategory.Items.IndexOf(grp);
        //    }
        //}

        public FavoriteHolder GetHolder()
        {
            string group = ((FavoriteGroup)cbxCategory.SelectedItem).Name;
            string fn    = Path.Combine(Path.Combine(Core.FavoritesDirectory, group), FavoriteName + ".fav");
            var    res   = new FavoriteHolder(fn, group);

            res.Favorite = m_favorite;
            return(res);
        }
示例#4
0
        public static void AddFirst(FavoriteHolder fav)
        {
            var items = LoadGroup(fav.Group);

            if (items.Count > 0)
            {
                fav.Position = items[0].Position - 1;
            }
            fav.Save();
        }