Добавлен проект UI
This commit is contained in:
43
Lattice.UI/Controls/LatticeTabStrip.cs
Normal file
43
Lattice.UI/Controls/LatticeTabStrip.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user