Пример #1
0
        public void DeleteCollection(string collection)
        {
            NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                _store.DeleteCollection(collection);
            });
        }
Пример #2
0
        /// <summary>
        /// Save a list of UIContext items in the settings store.
        /// </summary>
        /// <param name="settingsStore"></param>
        /// <param name="list"></param>
        /// <param name="name"></param>
        private void SaveContextIDList(IVsWritableSettingsStore settingsStore, ObservableCollection <UIContextInformation> list, string name)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            string collectionRoot = SettingsRoot + "\\" + name;

            // rewrite the collection
            settingsStore.DeleteCollection(collectionRoot);
            settingsStore.CreateCollection(collectionRoot);

            for (int iContext = 0; iContext < list.Count; iContext++)
            {
                string guidString = list[iContext].Guid.ToString();
                settingsStore.SetString(collectionRoot, guidString, list[iContext].Name);
            }
        }
        private void InPlaceEditSubCollectionName(SettingsStoreSubCollection subCollection, IVsWritableSettingsStore settingsStore)
        {
            _control.InPlaceEditTreeViewItem(subCollection, subCollection.Name, newName =>
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                if (newName.Length == 0)
                {
                    var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                    ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(0, Guid.Empty, "Error renaming collection", $"A collection name cannot be blank. Try again with a different name.", null, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_CRITICAL, 0, out int result));
                    return;
                }

                if (newName.IndexOfAny(s_invalidCollectionNameChars) >= 0)
                {
                    var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                    ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(0, Guid.Empty, "Error renaming collection", $"A collection name cannot contain a backslash character (\\). Try again with a different name.", null, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_CRITICAL, 0, out int result));
                    return;
                }

                // Create a sibling and check for duplicate names.
                var parent = subCollection.Parent;
                var renamedSubCollection = new SettingsStoreSubCollection(parent, newName);
                if (settingsStore.CollectionExists(renamedSubCollection.Path))
                {
                    var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                    ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(0, Guid.Empty, "Error renaming collection", $"There is already a collection called '{newName}'. Try again with a different name.", null, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_CRITICAL, 0, out int result));
                    return;
                }

                // Clone and recreate the entire tree beneath this collection and then delete the original.
                ErrorHandler.ThrowOnFailure(settingsStore.CreateCollection(renamedSubCollection.Path));
                settingsStore.CopyTree(subCollection, renamedSubCollection);
                ErrorHandler.ThrowOnFailure(settingsStore.DeleteCollection(subCollection.Path));

                // Update the view model.
                subCollection.Rename(newName);

                // Select the newly-renamed sub-collection.
                _control.SetTreeViewSelection(subCollection);

                Telemetry.Client.TrackEvent("RenameSubCollection");
            });
        }
Пример #4
0
 public void DeleteCollection(string collection)
 {
     _store.DeleteCollection(collection);
 }
 public void Reset()
 {
     _settingsStore.DeleteCollection(SettingsRoot);
 }