Пример #1
0
        void RunActions()
        {
            // all actions from XML
            foreach (var actXml in _actionXmls)
            {
                var type = X.getStringAttr(actXml, "Type");

                if (type.ToLower() == "StartPlan".ToLower())
                {
                    var planName = X.getStringAttr(actXml, "PlanName");

                    log.DebugFormat("Running action: StartPlan '{0}'", planName);

                    _ctrl.Send(new Net.StartPlanMessage(_ctrl.Name, planName));
                }
                else if (type.ToLower() == "LaunchApp".ToLower())
                {
                    var appIdTupleStr = X.getStringAttr(actXml, "AppIdTuple");

                    log.DebugFormat("Running action: LauchApp '{0}'", appIdTupleStr);

                    var(appIdTuple, planName) = Tools.ParseAppIdWithPlan(appIdTupleStr);

                    _ctrl.Send(new Net.StartAppMessage(_ctrl.Name, appIdTuple, planName));
                }
            }
        }
Пример #2
0
        public void DrawUI()
        {
            //ClientTop = 0;
            if (ImGui.BeginMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Exit"))
                    {
                        _wnd.Close();
                    }
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Tools"))
                {
                    if (ImGui.MenuItem("Reload Shared Config"))
                    {
                        _ctrl.Send(new Net.ReloadSharedConfigMessage());
                    }

                    if (ImGui.MenuItem("Kill All"))
                    {
                        _ctrl.Send(new Net.KillAllMessage(_ctrl.Name, new KillAllArgs()));
                    }

                    ImGui.EndMenu();
                }

                //var mainMenuSize = ImGui.GetWindowSize();
                //ClientTop = mainMenuSize.Y;
                ImGui.EndMenuBar();
            }
        }
Пример #3
0
        public void DrawUI()
        {
            ImGui.PushID(_uniqueUiId);

            ScriptState?scriptState = _ctrl.GetScriptState(_id);
            ScriptDef?  scriptDef   = _ctrl.GetScriptDef(_id);

            string statusText = scriptState != null?Tools.GetScriptStateText(scriptState) : string.Empty;

            ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(1f, 1f, 0f, 1f));
            bool opened = ImGui.TreeNodeEx(_id, ImGuiTreeNodeFlags.FramePadding);

            ImGui.PopStyleColor();
            if (ImGui.BeginPopupContextItem())
            {
                if (ImGui.MenuItem("Start"))
                {
                    _ctrl.Send(new Net.StartScriptMessage(_ctrl.Name, _id, null));
                }

                if (ImGui.MenuItem("Kill"))
                {
                    _ctrl.Send(new Net.KillScriptMessage(_ctrl.Name, _id));
                }

                ImGui.EndPopup();
            }

            ImGui.SameLine();
            ImGui.SetCursorPosX(ImGui.GetWindowWidth() * 3 / 4.5f);
            if (ImGuiTools.ImgBtn(_txStart))
            {
                _ctrl.Send(new Net.StartScriptMessage(_ctrl.Name, _id, null));
            }
            ImGui.SameLine();
            if (ImGuiTools.ImgBtn(_txKill))
            {
                _ctrl.Send(new Net.KillScriptMessage(_ctrl.Name, _id));
            }

            ImGui.SameLine();
            ImGui.SetCursorPosX(ImGui.GetWindowWidth() / 4.5f * 2f);
            ImGui.TextColored(GetScriptStateColor(statusText), statusText);

            //ImGui.SameLine();
            //ImGui.SetCursorPosX( ImGui.GetWindowWidth()/4f);
            //DrawOptions();

            if (opened)
            {
                //DrawUIBody();

                string jsonString = JsonSerializer.Serialize(scriptDef, new JsonSerializerOptions()
                {
                    WriteIndented = true, IncludeFields = true
                });
                ImGui.TextWrapped(jsonString.Replace("%", "%%"));                 // TextWrapped doesn't like %s etc, percent signs needs to be doubled

                ImGui.TreePop();
            }

            ImGui.PopID();
        }
