Beispiel #1
0
        public GuiWindow(ImGuiWindow wnd, AppConfig ac)
        {
            _wnd = wnd;
            _ac  = ac;
            log.Debug($"Running with masterIp={_ac.MasterIP}, masterPort={_ac.MasterPort}");
            _clientIdent             = new Net.ClientIdent(_ac.ClientId, Net.EMsgRecipCateg.Gui);       // client name will be assigned automatically (a guid)
            _client                  = new Net.Client(_clientIdent, _ac.MasterIP, _ac.MasterPort, autoConn: true);
            _client.MessageReceived += OnMessage;
            _reflStates              = new ReflectedStateRepo(_client);
            _txKillAll               = _wnd.GetImage("Resources/skull.png");

            _menuRenderer  = new GuiWinMenuRenderer(_wnd, _reflStates);
            _errorRenderer = new ErrorRenderer(_wnd);

            _appTreeRenderer    = new AppTreeRenderer(_wnd, _reflStates);
            _planTreeRenderer   = new PlanTreeRenderer(_wnd, _reflStates);
            _scriptTreeRenderer = new ScriptTreeRenderer(_wnd, _reflStates);

            _reflStates.OnReset           += Reset;
            _reflStates.OnAppsReceived    += _appTreeRenderer.Reset;
            _reflStates.OnPlansReceived   += _planTreeRenderer.Reset;
            _reflStates.OnScriptsReceived += _scriptTreeRenderer.Reset;

            Reset();
        }
Beispiel #2
0
 void myDispose()
 {
     tmrTick.Enabled = false;
     if (_client is not null)
     {
         _client.MessageReceived -= OnMessage;
         _client.Dispose();
         _client = null;
     }
 }
Beispiel #3
0
        public frmMain(
            AppConfig ac,
            NotifyIcon notifyIcon,
            string machineId             // empty if no local agent was started with the GUI
            )
        {
            _ac          = ac;
            _machineId   = machineId;           // FIXME: this is only valid if we are running a local agent! How do we know??
            _clientIdent = new Net.ClientIdent()
            {
                Sender = Guid.NewGuid().ToString(), SubscribedTo = Net.EMsgRecipCateg.Gui
            };
            _notifyIcon = notifyIcon;
            _allowLocalIfDisconnected = true;

            log.Debug($"Running with masterIp={_ac.MasterIP}, masterPort={_ac.MasterPort}");


            InitializeComponent();

            if (Common.Properties.Settings.Default.GridRowSpacing > 0)
            {
                this.gridPlans.RowTemplate.Height = Common.Properties.Settings.Default.GridRowSpacing;
                this.gridApps.RowTemplate.Height  = Common.Properties.Settings.Default.GridRowSpacing;
            }

            if (Common.Properties.Settings.Default.GridButtonSpacing > 0)
            {
                this.hdrPlanStart.Width   = Common.Properties.Settings.Default.GridButtonSpacing;
                this.hdrPlanStop.Width    = Common.Properties.Settings.Default.GridButtonSpacing;
                this.hdrPlanKill.Width    = Common.Properties.Settings.Default.GridButtonSpacing;
                this.hdrPlanRestart.Width = Common.Properties.Settings.Default.GridButtonSpacing;
                this.hdrKillIcon.Width    = Common.Properties.Settings.Default.GridButtonSpacing;
                this.hdrLaunchIcon.Width  = Common.Properties.Settings.Default.GridButtonSpacing;
                this.hdrRestartIcon.Width = Common.Properties.Settings.Default.GridButtonSpacing;
            }


            registerHotKeys();

            //setDoubleBuffered(gridApps, true); // not needed anymore, DataViewGrid does not flicker

            _planRepo = new List <PlanDef>();

            _client = new Net.Client(_clientIdent, ac.MasterIP, ac.MasterPort, autoConn: true);
            _client.MessageReceived += OnMessage;
            _reflStates              = new ReflectedStateRepo(_client);

            bool firstGotPlans = true;

            _reflStates.OnPlansReceived += () =>
            {
                if (firstGotPlans)
                {
                    selectPlan(ac.StartupPlan);
                }
                firstGotPlans = false;

                // udate current plan reference in case the plan def has changed
                if (_currentPlan is not null)
                {
                    _currentPlan = _reflStates.GetPlanDef(_currentPlan.Name);
                }
            };

            _ctrl = _reflStates;

            // start ticking
            log.DebugFormat("MainForm's timer period: {0}", ac.TickPeriod);
            tmrTick.Interval = ac.TickPeriod;
            tmrTick.Enabled  = true;
        }
Beispiel #4
0
 public SendMessageBuffer(Net.Client client, Net.Message msg)
 {
     this.Client  = client;
     this.Message = msg;
 }