Skip to content

Commit 219e7c3

Browse files
committed
fixed settings were not migrated when starting newer version. They are now migrated automatically. A message is shown to notify of the migration. A new --no-upgrade-message command-line switch prevents that message from showing.
1 parent 334c6cf commit 219e7c3

9 files changed

Lines changed: 49 additions & 3 deletions

File tree

GabNetStats/Forms/FormMain.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailability
8080

8181
private void OnLoad(object sender, EventArgs e)
8282
{
83+
if (!Settings.Default.SettingsUpgraded)
84+
{
85+
Settings.Default.Upgrade();
86+
Settings.Default.SettingsUpgraded = true;
87+
Settings.Default.Save();
88+
if (!Program.NoUpgradeMessage)
89+
{
90+
MessageBox.Show(Res.str_SettingsMigrated, "GabNetStats", MessageBoxButtons.OK, MessageBoxIcon.Information);
91+
}
92+
}
93+
8394
trayIconManager = new TrayIconManager(this.notifyIconActivity, this.notifyIconPing);
8495
nicManager = new NetworkInterfaceManager();
8596
statsWorker = new NetworkStatsWorker(

GabNetStats/GabNetStats.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@
9090
<AssemblyTitle>GabNetStats</AssemblyTitle>
9191
<BaseOutputPath>bin\</BaseOutputPath>
9292
<Nullable>disable</Nullable>
93-
<AssemblyVersion>1.1.2.3</AssemblyVersion>
94-
<FileVersion>1.1.2.3</FileVersion>
95-
<Version>1.1.2.3</Version>
93+
<AssemblyVersion>1.1.2.4</AssemblyVersion>
94+
<FileVersion>1.1.2.4</FileVersion>
95+
<Version>1.1.2.4</Version>
9696
</PropertyGroup>
9797
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
9898
<Exec Command="echo Configuration: $(Configuration)&#xD;&#xA;echo DevEnvDir: $(DevEnvDir)&#xD;&#xA;echo OutDir: $(OutDir)&#xD;&#xA;echo ProjectDir: $(ProjectDir)&#xD;&#xA;echo VisualStudioVersion: $(VisualStudioVersion)&#xD;&#xA;echo AssemblySearchPaths: $(AssemblySearchPaths)&#xD;&#xA;echo AssemblyName: $(AssemblyName)&#xD;&#xA;echo BaseIntermediateOutputPath: $(BaseIntermediateOutputPath)&#xD;&#xA;echo CscToolPath: $(CscToolPath)&#xD;&#xA;echo MSBuildProjectDirectory: $(MSBuildProjectDirectory)&#xD;&#xA;del /F &quot;$(OutDir)\License.*.txt&quot;" />

GabNetStats/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ static class Program
2020
/// <summary>Set to true when --show-statistics was passed on the command line.</summary>
2121
public static bool ShowStatisticsOnStart { get; private set; }
2222

23+
/// <summary>Set to true when --no-upgrade-message was passed on the command line.</summary>
24+
public static bool NoUpgradeMessage { get; private set; }
25+
2326
[STAThread]
2427
static void Main()
2528
{
@@ -31,6 +34,8 @@ static void Main()
3134
ShowNetworkDetailsOnStart = true;
3235
if (arg.Equals("--show-statistics", StringComparison.OrdinalIgnoreCase))
3336
ShowStatisticsOnStart = true;
37+
if (arg.Equals("--no-upgrade-message", StringComparison.OrdinalIgnoreCase))
38+
NoUpgradeMessage = true;
3439
}
3540

3641
Application.EnableVisualStyles();

GabNetStats/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GabNetStats/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,8 @@
7474
<Setting Name="BalloonLocationY" Type="System.Int32" Scope="User">
7575
<Value Profile="(Default)">-1</Value>
7676
</Setting>
77+
<Setting Name="SettingsUpgraded" Type="System.Boolean" Scope="User">
78+
<Value Profile="(Default)">False</Value>
79+
</Setting>
7780
</Settings>
7881
</SettingsFile>

GabNetStats/Res.Designer.cs

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GabNetStats/Res.fr.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
<value>Une erreur s'est produite dans GabNetStats. Nous sommes désolé pour ce problème et espérons pouvoir le corriger dès que possible.
134134
Vous pouvez envoyer au développeur la cause de l'erreur affichée ci-dessous au moyen d'une capture d'écran :</value>
135135
</data>
136+
<data name="str_SettingsMigrated" xml:space="preserve">
137+
<value>Vos paramètres ont été migrés avec succès depuis la version précédente.</value>
138+
</data>
136139
<data name="str_Gbit" xml:space="preserve">
137140
<value>Gbit</value>
138141
</data>

GabNetStats/Res.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
<value>An error occurred in GabNetStats. We are sorry for this inconvenience and are looking to correct the problem as soon as possible.
134134
Below is displayed the cause of the error that you can send to the developer using a screenshot :</value>
135135
</data>
136+
<data name="str_SettingsMigrated" xml:space="preserve">
137+
<value>Your settings have been successfully migrated from the previous version.</value>
138+
</data>
136139
<data name="str_Gbit" xml:space="preserve">
137140
<value>Gbit</value>
138141
</data>

GabNetStats/Res.ru.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
<value>Произошла ошибка в программе. Приносим извинения за доставленные неудобства и надеемся исправить проблему как можно скорее.
134134
Ниже отображается причина ошибки, которую можно отправить разработчику с помощью скриншота:</value>
135135
</data>
136+
<data name="str_SettingsMigrated" xml:space="preserve">
137+
<value>Ваши настройки успешно перенесены из предыдущей версии.</value>
138+
</data>
136139
<data name="str_Gbit" xml:space="preserve">
137140
<value>Гбит</value>
138141
</data>

0 commit comments

Comments
 (0)