Exemplo n.º 1
0
        public void PersistCellLocation()
        {
            if (this.cell == null)
            {
                throw new NullReferenceException("The cell location is null. You have to call FindCellLocation before");
            }
            string location = this.Cell.Location;

            if (!string.IsNullOrWhiteSpace(location))
            {
                location = location.Substring(location.IndexOf(']') + 1);
                foreach (CellLocation cell in DataModel.Instance.CurrentWorkbook.ViolatedCells)
                {
                    Regex rgx = new Regex(@"\$|=");
                    if (cell.ViolationType.Equals(this.violationState) && rgx.Replace(cell.Location, "").Equals(rgx.Replace(location, "")))
                    {
                        this.Cell = cell;
                        cell.Violations.Add(this);
                        cell.SetVisibility(DataModel.Instance.CurrentWorkbook.SelectedTab);
                        return;
                    }
                }
                this.cell = new CellLocation(workbook, location);
                this.cell.ViolationType = this.violationState;
                this.cell.Violations.Add(this);
                DataModel.Instance.CurrentWorkbook.ViolatedCells.Add(this.cell);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks if the cell of the violation already has other violations and adds the new one or adds a new cell to the cellswithviolations and adds the violation to the
        /// respecting cell
        /// </summary>
        public void PersistCellLocation()
        {
            if (this.cell == null)
            {
                throw new NullReferenceException("The cell location is null. You have to call FindCellLocation before");
            }
            string location = Cell.Location;

            if (!string.IsNullOrWhiteSpace(location))
            {
                location = location.Substring(location.IndexOf(']') + 1);
                foreach (CellLocation cell in DataModel.Instance.CurrentWorkbook.ViolatedCells)
                {
                    Regex rgx = new Regex(@"\$|=");
                    if (cell.ViolationType.Equals(this.violationState) && rgx.Replace(cell.Location, "").Equals(rgx.Replace(location, "")))
                    {
                        Cell = cell;
                        cell.Violations.Add(this);
                        // Should the current Violation be visible (depending of the tab/categorie that is clicked in the sidepane)
                        cell.SetVisibility(DataModel.Instance.CurrentWorkbook.SelectedTab);
                        return;
                    }
                }
                //Only happens if until now there was no violation with matching cell found
                this.cell.ViolationType = violationState;
                this.cell.Violations.Add(this);
                DataModel.Instance.CurrentWorkbook.ViolatedCells.Add(this.cell);
            }
        }