コード例 #1
0
        /// <summary>
        /// Adds a check to the tab and returns true if the check causes a restructure
        /// </summary>
        /// <param name="check">The check display to add to the tab</param>
        /// <returns>True if check is new, false if replacing an existing check or filling an existing space</returns>
        public bool AddCheck(ICheckDisplay check)
        {
            bool returnValue = false;

            var indexInTypesArray = _types.IndexOf(check.GetCheckType());
            if (indexInTypesArray == -1)
            {
                indexInTypesArray = _types.Count;
                _types.Add(check.GetCheckType());
                _checks.AddRow();
                returnValue = true;
            }

            var indexInLocsArray = _locations.IndexOf(check.GetLocation());
            if (indexInLocsArray == -1)
            {
                indexInLocsArray = _locations.Count;
                _locations.Add(check.GetLocation());
                _checks.AddColumn();
                returnValue = true;
            }

            _checks.InsertItem(check, indexInTypesArray, indexInLocsArray);

            LastColumn = indexInLocsArray;
            LastRow = indexInTypesArray;

            return returnValue;
        }
コード例 #2
0
 public CheckDisplayDto(ICheckDisplay check)
 {
     IsLoading = check.IsLoading();
     IsPaused = check.IsPaused();
     HasError = check.HasError();
     IsTriggered = check.IsTriggered();
     Result = check.GetResult();
     Status = check.GetStatus();
     Error = check.GetError();
     Location = check.GetLocation();
     CheckType = check.GetCheckType();
     TabName = check.GetTab();
 }
 public void UpdateCheck(ICheckDisplay check)
 {
     _clients.Value.UpdateChecks(new[] { new CheckDisplayDto(check) });
 }
コード例 #4
0
        public void Update(ICheckDisplay check)
        {
            try
            {
                if (_mainForm == null)
                {
                    throw new Exception("The form has not yet been created");
                }
                else
                {
                    TabDisplay myTab = null; //must be outside of lock

                    lock (_tabs)
                    {
                        myTab = _tabs.FirstOrDefault(t => t.GetName() == check.GetTab());

                        if (myTab == null)
                        {
                            myTab = new TabDisplay(check.GetTab());
                            _mainForm.AddTab(check.GetTab());
                            _tabs = _tabs.Where(t => t != null).Concat(myTab).ToArray();
                        }

                    }

                    if (myTab.AddCheck(check))
                    {
                        lock (_mainForm)
                        {
                            _mainForm.DrawTable(myTab.GetName(), myTab.GetLocations(), myTab.GetTypes());
                        }

                        for (int i = 0; i < myTab.GetTypes().Count; i++)
                        {
                            for (int j = 0; j < myTab.GetLocations().Count; j++)
                            {
                                var cell = myTab.GetTable()[i, j];
                                if (cell != null)
                                {
                                    string mouseOverText;
                                    System.Drawing.Color cellColour;
                                    if (cell.IsTriggered())
                                    {
                                        cellColour = System.Drawing.Color.Red;
                                        mouseOverText = cell.GetStatus();
                                    }
                                    else if (cell.HasError())
                                    {
                                        cellColour = System.Drawing.Color.Yellow;
                                        mouseOverText = cell.GetError();
                                    }
                                    else if (cell.IsPaused())
                                    {
                                        cellColour = System.Drawing.Color.LightBlue;
                                        mouseOverText = cell.GetStatus();
                                    }
                                    else
                                    {
                                        cellColour = System.Drawing.Color.White;
                                        mouseOverText = cell.GetStatus();
                                    }

                                    lock (_mainForm)
                                    {
                                        var result = cell.GetResult();

                                        _mainForm.SetCell(myTab.GetName(), i, j, result, cellColour, mouseOverText);
                                    }
                                }
                                else
                                {
                                    lock (_mainForm)
                                    {
                                        _mainForm.SetCell(myTab.GetName(), i, j,
                                            "Not Applicable", System.Drawing.Color.Gray,
                                            "Not Applicable");
                                    }
                                }
                            }
                        }

                    }
                    else
                    {
                        //just update the cell
                        lock (_mainForm)
                        {
                            System.Drawing.Color cellColour;
                            if (check.IsTriggered())
                            {
                                cellColour = System.Drawing.Color.Red;
                            }
                            else if (check.HasError())
                            {
                                cellColour = System.Drawing.Color.Yellow;
                            }
                            else if (check.IsPaused())
                            {
                                cellColour = System.Drawing.Color.LightBlue;
                            }
                            else
                            {
                                cellColour = System.Drawing.Color.White;
                            }

                            _mainForm.SetCell(myTab.GetName(), myTab.LastRow, myTab.LastColumn,
                                   check.GetResult(), cellColour, check.GetStatus());
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "Update failed");
            }
        }