44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using Lattice.Core.Abstractions;
|
||
using Microsoft.UI.Xaml.Controls;
|
||
|
||
namespace Lattice.UI.Controls;
|
||
|
||
/// <summary>
|
||
/// Расширенный TabView для центральной области Lattice.
|
||
/// </summary>
|
||
public class LatticeTabStrip : TabView
|
||
{
|
||
private IContextService? _contextService;
|
||
|
||
public LatticeTabStrip()
|
||
{
|
||
this.TabCloseRequested += (s, e) =>
|
||
{
|
||
// Логика удаления вкладки из коллекции
|
||
this.TabItems.Remove(e.Tab);
|
||
|
||
// Если вкладок не осталось, сбрасываем контекст
|
||
if (this.TabItems.Count == 0)
|
||
{
|
||
_contextService?.SetContext("Common");
|
||
}
|
||
};
|
||
}
|
||
|
||
|
||
public void Initialize(IContextService contextService)
|
||
{
|
||
_contextService = contextService;
|
||
this.SelectionChanged += OnSelectionChanged;
|
||
}
|
||
|
||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||
{
|
||
if (this.SelectedItem is IDockableComponent component)
|
||
{
|
||
// Уведомляем ядро о смене контекста для обновления кнопок
|
||
_contextService?.SetContext(component.ContextGroup);
|
||
}
|
||
}
|
||
}
|