Пример #1
0
        public void ReportPluginSetStatus(object callingPluginObj, MinaryLib.Plugin.Status newPluginStatus)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new PluginSetStatusDelegate(this.ReportPluginSetStatus), new object[] { callingPluginObj, newPluginStatus });
                return;
            }

            IPlugin plugin  = null;
            TabPage tabPage = null;

            if (callingPluginObj == null)
            {
                return;
            }

            try
            {
                plugin  = (IPlugin)callingPluginObj;
                tabPage = this.FindTabPageInCatalog(plugin.Config.PluginName);
            }
            catch (Exception ex)
            {
                LogCons.Inst.Write(LogLevel.Error, $"ReportPluginSetStatus(): {ex.ToString()}");
            }

            if (tabPage == null)
            {
                return;
            }
            else if (tabPage.IsHandleCreated == false)
            {
                return;
            }

            var tmpNewPluginStatus = (int)newPluginStatus;
            int oldPluginStatus    = tabPage.ImageIndex;

            // Use method invoker because of cross thread access
            // by startallplugins.
            tabPage.Invoke((MethodInvoker) delegate
            {
                tmpNewPluginStatus = (newPluginStatus >= 0) ? (int)newPluginStatus : (int)MinaryLib.Plugin.Status.NotRunning;
                tabPage.ImageIndex = tmpNewPluginStatus;

                if (oldPluginStatus == tmpNewPluginStatus)
                {
                    return;
                }
            });


            LogCons.Inst.Write(LogLevel.Info, $"{plugin.Config.PluginName} : CurrentState:{oldPluginStatus}, NewState:{tmpNewPluginStatus}");
        }
Пример #2
0
        public void ReportPluginSetStatus(object callingPluginObj, MinaryLib.Plugin.Status newPluginStatus)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new PluginSetStatusDelegate(this.ReportPluginSetStatus), new object[] { callingPluginObj, newPluginStatus });
                return;
            }

            IPlugin plugin  = null;
            TabPage tabPage = null;

            if (callingPluginObj == null)
            {
                return;
            }

            try
            {
                plugin  = (IPlugin)callingPluginObj;
                tabPage = this.FindTabPageInCatalog(plugin.Config.PluginName);
            }
            catch (Exception ex)
            {
                LogCons.Inst.Write(LogLevel.Error, $"ReportPluginSetStatus(): {ex.ToString()}");
            }

            if (tabPage == null)
            {
                return;
            }

            var tmpNewPluginStatus = (int)newPluginStatus;
            int oldPluginStatus    = tabPage.ImageIndex;

            tmpNewPluginStatus = (newPluginStatus >= 0) ? (int)newPluginStatus : (int)MinaryLib.Plugin.Status.NotRunning;
            tabPage.ImageIndex = tmpNewPluginStatus;

            if (oldPluginStatus == tmpNewPluginStatus)
            {
                return;
            }

            LogCons.Inst.Write(LogLevel.Info, $"{plugin.Config.PluginName} : CurrentState:{oldPluginStatus}, NewState:{tmpNewPluginStatus}");
        }