Ejemplo n.º 1
0
 void SetBackOrTextColor(DataGridView gridView, int rowIndex, int columnIndex)
 {
     dlgColor.Color = ConditionalFormattingHelper.GetColorFromDisplayText((gridView.Rows[rowIndex].Cells[columnIndex]).Value.ToString());
     if (dlgColor.ShowDialog() == DialogResult.Cancel)
     {
         return;
     }
     (gridView.Rows[rowIndex].Cells[columnIndex]).Value = ConditionalFormattingHelper.GetDisplayTextFromColor(dlgColor.Color);
 }
Ejemplo n.º 2
0
        internal void SetSystemFormats()
        {//set backcolor and foreColor of systems' cells according to the conditional formatting settings defined by the user
            //first clear all current formats
            foreach (TreeListColumn formatColumn in _mainForm._specialFormatCells.Keys)
            {
                _mainForm._specialFormatCells[formatColumn].Clear();
            }
            _mainForm._specialFormatCells.Clear();

            foreach (TreeListColumn column in _mainForm.treeList.Columns)
            {
                if (IsFixedColumnLeft(column) || IsFixedColumnRight(column))
                {
                    continue; //no conditional formatting for policy-, group- and comment-column
                }
                SystemTreeListTag systemTag = column.Tag as SystemTreeListTag;
                foreach (CountryConfig.ConditionalFormatRow conditionalFormatRow in _countryConfigFacade.GetConditionalFormatRowsOfSystem(systemTag.GetSystemRow()))
                {
                    //first define condition ...
                    IsSpecificBase condition = null;

                    //'standard' conditional formatting: does cell value correspond to specific patterns
                    if (conditionalFormatRow.BaseSystemName == null || conditionalFormatRow.BaseSystemName == string.Empty)
                    {
                        condition = new DoesNodeMatchPatterns(conditionalFormatRow.Condition, column);
                    }
                    //special conditional formatting: show differences between the system and its base-system
                    else
                    {
                        TreeListColumn columnBaseSystem = _mainForm.treeList.Columns.ColumnByName(conditionalFormatRow.BaseSystemName);
                        if (columnBaseSystem == null)
                        {
                            continue; //base system does for whatever reason not exist (was e.g. deleted)
                        }
                        condition = new IsNodeValueDifferent(column, columnBaseSystem);
                    }

                    //... then find all cells which match condition ...
                    TreatSpecificNodes treater = new TreatSpecificNodes(condition, null, false);
                    _mainForm.treeList.NodesIterator.DoOperation(treater);

                    //... finally add to list of cells to be formatted: formatting is accomplished in MainForm's treeList_NodeCellStyle-callback (based on the list)
                    Color backColor = conditionalFormatRow.BackColor == ConditionalFormattingHelper._noSpecialColor ? Color.Empty : ConditionalFormattingHelper.GetColorFromDisplayText(conditionalFormatRow.BackColor);
                    Color foreColor = conditionalFormatRow.ForeColor == ConditionalFormattingHelper._noSpecialColor ? Color.Empty : ConditionalFormattingHelper.GetColorFromDisplayText(conditionalFormatRow.ForeColor);

                    AddToSpecialFormatCells(column, treater.GetSpecificNodes(), backColor, foreColor);
                }
            }
        }