Ejemplo n.º 1
0
        public void AddToFavorites(V viewModel, bool global)
        {
            FavoriteViewModel <T> favViewModel = Provider.CreateFavoriteViewModel(viewModel);

            favViewModel.FavoriteID       = -1;
            favViewModel.FavoriteParentID = 0;
            favViewModel.Model.IsGlobal   = global;
            favViewModel.Username         = User.Username;

            Populate();

            if (global)
            {
                _globalRoot.IsExpanded = true;
                _globalRoot.Children.Add(favViewModel);
                favViewModel.Parent = _globalRoot;
            }
            else
            {
                _userRoot.IsExpanded = true;
                _userRoot.Children.Add(favViewModel);
                favViewModel.Parent = _userRoot;
            }

            viewModel.IsSelected = true;

            RegisterPendingChange(Provider.GetInsertAction(favViewModel));
        }
Ejemplo n.º 2
0
        internal void RenameFavoriteGroup(FavoriteViewModel <T> fav)
        {
            if (fav == null)
            {
                return;
            }

            fav.IsSelected = true;
            fav.IsRenaming = true;
        }
Ejemplo n.º 3
0
        private void DeleteFavoriteGroup(FavoriteViewModel <T> favorite)
        {
            if (favorite == null)
            {
                return;
            }

            if (favorite.IsDeleted)
            {
                return;
            }

            favorite.IsDeleted = true;
            RegisterUniquePendingChange(new DeleteFavoriteCommand(favorite.FavoriteID));
        }
Ejemplo n.º 4
0
        internal void AddFavoriteGroup(HierarchicalViewModelBase parent)
        {
            int parentGroupID = 0;

            if (parent == null)
            {
                return;
            }

            bool?isGlobal = false;

            if (parent is ViewModelPlaceholder)
            {
                var pvm = parent as ViewModelPlaceholder;
                if (pvm.Tag != null)
                {
                    isGlobal = (bool?)(pvm).Tag;
                }
            }
            else if (parent is FavoriteViewModel <T> )
            {
                var parentViewModel = parent as FavoriteViewModel <T>;
                isGlobal      = parentViewModel.IsGlobal;
                parentGroupID = parentViewModel.FavoriteID;
            }

            T model = new T();

            model.IsGroup          = true;
            model.GroupName        = "<New Folder>";
            model.IsGlobal         = isGlobal.HasValue && isGlobal.Value;
            model.FavoriteParentID = parentGroupID;

            FavoriteViewModel <T> viewModel = Provider.CreateFavoriteViewModel(model);

            viewModel.Parent     = parent;
            viewModel.IsSelected = true;

            parent.Children.Add(viewModel);


            RegisterUniquePendingChange(new InsertFavoriteGroupCommand(model));
            viewModel.IsRenaming = true;
        }