Skip to content
This repository has been archived by the owner on Jul 23, 2022. It is now read-only.

Commit

Permalink
Fixed error with github checker
Browse files Browse the repository at this point in the history
  • Loading branch information
MelonIs45 committed Mar 9, 2022
1 parent 994cba4 commit f3dd480
Showing 1 changed file with 36 additions and 31 deletions.
67 changes: 36 additions & 31 deletions DanserMenuV3/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public SettingsWindow(MainWindow mainWindow)
{
InitializeComponent();

string version = System.Windows.Forms.Application.ProductVersion;



MessageBox.Show(version);

MainWindow = mainWindow;
SettingsObject = new Settings();
LanguageCodes = new string[] { "en", "fr", "es", "pl", "nl", "de", "ru" };
Expand All @@ -51,7 +45,12 @@ public SettingsWindow(MainWindow mainWindow)
}

ObjectJson = JObject.Parse(File.ReadAllText($"{Directory.GetCurrentDirectory()}\\menu-settings.json"));
DanserJson = JObject.Parse(File.ReadAllText($"{Directory.GetCurrentDirectory()}\\settings\\default.json"));

try
{
DanserJson = JObject.Parse(File.ReadAllText($"{Directory.GetCurrentDirectory()}\\settings\\default.json"));
}
catch { }
TebSettingsName.Text = "default";

for (int i = 0; i < Languages.Length; i++)
Expand Down Expand Up @@ -117,7 +116,7 @@ private void BuSave_Click(object sender, RoutedEventArgs e)
}

protected void SettingsClosing(object sender, CancelEventArgs e)
{
{
Visibility = Visibility.Hidden;
e.Cancel = true;
}
Expand Down Expand Up @@ -298,34 +297,40 @@ private void ChkAddDanser_Checked(object sender, RoutedEventArgs e)
private async void BtnCheckUpdates_Click(object sender, RoutedEventArgs e)
{
var checker = new UpdateChecker("melonis45", "dansermenu"); // uses your Application.ProductVersion

UpdateType update = await checker.CheckUpdate();

if (update == UpdateType.None)
{
MessageBox.Show("Up to date!", "Check was successful", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
try
{
// Ask the user if he wants to update
// You can use the prebuilt form for this if you want (it's really pretty!)
var result = new UpdateNotifyDialog(checker).ShowDialog();
if (result == System.Windows.Forms.DialogResult.Yes)
UpdateType update = await checker.CheckUpdate();
if (update == UpdateType.None)
{
string url = $"https://github.com/melonis45/dansermenu/releases/download/{checker.latestTag}/DANSER-Menu-V{checker.latestTag}.zip";
int processId = Process.GetCurrentProcess().Id;

Process updateProcess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
MessageBox.Show("Up to date!", "Check was successful", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
// Ask the user if he wants to update
// You can use the prebuilt form for this if you want (it's really pretty!)
var result = new UpdateNotifyDialog(checker).ShowDialog();
if (result == System.Windows.Forms.DialogResult.Yes)
{
FileName = "Updater.exe",
Arguments = $"{url} {processId}"
};

updateProcess.StartInfo = startInfo;
updateProcess.Start();
string url = $"https://github.com/melonis45/dansermenu/releases/download/{checker.latestTag}/DANSER-Menu-V{checker.latestTag}.zip";
int processId = Process.GetCurrentProcess().Id;

Process updateProcess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "Updater.exe",
Arguments = $"{url} {processId}"
};

updateProcess.StartInfo = startInfo;
updateProcess.Start();
}
}
}
catch (System.Net.Http.HttpRequestException)
{
MessageBox.Show("No internet connection found!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
}
}
}

0 comments on commit f3dd480

Please sign in to comment.