예제 #1
0
        //

        #endregion Lister Callbacks

        #region Tracing

#if TRACE
        private static void TraceOut(TraceLevel level, string text, string category)
        {
            if (writeTrace)
            {
                TcTrace.TraceOut(level, text, category);
            }
        }
예제 #2
0
        private static void TraceCall(TraceLevel level, string result)
        {
#if TRACE
            TcTrace.TraceCall(_plugin, level, _callSignature, result);
            _callSignature = null;
#endif
        }
예제 #3
0
 private static void TraceOut(string text, string category)
 {
     if (writeTrace)
     {
         if (category.Equals("Start"))
         {
             TcTrace.TraceDelimiter();
         }
         TcTrace.TraceOut(TraceLevel.Warning, text, category);
     }
 }
예제 #4
0
        public override void OnTcTrace(TraceLevel level, string text)
        {
            string msg = TcTrace.GetTraceTimeString() + " - " + level.ToString().Substring(0, 1) + " : " + text;

            foreach (object o in controls)
            {
                if (o is WpfListerControl)
                {
                    ((WpfListerControl)o).AddLogMessage(msg);
                }
            }
        }
예제 #5
0
        private void ListerPluginEvent(ListerMessage message, int value)
        {
            if (ListerHandle != IntPtr.Zero && ParentHandle != IntPtr.Zero)
            {
                var wParam = ((int)message * 0x10000) + value;
                NativeMethods.PostMessage(ParentHandle, NativeMethods.WM_COMMAND, new IntPtr(wParam), ListerHandle);
#if TRACE
                if (WriteTrace)
                {
                    TcTrace.TraceOut(TraceLevel.Info, $"  << Callback: ({ListerHandle}) {message.ToString()} = {value}", null);
                }
#endif
            }
        }
예제 #6
0
        private static TPlugin CreatePluginInstance <TPlugin>(Type pluginClass)
        {
            TcTrace.TraceDelimiter();
            var name  = pluginClass.Assembly.GetName().Name;
            var types = typeof(TPlugin).GetInterfaces().Select(_ => _.Name);

            TcTrace.TraceOut(TraceLevel.Warning, $"[{name}]{pluginClass.FullName}", $"{string.Join(",", types)} plugin load");

            var settings = GetSettings(pluginClass.Assembly);

            var ctor     = pluginClass.GetConstructor(new[] { typeof(Settings) });
            var tcPlugin = (TPlugin)ctor.Invoke(new object[] { settings });

            return(tcPlugin);
        }
예제 #7
0
        public static void StatusInfoW([MarshalAs(UnmanagedType.LPWStr)] string remoteDir, int startEnd, int operation)
        {
            try {
#if TRACE
                _callSignature = $"{((InfoOperation) operation).ToString()} - '{remoteDir}': {((InfoStartEnd) startEnd).ToString()}";
                if (Plugin.WriteStatusInfo)
                {
                    TcTrace.TraceOut(TraceLevel.Warning, _callSignature, Plugin.TraceTitle, startEnd == (int)InfoStartEnd.End ? -1 : startEnd == (int)InfoStartEnd.Start ? 1 : 0);
                }
#endif
                Plugin.StatusInfo(remoteDir, (InfoStartEnd)startEnd, (InfoOperation)operation);
            }
            catch (Exception ex) {
                ProcessException(ex);
            }
        }
예제 #8
0
        public static IntPtr GetPreviewBitmapInternal(string fileToLoad, int width, int height, byte[] contentBuf)
        {
            IntPtr result;

            _callSignature = $"GetPreviewBitmap '{fileToLoad}' ({width} x {height})";
            try {
                var bitmap = Plugin.GetPreviewBitmap(fileToLoad, width, height, contentBuf);
                result = bitmap.GetHbitmap(Plugin.BitmapBackgroundColor);
                TraceCall(TraceLevel.Info, result.Equals(IntPtr.Zero) ? "OK" : "None");
            }
            catch (Exception ex) {
#if TRACE
                TcTrace.TraceOut(TraceLevel.Error, $"{_callSignature}: {ex.Message}", $"ERROR ({Plugin.TraceTitle})");
#endif
                result = IntPtr.Zero;
            }

            return(result);
        }
예제 #9
0
        public static IntPtr GetPreviewBitmapInternal(string fileToLoad, int width, int height, byte[] contentBuf)
        {
            IntPtr result;

            callSignature = String.Format("GetPreviewBitmap '{0}' ({1} x {2})",
                                          fileToLoad, width, height);
            try {
                Bitmap bitmap = Plugin.GetPreviewBitmap(fileToLoad, width, height, contentBuf);
                result = bitmap.GetHbitmap(Plugin.BitmapBackgroundColor);
                TraceCall(TraceLevel.Info, result.Equals(IntPtr.Zero) ? "OK" : "None");
            } catch (Exception ex) {
#if TRACE
                TcTrace.TraceOut(TraceLevel.Error,
                                 String.Format("{0}: {1}", callSignature, ex.Message),
                                 String.Format("ERROR ({0})", Plugin.TraceTitle));
#endif
                result = IntPtr.Zero;
            }
            return(result);
        }
예제 #10
0
        public static void ProcessException(TcPlugin plugin, bool pluginDisconnected,
                                            string callSignature, Exception ex)
        {
#if TRACE
            string pluginTitle =
                plugin == null || pluginDisconnected ? "NULL" : plugin.TraceTitle;
            TcTrace.TraceError(String.Format("{0}: {1}", callSignature, ex.Message), pluginTitle);
#endif
            if (ex is MethodNotSupportedException)
            {
                if (!((MethodNotSupportedException)ex).Mandatory)
                {
                    return;
                }
            }
            if (plugin == null || pluginDisconnected || plugin.ShowErrorDialog)
            {
                ErrorDialog.Show(callSignature, ex);
            }

            // TODO: add - unload plugin AppDomain on crytical error (configurable)
        }
예제 #11
0
 private static void TraceCall(TraceLevel level, string result)
 {
     TcTrace.TraceCall(plugin, level, callSignature, result);
     callSignature = null;
 }
예제 #12
0
 public static void TraceCall(TraceLevel level, string result)
 {
     TcTrace.TraceCall(_plugin, level, _callSignature, result);
     _callSignature = null;
 }
예제 #13
0
 private static void TraceError(string text, string category)
 {
     TcTrace.TraceOut(TraceLevel.Error, text, category);
 }