Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions AxialSqlTools/AxialSqlTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
<DependentUpon>QueryHistoryWindowControl.xaml</DependentUpon>
</Compile>
<Compile Include="QueryHistory\RelayCommand.cs" />
<Compile Include="PivotTable\PivotTableTabManager.cs" />
<Compile Include="SqlServerBuilds\SqlServerBuildsWindow.cs" />
<Compile Include="SqlServerBuilds\SqlServerBuildsWindowCommand.cs" />
<Compile Include="SqlServerBuilds\SqlServerBuildsWindowControl.xaml.cs">
Expand All @@ -155,6 +156,10 @@
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2420.47" />
<PackageReference Include="NReco.PivotData" Version="1.5.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Data.SqlClient">
Expand Down
20 changes: 20 additions & 0 deletions AxialSqlTools/Commands/ResultGridCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public static async Task InitializeAsync(AxialSqlToolsPackage package)
btnControlSelectedHtml.Caption = "HTML";
btnControlSelectedHtml.Click += OnClick_CopySelectedAsHtml;

var btnControlPivot = (CommandBarButton)GridCommandBar.Controls.Add(MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);
btnControlPivot.Visible = true;
btnControlPivot.Caption = "Pivot Table";
btnControlPivot.Click += OnClick_OpenPivotTable;

var btnControlCCN = (CommandBarButton)GridCommandBar.Controls.Add(MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);
btnControlCCN.Visible = true;
btnControlCCN.Caption = "Copy Selected Column Names";
Expand Down Expand Up @@ -132,6 +137,21 @@ private static void OnClick_CopySelectedColumnNames(CommandBarButton Ctrl, ref b
CopyColumnNames(all: false);
}

private static void OnClick_OpenPivotTable(CommandBarButton Ctrl, ref bool CancelDefault)
{
ThreadHelper.ThrowIfNotOnUIThread();

var focusGridControl = GridAccess.GetFocusGridControl();
if (focusGridControl == null)
return;

using (var gridAdaptor = new ResultGridControlAdaptor(focusGridControl))
{
var dataTable = gridAdaptor.GridFocusAsDatatable();
PivotTableTabManager.ShowPivotTab(dataTable);
}
}

private static void OnClick_CopyAllColumnNames(CommandBarButton Ctrl, ref bool CancelDefault)
{
ThreadHelper.ThrowIfNotOnUIThread();
Expand Down
6 changes: 6 additions & 0 deletions AxialSqlTools/Modules/GridAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public static FieldInfo GetNonPublicFieldInfo(object obj, string field)
return obj.GetType().GetField(field, BindingFlags.NonPublic | BindingFlags.Instance);
}

public static object GetTabControl(object obj, string property)
{
if (obj == null) return null;
return obj.GetType().GetProperty(property, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(obj);
}

public static object GetSQLResultsControl()
{
var factoryType = ServiceCache.ScriptFactory.GetType();
Expand Down
Loading