Esempio 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);
 }
Esempio n. 2
0
 void btnSetDefaultSysDif_Click(object sender, EventArgs e)
 {
     for (int index = 0; index < dgvBaseSystemFormatting.Rows.Count; ++index)
     {
         dgvBaseSystemFormatting.Rows[index].Cells[colBackColorBaseSystemFormatting.Name].Value =
             ConditionalFormattingHelper.GetDisplayTextFromColor(_defaultColorSystemDifferences);
         dgvBaseSystemFormatting.Rows[index].Cells[colForeColorBaseSystemFormatting.Name].Value = ConditionalFormattingHelper._noSpecialColor;
     }
 }
        internal override bool Execute(TreeListNode senderNode)
        {
            if (!senderNode.Visible || !_column.Visible) //do not take into account cells which are hidden due to row-hiding or columns moved to the hidden-system-box
            {
                return(false);                           //(not visible cells cannot be focused and thus are a e.g. a problem with search next)
            }
            if (_mustBeExpanded && !IsFullyExpanded(senderNode))
            {
                return(false);
            }

            if (_mustBeWithinNodes != null && !_mustBeWithinNodes.Contains(senderNode))
            {
                return(false);
            }

            object cellValue = senderNode.GetValue(_column);

            if (cellValue == null)
            {
                return(false);
            }
            foreach (string pattern in ConditionalFormattingHelper.GetFormatConditionPatterns(_patterns))
            {
                if (EM_Helpers.DoesValueMatchPattern(pattern, cellValue.ToString(), _matchCase, _matchWord))
                {
                    return(true);
                }

                if (_includePrivateComments && TreeListManagement.TreeListBuilder.IsCommentColumn(_column))
                {
                    TreeListTags.BaseTreeListTag tag = senderNode.Tag as TreeListTags.BaseTreeListTag;
                    if (tag != null && EM_Helpers.DoesValueMatchPattern(pattern, tag.GetPrivateComment(), _matchCase, _matchWord))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 4
0
        internal ConditionalFormattingForm(string countryShortName, CountryConfigFacade countryConfigFacade)
        {
            InitializeComponent();

            _countryConfigFacade = countryConfigFacade;
            lblCountry.Text      = countryShortName;

            //put all systems in a list for easier access
            List <string> allSystemNames = new List <string>();

            foreach (CountryConfig.SystemRow systemRow in countryConfigFacade.GetSystemRows())
            {
                allSystemNames.Add(systemRow.Name);
            }

            //grid for format settings of base-derived-system differences:
            //add a row for each system (to be completed by base-system and format settings below, if there are any)
            //fill combo for selecting base system (with all available systems)
            foreach (string systemName in allSystemNames)
            {
                int index = dgvBaseSystemFormatting.Rows.Add(systemName, string.Empty,
                                                             ConditionalFormattingHelper._noSpecialColor, ConditionalFormattingHelper._noSpecialColor);
                dgvBaseSystemFormatting.Rows[index].Cells[colBackColorBaseSystemFormatting.Name].Value =
                    ConditionalFormattingHelper.GetDisplayTextFromColor(_defaultColorSystemDifferences);
                dgvBaseSystemFormatting.Rows[index].Tag = null;
            }

            foreach (CountryConfig.ConditionalFormatRow conditionalFormatRow in countryConfigFacade.GetConditionalFormatRows())
            {
                //fill grid for format settings of conditional formatting
                if (conditionalFormatRow.Condition != null && conditionalFormatRow.Condition != string.Empty)
                {
                    string applySystemNames = string.Empty;
                    foreach (CountryConfig.ConditionalFormat_SystemsRow conditionalFormat_SystemsRow in conditionalFormatRow.GetConditionalFormat_SystemsRows())
                    {
                        applySystemNames += conditionalFormat_SystemsRow.SystemName + _separator;
                    }
                    if (applySystemNames != string.Empty)
                    {
                        applySystemNames = applySystemNames.Substring(0, applySystemNames.Length - 1);
                    }
                    int index = dgvConditionalFormatting.Rows.Add(conditionalFormatRow.Condition, applySystemNames,
                                                                  conditionalFormatRow.BackColor == string.Empty ? ConditionalFormattingHelper._noSpecialColor : conditionalFormatRow.BackColor,
                                                                  conditionalFormatRow.ForeColor == string.Empty ? ConditionalFormattingHelper._noSpecialColor : conditionalFormatRow.ForeColor);
                    dgvConditionalFormatting.Rows[index].Tag = conditionalFormatRow;
                }

                //complete grid for format settings of base-derived-system differences
                if (conditionalFormatRow.BaseSystemName != null && conditionalFormatRow.BaseSystemName != string.Empty)
                {
                    if (countryConfigFacade.GetSystemRowByName(conditionalFormatRow.BaseSystemName) == null)
                    {
                        continue; //base system may have been deleted meanwhile
                    }
                    if (conditionalFormatRow.GetConditionalFormat_SystemsRows().Count() == 0)
                    {
                        continue; //should not happen, there ought to be either no or exactely one base-derived-differences setting (and if there is a setting there must be a respective system-format-link)
                    }
                    CountryConfig.ConditionalFormat_SystemsRow conditionalFormat_SystemsRow = conditionalFormatRow.GetConditionalFormat_SystemsRows().ElementAt(0);
                    int index = allSystemNames.IndexOf(conditionalFormat_SystemsRow.SystemName);
                    if (index < 0)
                    {
                        continue; //should not happen (would mean incomplete delete of a system or a similar error)
                    }
                    dgvBaseSystemFormatting.Rows[index].Cells[colBaseSystem.Name].Value = conditionalFormatRow.BaseSystemName;
                    dgvBaseSystemFormatting.Rows[index].Cells[colBackColorBaseSystemFormatting.Name].Value =
                        conditionalFormatRow.BackColor == string.Empty ? ConditionalFormattingHelper._noSpecialColor : conditionalFormatRow.BackColor;
                    dgvBaseSystemFormatting.Rows[index].Cells[colForeColorBaseSystemFormatting.Name].Value =
                        conditionalFormatRow.ForeColor == string.Empty ? ConditionalFormattingHelper._noSpecialColor : conditionalFormatRow.ForeColor;
                    dgvBaseSystemFormatting.Rows[index].Tag = conditionalFormatRow;
                }
            }
        }
Esempio n. 5
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);
                }
            }
        }