private void InPlaceEditPropertyName(SettingsStoreProperty property, IVsWritableSettingsStore settingsStore) { _control.InPlaceEditListViewItem(property, property.Name, newName => { ThreadHelper.ThrowIfNotOnUIThread(); // Allow renaming to blank to support the (Default) value, but only for strings. if (newName.Length == 0 && property.Type != __VsSettingsType.SettingsType_String) { ShowErrorMessage("Error renaming property", "Only a string property may have a blank name. Try again with a different name."); return; } // Check for duplicate names. if (settingsStore.PropertyExists(property.CollectionPath, newName)) { var message = newName.Length == 0 ? "There is already a (Default) property. Delete it first and try again or use a different name." : $"There is already a property called '{newName}'. Try again with a different name."; ShowErrorMessage("Error renaming property", message); return; } // Clone the property then delete the original. settingsStore.CopyProperty(property, newName); ErrorHandler.ThrowOnFailure(settingsStore.DeleteProperty(property.CollectionPath, property.Name)); // Update the view model (keeping the selection the same) property.Rename(newName); Telemetry.Client.TrackEvent("RenameProperty"); }); }
public bool Exists(string name) { int exists; _writableSettingsStore.CollectionExists(_collectionName, out exists); if (exists == 0) { return(false); } _writableSettingsStore.PropertyExists(_collectionName, name, out exists); return(exists == 1); }
private void InPlaceEditPropertyName(SettingsStoreProperty property, IVsWritableSettingsStore settingsStore) { _control.InPlaceEditListViewItem(property, property.Name, newName => { ThreadHelper.ThrowIfNotOnUIThread(); // Allow renaming to blank to support the (Default) value, but only for strings. if (newName.Length == 0 && property.Type != __VsSettingsType.SettingsType_String) { var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(0, Guid.Empty, "Error renaming property", "Only a string property may have a blank name. Try again with a different name.", null, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_CRITICAL, 0, out int result)); return; } // Check for duplicate names. if (settingsStore.PropertyExists(property.CollectionPath, newName)) { var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); var message = newName.Length == 0 ? "There is already a (Default) property. Delete it first and try again or use a different name." : $"There is already a property called '{newName}'. Try again with a different name."; ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(0, Guid.Empty, "Error renaming property", message, null, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_CRITICAL, 0, out int result)); return; } // Clone the property then delete the original. settingsStore.CopyProperty(property, newName); ErrorHandler.ThrowOnFailure(settingsStore.DeleteProperty(property.CollectionPath, property.Name)); // Update the view model (keeping the selection the same) property.Rename(newName); Telemetry.Client.TrackEvent("RenameProperty"); }); }