Skip to content

Commit

Permalink
Additions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lixkote committed May 21, 2024
1 parent 96b37cb commit 67240cc
Show file tree
Hide file tree
Showing 9 changed files with 308 additions and 123 deletions.
163 changes: 99 additions & 64 deletions DirectStart/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Windows;
using B8TAM;
using System.Diagnostics;
using System.Linq;
using System.IO.Pipes;

namespace AFSM
{
Expand All @@ -24,89 +26,122 @@ public App()
Current.Shutdown();
}
}
private void HandleTriggerArgument()
{
using (var client = new NamedPipeClientStream(".", "DirectStartPipe", PipeDirection.Out))
{
try
{
client.Connect();
using (var writer = new StreamWriter(client))
{
writer.WriteLine("TRIGGER");
writer.Flush();
}
}
catch (IOException ex)
{
// Log or handle the error as needed
Debug.WriteLine("Named pipe error: " + ex.Message);
}
}
}

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

// Read the text file from %HOMEPATH%
string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "DirectStart", "Tiles", "config.txt");
try
string debug = "false";

// Check if the trigger argument is passed
if (e.Args.Contains("/trigger") || debug == "true")
{
// Handle the trigger functionality
HandleTriggerArgument();
// Shutdown the application if it was started just to trigger
Environment.Exit(0);
}
else
{
if (File.Exists(filePath))
// Read the text file from %HOMEPATH%
string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "DirectStart", "Tiles", "config.txt");
try
{
// Read the content of the text file
string[] lines = File.ReadAllLines(filePath);
if (File.Exists(filePath))
{
// Read the content of the text file
string[] lines = File.ReadAllLines(filePath);

// Initialize variables to hold configuration values
string theme = null;
string profilePictureShape = null;
string forceFillStartButton = null;
string retrobarfix = null;
// Initialize variables to hold configuration values
string theme = null;
string profilePictureShape = null;
string forceFillStartButton = null;
string retrobarfix = null;

// Parse each line of the config file
foreach (string line in lines)
{
string[] parts = line.Split('=');
if (parts.Length == 2)
// Parse each line of the config file
foreach (string line in lines)
{
string key = parts[0].Trim();
string value = parts[1].Trim();

// Apply configuration based on the key
switch (key.ToLower())
string[] parts = line.Split('=');
if (parts.Length == 2)
{
case "theme":
theme = value;
break;
case "profilepictureshape":
profilePictureShape = value;
break;
case "forcefillstartbutton":
forceFillStartButton = value;
break;
case "RetroBarFix":
retrobarfix = value;
break;
default:
// Handle unknown keys if necessary
break;
string key = parts[0].Trim();
string value = parts[1].Trim();

// Apply configuration based on the key
switch (key.ToLower())
{
case "theme":
theme = value;
break;
case "profilepictureshape":
profilePictureShape = value;
break;
case "forcefillstartbutton":
forceFillStartButton = value;
break;
case "RetroBarFix":
retrobarfix = value;
break;
default:
// Handle unknown keys if necessary
break;
}
}
}
}

// Apply the theme
if (!string.IsNullOrEmpty(theme))
{
string resourceDictionaryPath = GetResourceDictionaryPath(theme);
if (!string.IsNullOrEmpty(resourceDictionaryPath))
{
// Set the ResourceDictionary for the theme
ResourceDictionary skinDictionary = new ResourceDictionary();
skinDictionary.Source = new Uri(resourceDictionaryPath, UriKind.RelativeOrAbsolute);
Resources.MergedDictionaries.Add(skinDictionary);
}
else
// Apply the theme
if (!string.IsNullOrEmpty(theme))
{
MessageBox.Show("Invalid theme specified in the config file.");
string resourceDictionaryPath = GetResourceDictionaryPath(theme);
if (!string.IsNullOrEmpty(resourceDictionaryPath))
{
// Set the ResourceDictionary for the theme
ResourceDictionary skinDictionary = new ResourceDictionary();
skinDictionary.Source = new Uri(resourceDictionaryPath, UriKind.RelativeOrAbsolute);
Resources.MergedDictionaries.Add(skinDictionary);
}
else
{
MessageBox.Show("Invalid theme specified in the config file.");
}
}
}

// Store profilePictureShape and forceFillStartButton in application-level resources
this.Resources["ProfilePictureShape"] = profilePictureShape;
this.Resources["ForceFillStartButton"] = forceFillStartButton;
this.Resources["RetroBarFix"] = retrobarfix;
// Store profilePictureShape and forceFillStartButton in application-level resources
this.Resources["ProfilePictureShape"] = profilePictureShape;
this.Resources["ForceFillStartButton"] = forceFillStartButton;
this.Resources["RetroBarFix"] = retrobarfix;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "B8taMenu had an issue loading the config file or its values.");
Debug.WriteLine(ex.ToString(), "B8taMenu had an issue loading the config file or its values.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "B8taMenu had an issue loading the config file or its values.");
Debug.WriteLine(ex.ToString(), "B8taMenu had an issue loading the config file or its values.");
}

// Initialize your main window or any other startup logic
StartMenu mainWindow = new StartMenu();
mainWindow.Show();
// Initialize your main window or any other startup logic
StartMenu mainWindow = new StartMenu();
mainWindow.Show();
}
}

private string GetResourceDictionaryPath(string themeName)
Expand Down
6 changes: 3 additions & 3 deletions DirectStart/Skins/Metro.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Style x:Key="IsSkinSupportDuiBackgroundColor" TargetType="{x:Type TextBlock}">
<!-- False for not support background dui color, true for support background dui color. -->
<!-- This applies the metro dui color (the one from windows 8.1 start screen) to the start menu background-->
<Setter Property="Text" Value="False"></Setter>
<Setter Property="Text" Value="True"></Setter>
</Style>

<Style x:Key="PowerGlyphStyle" TargetType="{x:Type Image}">
Expand Down Expand Up @@ -54,11 +54,11 @@
</Style>

<Style x:Key="StartMenuBackgroundStyle" TargetType="{x:Type Grid}">
<Setter Property="Background">
<!--<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="pack://siteoforigin:,,,/Resources/demo3.png"/>
</Setter.Value>
</Setter>
</Setter>-->
</Style>


Expand Down
2 changes: 1 addition & 1 deletion DirectStart/StartMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Visibility="{Binding Text.IsEmpty, Converter={StaticResource BoolToVis}, Element
<SolidColorBrush Color="#CC000000" Opacity="0.7"/>
</TextBlock.Foreground>
</TextBlock>
<TextBox x:Name="SearchText" HorizontalAlignment="Stretch" TextChanged="TextBox_TextChanged" VerticalContentAlignment="Center" Background="Transparent" BorderThickness="0" Margin="15,0,0,0">
<TextBox x:Name="SearchText" HorizontalAlignment="Stretch" TextChanged="SearchText_TextChanged" VerticalContentAlignment="Center" Background="Transparent" BorderThickness="0" Margin="15,0,0,0">
<TextBox.InputBindings>
<KeyBinding Key="Return"
Command="{Binding Run}"
Expand Down
Loading

0 comments on commit 67240cc

Please sign in to comment.