Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new XAML option page #10

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/fsharp-highlighting
Submodule fsharp-highlighting added at e9f1af
11 changes: 11 additions & 0 deletions src/FantomasOptionsDialogPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace FantomasVs
{
using Microsoft.VisualStudio.Shell;
using System.Windows;

public class FantomasOptionsDialogPage : UIElementDialogPage
deviousasti marked this conversation as resolved.
Show resolved Hide resolved
{
private FantomasOptionsPage2 _page;
protected override UIElement Child => _page ??= new FantomasOptionsPage2();
}
}
40 changes: 40 additions & 0 deletions src/FantomasOptionsPage2.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<UserControl
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine the page to be some kind of fusion of

Resharper settings:
image

The old C# settings:
image

The new C# settings:
image

x:Class="FantomasVs.FantomasOptionsPage2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid>

<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="2*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<TextBlock
Grid.Row="0"
Text="Displays settings as defined in the .editorconfig or if no settings can be found the user profile's formatting options."
TextWrapping="Wrap" />

<Button
Grid.Row="1"
Margin="0,5"
Padding="5"
HorizontalAlignment="Left"
Content="Generate .editorconfig file from settings" />

<DataGrid Grid.Row="2">
deviousasti marked this conversation as resolved.
Show resolved Hide resolved
<!-- Here goes options -->
</DataGrid>

<Grid Grid.Row="3" Margin="0,5,0,0">
<!-- Here goes code example -->
deviousasti marked this conversation as resolved.
Show resolved Hide resolved
</Grid>

</Grid>
</UserControl>
15 changes: 15 additions & 0 deletions src/FantomasOptionsPage2.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace FantomasVs
{
using System.Windows.Controls;

/// <summary>
/// Interaction logic for FantomasOptionsPage2.xaml
/// </summary>
public partial class FantomasOptionsPage2 : UserControl
{
public FantomasOptionsPage2()
{
InitializeComponent();
}
}
}
12 changes: 12 additions & 0 deletions src/FantomasVs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="ContentTypeNames.cs" />
<Compile Include="FantomasOptionsDialogPage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FantomasOptionsPage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FantomasHandler.cs" />
<Compile Include="FantomasOptionsPage2.xaml.cs">
<DependentUpon>FantomasOptionsPage2.xaml</DependentUpon>
</Compile>
<Compile Include="FantomasWarmUp.cs" />
<Compile Include="PredefinedCommandHandlerNames.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down Expand Up @@ -120,6 +126,12 @@
<Name>Fantomas</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="FantomasOptionsPage2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup>
Expand Down
8 changes: 5 additions & 3 deletions src/FantomasVsPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace FantomasVs
{

// DO NOT REMOVE THIS MAGICAL INCANTATION NO MATTER HOW MUCH VS WARNS YOU OF DEPRECATION
// DO NOT REMOVE THIS MAGICAL INCANTATION NO MATTER HOW MUCH VS WARNS YOU OF DEPRECATION
deviousasti marked this conversation as resolved.
Show resolved Hide resolved
// --------------------------------------------------------------------------------------
[InstalledProductRegistration("F# Formatting", "F# source code formatting using Fantomas.", "0.7", IconResourceID = 400)]
// --------------------------------------------------------------------------------------
Expand All @@ -25,6 +25,7 @@ namespace FantomasVs

// Options page
[ProvideOptionPage(typeof(FantomasOptionsPage), "F# Tools", "Formatting", 0, 0, supportsAutomation: true)]
[ProvideOptionPage(typeof(FantomasOptionsDialogPage), "F# Tools", "Formatting 2", 0, 0, supportsAutomation: true)]

public sealed partial class FantomasVsPackage : AsyncPackage
{
Expand All @@ -37,6 +38,7 @@ public sealed partial class FantomasVsPackage : AsyncPackage
public static Task<FantomasVsPackage> Instance => _instance.Task;

public FantomasOptionsPage Options => GetDialogPage(typeof(FantomasOptionsPage)) as FantomasOptionsPage ?? new FantomasOptionsPage();
public FantomasOptionsDialogPage Options2 => GetDialogPage(typeof(FantomasOptionsDialogPage)) as FantomasOptionsDialogPage ?? new FantomasOptionsDialogPage();

public IComponentModel MefHost { get; private set; }

Expand All @@ -52,12 +54,12 @@ public sealed partial class FantomasVsPackage : AsyncPackage
/// <param name="progress">A provider for progress updates.</param>
/// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
{
Trace.WriteLine("Fantomas Vs Package Loaded");

MefHost = await this.GetServiceAsync<SComponentModel, IComponentModel>();
Statusbar = await this.GetServiceAsync<SVsStatusbar, IVsStatusbar>();

// signal that package is ready
_instance.SetResult(this);

Expand Down