trying to fix avalonia
This commit is contained in:
265
launcher-client-wpf/GUI/App.xaml
Normal file
265
launcher-client-wpf/GUI/App.xaml
Normal file
@@ -0,0 +1,265 @@
|
||||
<Application x:Class="Launcher.Client.WPF.GUI.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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" />
|
||||
|
||||
|
||||
<ControlTemplate x:Key="myScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid x:Name="Bg" SnapsToDevicePixels="True">
|
||||
<Border Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="{DynamicResource MyDarkTr}"
|
||||
BorderThickness="0" />
|
||||
<Track x:Name="PART_Track"
|
||||
IsDirectionReversed="True"
|
||||
IsEnabled="{TemplateBinding IsMouseOver}">
|
||||
<Track.Thumb>
|
||||
<Thumb>
|
||||
<Thumb.Style>
|
||||
<Style TargetType="{x:Type Thumb}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Border x:Name="rectangle"
|
||||
Width="6"
|
||||
Height="{TemplateBinding Height}"
|
||||
Background="{DynamicResource MyGray}"
|
||||
SnapsToDevicePixels="True" />
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="rectangle" Property="Background" Value="{DynamicResource MyGray}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsDragging" Value="True">
|
||||
<Setter TargetName="rectangle" Property="Background" Value="{DynamicResource MySelectionColor}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Thumb.Style>
|
||||
</Thumb>
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="myScrollViewer" TargetType="{x:Type ScrollViewer}">
|
||||
<Grid x:Name="Grid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle x:Name="Corner"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
|
||||
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
CanContentScroll="{TemplateBinding CanContentScroll}"
|
||||
CanHorizontallyScroll="False"
|
||||
CanVerticallyScroll="False"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
<ScrollBar x:Name="PART_VerticalScrollBar"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
AutomationProperties.AutomationId="VerticalScrollBar"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Cursor="Arrow"
|
||||
Maximum="{TemplateBinding ScrollableHeight}"
|
||||
Minimum="0"
|
||||
Template="{DynamicResource myScrollBar}"
|
||||
ViewportSize="{TemplateBinding ViewportHeight}"
|
||||
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
|
||||
Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<ScrollBar x:Name="PART_HorizontalScrollBar"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
AutomationProperties.AutomationId="HorizontalScrollBar"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Cursor="Arrow"
|
||||
Maximum="{TemplateBinding ScrollableWidth}"
|
||||
Minimum="0"
|
||||
Orientation="Horizontal"
|
||||
Template="{DynamicResource myScrollBar}"
|
||||
ViewportSize="{TemplateBinding ViewportWidth}"
|
||||
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
|
||||
Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="MyTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="IsReadOnly" Value="True" />
|
||||
<Setter Property="Background" Value="{DynamicResource MyDarkTr}" />
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource MyWhite}" />
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource MySelectionColor}" />
|
||||
<Setter Property="Template" Value="{DynamicResource myTextBox}" />
|
||||
<Setter Property="TextWrapping" Value="Wrap" />
|
||||
</Style>
|
||||
<ControlTemplate x:Key="myTextBox" TargetType="{x:Type TextBoxBase}">
|
||||
<Border Name="Border"
|
||||
Padding="0"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderThickness="2">
|
||||
<ScrollViewer x:Name="PART_ContentHost"
|
||||
Margin="0"
|
||||
Template="{DynamicResource myScrollViewer}" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter TargetName="Border" Property="Background" Value="Black" />
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="White" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="MyButtonStyle" TargetType="Button">
|
||||
<Setter Property="Template" Value="{DynamicResource MyButton}" />
|
||||
<Setter Property="Background" Value="{DynamicResource MyDarkTr}" />
|
||||
<Setter Property="BorderThickness" Value="3" />
|
||||
<Setter Property="FontFamily" Value="Unispace" />
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource MyWhite}" />
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="MyButton" TargetType="Button">
|
||||
<Border x:Name="Border"
|
||||
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderBrush="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<Grid>
|
||||
<Border x:Name="Border_fade"
|
||||
Background="{DynamicResource MyWhite}"
|
||||
Opacity="0.2"
|
||||
Visibility="Hidden" />
|
||||
<Border x:Name="Border_fade2"
|
||||
Background="{DynamicResource MyGray}"
|
||||
Opacity="0.4"
|
||||
Visibility="Hidden" />
|
||||
<ContentPresenter Margin="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
RecognizesAccessKey="True" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter TargetName="Border_fade" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter TargetName="Border_fade" Property="Visibility" Value="Hidden" />
|
||||
<Setter TargetName="Border_fade2" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="MyLabelStyle" TargetType="Label">
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="Background" Value="{DynamicResource MyDarkTr}" />
|
||||
<Setter Property="FontFamily" Value="Unispace" />
|
||||
<Setter Property="FontStyle" Value="Normal" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource MyWhite}" />
|
||||
<!-->disables some shit which removes underscores from Content<!-->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Label}">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
RecognizesAccessKey="False" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="MyComboBox" TargetType="ComboBox">
|
||||
<Grid>
|
||||
<ToggleButton Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="5*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border x:Name="Border"
|
||||
Grid.ColumnSpan="2"
|
||||
Background="{DynamicResource MyDarkTr}" />
|
||||
<Border Grid.Column="0"
|
||||
Margin="1"
|
||||
Background="{DynamicResource MyDarkTr}" />
|
||||
<Path x:Name="Arrow"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Data="M 0 0 L 4 4 L 8 0 Z"
|
||||
Fill="{DynamicResource MySelectionColor}" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="ToggleButton.IsMouseOver" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MySelectionColor}" />
|
||||
</Trigger>
|
||||
<Trigger Property="ToggleButton.IsChecked" Value="true">
|
||||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource MySelectionColor}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
</ToggleButton>
|
||||
<ContentPresenter Name="ContentSite"
|
||||
Margin="3"
|
||||
Content="{TemplateBinding SelectionBoxItem}"
|
||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
|
||||
IsHitTestVisible="False" />
|
||||
<TextBox x:Name="PART_EditableTextBox"
|
||||
IsReadOnly="{TemplateBinding IsReadOnly}"
|
||||
Visibility="Hidden" />
|
||||
<Popup Name="Popup"
|
||||
AllowsTransparency="True"
|
||||
Focusable="False"
|
||||
IsOpen="{TemplateBinding IsDropDownOpen}"
|
||||
Placement="Bottom"
|
||||
PopupAnimation="Slide">
|
||||
<Grid Name="DropDown"
|
||||
MinWidth="{TemplateBinding ActualWidth}"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
SnapsToDevicePixels="True">
|
||||
<Border x:Name="DropDownBorder" Background="{DynamicResource MyDarkTr}" />
|
||||
<ScrollViewer SnapsToDevicePixels="True">
|
||||
<StackPanel IsItemsHost="True" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Popup>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
27
launcher-client-wpf/GUI/App.xaml.cs
Normal file
27
launcher-client-wpf/GUI/App.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public static SolidColorBrush MyDark,MySoftDark, MyWhite, MyGreen, MyOrange, MySelectionColor;
|
||||
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
base.OnStartup(e);
|
||||
MyDark = (SolidColorBrush)Resources["MyDarkTr"];
|
||||
MySoftDark = (SolidColorBrush)Resources["MyGray"];
|
||||
MyWhite = (SolidColorBrush)Resources["MyWhite"];
|
||||
MyGreen = (SolidColorBrush)Resources["MyGreen"];
|
||||
MyOrange = (SolidColorBrush)Resources["MySelectionColor"];
|
||||
MySelectionColor = (SolidColorBrush)Resources["MySelectionColor"];
|
||||
_Main(e.Args);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{ LogError("STARTUP",ex); }
|
||||
}
|
||||
}
|
||||
|
||||
226
launcher-client-wpf/GUI/LauncherWindow.xaml
Normal file
226
launcher-client-wpf/GUI/LauncherWindow.xaml
Normal file
@@ -0,0 +1,226 @@
|
||||
<Window x:Class="Launcher.Client.WPF.GUI.LauncherWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Launcher.Client.WPF.GUI"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="Launcher"
|
||||
Width="800"
|
||||
Height="500"
|
||||
MinWidth="800"
|
||||
MinHeight="500"
|
||||
Background="{DynamicResource MyBackgroundColor}"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="40" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="5" />
|
||||
</Grid.RowDefinitions>
|
||||
<Image x:Name="BackgroundImage"
|
||||
Grid.RowSpan="5"
|
||||
Grid.ColumnSpan="3"
|
||||
HorizontalAlignment="Center"
|
||||
Stretch="UniformToFill" />
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<local:TabButton x:Name="LibraryButton"
|
||||
Grid.Column="0"
|
||||
Content="Library"
|
||||
FontSize="18"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<local:TabButton x:Name="DownloadsButton"
|
||||
Grid.Column="2"
|
||||
Content="Downloads"
|
||||
FontSize="18"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<local:TabButton x:Name="LogButton"
|
||||
Grid.Column="4"
|
||||
Content="Log"
|
||||
FontSize="18"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<local:TabButton x:Name="SettingsButton"
|
||||
Grid.Column="6"
|
||||
Content="Settings"
|
||||
FontSize="18"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="LibraryGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Visibility="Visible">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="220" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="220" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<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">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="70" />
|
||||
<RowDefinition Height="5" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label x:Name="NameLabel"
|
||||
Grid.Row="0"
|
||||
Content="name"
|
||||
FontSize="19"
|
||||
FontWeight="Bold"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<StackPanel Grid.Row="2"
|
||||
HorizontalAlignment="Right"
|
||||
ClipToBounds="True"
|
||||
Orientation="Horizontal">
|
||||
<Button x:Name="RemoveButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Background="{DynamicResource MyRed}"
|
||||
Content="Remove"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<Button x:Name="InstallButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Content="Install"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<Button x:Name="UpdateButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Content="Update"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
<Button x:Name="LaunchButton"
|
||||
Width="100"
|
||||
Margin="2,0"
|
||||
Background="{DynamicResource MyGreen}"
|
||||
Content="Launch"
|
||||
Style="{DynamicResource MyButtonStyle}" />
|
||||
</StackPanel>
|
||||
<TextBox x:Name="DescriptionBox"
|
||||
Grid.Row="4"
|
||||
Style="{DynamicResource MyTextBoxStyle}"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
<TextBox x:Name="ProgramLogBox"
|
||||
Grid.Row="6"
|
||||
Style="{DynamicResource MyTextBoxStyle}"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="0" Grid.Column="4">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="95" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Content="version:"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Background="{DynamicResource MyDarkTr}"
|
||||
Template="{DynamicResource MyComboBox}">
|
||||
<ComboBoxItem IsSelected="True">
|
||||
<Label Background="Transparent"
|
||||
Content="v1"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<Label Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Content="directory:"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<Label Name="ProgramDirectoryLabel"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Content="0"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<Label Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Content="size:"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<Label Name="ProgramSizeLabel"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Content="0"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
</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"
|
||||
Visibility="Hidden" />
|
||||
|
||||
<Grid x:Name="LogGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Visibility="Hidden">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Label x:Name="LogfileLabel"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Content="logfile"
|
||||
FontStyle="Italic"
|
||||
Style="{DynamicResource MyLabelStyle}" />
|
||||
<TextBox x:Name="LogBox"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Style="{DynamicResource MyTextBoxStyle}"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="SettingsGrid"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Visibility="Hidden" />
|
||||
</Grid>
|
||||
</Window>
|
||||
100
launcher-client-wpf/GUI/LauncherWindow.xaml.cs
Normal file
100
launcher-client-wpf/GUI/LauncherWindow.xaml.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public partial class LauncherWindow : Window
|
||||
{
|
||||
public LauncherWindow()
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
LogBox.Text = Logger.Buffer;
|
||||
Logger.MessageSent += LogHandler;
|
||||
LogfileLabel.Content = Logger.LogfileName.Remove(0,Logger.LogfileName.LastIndexOf(Путь.Разд)+1);
|
||||
LogfileLabel.MouseLeftButtonDown += (_,_)=>
|
||||
Process.Start("explorer.exe", LauncherLogger.LogfileDir);
|
||||
LogfileLabel.MouseEnter += (_,_)=>LogfileLabel.Foreground=App.MySelectionColor;
|
||||
LogfileLabel.MouseLeave += (_,_)=>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.Visibility = Visibility.Hidden;
|
||||
SelectTab(LibraryButton, null);
|
||||
FillProgramsPanel();
|
||||
Logger.Log("launcher started");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{ LogError("LAUNCHER WINDOW INIT",ex); }
|
||||
}
|
||||
|
||||
void LogHandler(string m) => Dispatcher.Invoke(()=>LogBox.Text += m);
|
||||
|
||||
|
||||
private TabButton CurrentTab;
|
||||
void SelectTab(object sender, RoutedEventArgs _)
|
||||
{
|
||||
if(CurrentTab!=null)
|
||||
{
|
||||
CurrentTab.Background = App.MyDark;
|
||||
CurrentTab.TabGrid.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
var selected = (TabButton)sender;
|
||||
selected.Background = App.MySelectionColor;
|
||||
selected.TabGrid.Visibility = Visibility.Visible;
|
||||
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 = FontWeights.Normal;
|
||||
}
|
||||
else ProgramGrid.Visibility = Visibility.Visible;
|
||||
|
||||
selectedProg.ProgramLabel.Foreground = App.MySelectionColor;
|
||||
selectedProg.ProgramLabel.FontWeight = FontWeights.Bold;
|
||||
|
||||
NameLabel.Content = selectedProg.Name;
|
||||
DescriptionBox.Text = selectedProg.Description;
|
||||
BackgroundImage.Source =
|
||||
new BitmapImage(new Uri(
|
||||
$"{Directory.GetCurrent()}{Путь.Разд}backgrounds{Путь.Разд}{selectedProg.BackgroundFile}",
|
||||
UriKind.Absolute));
|
||||
ProgramSettingsViever.Content = selectedProg.SettingsPanel;
|
||||
DisplayingProgram = selectedProg;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{ LogError("SelectProgram()",ex); }
|
||||
}
|
||||
}
|
||||
33
launcher-client-wpf/GUI/ProgramLabel.xaml
Normal file
33
launcher-client-wpf/GUI/ProgramLabel.xaml
Normal file
@@ -0,0 +1,33 @@
|
||||
<UserControl x:Class="Launcher.Client.WPF.GUI.ProgramLabel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Launcher.Client.WPF.GUI"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Height="50"
|
||||
Background="{DynamicResource MyDarkTr}"
|
||||
BorderBrush="{Binding Foreground, RelativeSource={RelativeSource Self}}"
|
||||
BorderThickness="3"
|
||||
Foreground="{DynamicResource MyWhite}"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding Height, RelativeSource={RelativeSource FindAncestor, AncestorType=local:ProgramLabel}}" />
|
||||
<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 Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProgramLabel}}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
16
launcher-client-wpf/GUI/ProgramLabel.xaml.cs
Normal file
16
launcher-client-wpf/GUI/ProgramLabel.xaml.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public partial class ProgramLabel : UserControl
|
||||
{
|
||||
public ProgramLabel(string label, string icon)
|
||||
{
|
||||
InitializeComponent();
|
||||
NameLabel.Content = label;
|
||||
IconImage.Source = new BitmapImage(new Uri(
|
||||
$"{Directory.GetCurrent()}{Путь.Разд}icons{Путь.Разд}{icon}",
|
||||
UriKind.Absolute));
|
||||
}
|
||||
}
|
||||
28
launcher-client-wpf/GUI/ProgramSettingsPanelItem.xaml
Normal file
28
launcher-client-wpf/GUI/ProgramSettingsPanelItem.xaml
Normal file
@@ -0,0 +1,28 @@
|
||||
<UserControl x:Class="Launcher.Client.WPF.GUI.ProgramSettingsPanelItem"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Launcher.Client.WPF.GUI"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignWidth="100"
|
||||
d:DesignHeight="30"
|
||||
mc:Ignorable="d"
|
||||
Background="Transparent">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Name="KeyLabel" Grid.Column="0"
|
||||
Content="{Binding SettingKey, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProgramSettingsPanelItem}}"
|
||||
Style="{DynamicResource MyLabelStyle}"
|
||||
FontFamily="default"
|
||||
FontSize="16"/>
|
||||
<TextBox Name="ValueBox" Grid.Column="1"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
Style="{DynamicResource MyTextBoxStyle}"
|
||||
VerticalScrollBarVisibility="Disabled"
|
||||
IsReadOnly="False"
|
||||
Text="{Binding SettingValue, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProgramSettingsPanelItem}}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
45
launcher-client-wpf/GUI/ProgramSettingsPanelItem.xaml.cs
Normal file
45
launcher-client-wpf/GUI/ProgramSettingsPanelItem.xaml.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public partial class ProgramSettingsPanelItem : UserControl
|
||||
{
|
||||
public static readonly DependencyProperty SettingKeyProp = DependencyProperty.Register(
|
||||
"SettingKey",
|
||||
typeof(string),
|
||||
typeof(ProgramSettingsPanelItem));
|
||||
public string SettingKey
|
||||
{
|
||||
get => (string)GetValue(SettingKeyProp);
|
||||
set
|
||||
{
|
||||
SetValue(SettingKeyProp, value);
|
||||
KeyLabel.ToolTip = new ToolTip
|
||||
{
|
||||
Content = value,
|
||||
Foreground = App.MyWhite,
|
||||
Background = App.MySoftDark
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SettingValueProp = DependencyProperty.Register(
|
||||
"SettingValue",
|
||||
typeof(string),
|
||||
typeof(ProgramSettingsPanelItem));
|
||||
public string SettingValue
|
||||
{
|
||||
get => (string)GetValue(SettingValueProp);
|
||||
set => SetValue(SettingValueProp, value);
|
||||
}
|
||||
|
||||
public event Action<ProgramSettingsPanelItem> UpdatedEvent;
|
||||
|
||||
public ProgramSettingsPanelItem(string key, string value)
|
||||
{
|
||||
InitializeComponent();
|
||||
SettingKey = key;
|
||||
SettingValue = value;
|
||||
ValueBox.TextChanged += (_,_)=> UpdatedEvent?.Invoke(this);
|
||||
}
|
||||
}
|
||||
16
launcher-client-wpf/GUI/TabButton.cs
Normal file
16
launcher-client-wpf/GUI/TabButton.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Launcher.Client.WPF.GUI;
|
||||
|
||||
public class TabButton : Button
|
||||
{
|
||||
public static readonly DependencyProperty TabGridProp = DependencyProperty.Register(
|
||||
"TabGrid",
|
||||
typeof(Grid),
|
||||
typeof(TabButton));
|
||||
public Grid TabGrid
|
||||
{
|
||||
get => (Grid)GetValue(TabGridProp);
|
||||
set => SetValue(TabGridProp, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user