forked from amkovkov/GranuSightSoftware2
feat: SystemView
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using Avalonia.Threading;
|
||||
|
||||
using GSS2.UI.Core.ViewModels;
|
||||
|
||||
namespace GSS2.ViewModels.Common;
|
||||
@@ -8,4 +16,39 @@ public partial class SystemViewModel : ViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
void Close()
|
||||
{
|
||||
|
||||
Dispatcher.UIThread.InvokeShutdown();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
void Shutdown()
|
||||
{
|
||||
var process = new Process();
|
||||
process.StartInfo.FileName = "/usr/bin/sudo";
|
||||
process.StartInfo.Arguments = "/sbin/shutdown -h now";
|
||||
process.Start();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
void Reboot()
|
||||
{
|
||||
var process = new Process();
|
||||
process.StartInfo.FileName = "/usr/bin/sudo";
|
||||
process.StartInfo.Arguments = "/sbin/shutdown -r now";
|
||||
process.Start();
|
||||
}
|
||||
[RelayCommand]
|
||||
void Restart()
|
||||
{
|
||||
var process = new Process();
|
||||
process.StartInfo.FileName = "/home/granusight/.dotnet/dotnet";
|
||||
process.StartInfo.Arguments = Assembly.GetExecutingAssembly().Location;
|
||||
Dispatcher.UIThread.InvokeShutdown();
|
||||
process.Start();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,85 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
x:DataType="vm:SystemViewModel">
|
||||
|
||||
<Grid>
|
||||
<TextBlock Text="Системная страница" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<UserControl.Resources>
|
||||
<SolidColorBrush x:Key="MenuBackground" Color="#00357a" />
|
||||
<SolidColorBrush x:Key="MenuBorder" Color="#0865b2" />
|
||||
<SolidColorBrush x:Key="Overlay" Color="#0865b23f" />
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="#0865b2" />
|
||||
<SolidColorBrush x:Key="ButtonDangerBackground" Color="#b20808" />
|
||||
<SolidColorBrush x:Key="ButtonForeground" Color="#ffffff" />
|
||||
<SolidColorBrush x:Key="MainBackground" Color="#001e46" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.Styles>
|
||||
|
||||
<Style Selector="Button">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Background" Value="{StaticResource ButtonBackground}" />
|
||||
<Setter Property="Foreground" Value="{StaticResource ButtonForeground}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="Button.danger">
|
||||
<Setter Property="Background" Value="{StaticResource ButtonDangerBackground}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="Button.vertical">
|
||||
<Setter Property="MinWidth" Value="40" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="TextBox">
|
||||
<Setter Property="FontSize" Value="20"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="TextBox.singleline">
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="TextBox.multiline">
|
||||
<Setter Property="VerticalContentAlignment" Value="Top" />
|
||||
<Setter Property="AcceptsReturn" Value="True" />
|
||||
<Setter Property="TextWrapping" Value="Wrap" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="TextBlock">
|
||||
<Setter Property="FontSize" Value="20"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="TextBlock.mini">
|
||||
<Setter Property="FontSize" Value="16"/>
|
||||
<Setter Property="Margin" Value="0,0,0,0" />
|
||||
</Style>
|
||||
|
||||
</UserControl.Styles>
|
||||
|
||||
<Border Width="1080" Height="540">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" ColumnSpacing="20" RowSpacing="20">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="300"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Button Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" Command="{Binding CloseCommand}" >
|
||||
<TextBlock Text="Закрыть ПО"/>
|
||||
</Button>
|
||||
<Button Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" Command="{Binding RestartCommand}" >
|
||||
<TextBlock Text="Перезагрузить ПО"/>
|
||||
</Button>
|
||||
<Button Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" Command="{Binding ShutdownCommand}" >
|
||||
<TextBlock Text="Выключить прибор"/>
|
||||
</Button>
|
||||
<Button Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" Command="{Binding RebootCommand}" >
|
||||
<TextBlock Text="Перезагрузить прибор"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user