Improve Emulator management layout
This commit is contained in:
1 parent
8520c599b4
commit
5e6afd32d4
3 files changed
+234
-67
No files matched your search
+7
-3
@@ -51,7 +51,7 @@ internal static class EmulatorCli
|
|||||||
using var process = Process.Start(info) ?? throw new InvalidOperationException("无法启动 Emulator。");
|
using var process = Process.Start(info) ?? throw new InvalidOperationException("无法启动 Emulator。");
|
||||||
process.StandardInput.Close();
|
process.StandardInput.Close();
|
||||||
var capture = args[0] is "-list" or "-imageList";
|
var capture = args[0] is "-list" or "-imageList";
|
||||||
var stdout = ReadAsync(process.StandardOutput, log, capture, cancellation);
|
var stdout = ReadAsync(process.StandardOutput, capture ? null : log, capture, cancellation);
|
||||||
var stderr = ReadAsync(process.StandardError, log, false, cancellation);
|
var stderr = ReadAsync(process.StandardError, log, false, cancellation);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -66,17 +66,21 @@ internal static class EmulatorCli
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.ExitCode != 0)
|
if (process.ExitCode != 0)
|
||||||
|
{
|
||||||
|
if (capture)
|
||||||
|
log(await stdout);
|
||||||
throw new InvalidOperationException($"Emulator 退出码 {process.ExitCode}。请查看命令输出。");
|
throw new InvalidOperationException($"Emulator 退出码 {process.ExitCode}。请查看命令输出。");
|
||||||
|
}
|
||||||
return await stdout;
|
return await stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<string> ReadAsync(
|
private static async Task<string> ReadAsync(
|
||||||
StreamReader reader, Action<string> log, bool capture, CancellationToken cancellation)
|
StreamReader reader, Action<string>? log, bool capture, CancellationToken cancellation)
|
||||||
{
|
{
|
||||||
var output = new System.Text.StringBuilder();
|
var output = new System.Text.StringBuilder();
|
||||||
while (await reader.ReadLineAsync(cancellation) is { } line)
|
while (await reader.ReadLineAsync(cancellation) is { } line)
|
||||||
{
|
{
|
||||||
log(line);
|
log?.Invoke(line);
|
||||||
if (capture)
|
if (capture)
|
||||||
output.AppendLine(line);
|
output.AppendLine(line);
|
||||||
}
|
}
|
||||||
|
|||||||
+225
-62
@@ -1,5 +1,6 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Templates;
|
||||||
using Avalonia.Layout;
|
using Avalonia.Layout;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
@@ -7,15 +8,21 @@ using Avalonia.Threading;
|
|||||||
internal sealed class MainWindow : Window
|
internal sealed class MainWindow : Window
|
||||||
{
|
{
|
||||||
private readonly TextBox executable = new() { Text = EmulatorCli.DefaultPath(), Watermark = "Emulator 可执行文件路径" };
|
private readonly TextBox executable = new() { Text = EmulatorCli.DefaultPath(), Watermark = "Emulator 可执行文件路径" };
|
||||||
private readonly TextBox name = new() { Watermark = "实例名称", Width = 210 };
|
private readonly TextBox targetName = new() { Watermark = "选择列表中的实例" };
|
||||||
private readonly TextBox deviceType = new() { Watermark = "设备类型,如 phone", Width = 170, Text = "phone" };
|
private readonly TextBox name = new() { Watermark = "例如 My Phone" };
|
||||||
private readonly TextBox version = new() { Watermark = "HarmonyOS 镜像版本", Width = 270 };
|
private readonly TextBox deviceType = new() { Watermark = "例如 phone", Text = "phone" };
|
||||||
|
private readonly TextBox version = new() { Watermark = "例如 HarmonyOS 7.0.0(26.0.0)" };
|
||||||
private readonly CheckBox headless = new() { Content = "无窗口启动" };
|
private readonly CheckBox headless = new() { Content = "无窗口启动" };
|
||||||
private readonly ListBox instances = new() { MinHeight = 120 };
|
private readonly ListBox instances = new() { MinHeight = 120 };
|
||||||
private readonly ListBox images = new() { MinHeight = 120 };
|
private readonly ListBox images = new() { MinHeight = 120 };
|
||||||
private readonly ListBox output = new();
|
private readonly ListBox output = new() { MaxHeight = 156, MinHeight = 104 };
|
||||||
private readonly TextBlock status = new() { Text = "就绪", VerticalAlignment = VerticalAlignment.Center };
|
private readonly Button logToggle = new() { Content = "展开命令输出" };
|
||||||
private readonly Button cancel = new() { Content = "取消命令", IsEnabled = false };
|
private readonly TextBlock status = new()
|
||||||
|
{
|
||||||
|
Text = "就绪", VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
TextTrimming = TextTrimming.CharacterEllipsis
|
||||||
|
};
|
||||||
|
private readonly Button cancel = new() { Content = "取消命令", IsVisible = false };
|
||||||
private readonly List<Button> actions = [];
|
private readonly List<Button> actions = [];
|
||||||
private readonly HashSet<(string Executable, string Name)> starting = [];
|
private readonly HashSet<(string Executable, string Name)> starting = [];
|
||||||
private CancellationTokenSource? active;
|
private CancellationTokenSource? active;
|
||||||
@@ -23,10 +30,10 @@ internal sealed class MainWindow : Window
|
|||||||
internal MainWindow(bool smoke, Action<int> shutdown)
|
internal MainWindow(bool smoke, Action<int> shutdown)
|
||||||
{
|
{
|
||||||
Title = "HarmonyOS Emulator 管理器";
|
Title = "HarmonyOS Emulator 管理器";
|
||||||
Width = 990;
|
Width = 1060;
|
||||||
Height = 730;
|
Height = 690;
|
||||||
MinWidth = 740;
|
MinWidth = 780;
|
||||||
MinHeight = 580;
|
MinHeight = 570;
|
||||||
executable.TextChanged += (_, _) =>
|
executable.TextChanged += (_, _) =>
|
||||||
{
|
{
|
||||||
instances.ItemsSource = null;
|
instances.ItemsSource = null;
|
||||||
@@ -43,7 +50,7 @@ internal sealed class MainWindow : Window
|
|||||||
instances.SelectionChanged += (_, _) =>
|
instances.SelectionChanged += (_, _) =>
|
||||||
{
|
{
|
||||||
if (instances.SelectedItem is EmulatorInstance instance)
|
if (instances.SelectedItem is EmulatorInstance instance)
|
||||||
name.Text = instance.Name;
|
targetName.Text = instance.Name;
|
||||||
};
|
};
|
||||||
cancel.Click += (_, _) => active?.Cancel();
|
cancel.Click += (_, _) => active?.Cancel();
|
||||||
Closing += (_, args) =>
|
Closing += (_, args) =>
|
||||||
@@ -56,8 +63,15 @@ internal sealed class MainWindow : Window
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var instancePage = Page(
|
var instancePage = ManagementPage(
|
||||||
Row(headless, Command("刷新", RefreshInstances),
|
"模拟器实例", Row(Command("刷新", RefreshInstances)),
|
||||||
|
Table(instances, "1.1*,0.65*,1.55*,0.65*", ["实例名称", "设备类型", "系统版本", "状态"],
|
||||||
|
(EmulatorInstance item) => [item.Name, item.Type, item.Version, item.Running]),
|
||||||
|
Panel(
|
||||||
|
Caption("实例操作"),
|
||||||
|
Field("目标实例", targetName),
|
||||||
|
headless,
|
||||||
|
Row(
|
||||||
Command("启动", _ =>
|
Command("启动", _ =>
|
||||||
{
|
{
|
||||||
StartInstance();
|
StartInstance();
|
||||||
@@ -65,33 +79,36 @@ internal sealed class MainWindow : Window
|
|||||||
}),
|
}),
|
||||||
Command("停止", async token =>
|
Command("停止", async token =>
|
||||||
{
|
{
|
||||||
await Run(token, "-stop", Required(name, "实例名称"));
|
await Run(token, "-stop", Required(targetName, "目标实例"));
|
||||||
await RefreshInstances(token);
|
await RefreshInstances(token);
|
||||||
}),
|
})),
|
||||||
Command("删除实例", async token =>
|
Command("删除实例", async token =>
|
||||||
{
|
{
|
||||||
var target = Required(name, "实例名称");
|
var target = Required(targetName, "目标实例");
|
||||||
if (await Confirm($"删除实例「{target}」及其数据?"))
|
if (await Confirm($"删除实例「{target}」及其数据?"))
|
||||||
{
|
{
|
||||||
await Run(token, "-delete", target, "-force");
|
await Run(token, "-delete", target, "-force");
|
||||||
await RefreshInstances(token);
|
await RefreshInstances(token);
|
||||||
}
|
}
|
||||||
})),
|
})));
|
||||||
instances);
|
|
||||||
|
|
||||||
var imagePage = Page(
|
var imagePage = ManagementPage(
|
||||||
|
"系统镜像",
|
||||||
Row(Command("已下载", token => RefreshImages(token, true)),
|
Row(Command("已下载", token => RefreshImages(token, true)),
|
||||||
Command("全部镜像", token => RefreshImages(token, false)),
|
Command("全部镜像", token => RefreshImages(token, false))),
|
||||||
|
Table(images, "0.85*,1.65*,0.7*", ["设备类型", "系统版本", "下载状态"],
|
||||||
|
(EmulatorImage item) => [item.Type, item.Version, item.Downloaded]),
|
||||||
|
Panel(
|
||||||
|
Caption("镜像操作"),
|
||||||
|
Field("设备类型", deviceType),
|
||||||
|
Field("系统版本", version),
|
||||||
|
Row(
|
||||||
Command("下载镜像", async token =>
|
Command("下载镜像", async token =>
|
||||||
{
|
{
|
||||||
|
ShowLog(true);
|
||||||
await Run(token, ImageArgs("-install"));
|
await Run(token, ImageArgs("-install"));
|
||||||
await RefreshImages(token, true);
|
await RefreshImages(token, true);
|
||||||
}),
|
}),
|
||||||
Command("创建实例", async token =>
|
|
||||||
{
|
|
||||||
await Run(token, ["-create", Required(name, "实例名称"), .. ImageArgs()]);
|
|
||||||
await RefreshInstances(token);
|
|
||||||
}),
|
|
||||||
Command("删除镜像", async token =>
|
Command("删除镜像", async token =>
|
||||||
{
|
{
|
||||||
var args = ImageArgs("-uninstall");
|
var args = ImageArgs("-uninstall");
|
||||||
@@ -101,40 +118,65 @@ internal sealed class MainWindow : Window
|
|||||||
await RefreshImages(token, true);
|
await RefreshImages(token, true);
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
images);
|
Caption("创建模拟器"),
|
||||||
// The inputs stay visible while switching between instances and images.
|
Field("实例名称", name),
|
||||||
|
Command("创建实例", async token =>
|
||||||
|
{
|
||||||
|
await Run(token, ["-create", Required(name, "实例名称"), .. ImageArgs()]);
|
||||||
|
await RefreshInstances(token);
|
||||||
|
})));
|
||||||
|
output.ItemTemplate = new FuncDataTemplate<string>((line, _) => new TextBlock
|
||||||
|
{
|
||||||
|
Text = line, FontFamily = new FontFamily("monospace"), FontSize = 12,
|
||||||
|
TextWrapping = TextWrapping.Wrap
|
||||||
|
});
|
||||||
|
output.IsVisible = false;
|
||||||
|
logToggle.Click += (_, _) => ShowLog(!output.IsVisible);
|
||||||
|
|
||||||
|
var settings = Panel(
|
||||||
|
Caption("Emulator 工具"),
|
||||||
|
Field("可执行文件路径", executable),
|
||||||
|
Row(OutputCommand("查看版本", "-version"), OutputCommand("命令帮助", "--help"),
|
||||||
|
OutputCommand("查看许可协议", "-license"),
|
||||||
|
Command("接受许可", async token =>
|
||||||
|
{
|
||||||
|
if (await Confirm("确认已阅读并接受 Emulator 显示的许可协议?"))
|
||||||
|
{
|
||||||
|
ShowLog(true);
|
||||||
|
await Run(token, "-license", "accept");
|
||||||
|
}
|
||||||
|
})));
|
||||||
var tabs = new TabControl
|
var tabs = new TabControl
|
||||||
{
|
{
|
||||||
ItemsSource = new[]
|
ItemsSource = new[]
|
||||||
{
|
{
|
||||||
new TabItem { Header = "模拟器实例", Content = instancePage },
|
new TabItem { Header = "模拟器实例", Content = instancePage },
|
||||||
new TabItem { Header = "系统镜像", Content = imagePage }
|
new TabItem { Header = "系统镜像", Content = imagePage },
|
||||||
|
new TabItem { Header = "工具设置", Content = new Border
|
||||||
|
{
|
||||||
|
Margin = new Thickness(0, 16, 0, 0),
|
||||||
|
VerticalAlignment = VerticalAlignment.Top, Child = Card(settings)
|
||||||
|
} }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
tabs.SelectionChanged += async (_, args) =>
|
||||||
|
{
|
||||||
|
if (!smoke && args.Source == tabs && tabs.SelectedIndex == 1 && images.ItemsSource is null)
|
||||||
|
await Execute(token => RefreshImages(token, true));
|
||||||
|
};
|
||||||
var layout = new Grid
|
var layout = new Grid
|
||||||
{
|
{
|
||||||
Margin = new Thickness(24),
|
Margin = new Thickness(24),
|
||||||
RowDefinitions = new RowDefinitions("Auto,Auto,Auto,*,Auto,170,Auto")
|
RowDefinitions = new RowDefinitions("Auto,*,Auto")
|
||||||
};
|
};
|
||||||
Add(layout, new TextBlock { Text = "Emulator 管理", FontSize = 28, FontWeight = FontWeight.SemiBold }, 0);
|
Add(layout, new TextBlock { Text = "Emulator 管理", FontSize = 26, FontWeight = FontWeight.SemiBold }, 0);
|
||||||
var tools = new DockPanel { LastChildFill = true };
|
Add(layout, tabs, 1);
|
||||||
var help = Row(Command("版本", token => Run(token, "-version")),
|
var footer = new DockPanel();
|
||||||
Command("帮助", token => Run(token, "--help")),
|
var controls = Row(logToggle, cancel);
|
||||||
Command("许可协议", token => Run(token, "-license")),
|
DockPanel.SetDock(controls, Dock.Right);
|
||||||
Command("接受许可", async token =>
|
footer.Children.Add(controls);
|
||||||
{
|
footer.Children.Add(status);
|
||||||
if (await Confirm("确认已阅读并接受 Emulator 显示的许可协议?"))
|
Add(layout, Card(Panel(footer, output)), 2);
|
||||||
await Run(token, "-license", "accept");
|
|
||||||
}));
|
|
||||||
DockPanel.SetDock(help, Dock.Right);
|
|
||||||
tools.Children.Add(help);
|
|
||||||
tools.Children.Add(executable);
|
|
||||||
Add(layout, tools, 1);
|
|
||||||
Add(layout, Row(name, deviceType, version), 2);
|
|
||||||
Add(layout, tabs, 3);
|
|
||||||
Add(layout, new TextBlock { Text = "命令输出", FontWeight = FontWeight.SemiBold }, 4);
|
|
||||||
Add(layout, output, 5);
|
|
||||||
Add(layout, Row(cancel, status), 6);
|
|
||||||
Content = layout;
|
Content = layout;
|
||||||
|
|
||||||
if (smoke)
|
if (smoke)
|
||||||
@@ -162,12 +204,34 @@ internal sealed class MainWindow : Window
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RefreshInstances(CancellationToken token) =>
|
private async Task RefreshInstances(CancellationToken token)
|
||||||
instances.ItemsSource = EmulatorCli.Instances(await Run(token, "-list", "-details"));
|
{
|
||||||
|
var items = await ReadList(token, EmulatorCli.Instances, "-list", "-details");
|
||||||
|
instances.ItemsSource = items;
|
||||||
|
AppendOutput($"已读取 {items.Length} 个模拟器实例。");
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RefreshImages(CancellationToken token, bool downloaded) =>
|
private async Task RefreshImages(CancellationToken token, bool downloaded)
|
||||||
images.ItemsSource = EmulatorCli.Images(await Run(token, downloaded
|
{
|
||||||
? ["-imageList", "-downloaded", "true"] : ["-imageList"]));
|
var items = await ReadList(token, EmulatorCli.Images, downloaded
|
||||||
|
? ["-imageList", "-downloaded", "true"] : ["-imageList"]);
|
||||||
|
images.ItemsSource = items;
|
||||||
|
AppendOutput($"已读取 {items.Length} 个镜像。");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<T[]> ReadList<T>(CancellationToken token, Func<string, T[]> parse, params string[] args)
|
||||||
|
{
|
||||||
|
var raw = await Run(token, args);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return parse(raw);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
AppendOutput(raw);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string[] ImageArgs(params string[] prefix) =>
|
private string[] ImageArgs(params string[] prefix) =>
|
||||||
[.. prefix, "-deviceType", Required(deviceType, "设备类型"), "-osVersion", Required(version, "镜像版本")];
|
[.. prefix, "-deviceType", Required(deviceType, "设备类型"), "-osVersion", Required(version, "镜像版本")];
|
||||||
@@ -175,7 +239,7 @@ internal sealed class MainWindow : Window
|
|||||||
private void StartInstance()
|
private void StartInstance()
|
||||||
{
|
{
|
||||||
var path = Required(executable, "Emulator 路径");
|
var path = Required(executable, "Emulator 路径");
|
||||||
var target = Required(name, "实例名称");
|
var target = Required(targetName, "目标实例");
|
||||||
if (!starting.Add((path, target)))
|
if (!starting.Add((path, target)))
|
||||||
throw new InvalidOperationException($"「{target}」已有启动进程。");
|
throw new InvalidOperationException($"「{target}」已有启动进程。");
|
||||||
string[] args = headless.IsChecked == true ? ["-start", target, "-noWindow"] : ["-start", target];
|
string[] args = headless.IsChecked == true ? ["-start", target, "-noWindow"] : ["-start", target];
|
||||||
@@ -207,12 +271,27 @@ internal sealed class MainWindow : Window
|
|||||||
if (output.ItemCount >= 1500)
|
if (output.ItemCount >= 1500)
|
||||||
output.Items.RemoveAt(0);
|
output.Items.RemoveAt(0);
|
||||||
output.Items.Add(line);
|
output.Items.Add(line);
|
||||||
output.ScrollIntoView(line);
|
if (output.IsVisible)
|
||||||
|
output.ScrollIntoView(output.ItemCount - 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
private void ShowLog(bool visible)
|
||||||
|
{
|
||||||
|
output.IsVisible = visible;
|
||||||
|
logToggle.Content = visible ? "收起命令输出" : "展开命令输出";
|
||||||
|
if (visible && output.ItemCount > 0)
|
||||||
|
output.ScrollIntoView(output.ItemCount - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Button OutputCommand(string label, string argument) => Command(label, token =>
|
||||||
|
{
|
||||||
|
ShowLog(true);
|
||||||
|
return Run(token, argument);
|
||||||
});
|
});
|
||||||
|
|
||||||
private Button Command(string label, Func<CancellationToken, Task> action)
|
private Button Command(string label, Func<CancellationToken, Task> action)
|
||||||
{
|
{
|
||||||
var button = new Button { Content = label };
|
var button = new Button { Content = label, HorizontalAlignment = HorizontalAlignment.Left };
|
||||||
button.Click += async (_, _) => await Execute(action);
|
button.Click += async (_, _) => await Execute(action);
|
||||||
actions.Add(button);
|
actions.Add(button);
|
||||||
return button;
|
return button;
|
||||||
@@ -226,7 +305,7 @@ internal sealed class MainWindow : Window
|
|||||||
using var source = new CancellationTokenSource();
|
using var source = new CancellationTokenSource();
|
||||||
active = source;
|
active = source;
|
||||||
executable.IsEnabled = false;
|
executable.IsEnabled = false;
|
||||||
cancel.IsEnabled = true;
|
cancel.IsVisible = true;
|
||||||
actions.ForEach(button => button.IsEnabled = false);
|
actions.ForEach(button => button.IsEnabled = false);
|
||||||
status.Text = "正在执行…";
|
status.Text = "正在执行…";
|
||||||
try
|
try
|
||||||
@@ -241,12 +320,14 @@ internal sealed class MainWindow : Window
|
|||||||
catch (Exception error)
|
catch (Exception error)
|
||||||
{
|
{
|
||||||
status.Text = error.Message;
|
status.Text = error.Message;
|
||||||
|
AppendOutput(error.Message);
|
||||||
|
ShowLog(true);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
active = null;
|
active = null;
|
||||||
executable.IsEnabled = true;
|
executable.IsEnabled = true;
|
||||||
cancel.IsEnabled = false;
|
cancel.IsVisible = false;
|
||||||
actions.ForEach(button => button.IsEnabled = true);
|
actions.ForEach(button => button.IsEnabled = true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,15 +371,97 @@ internal sealed class MainWindow : Window
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DockPanel Page(Control toolbar, Control list)
|
private static Control ManagementPage(string title, Control toolbar, Control table, Control controls)
|
||||||
{
|
{
|
||||||
var panel = new DockPanel { Margin = new Thickness(0, 8, 0, 0) };
|
var header = new DockPanel();
|
||||||
DockPanel.SetDock(toolbar, Dock.Top);
|
DockPanel.SetDock(toolbar, Dock.Right);
|
||||||
panel.Children.Add(toolbar);
|
header.Children.Add(toolbar);
|
||||||
|
header.Children.Add(Caption(title));
|
||||||
|
var left = new Grid { RowDefinitions = new RowDefinitions("Auto,*") };
|
||||||
|
Add(left, header, 0);
|
||||||
|
Add(left, table, 1);
|
||||||
|
var grid = new Grid
|
||||||
|
{
|
||||||
|
Margin = new Thickness(0, 16, 0, 0),
|
||||||
|
ColumnDefinitions = new ColumnDefinitions("*,252")
|
||||||
|
};
|
||||||
|
grid.Children.Add(Card(left));
|
||||||
|
var sidebar = Card(new ScrollViewer { Content = controls });
|
||||||
|
sidebar.Margin = new Thickness(14, 0, 0, 0);
|
||||||
|
Grid.SetColumn(sidebar, 1);
|
||||||
|
grid.Children.Add(sidebar);
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Control Table<T>(ListBox list, string columns, string[] headings, Func<T, string[]> cells)
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
list.ItemTemplate = new FuncDataTemplate<T>((item, _) => TableRow(columns, cells(item!), false));
|
||||||
|
list.Padding = new Thickness(0);
|
||||||
|
var panel = new DockPanel();
|
||||||
|
var header = new Border
|
||||||
|
{
|
||||||
|
Background = new SolidColorBrush(Color.FromArgb(20, 128, 128, 128)),
|
||||||
|
CornerRadius = new CornerRadius(6),
|
||||||
|
Padding = new Thickness(10, 7),
|
||||||
|
Child = TableRow(columns, headings, true)
|
||||||
|
};
|
||||||
|
DockPanel.SetDock(header, Dock.Top);
|
||||||
|
panel.Children.Add(header);
|
||||||
panel.Children.Add(list);
|
panel.Children.Add(list);
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Grid TableRow(string columns, string[] values, bool header)
|
||||||
|
{
|
||||||
|
var grid = new Grid { ColumnDefinitions = new ColumnDefinitions(columns) };
|
||||||
|
for (var index = 0; index < values.Length; index++)
|
||||||
|
{
|
||||||
|
var cell = new TextBlock
|
||||||
|
{
|
||||||
|
Text = values[index],
|
||||||
|
TextTrimming = TextTrimming.CharacterEllipsis,
|
||||||
|
FontWeight = header || index == 0 ? FontWeight.SemiBold : FontWeight.Normal,
|
||||||
|
FontSize = 13, Margin = new Thickness(0, 0, 8, 0)
|
||||||
|
};
|
||||||
|
ToolTip.SetTip(cell, values[index]);
|
||||||
|
Grid.SetColumn(cell, index);
|
||||||
|
grid.Children.Add(cell);
|
||||||
|
}
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TextBlock Caption(string text) => new()
|
||||||
|
{
|
||||||
|
Text = text, FontSize = 16, FontWeight = FontWeight.SemiBold,
|
||||||
|
VerticalAlignment = VerticalAlignment.Center
|
||||||
|
};
|
||||||
|
|
||||||
|
private static StackPanel Field(string label, Control field)
|
||||||
|
{
|
||||||
|
var panel = Panel(new TextBlock { Text = label, FontSize = 12, Opacity = 0.78 }, field);
|
||||||
|
panel.Spacing = 5;
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static StackPanel Panel(params Control[] controls)
|
||||||
|
{
|
||||||
|
var panel = new StackPanel { Spacing = 10 };
|
||||||
|
foreach (var control in controls)
|
||||||
|
panel.Children.Add(control);
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Border Card(Control child) => new()
|
||||||
|
{
|
||||||
|
BorderThickness = new Thickness(1),
|
||||||
|
BorderBrush = new SolidColorBrush(Color.FromArgb(62, 128, 128, 128)),
|
||||||
|
Background = new SolidColorBrush(Color.FromArgb(12, 128, 128, 128)),
|
||||||
|
CornerRadius = new CornerRadius(10),
|
||||||
|
Padding = new Thickness(14),
|
||||||
|
Child = child
|
||||||
|
};
|
||||||
|
|
||||||
private static void Add(Grid grid, Control control, int row)
|
private static void Add(Grid grid, Control control, int row)
|
||||||
{
|
{
|
||||||
if (row > 0)
|
if (row > 0)
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
dotnet run --project EmulatorManager.csproj
|
dotnet run --project EmulatorManager.csproj
|
||||||
```
|
```
|
||||||
|
|
||||||
可在窗口顶部编辑 Emulator 路径,或预先设置环境变量 `HARMONY_EMULATOR`。程序也会尝试 `DEVECO_CLI_CLT_PATH`、常见安装目录和 PATH。Linux 上请按华为要求配置 KVM,必要时勾选无窗口启动。
|
可在「工具设置」中编辑 Emulator 路径,或预先设置环境变量 `HARMONY_EMULATOR`。程序也会尝试 `DEVECO_CLI_CLT_PATH`、常见安装目录和 PATH。Linux 上请按华为要求配置 KVM,必要时勾选无窗口启动。
|
||||||
|
|
||||||
- **模拟器实例**支持刷新、启动、停止、删除。
|
- **模拟器实例**支持刷新、启动、停止、删除。
|
||||||
- **系统镜像**支持查询全部和已下载镜像、下载、删除,也可用所选镜像创建实例。创建时填入实例名称。
|
- **系统镜像**支持查询全部和已下载镜像、下载、删除,也可用所选镜像创建实例。创建时填入实例名称。
|
||||||
- 首次使用可在界面中查看许可并确认接受。命令输出区显示官方工具返回的信息。
|
- 可在「工具设置」中查看许可并确认接受。底部可展开命令输出。
|
||||||
|
|
||||||
## 构建、运行并同步
|
## 构建、运行并同步
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user