Files
Sharepoint-Toolbox/SharepointToolbox/Views/Tabs/StorageView.xaml.cs
Dev fd442f3b4c
Some checks failed
Release SharePoint Toolbox v2 / release (push) Failing after 14s
chore: archive v1.1 Enhanced Reports milestone
v1.1 shipped with 4 phases (25 plans), 10/10 requirements complete:
- Global site selection (toolbar picker, all tabs consume)
- User access audit (Graph people-picker, direct/group/inherited)
- Simplified permissions (plain-language labels, risk levels, detail toggle)
- Storage visualization (LiveCharts2 pie/donut + bar charts)

Post-phase polish: centralized site selection (removed per-tab pickers),
claims prefix stripping, StorageMetrics backfill, chart tooltip fix,
summary stats in app + HTML exports.

205 tests passing, 10,484 LOC.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 10:21:02 +02:00

54 lines
1.6 KiB
C#

using System.Windows.Controls;
using LiveChartsCore;
using LiveChartsCore.Kernel;
using LiveChartsCore.Kernel.Sketches;
namespace SharepointToolbox.Views.Tabs;
public partial class StorageView : UserControl
{
public StorageView(ViewModels.Tabs.StorageViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
StoragePieChart.Tooltip = new SingleSliceTooltip();
}
}
/// <summary>
/// Custom tooltip that only shows the single closest/hovered pie slice
/// instead of LiveCharts2's default which shows multiple nearby slices.
/// </summary>
internal sealed class SingleSliceTooltip : IChartTooltip
{
private readonly System.Windows.Controls.ToolTip _tip = new()
{
Padding = new System.Windows.Thickness(8, 4, 8, 4),
FontSize = 13,
Background = new System.Windows.Media.SolidColorBrush(
System.Windows.Media.Color.FromRgb(255, 255, 255)),
BorderBrush = new System.Windows.Media.SolidColorBrush(
System.Windows.Media.Color.FromRgb(200, 200, 200)),
BorderThickness = new System.Windows.Thickness(1),
};
public void Show(IEnumerable<ChartPoint> foundPoints, Chart chart)
{
// Only show the first (closest) point
var point = foundPoints.FirstOrDefault();
if (point == null) { Hide(chart); return; }
var label = point.Context.Series.GetPrimaryToolTipText(point);
if (string.IsNullOrEmpty(label)) label = point.Context.Series.Name ?? "";
_tip.Content = label;
_tip.IsOpen = true;
}
public void Hide(Chart chart)
{
_tip.IsOpen = false;
}
}