提交 2c0695d8 编写于 作者: B Balaji Krishnan

Code style preview: when no codestyle..

.. is selected, use the first codestyle to show a preview.
上级 fdcd79a1
...@@ -20,8 +20,6 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options.Formatting ...@@ -20,8 +20,6 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options.Formatting
/// </remarks> /// </remarks>
internal class StyleViewModel : AbstractOptionPreviewViewModel internal class StyleViewModel : AbstractOptionPreviewViewModel
{ {
public ObservableCollection<AbstractCodeStyleOptionViewModel> CodeStyleItems { get; set; }
internal override bool ShouldPersistOption(OptionKey key) internal override bool ShouldPersistOption(OptionKey key)
{ {
return key.Option.Feature == CSharpCodeStyleOptions.FeatureName || key.Option.Feature == SimplificationOptions.PerLanguageFeatureName; return key.Option.Feature == CSharpCodeStyleOptions.FeatureName || key.Option.Feature == SimplificationOptions.PerLanguageFeatureName;
...@@ -168,8 +166,6 @@ void foo() ...@@ -168,8 +166,6 @@ void foo()
internal StyleViewModel(OptionSet optionSet, IServiceProvider serviceProvider) : base(optionSet, serviceProvider, LanguageNames.CSharp) internal StyleViewModel(OptionSet optionSet, IServiceProvider serviceProvider) : base(optionSet, serviceProvider, LanguageNames.CSharp)
{ {
CodeStyleItems = new ObservableCollection<AbstractCodeStyleOptionViewModel>();
var collectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(CodeStyleItems); var collectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(CodeStyleItems);
collectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AbstractCodeStyleOptionViewModel.GroupName))); collectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AbstractCodeStyleOptionViewModel.GroupName)));
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
...@@ -39,6 +40,7 @@ internal abstract class AbstractOptionPreviewViewModel : AbstractNotifyPropertyC ...@@ -39,6 +40,7 @@ internal abstract class AbstractOptionPreviewViewModel : AbstractNotifyPropertyC
private IContentTypeRegistryService _contentTypeRegistryService; private IContentTypeRegistryService _contentTypeRegistryService;
public List<object> Items { get; set; } public List<object> Items { get; set; }
public ObservableCollection<AbstractCodeStyleOptionViewModel> CodeStyleItems { get; set; }
public OptionSet Options { get; set; } public OptionSet Options { get; set; }
...@@ -46,6 +48,7 @@ protected AbstractOptionPreviewViewModel(OptionSet options, IServiceProvider ser ...@@ -46,6 +48,7 @@ protected AbstractOptionPreviewViewModel(OptionSet options, IServiceProvider ser
{ {
this.Options = options; this.Options = options;
this.Items = new List<object>(); this.Items = new List<object>();
this.CodeStyleItems = new ObservableCollection<AbstractCodeStyleOptionViewModel>();
_componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); _componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // 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;
using System.Linq;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Options;
...@@ -56,9 +57,8 @@ internal override void LoadSettings() ...@@ -56,9 +57,8 @@ internal override void LoadSettings()
{ {
this.ViewModel = _createViewModel(this.OptionService.GetOptions(), _serviceProvider); this.ViewModel = _createViewModel(this.OptionService.GetOptions(), _serviceProvider);
// TODO: Use the first item's preview. This doesn't work yet. var firstItem = this.ViewModel.CodeStyleItems.OfType<AbstractCodeStyleOptionViewModel>().First();
// var firstItem = this.ViewModel.Items.OfType<AbstractCodeStyleOptionViewModel>().First(); this.ViewModel.SetOptionAndUpdatePreview(firstItem.SelectedPreference.IsChecked, firstItem.Option, firstItem.GetPreview());
// this.ViewModel.SetOptionAndUpdatePreview(firstItem.SelectedPreference.IsChecked, firstItem.Option, firstItem.GetPreview());
DataContext = ViewModel; DataContext = ViewModel;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册