Console improvements, info providers
This commit is contained in:
@@ -12,7 +12,7 @@ public interface ITabViewModel : IInitable<ITab, int>, IDisposable
|
|||||||
{
|
{
|
||||||
ITab? Tab { get; }
|
ITab? Tab { get; }
|
||||||
int TabNumber { get; }
|
int TabNumber { get; }
|
||||||
IObservable<bool> IsSelected { get; }
|
IDeclarativeProperty<bool> IsSelected { get; }
|
||||||
IDeclarativeProperty<IContainer?> CurrentLocation { get; }
|
IDeclarativeProperty<IContainer?> CurrentLocation { get; }
|
||||||
IDeclarativeProperty<IItemViewModel?> CurrentSelectedItem { get; }
|
IDeclarativeProperty<IItemViewModel?> CurrentSelectedItem { get; }
|
||||||
IDeclarativeProperty<IContainerViewModel?> CurrentSelectedItemAsContainer { get; }
|
IDeclarativeProperty<IContainerViewModel?> CurrentSelectedItemAsContainer { get; }
|
||||||
|
|||||||
@@ -103,15 +103,15 @@ public class MainConfiguration
|
|||||||
//new CommandBindingConfiguration(ConfigCommand.ShowAllShortcut, Keys.F1),
|
//new CommandBindingConfiguration(ConfigCommand.ShowAllShortcut, Keys.F1),
|
||||||
new(DeleteCommand.SoftDeleteCommandName, new[] {new KeyConfig(Keys.D), new KeyConfig(Keys.D, shift: true)}),
|
new(DeleteCommand.SoftDeleteCommandName, new[] {new KeyConfig(Keys.D), new KeyConfig(Keys.D, shift: true)}),
|
||||||
new(IdentifiableSearchCommand.SearchByNameContainsCommandName, new[] {Keys.S, Keys.N}),
|
new(IdentifiableSearchCommand.SearchByNameContainsCommandName, new[] {Keys.S, Keys.N}),
|
||||||
new(SwitchToTabCommand.SwitchToLastTabCommandName, new[] {new KeyConfig(Keys.F9, alt: true)}),
|
new(SwitchToTabCommand.SwitchToLastTabCommandName, new[] {new KeyConfig(Keys.Num9, alt: true)}),
|
||||||
new(SwitchToTabCommand.SwitchToTab1CommandName, new[] {new KeyConfig(Keys.F1, alt: true)}),
|
new(SwitchToTabCommand.SwitchToTab1CommandName, new[] {new KeyConfig(Keys.Num1, alt: true)}),
|
||||||
new(SwitchToTabCommand.SwitchToTab2CommandName, new[] {new KeyConfig(Keys.F2, alt: true)}),
|
new(SwitchToTabCommand.SwitchToTab2CommandName, new[] {new KeyConfig(Keys.Num2, alt: true)}),
|
||||||
new(SwitchToTabCommand.SwitchToTab3CommandName, new[] {new KeyConfig(Keys.F3, alt: true)}),
|
new(SwitchToTabCommand.SwitchToTab3CommandName, new[] {new KeyConfig(Keys.Num3, alt: true)}),
|
||||||
new(SwitchToTabCommand.SwitchToTab4CommandName, new[] {new KeyConfig(Keys.F4, alt: true)}),
|
new(SwitchToTabCommand.SwitchToTab4CommandName, new[] {new KeyConfig(Keys.Num4, alt: true)}),
|
||||||
new(SwitchToTabCommand.SwitchToTab5CommandName, new[] {new KeyConfig(Keys.F5, alt: true)}),
|
new(SwitchToTabCommand.SwitchToTab5CommandName, new[] {new KeyConfig(Keys.Num5, alt: true)}),
|
||||||
new(SwitchToTabCommand.SwitchToTab6CommandName, new[] {new KeyConfig(Keys.F6, alt: true)}),
|
new(SwitchToTabCommand.SwitchToTab6CommandName, new[] {new KeyConfig(Keys.Num6, alt: true)}),
|
||||||
new(SwitchToTabCommand.SwitchToTab7CommandName, new[] {new KeyConfig(Keys.F7, alt: true)}),
|
new(SwitchToTabCommand.SwitchToTab7CommandName, new[] {new KeyConfig(Keys.Num7, alt: true)}),
|
||||||
new(SwitchToTabCommand.SwitchToTab8CommandName, new[] {new KeyConfig(Keys.F8, alt: true)}),
|
new(SwitchToTabCommand.SwitchToTab8CommandName, new[] {new KeyConfig(Keys.Num8, alt: true)}),
|
||||||
new(PauseCommandSchedulerCommand.CommandName, new[] {Keys.T, Keys.P}),
|
new(PauseCommandSchedulerCommand.CommandName, new[] {Keys.T, Keys.P}),
|
||||||
//new CommandBindingConfiguration(ConfigCommand.TimelineRefresh, new[] { Keys.T, Keys.R }),
|
//new CommandBindingConfiguration(ConfigCommand.TimelineRefresh, new[] { Keys.T, Keys.R }),
|
||||||
new(StartCommandSchedulerCommand.CommandName, new[] {Keys.T, Keys.S}),
|
new(StartCommandSchedulerCommand.CommandName, new[] {Keys.T, Keys.S}),
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public partial class TabViewModel : ITabViewModel
|
|||||||
public ITab? Tab { get; private set; }
|
public ITab? Tab { get; private set; }
|
||||||
public int TabNumber { get; private set; }
|
public int TabNumber { get; private set; }
|
||||||
|
|
||||||
public IObservable<bool> IsSelected { get; }
|
public IDeclarativeProperty<bool> IsSelected { get; }
|
||||||
|
|
||||||
public IDeclarativeProperty<IContainer?> CurrentLocation { get; private set; }
|
public IDeclarativeProperty<IContainer?> CurrentLocation { get; private set; }
|
||||||
public IDeclarativeProperty<IItemViewModel?> CurrentSelectedItem { get; private set; }
|
public IDeclarativeProperty<IItemViewModel?> CurrentSelectedItem { get; private set; }
|
||||||
@@ -60,7 +60,7 @@ public partial class TabViewModel : ITabViewModel
|
|||||||
_appState = appState;
|
_appState = appState;
|
||||||
|
|
||||||
MarkedItems = _markedItems.Watch();
|
MarkedItems = _markedItems.Watch();
|
||||||
IsSelected = _appState.SelectedTab.Select(s => s == this);
|
IsSelected = _appState.SelectedTab.Map(s => s == this);
|
||||||
_timelessContentProvider = timelessContentProvider;
|
_timelessContentProvider = timelessContentProvider;
|
||||||
_refreshSmoothnessCalculator = refreshSmoothnessCalculator;
|
_refreshSmoothnessCalculator = refreshSmoothnessCalculator;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace FileTime.ConsoleUI.App;
|
||||||
|
|
||||||
|
public interface IColorSampleProvider
|
||||||
|
{
|
||||||
|
public Type? ForegroundColors { get; }
|
||||||
|
public Type? BackgroundColors { get; }
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using TerminalUI.Color;
|
using TerminalUI.Color;
|
||||||
using TerminalUI.Models;
|
|
||||||
|
|
||||||
namespace FileTime.ConsoleUI.App;
|
namespace FileTime.ConsoleUI.App;
|
||||||
|
|
||||||
@@ -10,4 +9,5 @@ public interface ITheme
|
|||||||
IColor? ElementColor { get; }
|
IColor? ElementColor { get; }
|
||||||
IColor? ContainerColor { get; }
|
IColor? ContainerColor { get; }
|
||||||
IColor? MarkedItemColor { get; }
|
IColor? MarkedItemColor { get; }
|
||||||
|
IColor? SelectedTabBackgroundColor { get; }
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,5 @@ namespace FileTime.ConsoleUI.App.KeyInputHandling;
|
|||||||
|
|
||||||
public interface IKeyInputHandlerService
|
public interface IKeyInputHandlerService
|
||||||
{
|
{
|
||||||
void HandleKeyInput(GeneralKeyEventArgs keyEvent);
|
void HandleKeyInput(GeneralKeyEventArgs keyEvent, SpecialKeysStatus specialKeysStatus);
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public class App : IApplication
|
|||||||
|
|
||||||
((INotifyCollectionChanged) _appState.Tabs).CollectionChanged += (_, _) =>
|
((INotifyCollectionChanged) _appState.Tabs).CollectionChanged += (_, _) =>
|
||||||
{
|
{
|
||||||
if(_appState.Tabs.Count == 0)
|
if (_appState.Tabs.Count == 0)
|
||||||
_applicationContext.IsRunning = false;
|
_applicationContext.IsRunning = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,13 +68,21 @@ public class App : IApplication
|
|||||||
if (_consoleDriver.CanRead())
|
if (_consoleDriver.CanRead())
|
||||||
{
|
{
|
||||||
var key = _consoleDriver.ReadKey();
|
var key = _consoleDriver.ReadKey();
|
||||||
|
|
||||||
if (_appKeyService.MapKey(key.Key) is { } mappedKey)
|
if (_appKeyService.MapKey(key.Key) is { } mappedKey)
|
||||||
{
|
{
|
||||||
|
SpecialKeysStatus specialKeysStatus = new(
|
||||||
|
(key.Modifiers & ConsoleModifiers.Alt) != 0,
|
||||||
|
(key.Modifiers & ConsoleModifiers.Shift) != 0,
|
||||||
|
(key.Modifiers & ConsoleModifiers.Control) != 0
|
||||||
|
);
|
||||||
|
|
||||||
var keyEventArgs = new GeneralKeyEventArgs
|
var keyEventArgs = new GeneralKeyEventArgs
|
||||||
{
|
{
|
||||||
Key = mappedKey
|
Key = mappedKey
|
||||||
};
|
};
|
||||||
_keyInputHandlerService.HandleKeyInput(keyEventArgs);
|
|
||||||
|
_keyInputHandlerService.HandleKeyInput(keyEventArgs, specialKeysStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ public class KeyInputHandlerService : IKeyInputHandlerService
|
|||||||
private readonly IAppState _appState;
|
private readonly IAppState _appState;
|
||||||
private readonly IDefaultModeKeyInputHandler _defaultModeKeyInputHandler;
|
private readonly IDefaultModeKeyInputHandler _defaultModeKeyInputHandler;
|
||||||
private readonly IRapidTravelModeKeyInputHandler _rapidTravelModeKeyInputHandler;
|
private readonly IRapidTravelModeKeyInputHandler _rapidTravelModeKeyInputHandler;
|
||||||
bool _isCtrlPressed = false;
|
|
||||||
bool _isShiftPressed = false;
|
|
||||||
bool _isAltPressed = false;
|
|
||||||
|
|
||||||
public KeyInputHandlerService(
|
public KeyInputHandlerService(
|
||||||
IAppState appState,
|
IAppState appState,
|
||||||
@@ -24,9 +21,8 @@ public class KeyInputHandlerService : IKeyInputHandlerService
|
|||||||
_rapidTravelModeKeyInputHandler = rapidTravelModeKeyInputHandler;
|
_rapidTravelModeKeyInputHandler = rapidTravelModeKeyInputHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleKeyInput(GeneralKeyEventArgs keyEvent)
|
public void HandleKeyInput(GeneralKeyEventArgs keyEvent, SpecialKeysStatus specialKeysStatus)
|
||||||
{
|
{
|
||||||
var specialKeysStatus = new SpecialKeysStatus(_isAltPressed, _isShiftPressed, _isCtrlPressed);
|
|
||||||
if (_appState.ViewMode.Value == ViewMode.Default)
|
if (_appState.ViewMode.Value == ViewMode.Default)
|
||||||
{
|
{
|
||||||
Task.Run(async () => await _defaultModeKeyInputHandler.HandleInputKey(keyEvent, specialKeysStatus)).Wait();
|
Task.Run(async () => await _defaultModeKeyInputHandler.HandleInputKey(keyEvent, specialKeysStatus)).Wait();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using TerminalUI;
|
|||||||
using TerminalUI.Color;
|
using TerminalUI.Color;
|
||||||
using TerminalUI.Controls;
|
using TerminalUI.Controls;
|
||||||
using TerminalUI.Extensions;
|
using TerminalUI.Extensions;
|
||||||
|
using TerminalUI.Models;
|
||||||
using TerminalUI.ViewExtensions;
|
using TerminalUI.ViewExtensions;
|
||||||
using ConsoleColor = TerminalUI.Color.ConsoleColor;
|
using ConsoleColor = TerminalUI.Color.ConsoleColor;
|
||||||
|
|
||||||
@@ -38,15 +39,23 @@ public class MainWindow
|
|||||||
RowDefinitionsObject = "Auto *",
|
RowDefinitionsObject = "Auto *",
|
||||||
ChildInitializer =
|
ChildInitializer =
|
||||||
{
|
{
|
||||||
new TextBlock<IAppState>()
|
new Grid<IAppState>
|
||||||
.Setup(t =>
|
{
|
||||||
t.Bind(
|
ColumnDefinitionsObject = "* Auto",
|
||||||
t,
|
ChildInitializer =
|
||||||
appState => appState.SelectedTab.Value.CurrentLocation.Value.FullName.Path,
|
{
|
||||||
tb => tb.Text,
|
new TextBlock<IAppState>()
|
||||||
value => value
|
.Setup(t =>
|
||||||
)
|
t.Bind(
|
||||||
),
|
t,
|
||||||
|
appState => appState.SelectedTab.Value.CurrentLocation.Value.FullName.Path,
|
||||||
|
tb => tb.Text,
|
||||||
|
value => value
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TabControl()
|
||||||
|
}
|
||||||
|
},
|
||||||
new Grid<IAppState>
|
new Grid<IAppState>
|
||||||
{
|
{
|
||||||
ColumnDefinitionsObject = "* 4* 4*",
|
ColumnDefinitionsObject = "* 4* 4*",
|
||||||
@@ -66,6 +75,44 @@ public class MainWindow
|
|||||||
_root = root;
|
_root = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IView<IAppState> TabControl()
|
||||||
|
{
|
||||||
|
var tabList = new ListView<IAppState, ITabViewModel>
|
||||||
|
{
|
||||||
|
Orientation = Orientation.Horizontal,
|
||||||
|
Extensions =
|
||||||
|
{
|
||||||
|
new GridPositionExtension(1, 0)
|
||||||
|
},
|
||||||
|
ItemTemplate = item =>
|
||||||
|
{
|
||||||
|
var textBlock = item.CreateChild<TextBlock<ITabViewModel>>();
|
||||||
|
textBlock.Foreground = _theme.DefaultForegroundColor;
|
||||||
|
|
||||||
|
textBlock.Bind(
|
||||||
|
textBlock,
|
||||||
|
dc => dc.TabNumber.ToString(),
|
||||||
|
tb => tb.Text,
|
||||||
|
fallbackValue: "?");
|
||||||
|
|
||||||
|
textBlock.Bind(
|
||||||
|
textBlock,
|
||||||
|
dc => dc.IsSelected.Value ? _theme.SelectedTabBackgroundColor : null,
|
||||||
|
tb => tb.Background,
|
||||||
|
fallbackValue: null
|
||||||
|
);
|
||||||
|
return textBlock;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tabList.Bind(
|
||||||
|
tabList,
|
||||||
|
appState => appState == null ? null : appState.Tabs,
|
||||||
|
v => v.ItemsSource);
|
||||||
|
|
||||||
|
return tabList;
|
||||||
|
}
|
||||||
|
|
||||||
private ListView<IAppState, IItemViewModel> SelectedItemsView()
|
private ListView<IAppState, IItemViewModel> SelectedItemsView()
|
||||||
{
|
{
|
||||||
var list = new ListView<IAppState, IItemViewModel>
|
var list = new ListView<IAppState, IItemViewModel>
|
||||||
|
|||||||
@@ -8,22 +8,32 @@ public record Theme(
|
|||||||
IColor? DefaultBackgroundColor,
|
IColor? DefaultBackgroundColor,
|
||||||
IColor? ElementColor,
|
IColor? ElementColor,
|
||||||
IColor? ContainerColor,
|
IColor? ContainerColor,
|
||||||
IColor? MarkedItemColor) : ITheme;
|
IColor? MarkedItemColor,
|
||||||
|
IColor? SelectedTabBackgroundColor,
|
||||||
|
Type? ForegroundColors,
|
||||||
|
Type? BackgroundColors) : ITheme, IColorSampleProvider;
|
||||||
|
|
||||||
public static class DefaultThemes
|
public static class DefaultThemes
|
||||||
{
|
{
|
||||||
public static Theme Color256Theme => new(
|
public static Theme Color256Theme => new(
|
||||||
DefaultForegroundColor: Color256Colors.Foregrounds.Gray,
|
DefaultForegroundColor: Color256Colors.Foregrounds.Gray,
|
||||||
DefaultBackgroundColor: Color256Colors.Foregrounds.Black,
|
DefaultBackgroundColor: null,
|
||||||
ElementColor: Color256Colors.Foregrounds.Gray,
|
ElementColor: Color256Colors.Foregrounds.Gray,
|
||||||
ContainerColor: Color256Colors.Foregrounds.Blue,
|
ContainerColor: Color256Colors.Foregrounds.Blue,
|
||||||
MarkedItemColor: Color256Colors.Foregrounds.Black
|
MarkedItemColor: Color256Colors.Foregrounds.Black,
|
||||||
|
SelectedTabBackgroundColor: Color256Colors.Backgrounds.Green,
|
||||||
|
ForegroundColors: typeof(Color256Colors.Foregrounds),
|
||||||
|
BackgroundColors: typeof(Color256Colors.Backgrounds)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static Theme ConsoleColorTheme => new(
|
public static Theme ConsoleColorTheme => new(
|
||||||
DefaultForegroundColor: ConsoleColors.Foregrounds.Gray,
|
DefaultForegroundColor: ConsoleColors.Foregrounds.Gray,
|
||||||
DefaultBackgroundColor: ConsoleColors.Foregrounds.Black,
|
DefaultBackgroundColor: ConsoleColors.Backgrounds.Black,
|
||||||
ElementColor: ConsoleColors.Foregrounds.Gray,
|
ElementColor: ConsoleColors.Foregrounds.Gray,
|
||||||
ContainerColor: ConsoleColors.Foregrounds.Blue,
|
ContainerColor: ConsoleColors.Foregrounds.Blue,
|
||||||
MarkedItemColor: ConsoleColors.Foregrounds.Black);
|
MarkedItemColor: ConsoleColors.Foregrounds.Black,
|
||||||
|
SelectedTabBackgroundColor: ConsoleColors.Backgrounds.Green,
|
||||||
|
ForegroundColors: typeof(ConsoleColors.Foregrounds),
|
||||||
|
BackgroundColors: typeof(ConsoleColors.Backgrounds)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,7 @@ public static class DI
|
|||||||
.WriteTo.File(
|
.WriteTo.File(
|
||||||
Path.Combine(Program.AppDataRoot, "logs", "appLog.log"),
|
Path.Combine(Program.AppDataRoot, "logs", "appLog.log"),
|
||||||
fileSizeLimitBytes: 10 * 1024 * 1024,
|
fileSizeLimitBytes: 10 * 1024 * 1024,
|
||||||
|
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}",
|
||||||
rollingInterval: RollingInterval.Day,
|
rollingInterval: RollingInterval.Day,
|
||||||
rollOnFileSizeLimit: true)
|
rollOnFileSizeLimit: true)
|
||||||
.WriteTo.Sink(serviceProvider.GetRequiredService<CustomLoggerSink>());
|
.WriteTo.Sink(serviceProvider.GetRequiredService<CustomLoggerSink>());
|
||||||
|
|||||||
129
src/ConsoleApp/FileTime.ConsoleUI/InfoProviders/ColorSchema.cs
Normal file
129
src/ConsoleApp/FileTime.ConsoleUI/InfoProviders/ColorSchema.cs
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
using FileTime.ConsoleUI.App;
|
||||||
|
using TerminalUI.Color;
|
||||||
|
using TerminalUI.ConsoleDrivers;
|
||||||
|
using TerminalUI.Models;
|
||||||
|
|
||||||
|
namespace FileTime.ConsoleUI.InfoProviders;
|
||||||
|
|
||||||
|
public static class ColorSchema
|
||||||
|
{
|
||||||
|
private const int ColorTextMargin = 5;
|
||||||
|
|
||||||
|
public static void PrintColorSchema(ITheme theme, IConsoleDriver consoleDriver)
|
||||||
|
{
|
||||||
|
consoleDriver.Dispose();
|
||||||
|
consoleDriver.ResetColor();
|
||||||
|
PrintThemeColors(theme, consoleDriver);
|
||||||
|
|
||||||
|
if (theme is IColorSampleProvider colorSampleProvider)
|
||||||
|
PrintColorPalette(colorSampleProvider, consoleDriver);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PrintThemeColors(ITheme theme, IConsoleDriver consoleDriver)
|
||||||
|
{
|
||||||
|
consoleDriver.Write("Theme colors:" + Environment.NewLine);
|
||||||
|
|
||||||
|
var colorType = typeof(IColor);
|
||||||
|
var colorProperties = typeof(ITheme)
|
||||||
|
.GetProperties()
|
||||||
|
.Where(p => p.PropertyType.IsAssignableTo(colorType))
|
||||||
|
.OrderBy(p => p.Name)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (colorProperties.Count == 0)
|
||||||
|
{
|
||||||
|
consoleDriver.Write("No colors properties found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var colorTextStartX = colorProperties.Max(p => p.Name.Length) + ColorTextMargin;
|
||||||
|
|
||||||
|
foreach (var colorProperty in colorProperties)
|
||||||
|
{
|
||||||
|
var color = colorProperty.GetValue(theme) as IColor;
|
||||||
|
|
||||||
|
PrintColor(consoleDriver, colorProperty.Name, color, colorTextStartX);
|
||||||
|
}
|
||||||
|
|
||||||
|
consoleDriver.ResetColor();
|
||||||
|
consoleDriver.Write(Environment.NewLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PrintColorPalette(IColorSampleProvider colorSampleProvider, IConsoleDriver consoleDriver)
|
||||||
|
{
|
||||||
|
if (colorSampleProvider.ForegroundColors is { } foregroundColors)
|
||||||
|
{
|
||||||
|
PrintColorPalette("foreground", foregroundColors, consoleDriver);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colorSampleProvider.BackgroundColors is { } backgroundColors)
|
||||||
|
{
|
||||||
|
PrintColorPalette("background", backgroundColors, consoleDriver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PrintColorPalette(string paletteName, Type colorPalette, IConsoleDriver consoleDriver)
|
||||||
|
{
|
||||||
|
var colorType = typeof(IColor);
|
||||||
|
var colorFields = colorPalette
|
||||||
|
.GetFields()
|
||||||
|
.Where(f => f.FieldType.IsAssignableTo(colorType) && f.IsStatic)
|
||||||
|
.ToDictionary(f => f.Name, f => (IColor?) f.GetValue(null));
|
||||||
|
var colorProperties = colorPalette
|
||||||
|
.GetProperties()
|
||||||
|
.Where(p => p.PropertyType.IsAssignableTo(colorType) && (p.GetMethod?.IsStatic ?? false))
|
||||||
|
.ToDictionary(p => p.Name, p => (IColor?) p.GetValue(null));
|
||||||
|
|
||||||
|
var colors = colorFields
|
||||||
|
.Concat(colorProperties)
|
||||||
|
.OrderBy(v => v.Key)
|
||||||
|
.ToDictionary(k => k.Key, v => v.Value);
|
||||||
|
|
||||||
|
consoleDriver.Write("Color theme for " + paletteName + Environment.NewLine);
|
||||||
|
|
||||||
|
if (colors.Count == 0)
|
||||||
|
{
|
||||||
|
consoleDriver.Write("No colors found");
|
||||||
|
consoleDriver.Write(Environment.NewLine);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var colorTextStartX = colors.Max(p => p.Key.Length) + ColorTextMargin;
|
||||||
|
foreach (var (key, value) in colors)
|
||||||
|
{
|
||||||
|
PrintColor(consoleDriver, key, value, colorTextStartX);
|
||||||
|
}
|
||||||
|
|
||||||
|
consoleDriver.ResetColor();
|
||||||
|
consoleDriver.Write(Environment.NewLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PrintColor(IConsoleDriver consoleDriver, string name, IColor? color, int colorTextStartX)
|
||||||
|
{
|
||||||
|
consoleDriver.ResetColor();
|
||||||
|
consoleDriver.Write(name + ":");
|
||||||
|
var y = consoleDriver.GetCursorPosition().Y;
|
||||||
|
consoleDriver.SetCursorPosition(new Position(colorTextStartX, y));
|
||||||
|
|
||||||
|
if (color is null)
|
||||||
|
{
|
||||||
|
consoleDriver.Write("<null>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (color.Type == ColorType.Foreground)
|
||||||
|
{
|
||||||
|
consoleDriver.SetForegroundColor(color);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
consoleDriver.SetBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
consoleDriver.Write("Sample text");
|
||||||
|
}
|
||||||
|
|
||||||
|
consoleDriver.ResetColor();
|
||||||
|
consoleDriver.Write(Environment.NewLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,23 +2,30 @@
|
|||||||
using FileTime.App.Core.Configuration;
|
using FileTime.App.Core.Configuration;
|
||||||
using FileTime.ConsoleUI.App.Configuration;
|
using FileTime.ConsoleUI.App.Configuration;
|
||||||
|
|
||||||
namespace FileTime.ConsoleUI;
|
namespace FileTime.ConsoleUI.InfoProviders;
|
||||||
|
|
||||||
public static class Help
|
public static class Help
|
||||||
{
|
{
|
||||||
public static void PrintHelp()
|
public static void PrintHelp(IEnumerable<string> infoProvidersKeys)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new();
|
StringBuilder sb = new();
|
||||||
|
|
||||||
sb.AppendLine("Options:");
|
sb.AppendLine("Options:");
|
||||||
PrintDriverOption(sb);
|
PrintDriverOption(sb);
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine("Info providers:");
|
||||||
|
foreach (var infoProviderKey in infoProvidersKeys.Order())
|
||||||
|
{
|
||||||
|
sb.AppendLine("\t" + infoProviderKey);
|
||||||
|
}
|
||||||
|
|
||||||
Console.Write(sb.ToString());
|
Console.Write(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PrintDriverOption(StringBuilder sb)
|
private static void PrintDriverOption(StringBuilder sb)
|
||||||
{
|
{
|
||||||
sb.AppendLine($"--{SectionNames.ApplicationSectionName}.{nameof(ConsoleApplicationConfiguration.ConsoleDriver)}");
|
sb.AppendLine($"--{SectionNames.ApplicationSectionName}.{nameof(ConsoleApplicationConfiguration.ConsoleDriver)}");
|
||||||
foreach (var driver in Startup.Drivers.Keys)
|
foreach (var driver in Startup.Drivers.Keys.Order())
|
||||||
{
|
{
|
||||||
sb.AppendLine("\t" + driver);
|
sb.AppendLine("\t" + driver);
|
||||||
}
|
}
|
||||||
@@ -3,18 +3,13 @@ using FileTime.App.Core;
|
|||||||
using FileTime.App.Core.Configuration;
|
using FileTime.App.Core.Configuration;
|
||||||
using FileTime.ConsoleUI;
|
using FileTime.ConsoleUI;
|
||||||
using FileTime.ConsoleUI.App;
|
using FileTime.ConsoleUI.App;
|
||||||
|
using FileTime.ConsoleUI.InfoProviders;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Debugging;
|
using Serilog.Debugging;
|
||||||
using TerminalUI.ConsoleDrivers;
|
using TerminalUI.ConsoleDrivers;
|
||||||
|
|
||||||
if(args.Contains("--help"))
|
|
||||||
{
|
|
||||||
Help.PrintHelp();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IConsoleDriver? driver = null;
|
IConsoleDriver? driver = null;
|
||||||
|
|
||||||
(AppDataRoot, EnvironmentName) = Init.InitDevelopment();
|
(AppDataRoot, EnvironmentName) = Init.InitDevelopment();
|
||||||
@@ -25,8 +20,11 @@ try
|
|||||||
|
|
||||||
var serviceProvider = DI.Initialize(configuration);
|
var serviceProvider = DI.Initialize(configuration);
|
||||||
|
|
||||||
|
if (HandleInfoProviders(args, serviceProvider)) return;
|
||||||
|
|
||||||
driver = serviceProvider.GetRequiredService<IConsoleDriver>();
|
driver = serviceProvider.GetRequiredService<IConsoleDriver>();
|
||||||
Log.Logger.Debug("Using driver {Driver}", driver.GetType().Name);
|
Log.Logger.Debug("Using driver {Driver}", driver.GetType().Name);
|
||||||
|
|
||||||
driver.SetCursorVisible(false);
|
driver.SetCursorVisible(false);
|
||||||
|
|
||||||
var app = serviceProvider.GetRequiredService<IApplication>();
|
var app = serviceProvider.GetRequiredService<IApplication>();
|
||||||
@@ -54,6 +52,7 @@ static void InitLogging()
|
|||||||
.WriteTo.File(
|
.WriteTo.File(
|
||||||
Path.Combine(logFolder, "appLog.log"),
|
Path.Combine(logFolder, "appLog.log"),
|
||||||
fileSizeLimitBytes: 10 * 1024 * 1024,
|
fileSizeLimitBytes: 10 * 1024 * 1024,
|
||||||
|
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}",
|
||||||
rollingInterval: RollingInterval.Day,
|
rollingInterval: RollingInterval.Day,
|
||||||
rollOnFileSizeLimit: true)
|
rollOnFileSizeLimit: true)
|
||||||
.CreateBootstrapLogger();
|
.CreateBootstrapLogger();
|
||||||
@@ -72,6 +71,32 @@ static IConfigurationRoot CreateConfiguration(string[] strings)
|
|||||||
return configurationRoot;
|
return configurationRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool HandleInfoProviders(string[] args, IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
Dictionary<string, Action> infoProviders = new()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"--info=colors",
|
||||||
|
() => ColorSchema.PrintColorSchema(
|
||||||
|
serviceProvider.GetRequiredService<ITheme>(),
|
||||||
|
serviceProvider.GetRequiredService<IConsoleDriver>()
|
||||||
|
)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
infoProviders.Add("--help", () => Help.PrintHelp(infoProviders.Keys));
|
||||||
|
foreach (var infoProviderKey in infoProviders.Keys)
|
||||||
|
{
|
||||||
|
if (args.Contains(infoProviderKey))
|
||||||
|
{
|
||||||
|
infoProviders[infoProviderKey]();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public partial class Program
|
public partial class Program
|
||||||
{
|
{
|
||||||
public static string AppDataRoot { get; private set; }
|
public static string AppDataRoot { get; private set; }
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ public static class Startup
|
|||||||
if (driver == null)
|
if (driver == null)
|
||||||
{
|
{
|
||||||
driver = new XTermDriver();
|
driver = new XTermDriver();
|
||||||
var asd = driver.GetCursorPosition();
|
|
||||||
driver.Init();
|
|
||||||
if (!driver.Init())
|
if (!driver.Init())
|
||||||
{
|
{
|
||||||
driver = new DotnetDriver();
|
driver = new DotnetDriver();
|
||||||
|
|||||||
@@ -426,7 +426,7 @@
|
|||||||
<Rectangle
|
<Rectangle
|
||||||
Fill="{DynamicResource ForegroundBrush}"
|
Fill="{DynamicResource ForegroundBrush}"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
IsVisible="{Binding IsSelected^}" />
|
IsVisible="{Binding IsSelected.Value}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public static class Program
|
|||||||
.WriteTo.File(
|
.WriteTo.File(
|
||||||
Path.Combine(logFolder, "appLog.log"),
|
Path.Combine(logFolder, "appLog.log"),
|
||||||
fileSizeLimitBytes: 10 * 1024 * 1024,
|
fileSizeLimitBytes: 10 * 1024 * 1024,
|
||||||
|
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}",
|
||||||
rollingInterval: RollingInterval.Day,
|
rollingInterval: RollingInterval.Day,
|
||||||
rollOnFileSizeLimit: true)
|
rollOnFileSizeLimit: true)
|
||||||
.CreateBootstrapLogger();
|
.CreateBootstrapLogger();
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ public static class Startup
|
|||||||
.WriteTo.File(
|
.WriteTo.File(
|
||||||
Path.Combine(Program.AppDataRoot, "logs", "appLog.log"),
|
Path.Combine(Program.AppDataRoot, "logs", "appLog.log"),
|
||||||
fileSizeLimitBytes: 10 * 1024 * 1024,
|
fileSizeLimitBytes: 10 * 1024 * 1024,
|
||||||
|
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}",
|
||||||
rollingInterval: RollingInterval.Day,
|
rollingInterval: RollingInterval.Day,
|
||||||
rollOnFileSizeLimit: true)
|
rollOnFileSizeLimit: true)
|
||||||
.WriteTo.Sink(serviceProvider.GetRequiredService<ToastMessageSink>());
|
.WriteTo.Sink(serviceProvider.GetRequiredService<ToastMessageSink>());
|
||||||
|
|||||||
@@ -5,38 +5,40 @@ public static class Color256Colors
|
|||||||
public static class Backgrounds
|
public static class Backgrounds
|
||||||
{
|
{
|
||||||
public static readonly Color256 Black = new(0, ColorType.Background);
|
public static readonly Color256 Black = new(0, ColorType.Background);
|
||||||
public static readonly Color256 Blue = new(9, ColorType.Background);
|
public static readonly Color256 Blue = new(12, ColorType.Background);
|
||||||
public static readonly Color256 Cyan = new(11, ColorType.Background);
|
public static readonly Color256 Cyan = new(14, ColorType.Background);
|
||||||
public static readonly Color256 DarkBlue = new(1, ColorType.Background);
|
public static readonly Color256 DarkBlue = new(4, ColorType.Background);
|
||||||
public static readonly Color256 DarkCyan = new(3, ColorType.Background);
|
public static readonly Color256 DarkCyan = new(6, ColorType.Background);
|
||||||
public static readonly Color256 DarkGray = new(8, ColorType.Background);
|
public static readonly Color256 DarkGray = new(8, ColorType.Background);
|
||||||
public static readonly Color256 DarkGreen = new(2, ColorType.Background);
|
public static readonly Color256 DarkGreen = new(2, ColorType.Background);
|
||||||
public static readonly Color256 DarkMagenta = new(5, ColorType.Background);
|
public static readonly Color256 DarkMagenta = new(5, ColorType.Background);
|
||||||
public static readonly Color256 DarkRed = new(4, ColorType.Background);
|
public static readonly Color256 DarkRed = new(1, ColorType.Background);
|
||||||
public static readonly Color256 DarkYellow = new(6, ColorType.Background);
|
public static readonly Color256 DarkYellow = new(3, ColorType.Background);
|
||||||
public static readonly Color256 Gray = new(7, ColorType.Background);
|
public static readonly Color256 Gray = new(15, ColorType.Background);
|
||||||
public static readonly Color256 Green = new(10, ColorType.Background);
|
public static readonly Color256 Green = new(10, ColorType.Background);
|
||||||
public static readonly Color256 Magenta = new(13, ColorType.Background);
|
public static readonly Color256 Magenta = new(13, ColorType.Background);
|
||||||
public static readonly Color256 Red = new(12, ColorType.Background);
|
public static readonly Color256 Red = new(9, ColorType.Background);
|
||||||
public static readonly Color256 White = new(15, ColorType.Background);
|
public static readonly Color256 White = new(7, ColorType.Background);
|
||||||
|
public static readonly Color256 Yellow = new(11, ColorType.Background);
|
||||||
}
|
}
|
||||||
public static class Foregrounds
|
public static class Foregrounds
|
||||||
{
|
{
|
||||||
public static readonly Color256 Black = new(0, ColorType.Foreground);
|
public static readonly Color256 Black = new(0, ColorType.Foreground);
|
||||||
public static readonly Color256 Blue = new(9, ColorType.Foreground);
|
public static readonly Color256 Blue = new(12, ColorType.Foreground);
|
||||||
public static readonly Color256 Cyan = new(11, ColorType.Foreground);
|
public static readonly Color256 Cyan = new(14, ColorType.Foreground);
|
||||||
public static readonly Color256 DarkBlue = new(1, ColorType.Foreground);
|
public static readonly Color256 DarkBlue = new(4, ColorType.Foreground);
|
||||||
public static readonly Color256 DarkCyan = new(3, ColorType.Foreground);
|
public static readonly Color256 DarkCyan = new(6, ColorType.Foreground);
|
||||||
public static readonly Color256 DarkGray = new(8, ColorType.Foreground);
|
public static readonly Color256 DarkGray = new(8, ColorType.Foreground);
|
||||||
public static readonly Color256 DarkGreen = new(2, ColorType.Foreground);
|
public static readonly Color256 DarkGreen = new(2, ColorType.Foreground);
|
||||||
public static readonly Color256 DarkMagenta = new(5, ColorType.Foreground);
|
public static readonly Color256 DarkMagenta = new(5, ColorType.Foreground);
|
||||||
public static readonly Color256 DarkRed = new(4, ColorType.Foreground);
|
public static readonly Color256 DarkRed = new(1, ColorType.Foreground);
|
||||||
public static readonly Color256 DarkYellow = new(6, ColorType.Foreground);
|
public static readonly Color256 DarkYellow = new(3, ColorType.Foreground);
|
||||||
public static readonly Color256 Gray = new(7, ColorType.Foreground);
|
public static readonly Color256 Gray = new(15, ColorType.Foreground);
|
||||||
public static readonly Color256 Green = new(10, ColorType.Foreground);
|
public static readonly Color256 Green = new(10, ColorType.Foreground);
|
||||||
public static readonly Color256 Magenta = new(13, ColorType.Foreground);
|
public static readonly Color256 Magenta = new(13, ColorType.Foreground);
|
||||||
public static readonly Color256 Red = new(12, ColorType.Foreground);
|
public static readonly Color256 Red = new(9, ColorType.Foreground);
|
||||||
public static readonly Color256 White = new(15, ColorType.Foreground);
|
public static readonly Color256 White = new(7, ColorType.Foreground);
|
||||||
|
public static readonly Color256 Yellow = new(11, ColorType.Background);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using TerminalUI.Extensions;
|
using TerminalUI.Extensions;
|
||||||
using TerminalUI.Models;
|
using TerminalUI.Models;
|
||||||
using TerminalUI.ViewExtensions;
|
using TerminalUI.ViewExtensions;
|
||||||
@@ -7,6 +8,8 @@ namespace TerminalUI.Controls;
|
|||||||
|
|
||||||
public class Grid<T> : ChildContainerView<T>
|
public class Grid<T> : ChildContainerView<T>
|
||||||
{
|
{
|
||||||
|
private ILogger<Grid<T>>? Logger => ApplicationContext?.LoggerFactory?.CreateLogger<Grid<T>>();
|
||||||
|
|
||||||
private delegate void WithSizes(Span<int> widths, Span<int> heights);
|
private delegate void WithSizes(Span<int> widths, Span<int> heights);
|
||||||
|
|
||||||
private delegate TResult WithSizes<TResult>(Span<int> widths, Span<int> heights);
|
private delegate TResult WithSizes<TResult>(Span<int> widths, Span<int> heights);
|
||||||
@@ -91,6 +94,18 @@ public class Grid<T> : ChildContainerView<T>
|
|||||||
var x = positionExtension?.Column ?? 0;
|
var x = positionExtension?.Column ?? 0;
|
||||||
var y = positionExtension?.Row ?? 0;
|
var y = positionExtension?.Row ?? 0;
|
||||||
|
|
||||||
|
if (x > columnWidths.Length)
|
||||||
|
{
|
||||||
|
Logger?.LogWarning("Child {Child} is out of bounds, x: {X}, y: {Y}", child, x, y);
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y > rowHeights.Length)
|
||||||
|
{
|
||||||
|
Logger?.LogWarning("Child {Child} is out of bounds, x: {X}, y: {Y}", child, x, y);
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
var width = columnWidths[x];
|
var width = columnWidths[x];
|
||||||
var height = rowHeights[y];
|
var height = rowHeights[y];
|
||||||
|
|
||||||
|
|||||||
@@ -126,13 +126,103 @@ public partial class ListView<TDataContext, TItem> : View<TDataContext>
|
|||||||
if (_listViewItems is null || _listViewItemLength == 0)
|
if (_listViewItems is null || _listViewItemLength == 0)
|
||||||
return new Size(0, 0);
|
return new Size(0, 0);
|
||||||
|
|
||||||
var itemSize = _listViewItems[0].GetRequestedSize();
|
if (Orientation == Orientation.Vertical)
|
||||||
_requestedItemSize = itemSize;
|
{
|
||||||
return itemSize with {Height = itemSize.Height * _listViewItemLength};
|
var itemSize = _listViewItems[0].GetRequestedSize();
|
||||||
|
_requestedItemSize = itemSize;
|
||||||
|
return itemSize with {Height = itemSize.Height * _listViewItemLength};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var width = 0;
|
||||||
|
var height = 0;
|
||||||
|
for (var i = 0; i < _listViewItemLength; i++)
|
||||||
|
{
|
||||||
|
var item = _listViewItems[i];
|
||||||
|
width += item.GetRequestedSize().Width;
|
||||||
|
height = Math.Max(height, item.GetRequestedSize().Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Size(width, height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DefaultRenderer(Position position, Size size)
|
protected override void DefaultRenderer(Position position, Size size)
|
||||||
{
|
{
|
||||||
|
if (Orientation == Orientation.Vertical)
|
||||||
|
RenderVertical(position, size);
|
||||||
|
else
|
||||||
|
RenderHorizontal(position, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RenderHorizontal(Position position, Size size)
|
||||||
|
{
|
||||||
|
//Note: no support for same width elements
|
||||||
|
var listViewItems = InstantiateItemViews();
|
||||||
|
if (listViewItems.Length == 0) return;
|
||||||
|
|
||||||
|
Span<Size> requestedSizes = stackalloc Size[_listViewItemLength];
|
||||||
|
|
||||||
|
var totalRequestedWidth = 0;
|
||||||
|
Span<int> widthSumUpToIndex = stackalloc int[_listViewItemLength];
|
||||||
|
for (var i = 0; i < listViewItems.Length; i++)
|
||||||
|
{
|
||||||
|
widthSumUpToIndex[i] = totalRequestedWidth;
|
||||||
|
var item = listViewItems[i];
|
||||||
|
var requestedItemSize = item.GetRequestedSize();
|
||||||
|
totalRequestedWidth += requestedItemSize.Width;
|
||||||
|
requestedSizes[i] = requestedItemSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
var renderStartIndex = _renderStartIndex;
|
||||||
|
var lastItemIndex = _listViewItemLength;
|
||||||
|
|
||||||
|
if (totalRequestedWidth > size.Width)
|
||||||
|
{
|
||||||
|
//Moving the render "window" to the right
|
||||||
|
//Until the selected item's end is in it
|
||||||
|
//So when RenderStartPosition (ie all the widths up to RenderStartIndex) + size.Width >= SelectedItemEnd
|
||||||
|
var selectedIndexEnd = widthSumUpToIndex[SelectedIndex] + requestedSizes[SelectedIndex].Width;
|
||||||
|
var startXOfRenderStartItem = widthSumUpToIndex[renderStartIndex];
|
||||||
|
|
||||||
|
while (selectedIndexEnd > startXOfRenderStartItem + size.Width)
|
||||||
|
{
|
||||||
|
startXOfRenderStartItem += requestedSizes[renderStartIndex].Width;
|
||||||
|
renderStartIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Moving the render "window" to the left
|
||||||
|
//Until the selected item's start is in it
|
||||||
|
//So when RenderStartPosition (ie all the widths up to RenderStartIndex) <= SelectedItemStart
|
||||||
|
var selectedIndexStart = widthSumUpToIndex[SelectedIndex];
|
||||||
|
startXOfRenderStartItem = widthSumUpToIndex[renderStartIndex];
|
||||||
|
while (selectedIndexStart < startXOfRenderStartItem)
|
||||||
|
{
|
||||||
|
renderStartIndex--;
|
||||||
|
startXOfRenderStartItem -= requestedSizes[renderStartIndex].Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var deltaX = 0;
|
||||||
|
for (var i = renderStartIndex; i < _listViewItemLength; i++)
|
||||||
|
{
|
||||||
|
var item = listViewItems[i];
|
||||||
|
var requestedItemSize = requestedSizes[i];
|
||||||
|
var width = requestedItemSize.Width;
|
||||||
|
var nextDeltaX = deltaX + requestedItemSize.Width;
|
||||||
|
if (nextDeltaX > size.Width)
|
||||||
|
{
|
||||||
|
width = size.Width - deltaX;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.Render(position with {X = position.X + deltaX}, size with {Width = width});
|
||||||
|
deltaX = nextDeltaX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RenderVertical(Position position, Size size)
|
||||||
|
{
|
||||||
|
//Note: only same height is supported
|
||||||
var requestedItemSize = _requestedItemSize;
|
var requestedItemSize = _requestedItemSize;
|
||||||
if (requestedItemSize.Height == 0 || requestedItemSize.Width == 0)
|
if (requestedItemSize.Height == 0 || requestedItemSize.Width == 0)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user