Commit e7d70717 authored by Rene Hampölz's avatar Rene Hampölz 💻

Add functionality for programs without a menu, Code cleanup

parent 8797cd83
No preview for this file type
......@@ -26,20 +26,27 @@ namespace Main
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Height = 290;
MW.Width = 320;
if (App.Login || App.Register)
{
MW.Height = 290;
MW.Width = 320;
MW.ShowTitleBar = false;
MW.ShowMinButton = false;
MW.ShowTitleBar = false;
MW.ShowMinButton = false;
MW.CenterWindowOnScreen();
MW.CenterWindowOnScreen();
MW.Title = this.Title + " - " + App.AppName;
MW.Title = this.Title + " - " + App.AppName;
#pragma warning disable CS0618 // Typ oder Element ist veraltet
MW.WindowCloseButtonStyle = (Style)FindResource("CloseButtonStyle");
MW.WindowMinButtonStyle = null;
#pragma warning restore CS0618 // Typ oder Element ist veraltet
#pragma warning disable CS0618 // Typ oder Element ist veraltet
MW.WindowCloseButtonStyle = (Style)FindResource("CloseButtonStyle");
MW.WindowMinButtonStyle = null;
#pragma warning restore CS0618 // Typ oder Element ist veraltet
}
else if (App.SkipLogin || Properties.Settings.Default.SkipLogin)
{
MW.Load();
}
}
}
......
......@@ -25,6 +25,7 @@ namespace Main
public static String[] SiteTitle = {"Dein Konto"};
public static String[] SitePath = {"account.exe"};
public static String[] SitePathArgument = { "account.png" };
public static String[] SiteIcon = {"account.png"};
public static Boolean SkipLogin;
......@@ -33,6 +34,12 @@ namespace Main
public static String File;
public static Boolean HideMenu;
public static String EXE;
public static String EXEArgument;
private void App_Startup(object sender, StartupEventArgs e)
{
for (int i = 0; i != e.Args.Length; ++i)
......@@ -45,6 +52,7 @@ namespace Main
SiteTitle = XML.ReadList(e.Args[i + 1], "SiteTitle");
SitePath = XML.ReadList(e.Args[i + 1], "SitePath");
SitePathArgument = XML.ReadList(e.Args[i + 1], "SitePathArgument");
SiteIcon = XML.ReadList(e.Args[i + 1], "SiteIcon");
}
......@@ -61,6 +69,21 @@ namespace Main
{
Register = true;
}
if (e.Args[i] == "-HideMenu")
{
HideMenu = true;
}
if (e.Args[i] == "-LoadEXE")
{
EXE = e.Args[i + 1];
}
if (e.Args[i] == "-EXEArgument")
{
EXEArgument = e.Args[i + 1];
}
}
if (AppName == "")
......@@ -71,6 +94,9 @@ namespace Main
Window window = new MainWindow();
window.Show();
//
// For Add-Ons
//
//Mutex mutex = new Mutex(true, this.GetType().GUID.ToString(), out bool createdNew);
//if (createdNew)
//{
......
......@@ -63,7 +63,7 @@ namespace Main
+ "?subject=" + title
+ "&body=" + "**Programm Version:** " + Assembly.GetExecutingAssembly().GetName().Version.ToString() + "<br>%0D%0A"
+ "**Windows Version:** " + Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", "").ToString() + "<br>%0D%0A"
+ "**Config Datei:** " + App.File + " (Die Datei existiert nicht)<br>%0D%0A"
+ "**Config Datei:** " + App.File + " (Datei ist nicht verfügbar!)<br>%0D%0A"
+ "**EXE Datei:** " + file + "<br>%0D%0A"
+ "<br>%0D%0A"
+ "**Fehlermeldung:**" + "%0D%0A"
......
......@@ -12,9 +12,11 @@ namespace Main
{
public static void Set(String Page, Boolean removeMSG = true)
{
if (Application.Current.MainWindow is Main.MainWindow MW)
if (Application.Current.MainWindow is MainWindow MW)
{
MW.Index.Navigate(new Uri(Page + ".xaml", UriKind.Relative));
MW.Index.Visibility = Visibility.Visible;
MW.IndexGrid.Visibility = Visibility.Collapsed;
}
if (removeMSG)
......@@ -23,25 +25,15 @@ namespace Main
}
}
public static void SetPage(String Page)
{
if (Application.Current.MainWindow is Main.MainWindow MW)
{
MW.IndexFrame.Navigate(new Uri(Page + ".xaml", UriKind.Relative));
MW.IndexFrame.Visibility = Visibility.Visible;
MW.IndexGrid.Visibility = Visibility.Collapsed;
}
}
public static void LoadEXE(String Path)
public static void SetEXE(String Path, String Argument)
{
if (Application.Current.MainWindow is Main.MainWindow MW)
{
MW.SetIndex(Path);
MW.SetIndex(Path, Argument);
}
}
public static void LoadError(String Exception, String Title)
public static void SetError(String Exception, String Title)
{
if (Application.Current.MainWindow is Main.MainWindow MW)
{
......@@ -50,8 +42,8 @@ namespace Main
ErrorFrame.Navigate(new Uri("Error.xaml", UriKind.Relative));
MW.Menu.Visibility = Visibility.Collapsed;
MW.Index.Visibility = Visibility.Collapsed;
MW.IndexFrame.Visibility = Visibility.Collapsed;
MW.IndexGrid.Visibility = Visibility.Collapsed;
Error.error = Exception;
......
......@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Main
{
class MoveToForeground
public static class MoveToForeground
{
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
......
......@@ -37,7 +37,7 @@ namespace Main
}
catch (Exception ex)
{
Index.LoadError(ex.ToString(), "Fehler beim Laden der Konfigurationsdatei");
Index.SetError(ex.ToString(), "Fehler beim Laden der Konfigurationsdatei");
}
return Value;
......@@ -70,7 +70,7 @@ namespace Main
}
catch (Exception ex)
{
Index.LoadError(ex.ToString(), "Fehler beim Laden der Konfigurationsdatei");
Index.SetError(ex.ToString(), "Fehler beim Laden der Konfigurationsdatei");
}
return Values.Select(i => i.ToString()).ToArray();
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>-Config "C:\Users\reneh\Desktop\config.xml"</StartArguments>
<StartArguments>-Config "C:\Users\reneh\Desktop\config.xml" -LoadEXE "E:\Hampis Cloud\Hampis Projekte\Projekte\RH Utensils\Programme\Windows\Main\bin\Debug\RH Utensils.exe" -HideMenu</StartArguments>
</PropertyGroup>
</Project>
\ No newline at end of file
......@@ -36,15 +36,6 @@ namespace Main
ThemeManager.ChangeAppStyle(this, ThemeManager.GetAccent("Blue"), ThemeManager.GetAppTheme("BaseLight"));
}
if (App.Login || App.Register)
{
}
else if (App.SkipLogin || Properties.Settings.Default.SkipLogin)
{
Load();
}
}
public Boolean isMSG = false;
......@@ -55,39 +46,72 @@ namespace Main
}
public Grid IndexGrid = new Grid();
public Frame IndexFrame = new Frame();
public Frame Menu = new Frame();
public void Load()
{
//Window
int margin = 100;
MinHeight = 640;
MinWidth = 1024;
for (int i = 0; i < App.SiteTitle.Length; ++i)
if(App.HideMenu)
{
//IndexGrid
Grid.Children.Add(IndexGrid);
//Index
Index.Visibility = Visibility.Collapsed;
SetIndex(App.EXE, App.EXEArgument);
}
else
{
if (App.SiteTitle[i] == "")
//Window
int margin = 100;
for (int i = 0; i < App.SiteTitle.Length; ++i)
{
margin = margin + 20;
if (App.SiteTitle[i] == "")
{
margin = margin + 20;
}
else
{
margin = margin + 60;
}
}
else
if (margin > 420)
{
margin = margin + 60;
MinHeight = 640 + margin - 420;
}
}
if (margin > 420)
{
MinHeight = 640 + margin - 420;
//IndexGrid
IndexGrid.Margin = new Thickness(250, 0, 0, 0);
Grid.Children.Add(IndexGrid);
//Index
Index.Margin = new Thickness(250, 0, 0, 0);
Index.Visibility = Visibility.Collapsed;
//Menu
Menu.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
Menu.NavigationUIVisibility = NavigationUIVisibility.Hidden;
Menu.Navigate(new Uri("Menu.xaml", UriKind.Relative));
Menu.Width = 250;
Grid.Children.Add(Menu);
//MSG
Overlay.Margin = new Thickness(250, 0, 0, 0);
}
//Window
Height = MinHeight;
Width = MinWidth;
ShowTitleBar = true;
ShowMinButton = true;
ShowCloseButton = true;
ShowMaxRestoreButton = true;
ResizeMode = ResizeMode.CanResize;
......@@ -97,26 +121,6 @@ namespace Main
WindowCloseButtonStyle = (Style)FindResource("CloseMainWindowButtonStyle");
WindowMinButtonStyle = (Style)FindResource("MinMainWindowButtonStyle");
#pragma warning restore CS0618 // Typ oder Element ist veraltet
//IndexGrid
IndexGrid.Margin = new Thickness(250, 0, 0, 0);
Grid.Children.Add(IndexGrid);
//IndexFrame
IndexFrame.Margin = new Thickness(250, 0, 0, 0);
IndexFrame.Visibility = Visibility.Collapsed;
IndexFrame.NavigationUIVisibility = NavigationUIVisibility.Hidden;
Grid.Children.Add(IndexFrame);
//Menu
Index.Margin = new Thickness(0, 0, 0, 0);
Index.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
Index.NavigationUIVisibility = NavigationUIVisibility.Hidden;
Index.Navigate(new Uri("Menu.xaml", UriKind.Relative));
Index.Width = 250;
//MSG
Overlay.Margin = new Thickness(250, 0, 0, 0);
}
[DllImport("user32.dll", SetLastError = true)]
......@@ -132,24 +136,27 @@ namespace Main
System.Windows.Forms.Panel panel = new System.Windows.Forms.Panel();
public void SetIndex(String exe)
public void SetIndex(String exe, String Argument)
{
System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();
IndexFrame.Visibility = Visibility.Collapsed;
Index.Visibility = Visibility.Collapsed;
IndexGrid.Visibility = Visibility.Visible;
try
{
if (exe == "account.exe")
{
Main.Index.SetPage(@"Account\Account");
Main.Index.Set(@"Account\Account");
}
else
{
ProcessStartInfo ps = new ProcessStartInfo(exe);
ProcessStartInfo ps = new ProcessStartInfo(exe)
{
Arguments = Argument,
ps.WindowStyle = ProcessWindowStyle.Minimized;
WindowStyle = ProcessWindowStyle.Minimized
};
Process p = Process.Start(ps);
......@@ -167,8 +174,8 @@ namespace Main
}
catch (Exception ex)
{
IndexFrame.Navigate(new Uri("Error.xaml", UriKind.Relative));
IndexFrame.Visibility = Visibility.Visible;
Index.Navigate(new Uri("Error.xaml", UriKind.Relative));
Index.Visibility = Visibility.Visible;
IndexGrid.Visibility = Visibility.Collapsed;
Error.error = ex.ToString();
......
......@@ -90,7 +90,7 @@ namespace Main
}
Index.LoadEXE(App.SitePath[0]);
Index.SetEXE(App.SitePath[0], App.SitePathArgument[0]);
if (Application.Current.MainWindow is MainWindow MW)
{
......@@ -99,7 +99,7 @@ namespace Main
}
catch (Exception ex)
{
Index.LoadError(ex.ToString(), "Fehler beim Laden des Navigationsmenüs");
Index.SetError(ex.ToString(), "Fehler beim Laden des Navigationsmenüs");
}
}
......@@ -111,7 +111,7 @@ namespace Main
MoveCursorMenu(menuItem);
Index.LoadEXE(App.SitePath[menuItem]);
Index.SetEXE(App.SitePath[menuItem], App.SitePathArgument[menuItem]);
if (Application.Current.MainWindow is MainWindow MW)
{
......
4ad794a4dcfc39f51fa51e8f6d80ee60a89e6409
e56ffccf1788da003c396e35204858d6c7612980
......@@ -16,5 +16,5 @@ E:\Hampis Cloud\Hampis Projekte\Projekte\RH Utensils\Programme\Windows\Main\App.
21-1267453684
Account\Account.xaml;Account\RegisterCheck.xaml;Account\ResetPasswordFinal.xaml;Account\ResetPasswordCheck.xaml;Account\ResetPassword.xaml;Account\Register.xaml;Account\Login.xaml;Error.xaml;MainWindow.xaml;Menu.xaml;
True
False

FE:\Hampis Cloud\Hampis Projekte\Projekte\RH Utensils\Programme\Windows\Main\Account\Account.xaml;;
FE:\Hampis Cloud\Hampis Projekte\Projekte\RH Utensils\Programme\Windows\Main\Account\Login.xaml;;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment