diff --git a/launcher-client-win/GUI/App.xaml b/launcher-client-win/GUI/App.xaml
index e7e28b1..fc3e275 100644
--- a/launcher-client-win/GUI/App.xaml
+++ b/launcher-client-win/GUI/App.xaml
@@ -1,30 +1,46 @@
-
-
+
+
+
+
+
+
+
+
+
+
-
-
diff --git a/launcher-client-win/GUI/App.xaml.cs b/launcher-client-win/GUI/App.xaml.cs
index 38fddc6..fb2dabb 100644
--- a/launcher-client-win/GUI/App.xaml.cs
+++ b/launcher-client-win/GUI/App.xaml.cs
@@ -1,19 +1,28 @@
-namespace launcher_client_win;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace launcher_client_win.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["MyOrange"];
+ MySelectionColor = (SolidColorBrush)Resources["MySelectionColor"];
_Main(e.Args);
}
- catch (Exception ex)
- {
- MessageBox.Show($"STARTUP ERROR:\n{ex}");
- Shutdown();
- }
+ catch(Exception ex)
+ { LogError("STARTUP",ex); }
}
}
diff --git a/launcher-client-win/GUI/LauncherWindow.xaml b/launcher-client-win/GUI/LauncherWindow.xaml
index e1946fd..54254ab 100644
--- a/launcher-client-win/GUI/LauncherWindow.xaml
+++ b/launcher-client-win/GUI/LauncherWindow.xaml
@@ -1,98 +1,249 @@
-
+ xmlns:local="clr-namespace:launcher_client_win.GUI"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ Title="Launcher"
+ Width="800"
+ Height="500"
+ MinWidth="800"
+ MinHeight="500"
+ Background="#232328"
+ mc:Ignorable="d">
+
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
+
-
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
-
+
\ No newline at end of file
diff --git a/launcher-client-win/GUI/LauncherWindow.xaml.cs b/launcher-client-win/GUI/LauncherWindow.xaml.cs
index 9ef1b5b..efec0d0 100644
--- a/launcher-client-win/GUI/LauncherWindow.xaml.cs
+++ b/launcher-client-win/GUI/LauncherWindow.xaml.cs
@@ -1,9 +1,127 @@
-namespace launcher_client_win.GUI;
+using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+
+namespace launcher_client_win.GUI;
public partial class LauncherWindow : Window
{
public LauncherWindow()
{
- InitializeComponent();
+ try
+ {
+ InitializeComponent();
+ LogBox.Text = Logger.Buffer;
+ Logger.MessageSent += LogHandler;
+ LogfileLabel.Content = Logger.Logfile.Remove(0,Logger.Logfile.LastIndexOf(Path.Sep)+1);
+ LogfileLabel.MouseLeftButtonDown += (s,e)=>
+ Process.Start("explorer.exe", Logger.Logfile.Remove(Logger.Logfile.LastIndexOf(Path.Sep)));
+ LogfileLabel.MouseEnter += (s,e)=>LogfileLabel.Foreground=App.MySelectionColor;
+ LogfileLabel.MouseLeave += (s,e)=>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.Foreground = App.MyWhite;
+ CurrentTab.TabGrid.Visibility = Visibility.Collapsed;
+ }
+ var selected = (TabButton)sender;
+ selected.Foreground = App.MyGreen;
+ selected.TabGrid.Visibility = Visibility.Visible;
+ CurrentTab = selected;
+ }
+ void LibraryTab_activate(object sender, RoutedEventArgs eventArgs)
+ {
+ LibraryButton.Foreground = App.MyGreen;
+ LogButton.Foreground = App.MyWhite;
+ SettingsButton.Foreground = App.MyWhite;
+ LibraryGrid.Visibility = Visibility.Visible;
+ LogGrid.Visibility = Visibility.Hidden;
+ SettingsGrid.Visibility = Visibility.Hidden;
+ }
+ void LogTab_activate(object sender, RoutedEventArgs eventArgs)
+ {
+ LibraryButton.Foreground = App.MyWhite;
+ LogButton.Foreground = App.MyGreen;
+ SettingsButton.Foreground = App.MyWhite;
+ LibraryGrid.Visibility = Visibility.Hidden;
+ LogGrid.Visibility = Visibility.Visible;
+ SettingsGrid.Visibility = Visibility.Hidden;
+ }
+ void SettingsTab_activate(object sender, RoutedEventArgs eventArgs)
+ {
+ LibraryButton.Foreground = App.MyWhite;
+ LogButton.Foreground = App.MyWhite;
+ SettingsButton.Foreground = App.MyGreen;
+ LibraryGrid.Visibility = Visibility.Hidden;
+ LogGrid.Visibility = Visibility.Hidden;
+ SettingsGrid.Visibility = Visibility.Visible;
+ }
+
+ 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 selectedP)
+ {
+ try
+ {
+ if (DisplayingProgram != null)
+ {
+ DisplayingProgram.ProgramLabel.Foreground = App.MyWhite;
+ DisplayingProgram.ProgramLabel.FontWeight = FontWeights.Normal;
+ }
+ else ProgramGrid.Visibility = Visibility.Visible;
+
+ selectedP.ProgramLabel.Foreground = App.MyGreen;
+ selectedP.ProgramLabel.FontWeight = FontWeights.Bold;
+
+ NameLabel.Content = selectedP.Name;
+ DescriptionBox.Text = selectedP.Description;
+ BackgroundImage.Source =
+ new BitmapImage(new Uri(
+ $"{Directory.GetCurrent()}{Path.Sep}backgrounds{Path.Sep}{selectedP.BackgroundFile}",
+ UriKind.Absolute));
+ DisplayingProgram = selectedP;
+ }
+ catch(Exception ex)
+ { LogError("SelectProgram()",ex); }
}
}
\ No newline at end of file
diff --git a/launcher-client-win/GUI/ProgramLabel.xaml b/launcher-client-win/GUI/ProgramLabel.xaml
new file mode 100644
index 0000000..0657db5
--- /dev/null
+++ b/launcher-client-win/GUI/ProgramLabel.xaml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/launcher-client-win/GUI/ProgramLabel.xaml.cs b/launcher-client-win/GUI/ProgramLabel.xaml.cs
new file mode 100644
index 0000000..81920b2
--- /dev/null
+++ b/launcher-client-win/GUI/ProgramLabel.xaml.cs
@@ -0,0 +1,17 @@
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace launcher_client_win.GUI;
+
+public partial class ProgramLabel : UserControl
+{
+ public ProgramLabel(string label, string icon)
+ {
+ InitializeComponent();
+ NameLabel.Content = label;
+ IconImage.Source = new BitmapImage(new Uri(
+ $"{Directory.GetCurrent()}{Path.Sep}icons{Path.Sep}{icon}",
+ UriKind.Absolute));
+ }
+}
\ No newline at end of file
diff --git a/launcher-client-win/GUI/TabButton.cs b/launcher-client-win/GUI/TabButton.cs
new file mode 100644
index 0000000..db145dd
--- /dev/null
+++ b/launcher-client-win/GUI/TabButton.cs
@@ -0,0 +1,16 @@
+using System.Windows.Controls;
+
+namespace launcher_client_win.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);
+ }
+}
\ No newline at end of file
diff --git a/launcher-client-win/Launcher.cs b/launcher-client-win/Launcher.cs
index bf924ec..f1b528a 100644
--- a/launcher-client-win/Launcher.cs
+++ b/launcher-client-win/Launcher.cs
@@ -22,15 +22,20 @@ public static class Launcher
{
public static LauncherConfig Config;
public static readonly LauncherLogger Logger = new();
-
+ public static LauncherWindow CurrentLauncherWindow;
public static void _Main(string[] args)
{
Logger.Enable();
Config = new LauncherConfig();
- LauncherWindow launcherWindow = new();
- MessageBox.Show("HELLO");
- launcherWindow.Show();
+ Directory.Create("descriptors");
+ Directory.Create("icons");
+ Directory.Create("backgrounds");
+ Directory.Create("installed");
+ File.WriteAllText($"descriptors{Path.Sep}default.descriptor.template",
+ ReadResource("launcher_client_win.Resources.default.descriptor.template"));
+ CurrentLauncherWindow = new();
+ CurrentLauncherWindow.Show();
}
public static string ReadResource(string resource_path)
@@ -41,4 +46,11 @@ public static class Launcher
Encoding.UTF8);
return resourceStreamReader.ReadToEnd();
}
+
+ public static void LogError(string context, Exception ex)
+ {
+ string errmsg = $"{context} ERROR:\n{ex}";
+ MessageBox.Show(errmsg);
+ Logger.Log(errmsg);
+ }
}
\ No newline at end of file
diff --git a/launcher-client-win/Program.cs b/launcher-client-win/Program.cs
new file mode 100644
index 0000000..0b5d8d0
--- /dev/null
+++ b/launcher-client-win/Program.cs
@@ -0,0 +1,62 @@
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media.Imaging;
+using launcher_client_win.GUI;
+
+namespace launcher_client_win;
+
+public class Program
+{
+ public readonly string Name;
+ public readonly string Directory;
+ public readonly string Description;
+ public readonly string IconFile;
+ public readonly string BackgroundFile;
+ public readonly string LaunchFile;
+ public readonly string LaunchArgs;
+
+ public ProgramLabel ProgramLabel;
+ private Process ProgramProcess;
+
+ public Program(string descriptorFile)
+ {
+ DtsodV23 descriptor= new(File.ReadAllText(descriptorFile));
+ Name = descriptor["name"];
+ Directory = descriptor["directory"];
+ Description = descriptor["description"];
+ IconFile = descriptor["icon"];
+ BackgroundFile = descriptor["background"];
+ string startcommand = descriptor["launchcommand"];
+ LaunchFile = startcommand.Remove(startcommand.IndexOf(' '));
+ LaunchArgs = startcommand.Remove(0,startcommand.IndexOf(' '));
+ ProgramLabel = new ProgramLabel(Name, IconFile);
+
+ ProgramLabel.MouseLeftButtonDown += ProgramLabel_ClickHandler;
+ }
+
+ public event Action ProgramSelectedEvent;
+ void ProgramLabel_ClickHandler(object s, MouseButtonEventArgs e) => ProgramSelectedEvent?.Invoke(this);
+
+ public void Launch()
+ {
+ if(ProgramProcess.HasExited)
+ throw new Exception($"can't start program <{Name}>, because it hadn't stopped yet");
+ ProgramProcess = Process.Start(LaunchFile, LaunchArgs);
+ if (ProgramProcess is null)
+ throw new Exception($"program <{Name}> started, but ProgramProcess is null");
+ CurrentLauncherWindow.LaunchButton.Content = "Stop";
+ ProgramProcess.Exited += ProgramExitedHandler;
+ }
+
+ public void Stop()
+ {
+ if (!ProgramProcess.HasExited)
+ throw new Exception($"can't stop program <{Name}>, because it had stopped already");
+ ProgramProcess.Kill(true);
+ }
+
+ void ProgramExitedHandler(object sender, EventArgs eargs)
+ {
+ CurrentLauncherWindow.LaunchButton.Content = "Start";
+ }
+}
\ No newline at end of file
diff --git a/launcher-client-win/Resources/default.descriptor.template b/launcher-client-win/Resources/default.descriptor.template
new file mode 100644
index 0000000..876af23
--- /dev/null
+++ b/launcher-client-win/Resources/default.descriptor.template
@@ -0,0 +1,6 @@
+name: ""; #label, which displays in launcher
+directory: ""; #name of program' directory on server and client
+description: ""; #desctiption, which displays in launcher
+icon: ""; #name of the icon file
+background: ""; #name of the background file
+launchcommand: ""; #command, which starts the program
\ No newline at end of file
diff --git a/launcher-client-win/Resources/logo-D.ico b/launcher-client-win/Resources/logo-D.ico
new file mode 100644
index 0000000..9b68a7e
Binary files /dev/null and b/launcher-client-win/Resources/logo-D.ico differ
diff --git a/launcher-client-win/launcher-client-win.csproj b/launcher-client-win/launcher-client-win.csproj
index 4cec1c1..812a247 100644
--- a/launcher-client-win/launcher-client-win.csproj
+++ b/launcher-client-win/launcher-client-win.csproj
@@ -8,6 +8,8 @@
disable
disable
full
+ Resources\logo-D.ico
+