提交 1787cff1 编写于 作者: H Heejae Chang 提交者: GitHub

Merge pull request #15946 from heejaechang/oopOptions

added navigate to, FAR OOP options to Roslyn Option page
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Editor.Shared.Options;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.NavigateTo;
using Microsoft.CodeAnalysis.SymbolSearch;
using Microsoft.VisualStudio.LanguageServices;
using Microsoft.VisualStudio.LanguageServices.Implementation.Options;
using Roslyn.Utilities;
namespace Roslyn.VisualStudio.DiagnosticsWindow.OptionsPages
{
......@@ -36,19 +30,28 @@ public InternalFeaturesOptionsControl(string featureOptionName, IServiceProvider
protected override void AddOptions(Panel panel)
{
// add force low memory mode option
var group = new WrapPanel();
var lowMemoryGroup = new WrapPanel();
var cb = new CheckBox { Content = "Forced Low Memory Mode: allocate" };
BindToOption(cb, ForceLowMemoryMode.Enabled);
group.Children.Add(cb);
lowMemoryGroup.Children.Add(cb);
var textBox = new TextBox { MinWidth = 60 };
BindToOption(textBox, ForceLowMemoryMode.SizeInMegabytes);
group.Children.Add(textBox);
lowMemoryGroup.Children.Add(textBox);
group.Children.Add(new TextBlock { Text = "megabytes of extra memory in devenv.exe" });
lowMemoryGroup.Children.Add(new TextBlock { Text = "megabytes of extra memory in devenv.exe" });
panel.Children.Add(group);
panel.Children.Add(lowMemoryGroup);
// add OOP feature options
var oopFeatureGroup = new StackPanel();
AddOption(oopFeatureGroup, NavigateToOptions.OutOfProcessAllowed, nameof(NavigateToOptions));
AddOption(oopFeatureGroup, SymbolFinderOptions.OutOfProcessAllowed, nameof(SymbolFinderOptions));
AddOption(oopFeatureGroup, SymbolSearchOptions.OutOfProcessAllowed, nameof(SymbolSearchOptions));
panel.Children.Add(oopFeatureGroup);
// and add the rest of the options
base.AddOptions(panel);
......
......@@ -59,36 +59,36 @@ protected virtual void AddOptions(Panel panel)
}
}
private void AddOption(Panel panel, IOption option)
protected void AddOption(Panel panel, IOption option, string additional = null)
{
var uiElement = CreateControl(option);
var uiElement = CreateControl(option, additional: additional);
if (uiElement != null)
{
panel.Children.Add(uiElement);
}
}
private void AddPerLanguageOption(Panel panel, IOption option, string languageName)
protected void AddPerLanguageOption(Panel panel, IOption option, string languageName, string additional = null)
{
var uiElement = CreateControl(option, languageName);
var uiElement = CreateControl(option, languageName, additional);
if (uiElement != null)
{
panel.Children.Add(uiElement);
}
}
private UIElement CreateControl(IOption option, string languageName = null)
private UIElement CreateControl(IOption option, string languageName = null, string additional = null)
{
if (option.Type == typeof(bool))
{
var checkBox = new CheckBox() { Content = option.Name + GetLanguage(languageName) };
var checkBox = new CheckBox() { Content = option.Name + GetLanguage(languageName) + GetAdditionalText(additional) };
BindToCheckBox(checkBox, option, languageName);
return checkBox;
}
if (option.Type == typeof(int))
{
var label = new Label() { Content = option.Name + GetLanguage(languageName) };
var label = new Label() { Content = option.Name + GetLanguage(languageName) + GetAdditionalText(additional) };
var textBox = new TextBox();
BindToTextBox(textBox, option, languageName);
......@@ -102,6 +102,16 @@ private UIElement CreateControl(IOption option, string languageName = null)
return null;
}
private string GetAdditionalText(string additional)
{
if (additional == null)
{
return string.Empty;
}
return " [" + additional + "]";
}
private string GetLanguage(string languageName)
{
if (languageName == null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册