Пример #4
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0x0312)
            {
                var keyId = m.WParam.ToInt32();
                switch (keyId)
                {
                case HOTKEY_ID_START_CURRENT_PLAN:
                {
                    var currPlan = _currentPlan;
                    if (currPlan != null)
                    {
                        _ctrl.Send(new Net.StartPlanMessage(_ctrl.Name, currPlan.Name));
                    }
                    break;
                }

                case HOTKEY_ID_KILL_CURRENT_PLAN:
                {
                    var currPlan = _currentPlan;
                    if (currPlan != null)
                    {
                        _ctrl.Send(new Net.KillPlanMessage(_ctrl.Name, currPlan.Name));
                    }
                    break;
                }

                case HOTKEY_ID_RESTART_CURRENT_PLAN:
                {
                    var currPlan = _currentPlan;
                    if (currPlan != null)
                    {
                        _ctrl.Send(new Net.RestartPlanMessage(_ctrl.Name, currPlan.Name));
                    }
                    break;
                }


                case HOTKEY_ID_SELECT_PLAN_0:
                {
                    selectPlan(null);
                    break;
                }

                case HOTKEY_ID_SELECT_PLAN_1:
                case HOTKEY_ID_SELECT_PLAN_2:
                case HOTKEY_ID_SELECT_PLAN_3:
                case HOTKEY_ID_SELECT_PLAN_4:
                case HOTKEY_ID_SELECT_PLAN_5:
                case HOTKEY_ID_SELECT_PLAN_6:
                case HOTKEY_ID_SELECT_PLAN_7:
                case HOTKEY_ID_SELECT_PLAN_8:
                case HOTKEY_ID_SELECT_PLAN_9:
                {
                    int            i     = keyId - HOTKEY_ID_SELECT_PLAN_1;              // zero-based index of plan
                    List <PlanDef> plans = new List <PlanDef>(_ctrl.GetAllPlanDefs());
                    if (i < plans.Count)
                    {
                        var planName = plans[i].Name;
                        this._notifyIcon.ShowBalloonTip(1000, String.Format("{0}", planName), " ", ToolTipIcon.Info);
                        selectPlan(planName);
                    }
                    break;
                }
                }
            }
            base.WndProc(ref m);
        }
Пример #5
0
        public void DrawUI()
        {
            ImGui.PushID(_uniqueUiId);

            AppDef?appDef = _appDef ?? _ctrl.GetAppDef(_id);

            AppState?appState = _ctrl.GetAppState(_id);

            PlanState?planState = null;

            if (appState != null && !string.IsNullOrEmpty(appState.PlanName))
            {
                planState = _ctrl.GetPlanState(appState.PlanName);
            }

            string statusText = appState != null?Tools.GetAppStateText(appState, planState, appDef) : string.Empty;

            string?planName = _appDef?.PlanName ?? appState?.PlanName;                  // prefer plan from appdef


            ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(1.0f, 0f, 1f, 1f));
            bool opened = ImGui.TreeNodeEx($"{_id}##{_id}", ImGuiTreeNodeFlags.FramePadding);

            ImGui.PopStyleColor();
            if (ImGui.BeginPopupContextItem())
            {
                if (ImGui.MenuItem("Start"))
                {
                    _ctrl.Send(new Net.StartAppMessage(_ctrl.Name, _id, planName));
                }

                if (ImGui.MenuItem("Kill"))
                {
                    _ctrl.Send(new Net.KillAppMessage(_ctrl.Name, _id));
                }

                if (ImGui.MenuItem("Restart"))
                {
                    _ctrl.Send(new Net.RestartAppMessage(_ctrl.Name, _id));
                }
                ImGui.EndPopup();
            }
            ImGui.SameLine();
            ImGui.SetCursorPosX(ImGui.GetWindowWidth() * 3 / 4f);
            //if( ImGui.Button("S") )	_ctrl.Send( new Net.StartAppMessage( _id, planName ) );
            if (ImGuiTools.ImgBtn(_txStart))
            {
                _ctrl.Send(new Net.StartAppMessage(_ctrl.Name, _id, planName));
            }
            ImGui.SameLine();
            if (ImGuiTools.ImgBtn(_txKill))
            {
                _ctrl.Send(new Net.KillAppMessage(_ctrl.Name, _id));
            }
            ImGui.SameLine();
            if (ImGuiTools.ImgBtn(_txRestart))
            {
                _ctrl.Send(new Net.RestartAppMessage(_ctrl.Name, _id));
            }

            // enabled checkbox just for apps from a plan
            if (_appDef is not null && _appDef.PlanName is not null)
            {
                ImGui.SameLine();
                bool enabled = !_appDef.Disabled;
                if (ImGui.Checkbox("##enabled", ref enabled))
                {
                    _ctrl.Send(new Net.SetAppEnabledMessage(_ctrl.Name, _appDef.PlanName, _id, enabled));
                }
            }

            ImGui.SameLine();
            ImGui.SetCursorPosX(ImGui.GetWindowWidth() / 4 * 2f);
            ImGui.TextColored(GetAppStateColor(statusText, appDef), statusText);

            //ImGui.SameLine();
            //ImGui.SetCursorPosX( ImGui.GetWindowWidth()/4f);
            //DrawOptions();

            if (opened)
            {
                //DrawUIBody();
                string jsonString = JsonSerializer.Serialize(appDef, new JsonSerializerOptions()
                {
                    WriteIndented = true, IncludeFields = true
                });
                ImGui.TextWrapped(jsonString.Replace("%", "%%"));                 // TextWrapped doesn't like %s etc, percent signs needs to be doubled

                ImGui.TreePop();
            }

            ImGui.PopID();
        }