Debugger symbol for ConsoleApp

This commit is contained in:
2024-05-27 07:59:13 +02:00
parent ff5e5497c5
commit 96eb0c07bf
5 changed files with 30 additions and 3 deletions

View File

@@ -25,5 +25,6 @@ public interface IRootViewModel
IItemPreviewService ItemPreviewService { get; }
IClipboardService ClipboardService { get; }
IAdminElevationManager AdminElevationManager { get; }
IDeclarativeProperty<bool> IsDebuggerAttached { get; }
event Action<IInputElement>? FocusReadInputElement;
}

View File

@@ -1,4 +1,5 @@
using System.Globalization;
using System.Diagnostics;
using System.Globalization;
using FileTime.App.Core.Models.Enums;
using FileTime.App.Core.ViewModels;
using FileTime.ConsoleUI.App.Configuration;
@@ -172,6 +173,15 @@ public class MainWindow
}.Setup(t => t.Bind(
t,
dc => dc!.ClipboardService.Content.Count > 1,
tb => tb.IsVisible)),
new TextBlock<IRootViewModel>
{
Text = /*_consoleApplicationConfiguration.Value.ClipboardMultipleIcon ??*/
(_consoleApplicationConfiguration.Value.DisableUtf8 ? "DB " : "\udb80\udce4"),
AsciiOnly = false
}.Setup(t => t.Bind(
t,
dc => dc.IsDebuggerAttached.Value,
tb => tb.IsVisible))
}
},

View File

@@ -1,4 +1,5 @@
using DeclarativeProperty;
using System.Diagnostics;
using DeclarativeProperty;
using FileTime.App.CommandPalette.ViewModels;
using FileTime.App.Core.Services;
using FileTime.App.Core.ViewModels;
@@ -8,11 +9,13 @@ using FileTime.ConsoleUI.App.Services;
using FileTime.Core.Interactions;
using FileTime.Core.Models;
using FileTime.Providers.LocalAdmin;
using TerminalUI.Traits;
namespace FileTime.ConsoleUI.App;
public partial class RootViewModel : IRootViewModel
public partial class RootViewModel : IRootViewModel, IBeforeRender
{
private readonly DeclarativeProperty<bool> _isDebuggerAttached = new(Debugger.IsAttached);
public string UserName => Environment.UserName;
public string MachineName => Environment.MachineName;
public IPossibleCommandsViewModel PossibleCommands { get; }
@@ -25,6 +28,7 @@ public partial class RootViewModel : IRootViewModel
public IDialogService DialogService { get; }
public ITimelineViewModel TimelineViewModel { get; }
public IDeclarativeProperty<VolumeSizeInfo?> VolumeSizeInfo { get; }
public IDeclarativeProperty<bool> IsDebuggerAttached => _isDebuggerAttached;
public event Action<IInputElement>? FocusReadInputElement;
@@ -73,4 +77,6 @@ public partial class RootViewModel : IRootViewModel
.Switch()
.Map(async l => l is null ? null : await l.Provider.GetVolumeSizeInfoAsync(l.FullName!));
}
public void BeforeRender() => _isDebuggerAttached.SetValue(Debugger.IsAttached);
}

View File

@@ -209,6 +209,10 @@ public class RenderEngine : IRenderEngine
{
view.Attached = true;
view.GetRequestedSize();
if (view.DataContext is IBeforeRender beforeRenderHandler)
{
beforeRenderHandler.BeforeRender();
}
view.Render(renderContext, position, size);
}
catch (Exception e)

View File

@@ -0,0 +1,6 @@
namespace TerminalUI.Traits;
public interface IBeforeRender
{
void BeforeRender();
}