Skip to content

Commit d6720fe

Browse files
committed
Fixed settings not read after update+ clean up code
1 parent 843461d commit d6720fe

6 files changed

Lines changed: 41 additions & 10 deletions

File tree

Installer/Product.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<WixVariable Id="WixUILicenseRtf"
2828
Value="License.rtf" />
2929

30-
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed. Setup will now exit." />
30+
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
3131

3232
<Upgrade Id="$(var._UpgradeCode)">
3333
<UpgradeVersion OnlyDetect="yes"

InstallerHelper/CustomAction.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
using System;
22
using System.IO;
33
using System.Linq;
4+
using System.Reflection;
45
using Microsoft.Deployment.WindowsInstaller;
56

67
namespace InstallerHelper
78
{
89
public class CustomActions
910
{
11+
private static string CompanyName => Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCompanyAttribute>().Company;
1012
private static DirectoryInfo LocalAppParentDir => new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
11-
public static DirectoryInfo[] LocalAppDirectories => new DirectoryInfo(Path.Combine(LocalAppParentDir.FullName, "lwyeo@github")).GetDirectories("SoliditySHA3MinerUI*");
13+
14+
public static DirectoryInfo[] LocalAppDirectories => new DirectoryInfo(Path.Combine(LocalAppParentDir.FullName, CompanyName)).GetDirectories("SoliditySHA3MinerUI*");
1215

1316
[CustomAction]
1417
public static ActionResult DeleteLocalAppDir(Session session)

SoliditySHA3MinerUI/AboutWindow.xaml.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ public AboutWindow(AppTheme theme, Accent accent)
1818
Height *= scaleSize;
1919
Width *= scaleSize;
2020

21-
var assembly = Assembly.GetExecutingAssembly();
22-
var assemblyVersion = assembly.GetName().Version;
23-
var copyright = (assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true) as AssemblyCopyrightAttribute[])[0].Copyright;
24-
txbDescription.Text = string.Format(txbDescription.Text, assemblyVersion.Major, assemblyVersion.Minor, assemblyVersion.Build, copyright);
21+
var version = Helper.Processor.GetUIVersion;
22+
var copyright = Helper.Processor.GetCopyright;
23+
txbDescription.Text = string.Format(txbDescription.Text, version.Major, version.Minor, version.Build, copyright);
2524
}
2625
}
2726
}

SoliditySHA3MinerUI/Helper/FileSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace SoliditySHA3MinerUI.Helper
1313
public static class FileSystem
1414
{
1515
private static DirectoryInfo LocalAppParentDir => new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
16-
public static DirectoryInfo LocalAppDirectory => new DirectoryInfo(Path.Combine(LocalAppParentDir.FullName, "lwyeo@github", "SoliditySHA3MinerUI"));
16+
public static DirectoryInfo LocalAppDirectory => new DirectoryInfo(Path.Combine(LocalAppParentDir.FullName, Processor.CompanyName, Processor.ProductName));
1717
public static DirectoryInfo AppDirectory => Directory.GetParent(Assembly.GetExecutingAssembly().Location);
1818

1919
public static DirectoryInfo DownloadDirectory => new DirectoryInfo(Path.Combine(LocalAppDirectory.FullName, "Downloads"));

SoliditySHA3MinerUI/Helper/Processor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ namespace SoliditySHA3MinerUI.Helper
1515
{
1616
public static class Processor
1717
{
18-
public static Version MinimumDotnetCoreVersion => new Version("2.1.3");
18+
public static string ProductName => Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyProductAttribute>().Product;
19+
20+
public static string CompanyName => Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCompanyAttribute>().Company;
21+
22+
public static string GetCopyright => Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
1923

2024
public static Version GetUIVersion => Assembly.GetExecutingAssembly().GetName().Version;
2125

26+
public static Version MinimumDotnetCoreVersion => new Version("2.1.0");
27+
2228
public static Version GetUIVersionCompat
2329
{
2430
get

SoliditySHA3MinerUI/MainWindow.xaml.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ public MainWindow()
121121
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
122122
Language = System.Windows.Markup.XmlLanguage.GetLanguage(CultureInfo.InvariantCulture.Name);
123123

124+
CheckUserConfigFile();
125+
124126
MinerProcessor = new API.MinerProcessor(this);
125127
MinerProcessor.OnResponse += MinerProcessor_OnResponse;
126128
MinerProcessor.OnRequestSettings += MinerProcessor_OnRequestSettings;
@@ -508,9 +510,9 @@ private void _minerInstance_OnLogUpdated(string updatedLog, string newLog, int r
508510

509511
var newParagraph = new Paragraph();
510512
newParagraph.Inlines.Add(newLog);
511-
newParagraph.Foreground = newLog.StartsWith("[ERROR]")
513+
newParagraph.Foreground = (newLog.IndexOf("[ERROR]") > -1)
512514
? Brushes.Red
513-
: newLog.StartsWith("[WARN]")
515+
: (newLog.IndexOf("[WARN]") > -1)
514516
? Brushes.Yellow
515517
: (Brush)FindResource(SystemColors.ControlTextBrushKey);
516518

@@ -948,6 +950,27 @@ private async Task StopMiner()
948950

949951
#region Settings
950952

953+
private void CheckUserConfigFile()
954+
{
955+
var configFile = Helper.FileSystem.LocalAppDirectory.
956+
Parent.
957+
GetFiles("user.config", SearchOption.AllDirectories).
958+
FirstOrDefault();
959+
960+
if (configFile != null && new Version(configFile.Directory.Name) < Helper.Processor.GetUIVersion)
961+
{
962+
try
963+
{
964+
var currentPath = new DirectoryInfo(System.IO.Path.Combine(configFile.Directory.Parent.FullName,
965+
Helper.Processor.GetUIVersion.ToString()));
966+
configFile.Directory.MoveTo(currentPath.FullName);
967+
968+
Properties.Settings.Default.Reload();
969+
}
970+
catch { }
971+
}
972+
}
973+
951974
private async Task SaveSettings()
952975
{
953976
if (_isSettingsChanged)

0 commit comments

Comments
 (0)