This repository has been archived on 2025-07-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
EnvyUpdate/EnvyUpdate/InfoWindow.xaml.cs
2020-09-06 11:03:04 +02:00

135 lines
4.5 KiB
C#

using System;
using System.Windows;
using System.Windows.Input;
using System.IO;
namespace EnvyUpdate
{
/// <summary>
/// Interaction logic for InfoWindow.xaml
/// </summary>
public partial class InfoWindow : Window
{
bool defaultIsMobile = false;
bool isOverride = false;
public InfoWindow()
{
InitializeComponent();
if (GlobalVars.isMobile)
chkMobile.IsChecked = true;
defaultIsMobile = Util.IsMobile();
if (defaultIsMobile != GlobalVars.isMobile)
isOverride = true;
chkDCH.IsChecked = Util.IsDCH();
}
private void ButtonWeb_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/fyr77/EnvyUpdate/");
}
private void text_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
this.Cursor = Cursors.Hand;
}
private void text_MouseLeave(object sender, MouseEventArgs e)
{
this.Cursor = Cursors.Arrow;
}
private void textEnvyUpdate_MouseDown(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE");
}
private void textFody_MouseDown(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/Fody/Fody/blob/master/License.txt");
}
private void textCostura_MouseDown(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/Fody/Costura/blob/master/license.txt");
}
private void textNotifyIcon_MouseDown(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/hardcodet/wpf-notifyicon/blob/master/LICENSE");
}
private void textNotifications_MouseDown(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/Federerer/Notifications.Wpf/blob/master/LICENSE");
}
private void textNewtonsoft_MouseDown(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md");
}
private void textResourceEmbedder_MouseDown(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/MarcStan/resource-embedder/blob/master/LICENSE");
}
private void chkMobile_Checked(object sender, RoutedEventArgs e)
{
if (isOverride)
{
// If an override was present, delete it.
bool deleteSuccess = false;
while (!deleteSuccess)
{
try
{
File.Delete(GlobalVars.desktopOverride);
deleteSuccess = true;
}
catch (IOException)
{
// This is necessary in case someone ticks and unticks the option quickly, as the File.Create Method has sometimes yet to close the file.
}
}
isOverride = false;
}
else
{
File.Create(GlobalVars.mobileOverride).Close();
GlobalVars.isMobile = true;
isOverride = true;
}
}
private void chkMobile_Unchecked(object sender, RoutedEventArgs e)
{
if (isOverride)
{
// If an override was present, delete it.
bool deleteSuccess = false;
while (!deleteSuccess)
{
try
{
File.Delete(GlobalVars.mobileOverride);
deleteSuccess = true;
}
catch (IOException)
{
// This is necessary in case someone ticks and unticks the option quickly, as the File.Create Method has sometimes yet to close the file.
}
}
isOverride = false;
}
else
{
File.Create(GlobalVars.desktopOverride).Close();
GlobalVars.isMobile = false;
isOverride = true;
}
}
}
}