Skip to content

Commit

Permalink
Add pop-up about activation on first launch (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
salikhov authored Mar 25, 2024
1 parent ab84d7a commit 9b103a5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions AtopPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public AtopPlugin()
{
RegisterEventHandlers();
AtopMenu.Initialize();
TempActivationMessagePopup.PopUpActivationMessageIfFirstTime();
}

private static void RegisterEventHandlers()
Expand Down
1 change: 1 addition & 0 deletions AtopPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<Compile Include="UI\SettingsWindow.Designer.cs">
<DependentUpon>SettingsWindow.cs</DependentUpon>
</Compile>
<Compile Include="UI\TempActivationMessagePopup.cs"/>
</ItemGroup>
<ItemGroup>
<None Include="packages.config"/>
Expand Down
37 changes: 37 additions & 0 deletions UI/TempActivationMessagePopup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AtopPlugin.UI;

public static class TempActivationMessagePopup
{
private const string AcknowledgeFileName = ".atop_activation_ack";

public static void PopUpActivationMessageIfFirstTime()
{
if (ActivationAckFileExists()) return;
Task.Run(() => MessageBox.Show(
"""Starting with this version of the ATOP vatSys plugin, you will have to activate your session by clicking the "Activate" button under the "ATOP" menu in order to use the full controlling functionalities.""",
@"vatSys ATOP Plugin"
));
WriteActivationAckFile();
}

private static bool ActivationAckFileExists()
{
return File.Exists(GetAckFilePath());
}

private static void WriteActivationAckFile()
{
File.WriteAllBytes(GetAckFilePath(), new byte[] { });
}

private static string GetAckFilePath()
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!,
AcknowledgeFileName);
}
}

0 comments on commit 9b103a5

Please sign in to comment.