コード例 #1
0
 internal void InitPlugin(PluginHolder pluginData)
 {
     _ExternalPluginData  = pluginData;
     PluginDirectory      = pluginData.PluginDirectory;
     LocalPluginDirectory = PluginDirectory.Substring(PluginDirectory.IndexOf($@"\{PluginExtensionPlugin.PluginsDirectory}\") + 1);
     DiagnosticTimer      = new Stopwatch();
 }
コード例 #2
0
        private void DrawPlugin(PluginHolder plugin, float offsetX)
        {
            if (plugin.CanBeEnabledInOptions)       //for theme plugin
            {
                if (plugin.Settings.Enable == null) //If developer forget to init it
                {
                    plugin.Settings.Enable = false;
                }
                plugin.Settings.Enable = ImGuiExtension.Checkbox($"##{plugin.PluginName}Enabled", plugin.Settings.Enable.Value);
                ImGui.SameLine();
            }
            else
            {
                ImGui.Bullet();
                ImGui.SameLine();
            }

            var labelSize = ImGui.GetTextSize(plugin.PluginName).X + offsetX;

            if (PluginNameWidth < labelSize)
            {
                PluginNameWidth = labelSize;
            }

            if (ImGui.Selectable(plugin.PluginName, SelectedPlugin == plugin))
            {
                if (SelectedPlugin != plugin)
                {
                    SelectedPlugin = plugin;
                    SelectedPlugin.OnPluginSelectedInMenu();
                    Settings.LastOpenedPlugin = plugin.PluginName;
                }
            }
        }
コード例 #3
0
ファイル: WebContext.cs プロジェクト: RapidScada/scada-v6
        /// <summary>
        /// Initializes plugins.
        /// </summary>
        private void InitPlugins()
        {
            if (pluginsReady)
            {
                Log.WriteInfo(Locale.IsRussian ?
                              "Плагины добавляются один раз при запуске приложения" :
                              "Plugins are added once at application startup");
            }
            else
            {
                PluginHolder.Log = Log;

                foreach (string pluginCode in AppConfig.PluginCodes)
                {
                    if (PluginFactory.GetPluginLogic(AppDirs.ExeDir, pluginCode, this,
                                                     out PluginLogic pluginLogic, out string message))
                    {
                        Log.WriteAction(message);
                        PluginHolder.AddPlugin(pluginLogic);
                    }
コード例 #4
0
ファイル: WebContext.cs プロジェクト: RapidScada/scada-v6
        private Stats stats;                       // provides a statistics ID


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public WebContext()
        {
            storageWrapper       = null;
            configThread         = null;
            terminated           = false;
            pluginsReady         = false;
            configUpdateRequired = false;
            configUpdateStep     = ConfigUpdateStep.Idle;
            stats = null;

            IsReady                    = false;
            IsReadyToLogin             = false;
            InstanceConfig             = new InstanceConfig();
            AppConfig                  = new WebConfig();
            AppDirs                    = new WebDirs();
            Log                        = LogStub.Instance;
            ConfigDatabase             = new ConfigDatabase();
            ClientPool                 = new ScadaClientPool();
            PluginHolder               = new PluginHolder();
            CacheExpirationTokenSource = new CancellationTokenSource();

            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
        }
コード例 #5
0
        public void Render()
        {
            if (!Settings.Enable.Value)
            {
                return;
            }

            var opened = Settings.Enable.Value;

            Settings.IsCollapsed = !DrawInfoWindow("PoeHUD  " + PoeHUDVersion, ref opened,
                                                   Settings.MenuWindowPos.X, Settings.MenuWindowPos.Y, Settings.MenuWindowSize.X, Settings.MenuWindowSize.Y,
                                                   WindowFlags.Default, Condition.Appearing);
            Settings.Enable.Value = opened;

            if (!Settings.IsCollapsed)
            {
                ImGuiNative.igGetContentRegionAvail(out newcontentRegionArea);
                if (ImGui.BeginChild("PluginsList", new Vector2(PluginNameWidth + 60, newcontentRegionArea.Y), true, WindowFlags.Default))
                {
                    PluginNameWidth = 120;
                    var coreOpened = ImGui.TreeNodeEx("", Settings.CorePluginsTreeState);

                    ImGui.SameLine();
                    if (ImGui.Selectable(CoreMenu.Plugin.PluginName, SelectedPlugin == CoreMenu.Plugin))
                    {
                        SelectedPlugin = CoreMenu.Plugin;
                    }

                    if (coreOpened)
                    {
                        foreach (var defPlugin in CoreMenu.Childs)
                        {
                            if (defPlugin.Childs.Count == 0)
                            {
                                DrawPlugin(defPlugin.Plugin, 20);
                            }
                            else
                            {
                                defPlugin.Plugin.Settings.Enable =
                                    ImGuiExtension.Checkbox($"##{defPlugin.Plugin.PluginName}Enabled", defPlugin.Plugin.Settings.Enable.Value);

                                ImGui.SameLine();
                                var pluginOpened = ImGui.TreeNodeEx($"##{defPlugin.Plugin.PluginName}", TreeNodeFlags.OpenOnArrow);
                                ImGui.SameLine();

                                var labelSize = ImGui.GetTextSize(defPlugin.Plugin.PluginName).X + 30;
                                if (PluginNameWidth < labelSize)
                                {
                                    PluginNameWidth = labelSize;
                                }

                                if (ImGui.Selectable(defPlugin.Plugin.PluginName, SelectedPlugin == defPlugin.Plugin))
                                {
                                    SelectedPlugin = defPlugin.Plugin;
                                }

                                if (pluginOpened)
                                {
                                    foreach (var plugin in defPlugin.Childs)
                                    {
                                        DrawPlugin(plugin.Plugin, 30);
                                    }

                                    ImGuiNative.igUnindent();
                                }
                            }
                        }
                        ImGui.TreePop();
                        Settings.CorePluginsTreeState = TreeNodeFlags.DefaultOpen | TreeNodeFlags.OpenOnArrow;

                        ImGui.Text("");
                    }
                    else
                    {
                        Settings.CorePluginsTreeState = TreeNodeFlags.OpenOnArrow;
                    }

                    if (ImGui.TreeNodeEx("Installed Plugins", Settings.InstalledPluginsTreeNode))
                    {
                        foreach (var plugin in PluginExtensionPlugin.Plugins)
                        {
                            if (Settings.DeveloperMode.Value && Settings.ShowPluginsMS.Value)
                            {
                                var extPlugin = (plugin as ExternalPluginHolder).BPlugin;
                                if (extPlugin == null)    //This can happen while plugin update (using plugin updator) or recompile
                                {
                                    continue;
                                }
                                ImGuiExtension.Label(extPlugin.AwerageMs.ToString());
                                ImGui.SameLine();
                            }

                            DrawPlugin(plugin, 20);
                        }

                        ImGui.TreePop();
                        Settings.InstalledPluginsTreeNode = TreeNodeFlags.DefaultOpen;
                    }
                    else
                    {
                        Settings.InstalledPluginsTreeNode = (TreeNodeFlags)0;
                    }
                }

                ImGui.EndChild();
                ImGui.SameLine();


                if (SelectedPlugin != null)
                {
                    ImGuiNative.igGetContentRegionAvail(out newcontentRegionArea);
                    ImGui.BeginChild("PluginOptions", new Vector2(newcontentRegionArea.X, newcontentRegionArea.Y), true, WindowFlags.Default);

                    var extPlugin = SelectedPlugin as ExternalPluginHolder;
                    if (Settings.DeveloperMode.Value && extPlugin != null)
                    {
                        if (ImGuiExtension.Button("Reload Plugin"))
                        {
                            extPlugin.ReloadPlugin();
                        }

                        if (extPlugin.BPlugin != null)
                        {
                            ImGui.SameLine();
                            ImGuiExtension.Label("CurrentMS: " + extPlugin.BPlugin.CurrentMs);
                            ImGui.SameLine();
                            ImGuiExtension.Label("AwerageMS: " + extPlugin.BPlugin.AwerageMs);
                            ImGui.SameLine();
                            ImGuiExtension.Label("TopMS: " + extPlugin.BPlugin.TopMs);
                        }
                    }
                    SelectedPlugin.DrawSettingsMenu();

                    ImGui.EndChild();
                }

                Settings.MenuWindowSize = ImGui.GetWindowSize();
            }

            Settings.MenuWindowPos = ImGui.GetWindowPosition();
            ImGui.EndWindow();

            if (Settings.ShowImguiDemo.Value)
            {
                bool tmp = Settings.ShowImguiDemo.Value;
                ImGuiNative.igShowDemoWindow(ref tmp);
                Settings.ShowImguiDemo.Value = tmp;
            }
        }