|
| 1 | +namespace Microsoft.VisualStudio.FSharp.Editor |
| 2 | + |
| 3 | +open System.ComponentModel.Composition |
| 4 | +open System.Runtime.InteropServices |
| 5 | + |
| 6 | +open Microsoft.VisualStudio.FSharp.UIResources |
| 7 | +open SettingsPersistence |
| 8 | +open OptionsUIHelpers |
| 9 | + |
| 10 | +// CLIMutable to make the record work also as a view model |
| 11 | +[<CLIMutable>] |
| 12 | +type IntelliSenseOptions = |
| 13 | + { ShowAfterCharIsTyped: bool |
| 14 | + ShowAfterCharIsDeleted: bool } |
| 15 | + |
| 16 | +[<RequireQualifiedAccess>] |
| 17 | +type QuickInfoUnderlineStyle = Dot | Dash | Solid |
| 18 | + |
| 19 | +// autoproperties can be used to both define defaults and faciliate data binding in WPF controls, |
| 20 | +// but the type should otherwise be treated as immutable. |
| 21 | +type QuickInfoOptions() = |
| 22 | + member val DisplayLinks = true with get, set |
| 23 | + member val UnderlineStyle = QuickInfoUnderlineStyle.Solid with get, set |
| 24 | + |
| 25 | +[<Export(typeof<ISettings>)>] |
| 26 | +type internal Settings [<ImportingConstructor>](store: SettingsStore) = |
| 27 | + do // Initialize default settings |
| 28 | + |
| 29 | + { ShowAfterCharIsTyped = true |
| 30 | + ShowAfterCharIsDeleted = false } |
| 31 | + |> store.RegisterDefault |
| 32 | + |
| 33 | + QuickInfoOptions() |
| 34 | + |> store.RegisterDefault |
| 35 | + |
| 36 | + interface ISettings |
| 37 | + |
| 38 | + static member IntelliSense : IntelliSenseOptions = getSettings() |
| 39 | + static member QuickInfo : QuickInfoOptions = getSettings() |
| 40 | + |
| 41 | +module internal OptionsUI = |
| 42 | + |
| 43 | + [<Guid(Guids.intelliSenseOptionPageIdString)>] |
| 44 | + type internal IntelliSenseOptionPage() = |
| 45 | + inherit AbstractOptionPage<IntelliSenseOptions>() |
| 46 | + override this.CreateView() = |
| 47 | + let view = IntelliSenseOptionControl() |
| 48 | + view.charTyped.Unchecked.Add <| fun _ -> view.charDeleted.IsChecked <- System.Nullable false |
| 49 | + upcast view |
| 50 | + |
| 51 | + [<Guid(Guids.quickInfoOptionPageIdString)>] |
| 52 | + type internal QuickInfoOptionPage() = |
| 53 | + inherit AbstractOptionPage<QuickInfoOptions>() |
| 54 | + override this.CreateView() = |
| 55 | + let view = QuickInfoOptionControl() |
| 56 | + let path = "UnderlineStyle" |
| 57 | + bindRadioButton view.solid path QuickInfoUnderlineStyle.Solid |
| 58 | + bindRadioButton view.dot path QuickInfoUnderlineStyle.Dot |
| 59 | + bindRadioButton view.dash path QuickInfoUnderlineStyle.Dash |
| 60 | + bindCheckBox view.displayLinks "DisplayLinks" |
| 61 | + upcast view |
0 commit comments