part of client logic moved to new project
This commit is contained in:
24
Launcher.Client.Avalonia/GUI/App.axaml
Normal file
24
Launcher.Client.Avalonia/GUI/App.axaml
Normal file
@@ -0,0 +1,24 @@
|
||||
<Application x:Class="Launcher.Client.Avalonia.GUI.App"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Resources>
|
||||
<SolidColorBrush x:Key="MyBackgroundColor" Color="#232328" />
|
||||
<SolidColorBrush x:Key="MyDarkTr"
|
||||
Opacity="0.8"
|
||||
Color="#141419" />
|
||||
<SolidColorBrush x:Key="MyGray" Color="#46464B" />
|
||||
<SolidColorBrush x:Key="MyWhite" Color="#F0F0F0" />
|
||||
<SolidColorBrush x:Key="MyGreen" Color="#28C311" />
|
||||
<SolidColorBrush x:Key="MyRed" Color="#E5160A" />
|
||||
<SolidColorBrush x:Key="MySelectionColor" Color="#B7800A" />
|
||||
</Application.Resources>
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme Mode="Dark" />
|
||||
|
||||
<Style Selector="TextBox.MyTextBoxStyle" />
|
||||
<Style Selector="Label.MyLabelStyle" />
|
||||
<Style Selector="Button.MyButtonStyle" />
|
||||
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
38
Launcher.Client.Avalonia/GUI/App.axaml.cs
Normal file
38
Launcher.Client.Avalonia/GUI/App.axaml.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
global using Avalonia;
|
||||
global using Avalonia.Controls;
|
||||
global using Avalonia.Media;
|
||||
global using Avalonia.Media.Imaging;
|
||||
global using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
|
||||
namespace Launcher.Client.Avalonia.GUI
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
public static SolidColorBrush MyDark, MySoftDark, MyWhite, MyGreen, MyOrange, MySelectionColor;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
MyDark = (SolidColorBrush)Resources["MyDarkTr"];
|
||||
MySoftDark = (SolidColorBrush)Resources["MyGray"];
|
||||
MyWhite = (SolidColorBrush)Resources["MyWhite"];
|
||||
MyGreen = (SolidColorBrush)Resources["MyGreen"];
|
||||
MyOrange = (SolidColorBrush)Resources["MySelectionColor"];
|
||||
MySelectionColor = (SolidColorBrush)Resources["MySelectionColor"];
|
||||
}
|
||||
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
CurrentLauncherWindow = new LauncherWindow();
|
||||
desktop.MainWindow = CurrentLauncherWindow;
|
||||
CurrentLauncherWindow.Show();
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
180
Launcher.Client.Avalonia/GUI/LauncherWindow.axaml
Normal file
180
Launcher.Client.Avalonia/GUI/LauncherWindow.axaml
Normal file
@@ -0,0 +1,180 @@
|
||||
<Window x:Class="Launcher.Client.Avalonia.GUI.LauncherWindow"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Launcher.Client.Avalonia.GUI"
|
||||
Title="Launcher"
|
||||
Width="800"
|
||||
Height="500"
|
||||
MinWidth="800"
|
||||
MinHeight="500"
|
||||
Background="{DynamicResource MyBackgroundColor}">
|
||||
<Grid ColumnDefinitions="5,*,5" RowDefinitions="5,40,5,*,5">
|
||||
<Image x:Name="BackgroundImage"
|
||||
Grid.RowSpan="5"
|
||||
Grid.ColumnSpan="3"
|
||||
HorizontalAlignment="Center"
|
||||
Stretch="UniformToFill" />
|
||||
|
||||
<Grid x:Name="TopPanelGrid"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
ColumnDefinitions="*,5,*,5,*,5,*">
|
||||
<local:TabButton x:Name="LibraryButton"
|
||||
Grid.Column="0"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Library"
|
||||
FontSize="18" />
|
||||
<local:TabButton x:Name="DownloadsButton"
|
||||
Grid.Column="2"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Downloads"
|
||||
FontSize="18" />
|
||||
<local:TabButton x:Name="LogButton"
|
||||
Grid.Column="4"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Log"
|
||||
FontSize="18" />
|
||||
<local:TabButton x:Name="SettingsButton"
|
||||
Grid.Column="6"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Settings"
|
||||
FontSize="18" />
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="LibraryGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
ColumnDefinitions="220,5,*,5,220"
|
||||
IsVisible="true">
|
||||
<ScrollViewer Grid.Column="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Template="{DynamicResource myScrollViewer}"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel x:Name="ProgramsPanel" />
|
||||
</ScrollViewer>
|
||||
<Grid x:Name="ProgramGrid"
|
||||
Grid.Column="2"
|
||||
RowDefinitions="35,5,35,5,70,5,*">
|
||||
<Label x:Name="NameLabel"
|
||||
Grid.Row="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="name"
|
||||
FontSize="19"
|
||||
FontWeight="Bold" />
|
||||
<StackPanel Grid.Row="2"
|
||||
HorizontalAlignment="Right"
|
||||
ClipToBounds="True"
|
||||
Orientation="Horizontal">
|
||||
<Button x:Name="RemoveButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Background="{DynamicResource MyRed}"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Remove" />
|
||||
<Button x:Name="InstallButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Install" />
|
||||
<Button x:Name="UpdateButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Update" />
|
||||
<Button x:Name="LaunchButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Background="{DynamicResource MyGreen}"
|
||||
Classes="MyButtonStyle"
|
||||
Content="Launch" />
|
||||
</StackPanel>
|
||||
<TextBox x:Name="DescriptionBox"
|
||||
Grid.Row="4"
|
||||
Classes="MyTextBoxStyle"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" />
|
||||
<TextBox x:Name="ProgramLogBox"
|
||||
Grid.Row="6"
|
||||
Classes="MyTextBoxStyle"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="0"
|
||||
Grid.Column="4"
|
||||
RowDefinitions="95,*">
|
||||
<Grid Grid.Row="0"
|
||||
ColumnDefinitions="*,*"
|
||||
RowDefinitions="30,30,30">
|
||||
|
||||
<Label Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="version:" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Background="{DynamicResource MyDarkTr}"
|
||||
Template="{DynamicResource MyComboBox}">
|
||||
<ComboBoxItem IsSelected="True">
|
||||
<Label Background="Transparent"
|
||||
Classes="MyLabelStyle"
|
||||
Content="v1" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<Label Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="directory:" />
|
||||
<Label Name="ProgramDirectoryLabel"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Classes="MyLabelStyle"
|
||||
Content="0" />
|
||||
<Label Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="size:" />
|
||||
<Label Name="ProgramSizeLabel"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Classes="MyLabelStyle"
|
||||
Content="0" />
|
||||
</Grid>
|
||||
<ScrollViewer Name="ProgramSettingsViever"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Top"
|
||||
Template="{DynamicResource myScrollViewer}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Grid x:Name="DownloadsGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
IsVisible="false" />
|
||||
|
||||
<Grid x:Name="LogGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
IsVisible="false"
|
||||
RowDefinitions="30,*">
|
||||
<Label x:Name="LogfileLabel"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="logfile"
|
||||
FontStyle="Italic" />
|
||||
<TextBox x:Name="LogBox"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Classes="MyTextBoxStyle"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto" />
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="SettingsGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
IsVisible="false" />
|
||||
</Grid>
|
||||
</Window>
|
||||
94
Launcher.Client.Avalonia/GUI/LauncherWindow.axaml.cs
Normal file
94
Launcher.Client.Avalonia/GUI/LauncherWindow.axaml.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public partial class LauncherWindow : Window
|
||||
{
|
||||
public LauncherWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
LogBox.Text = Logger.Buffer;
|
||||
Logger.MessageSent += LogHandler;
|
||||
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Путь.Разд)+1);
|
||||
LogfileLabel.PointerPressed += (_,_)=>
|
||||
Process.Start("explorer.exe", LauncherLogger.LogfileDir);
|
||||
LogfileLabel.PointerEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
|
||||
LogfileLabel.PointerLeave += (_,_)=>LogfileLabel.Foreground=App.MyWhite;
|
||||
LibraryButton.TabGrid = LibraryGrid;
|
||||
DownloadsButton.TabGrid = DownloadsGrid;
|
||||
LogButton.TabGrid = LogGrid;
|
||||
SettingsButton.TabGrid = SettingsGrid;
|
||||
LibraryButton.Click += SelectTab;
|
||||
DownloadsButton.Click += SelectTab;
|
||||
LogButton.Click += SelectTab;
|
||||
SettingsButton.Click += SelectTab;
|
||||
ProgramGrid.IsVisible = false;
|
||||
SelectTab(LibraryButton, null);
|
||||
FillProgramsPanel();
|
||||
Logger.Log("launcher started");
|
||||
}
|
||||
|
||||
void LogHandler(string m) => Dispatcher.UIThread.InvokeAsync(()=>LogBox.Text += m);
|
||||
|
||||
|
||||
private TabButton CurrentTab;
|
||||
void SelectTab(object sender, RoutedEventArgs _)
|
||||
{
|
||||
if(CurrentTab!=null)
|
||||
{
|
||||
CurrentTab.Background = App.MyDark;
|
||||
CurrentTab.TabGrid.IsVisible = false;
|
||||
}
|
||||
var selected = (TabButton)sender;
|
||||
selected.Background = App.MySelectionColor;
|
||||
selected.TabGrid.IsVisible = true;
|
||||
CurrentTab = selected;
|
||||
}
|
||||
|
||||
public Program[] Programs;
|
||||
|
||||
private void FillProgramsPanel()
|
||||
{
|
||||
Logger.Log("reading descriptors...");
|
||||
string[] descriptors = Directory.GetFiles("descriptors");
|
||||
Programs = new Program[descriptors.Length];
|
||||
for (ushort i = 0; i < descriptors.Length; i++)
|
||||
{
|
||||
string descriptor = descriptors[i];
|
||||
if(descriptor.EndsWith(".descriptor"))
|
||||
{
|
||||
Logger.Log('\t'+descriptor);
|
||||
Programs[i] = new Program(descriptors[i]);
|
||||
ProgramsPanel.Children.Add(Programs[i].ProgramLabel);
|
||||
Programs[i].ProgramSelectedEvent += SelectProgram;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Program DisplayingProgram;
|
||||
public void SelectProgram(Program selectedProg)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DisplayingProgram != null)
|
||||
{
|
||||
DisplayingProgram.ProgramLabel.Foreground = App.MyWhite;
|
||||
DisplayingProgram.ProgramLabel.FontWeight = FontWeight.Normal;
|
||||
}
|
||||
else ProgramGrid.IsVisible = true;
|
||||
|
||||
selectedProg.ProgramLabel.Foreground = App.MySelectionColor;
|
||||
selectedProg.ProgramLabel.FontWeight = FontWeight.Bold;
|
||||
|
||||
NameLabel.Content = selectedProg.Name;
|
||||
DescriptionBox.Text = selectedProg.Description;
|
||||
BackgroundImage.Source = new Bitmap(
|
||||
$"{Directory.GetCurrent()}{Путь.Разд}backgrounds{Путь.Разд}{selectedProg.BackgroundFile}");
|
||||
ProgramSettingsViever.Content = selectedProg.SettingsPanel;
|
||||
DisplayingProgram = selectedProg;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{ LogError("SelectProgram()",ex); }
|
||||
}
|
||||
}
|
||||
9
Launcher.Client.Avalonia/GUI/MessageBox.axaml
Normal file
9
Launcher.Client.Avalonia/GUI/MessageBox.axaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<Window x:Class="Launcher.Client.Avalonia.GUI.MessageBox"
|
||||
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"
|
||||
Title="MessageBox"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d" />
|
||||
17
Launcher.Client.Avalonia/GUI/MessageBox.axaml.cs
Normal file
17
Launcher.Client.Avalonia/GUI/MessageBox.axaml.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public partial class MessageBox : Window
|
||||
{
|
||||
public MessageBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Show(string title, string text)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
30
Launcher.Client.Avalonia/GUI/ProgramLabel.axaml
Normal file
30
Launcher.Client.Avalonia/GUI/ProgramLabel.axaml
Normal file
@@ -0,0 +1,30 @@
|
||||
<UserControl x:Class="Launcher.Client.Avalonia.GUI.ProgramLabel"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Launcher.Client.Avalonia.GUI"
|
||||
Height="50"
|
||||
Background="{DynamicResource MyDarkTr}"
|
||||
BorderBrush="{Binding Foreground, RelativeSource={RelativeSource Self}}"
|
||||
BorderThickness="3"
|
||||
Foreground="{DynamicResource MyWhite}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding $parent[local:ProgramLabel].Height}" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image x:Name="IconImage"
|
||||
Grid.Column="0"
|
||||
Margin="3,3,3,3"
|
||||
Stretch="Fill" />
|
||||
|
||||
<Label Name="NameLabel"
|
||||
Grid.Column="1"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="label"
|
||||
FontFamily="Unispace"
|
||||
FontSize="15"
|
||||
FontWeight="Normal"
|
||||
Foreground="{Binding $parent[local:ProgramLabel].Foreground}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
14
Launcher.Client.Avalonia/GUI/ProgramLabel.axaml.cs
Normal file
14
Launcher.Client.Avalonia/GUI/ProgramLabel.axaml.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public partial class ProgramLabel : UserControl
|
||||
{
|
||||
public ProgramLabel() => InitializeComponent();
|
||||
|
||||
public ProgramLabel(string label, string icon)
|
||||
{
|
||||
InitializeComponent();
|
||||
NameLabel.Content = label;
|
||||
IconImage.Source = new Bitmap(
|
||||
$"{Directory.GetCurrent()}{Путь.Разд}icons{Путь.Разд}{icon}");
|
||||
}
|
||||
}
|
||||
22
Launcher.Client.Avalonia/GUI/ProgramSettingsPanelItem.axaml
Normal file
22
Launcher.Client.Avalonia/GUI/ProgramSettingsPanelItem.axaml
Normal file
@@ -0,0 +1,22 @@
|
||||
<UserControl x:Class="Launcher.Client.Avalonia.GUI.ProgramSettingsPanelItem"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Launcher.Client.Avalonia.GUI"
|
||||
Background="Transparent">
|
||||
<Grid ColumnDefinitions="*,*">
|
||||
<Label Name="KeyLabel"
|
||||
Grid.Column="0"
|
||||
Classes="MyLabelStyle"
|
||||
Content="{Binding $parent[local:ProgramSettingsPanelItem].SettingKey}"
|
||||
FontFamily="default"
|
||||
FontSize="16"
|
||||
ToolTip.Tip="{Binding $self.Content}" />
|
||||
<TextBox Name="ValueBox"
|
||||
Grid.Column="1"
|
||||
Classes="MyTextBoxStyle"
|
||||
IsReadOnly="False"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"
|
||||
Text="{Binding $parent[local:ProgramSettingsPanelItem].SettingValue}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public partial class ProgramSettingsPanelItem : UserControl
|
||||
{
|
||||
public static readonly StyledProperty<string> SettingKeyProp =
|
||||
AvaloniaProperty.Register<ProgramSettingsPanelItem, string>(
|
||||
"SettingKey");
|
||||
public string SettingKey
|
||||
{
|
||||
get => GetValue(SettingKeyProp);
|
||||
set => SetValue(SettingKeyProp, value);
|
||||
//TODO deal with textblock size
|
||||
/*KeyLabel.ToolTip = new ToolTip
|
||||
{
|
||||
Content = value,
|
||||
Foreground = App.MyWhite,
|
||||
Background = App.MySoftDark
|
||||
};*/
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<string> SettingValueProp =
|
||||
AvaloniaProperty.Register<ProgramSettingsPanelItem, string>("SettingValue");
|
||||
public string SettingValue
|
||||
{
|
||||
get => GetValue(SettingValueProp);
|
||||
set => SetValue(SettingValueProp, value);
|
||||
}
|
||||
|
||||
public event Action<ProgramSettingsPanelItem> UpdatedEvent;
|
||||
|
||||
public ProgramSettingsPanelItem() => InitializeComponent();
|
||||
|
||||
public ProgramSettingsPanelItem(string key, string value)
|
||||
{
|
||||
InitializeComponent();
|
||||
SettingKey = key;
|
||||
SettingValue = value;
|
||||
//TODO invoke UpdatedEvent only when focus changed
|
||||
ValueBox.TextInput += (_,_)=> UpdatedEvent?.Invoke(this);
|
||||
}
|
||||
}
|
||||
11
Launcher.Client.Avalonia/GUI/TabButton.cs
Normal file
11
Launcher.Client.Avalonia/GUI/TabButton.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Launcher.Client.Avalonia.GUI;
|
||||
|
||||
public class TabButton : Button
|
||||
{
|
||||
public static readonly StyledProperty<Grid> TabGridProp = AvaloniaProperty.Register<TabButton, Grid>("TabGrid");
|
||||
public Grid TabGrid
|
||||
{
|
||||
get => GetValue(TabGridProp);
|
||||
set => SetValue(TabGridProp, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user