12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Diagnostics;
- using System.Reflection;
- using NppChnConvPlugin.NppPluginInfrastructure;
- namespace NppChnConvPlugin
- {
- public static class AnyCpuBridgeMain
- {
- static AnyCpuBridgeMain()
- {
- try
- {
- InitReferenceAssembly();
- }
- catch (Exception exception)
- {
- System.Windows.Forms.MessageBox.Show($"Plugin init fail:{PluginName},{exception}");
- throw;
- }
- }
- private static void InitReferenceAssembly()
- {
- }
- public static readonly string PluginName = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductName;
- public static void CommandMenuInit()
- {
- PluginBridge.SetupPluginMenu();
- }
- public static void SetToolBarIcon()
- {
- PluginBridge.SetupToolBarIcon();
- }
- public static void OnNotification(ScNotification notification)
- {
- if (false == PluginBridge.Enable) return;
- //Check for updates
- if (notification.Header.Code == (uint)SciMsg.SCN_UPDATEUI)
- {
- //Update the view
- if (0 != (notification.Updated & (uint)SciMsg.SC_UPDATE_V_SCROLL)) PluginBridge.UpdateScroll();
- }
- else if (notification.Header.Code == (uint)NppMsg.NPPN_BUFFERACTIVATED)
- {
- //Update the scintilla handle in all cases to keep track of which instance is active
- PluginBridge.FlushState();
- PluginBridge.UpdateText();
- PluginBridge.UpdateScroll();
- }
- else if (notification.Header.Code == (uint)SciMsg.SCN_MODIFIED
- && (notification.ModificationType & ((uint)SciMsg.SC_MOD_INSERTTEXT | (uint)SciMsg.SC_MOD_DELETETEXT)) != 0)
- {
- //Track if any text modifications have been made
- PluginBridge.UpdateText();
- }
- }
- public static void PluginCleanUp()
- {
- PluginBridge.Exit();
- }
- }
- }
|