Skip to content

Commit 261d8d7

Browse files
author
Sébastien Geiser
committed
Refactorging and Cleaning
1 parent b517f1f commit 261d8d7

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

CSharpRegexTools4Npp/PluginInfrastructure/UnmanagedExports.cs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// NPP plugin platform for .Net v0.94.00 by Kasper B. Graversen etc.
2-
using System;
3-
using System.Runtime.InteropServices;
4-
using System.Windows;
52
using CSharpRegexTools4Npp.PluginInfrastructure;
63
using NppPlugin.DllExport;
4+
using System;
5+
using System.Runtime.InteropServices;
76

87
namespace CSharpRegexTools4Npp
98
{
@@ -47,26 +46,19 @@ static IntPtr getName()
4746
[DllExport(CallingConvention = CallingConvention.Cdecl)]
4847
static void beNotified(IntPtr notifyCode)
4948
{
50-
try
49+
ScNotification notification = (ScNotification)Marshal.PtrToStructure(notifyCode, typeof(ScNotification));
50+
if (notification.Header.Code == (uint)NppMsg.NPPN_TBMODIFICATION)
51+
{
52+
PluginBase._funcItems.RefreshItems();
53+
Main.SetToolBarIcon();
54+
}
55+
else if (notification.Header.Code == (uint)NppMsg.NPPN_SHUTDOWN)
5156
{
52-
ScNotification notification = (ScNotification)Marshal.PtrToStructure(notifyCode, typeof(ScNotification));
53-
if (notification.Header.Code == (uint)NppMsg.NPPN_TBMODIFICATION)
54-
{
55-
PluginBase._funcItems.RefreshItems();
56-
Main.SetToolBarIcon();
57-
}
58-
else if (notification.Header.Code == (uint)NppMsg.NPPN_SHUTDOWN)
59-
{
60-
Marshal.FreeHGlobal(_ptrPluginName);
61-
}
62-
else
63-
{
64-
Main.OnNotification(notification);
65-
}
57+
Marshal.FreeHGlobal(_ptrPluginName);
6658
}
67-
catch(Exception exception)
59+
else
6860
{
69-
MessageBox.Show(exception.Message, $"Error in {nameof(beNotified)}", MessageBoxButton.OK, MessageBoxImage.Error);
61+
Main.OnNotification(notification);
7062
}
7163
}
7264
}

CSharpRegexTools4Npp/PluginInfrastructure/Win32.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace CSharpRegexTools4Npp.PluginInfrastructure
88
{
9-
109
public class Win32
1110
{
1211
/// <summary>

0 commit comments

Comments
 (0)