Esempio n. 1
0
        private void RestoreFavorites(FavoritesFolder favoritesFolder,
                                      IEnumerable <Folder> folders, IEnumerable <Link> links)
        {
            foreach (var link in links)
            {
                if (link.MessageId != 0)
                {
                    _favManager.AddMessageLink(
                        link.MessageId, link.Comment, favoritesFolder);
                }
                else
                {
                    _favManager.AddUrlLink(
                        link.Url, link.Comment, favoritesFolder);
                }
            }

            foreach (var folder in folders)
            {
                _favManager.AddFolder(folder.Name, folder.Comment, favoritesFolder);

                var parentFolder =
// ReSharper disable AccessToModifiedClosure
                    favoritesFolder.SubFolders.FirstOrDefault(f => f.Name == folder.Name);
// ReSharper restore AccessToModifiedClosure

                if (parentFolder != null)
                {
                    RestoreFavorites(parentFolder, folder.Folders, folder.Links);
                }
            }
        }
Esempio n. 2
0
 public void ExecuteCreateFolder(ICommandContext context)
 {
     using (var pb = new FavoritesFolderForm(string.Empty, string.Empty, true))
         if (pb.ShowDialog(
                 context
                 .GetRequiredService <IUIShell>()
                 .GetMainWindowParent()) == DialogResult.OK)
         {
             var favFormSvc = context.GetRequiredService <IFavoritesDummyFormService>();
             _favManager.AddFolder(
                 pb.FolderName,
                 pb.FolderComment,
                 favFormSvc.SelectedEntries.Any() && !pb.CreateAsRoot
                                                 ? (FavoritesFolder)favFormSvc.SelectedEntries.Single()
                                                 : _favManager.RootFolder);
             favFormSvc.Refresh();
         }
 }
Esempio n. 3
0
        private void CreateFolderButtonClick(object sender, EventArgs e)
        {
            using (var pb = new FavoritesFolderForm(string.Empty, string.Empty, true))
                if (pb.ShowDialog(this) == DialogResult.OK)
                {
                    var activeFolder = _folderView.ActiveNode as FavoritesFolder;
                    if (activeFolder == null || pb.CreateAsRoot)
                    {
                        activeFolder = _favManager.RootFolder;
                    }

                    // TODO: Действия в AddFolder и Reload, приводят к тому,
                    // что добавление первой папки вызывает искючение при установке свойства Nodes дерева.
                    _favManager.AddFolder(pb.FolderName, pb.FolderComment, activeFolder);
                    _favManager.Reload();

                    var folders = _favManager.RootFolder;
                    folders.ShowLinks = false;

                    _folderView.VirtualListSize = folders.Count;
                    _folderView.Nodes           = folders;
                }
        }