mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-25 11:39:56 +08:00
ConsoleShell
This commit is contained in:
Submodule references/ArchiSteamFarm updated: 0e8796909b...11705eb67e
@@ -1,18 +0,0 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:AvalonEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="System.Application.UI.Views.Controls.AvaloniaShell">
|
||||
<AvalonEdit:TextEditor Name="Editor"
|
||||
FontFamily="Cascadia Code"
|
||||
Background="Gray"
|
||||
Margin="30"
|
||||
Foreground="White"
|
||||
SyntaxHighlighting="PowerShell"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
FontWeight="Light"
|
||||
FontSize="18" />
|
||||
</UserControl>
|
||||
@@ -1,19 +0,0 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace System.Application.UI.Views.Controls
|
||||
{
|
||||
public partial class AvaloniaShell : UserControl
|
||||
{
|
||||
public AvaloniaShell()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="System.Application.UI.Views.Controls.ConsoleShell">
|
||||
<UserControl.Styles>
|
||||
<Style Selector="TextBox">
|
||||
<Setter Property="FontSize" Value="16"></Setter>
|
||||
<Setter Property="Padding" Value="0"></Setter>
|
||||
<Setter Property="Margin" Value="0"></Setter>
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<ScrollViewer
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<Grid RowDefinitions="Auto,Auto">
|
||||
<TextBox x:Name="LogTextbox"
|
||||
Classes="readonlybox"
|
||||
TextWrapping="Wrap"/>
|
||||
<WrapPanel Grid.Row="1">
|
||||
<TextBlock Text="> "
|
||||
VerticalAlignment="Center"
|
||||
FontSize="16"/>
|
||||
<TextBox x:Name="CommandTextbox"
|
||||
Classes="readonlybox"
|
||||
IsReadOnly="False"
|
||||
VerticalContentAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
</TextBox>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,96 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ReactiveUI;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
|
||||
namespace System.Application.UI.Views.Controls
|
||||
{
|
||||
public partial class ConsoleShell : UserControl
|
||||
{
|
||||
public const string InputIndicator = "> ";
|
||||
public const string OutputIndicator = "< ";
|
||||
|
||||
///// <summary>
|
||||
///// Defines the <see cref="LogTexts"/> property.
|
||||
///// </summary>
|
||||
//public static readonly StyledProperty<IEnumerable?> LogTextsProperty =
|
||||
// AvaloniaProperty.Register<AvaloniaShell, IEnumerable?>(nameof(LogTexts), null);
|
||||
|
||||
///// <summary>
|
||||
///// 输出日志字符串集合
|
||||
///// </summary>
|
||||
//public IEnumerable? LogTexts
|
||||
//{
|
||||
// get => GetValue(LogTextsProperty);
|
||||
// set => SetValue(LogTextsProperty, value);
|
||||
//}
|
||||
|
||||
public StringBuilder LogText { get; set; } = new StringBuilder();
|
||||
|
||||
private CommandEventArgs? _commandSubmitArgs;
|
||||
/// <summary>
|
||||
/// 输入命令后按下回车触发
|
||||
/// </summary>
|
||||
public event EventHandler<CommandEventArgs>? CommandSubmit;
|
||||
|
||||
|
||||
private TextBox commandTextbox;
|
||||
private TextBox logTextbox;
|
||||
|
||||
public ConsoleShell()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
logTextbox = this.FindControl<TextBox>("LogTextbox");
|
||||
|
||||
commandTextbox = this.FindControl<TextBox>("CommandTextbox");
|
||||
commandTextbox.KeyUp += CommandTextbox_KeyUp;
|
||||
|
||||
//this.WhenAnyValue(x=>x.LogTexts)
|
||||
// .Subscribe(x=>x.);
|
||||
}
|
||||
|
||||
private void CommandTextbox_KeyUp(object? sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Avalonia.Input.Key.Enter)
|
||||
{
|
||||
OnCommandSubmit(commandTextbox.Text);
|
||||
commandTextbox.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnCommandSubmit(string command)
|
||||
{
|
||||
if (CommandSubmit != null)
|
||||
{
|
||||
if (_commandSubmitArgs == null)
|
||||
{
|
||||
_commandSubmitArgs = new CommandEventArgs();
|
||||
}
|
||||
else
|
||||
{
|
||||
_commandSubmitArgs.Command = command;
|
||||
}
|
||||
CommandSubmit(this, _commandSubmitArgs);
|
||||
}
|
||||
}
|
||||
|
||||
public void AppendLogText(string text)
|
||||
{
|
||||
LogText.AppendLine(OutputIndicator + text);
|
||||
logTextbox.Text = LogText.ToString();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class CommandEventArgs : EventArgs
|
||||
{
|
||||
public string? Command { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
<Separator Classes="Separator"></Separator>
|
||||
<ListBox SelectionMode="Single" Classes="metro" Background="Transparent">
|
||||
<ListBox SelectionMode="Single" Classes="metro" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="Button">
|
||||
<Setter Property="Width" Value="{Binding #UserMenu.Width}"></Setter>
|
||||
|
||||
+6
-4
@@ -33,16 +33,18 @@
|
||||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>-->
|
||||
|
||||
<AvalonEdit:TextEditor Name="Editor"
|
||||
<!--<AvalonEdit:TextEditor Name="Editor"
|
||||
FontFamily="{StaticResource UnicodeFont}"
|
||||
Background="Black"
|
||||
Background="{DynamicResource BackgroundColorKey}"
|
||||
Foreground="{DynamicResource HighlightForegroundBrushKey}"
|
||||
SyntaxHighlighting="PowerShell"
|
||||
SyntaxHighlighting="Json"
|
||||
WordWrap="true"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Visible" />
|
||||
VerticalScrollBarVisibility="Visible" />-->
|
||||
<!--<TextBox x:Name="console" IsReadOnly="True" AcceptsReturn="True" TextWrapping="Wrap" Text="{ReflectionBinding Source={x:Static service:ASFService.Current},Path=CommandText}"/>
|
||||
<TextBox x:Name="CommandTextbox" Grid.Row="1" Watermark="输入指令后按下Enter执行"/>-->
|
||||
<controls:ConsoleShell x:Name="ConsoleLog">
|
||||
</controls:ConsoleShell>
|
||||
</TabItem>
|
||||
<TabItem Header="ASF Web UI">
|
||||
<Panel>
|
||||
|
||||
+11
-4
@@ -8,12 +8,13 @@ using System.Application.Services;
|
||||
using System.IO;
|
||||
using AvaloniaEdit;
|
||||
using AvaloniaEdit.Highlighting;
|
||||
using System.Application.UI.Views.Controls;
|
||||
|
||||
namespace System.Application.UI.Views.Pages
|
||||
{
|
||||
public class ArchiSteamFarmPlusPage : ReactiveUserControl<ArchiSteamFarmPlusPageViewModel>
|
||||
{
|
||||
private readonly TextEditor _textEditor;
|
||||
private readonly ConsoleShell consoleShell;
|
||||
|
||||
public ArchiSteamFarmPlusPage()
|
||||
{
|
||||
@@ -23,18 +24,24 @@ namespace System.Application.UI.Views.Pages
|
||||
//commandTextbox = this.FindControl<TextBox>("CommandTextbox");
|
||||
//commandTextbox.KeyUp += CommandTextbox_KeyUp;
|
||||
|
||||
_textEditor = this.FindControl<TextEditor>("Editor");
|
||||
//_textEditor.ShowLineNumbers = true;
|
||||
//_textEditor = this.FindControl<TextEditor>("Editor");
|
||||
////_textEditor.ShowLineNumbers = true;
|
||||
|
||||
consoleShell = this.FindControl<ConsoleShell>("ConsoleLog");
|
||||
|
||||
IArchiSteamFarmService.Instance.GetConsoleWirteFunc = (message) =>
|
||||
{
|
||||
_textEditor.AppendText(message += Environment.NewLine);
|
||||
MainThreadDesktop.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
consoleShell.AppendLogText(message);
|
||||
});
|
||||
};
|
||||
|
||||
//_textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("PowerShell");
|
||||
//_textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered;
|
||||
//_textEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering;
|
||||
//_textEditor.TextArea.IndentationStrategy = new AvaloniaEdit.Indentation.CSharp.CSharpIndentationStrategy();
|
||||
|
||||
}
|
||||
|
||||
//private void CommandTextbox_KeyUp(object? sender, Avalonia.Input.KeyEventArgs e)
|
||||
|
||||
@@ -58,4 +58,10 @@
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.999-cibuild0014804-beta" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Application\UI\Views\Controls\ConsoleShell.axaml.cs">
|
||||
<DependentUpon>ConsoleShell.axaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user