コード例 #1
0
        public static void ShowModifyPropertyDialog(SettingsStoreProperty property, IVsWritableSettingsStore writableStore)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            switch (property.Type)
            {
            case __VsSettingsType.SettingsType_String:
            {
                Telemetry.Client.TrackPageView(nameof(EditStringDialog));
                var dialog = new EditStringDialog(property);
                if (dialog.ShowModal() == true)
                {
                    ErrorHandler.ThrowOnFailure(writableStore.SetString(property.CollectionPath, property.Name, (string)property.Value));
                    Telemetry.Client.TrackEvent("PropertyModified", new Dictionary <string, string> {
                            ["Type"] = property.Type.ToString()
                        });
                }
            }
            break;

            case __VsSettingsType.SettingsType_Int:
            {
                Telemetry.Client.TrackPageView(nameof(EditIntegerDialog) + "(32)");
                var dialog = new EditIntegerDialog("Edit DWORD (32-bit) Value", DwordToStringConverter.Instance, property);
                if (dialog.ShowModal() == true)
                {
                    ErrorHandler.ThrowOnFailure(writableStore.SetUnsignedInt(property.CollectionPath, property.Name, (uint)property.Value));
                    Telemetry.Client.TrackEvent("PropertyModified", new Dictionary <string, string> {
                            ["Type"] = property.Type.ToString()
                        });
                }
            }
            break;

            case __VsSettingsType.SettingsType_Int64:
            {
                Telemetry.Client.TrackPageView(nameof(EditIntegerDialog) + "(64)");
                var dialog = new EditIntegerDialog("Edit QWORD (64-bit) Value", QwordToStringConverter.Instance, property);
                if (dialog.ShowModal() == true)
                {
                    ErrorHandler.ThrowOnFailure(writableStore.SetUnsignedInt64(property.CollectionPath, property.Name, (ulong)property.Value));
                    Telemetry.Client.TrackEvent("PropertyModified", new Dictionary <string, string> {
                            ["Type"] = property.Type.ToString()
                        });
                }
            }
            break;

            case __VsSettingsType.SettingsType_Binary:
            {
                Telemetry.Client.TrackPageView(nameof(EditBinaryDialog));
                var dialog = new EditBinaryDialog(property);
                if (dialog.ShowModal() == true)
                {
                    var binary = (byte[])property.Value;
                    ErrorHandler.ThrowOnFailure(writableStore.SetBinary(property.CollectionPath, property.Name, (uint)binary.Length, binary));
                    Telemetry.Client.TrackEvent("PropertyModified", new Dictionary <string, string> {
                            ["Type"] = property.Type.ToString()
                        });
                }
            }
            break;

            default:
                break;
            }
        }