示例#1
0
        public MultipleCell(MultipleCell multiple, List <Cell> cells) : base(multiple, false)
        {
            _CellOptions = new List <Cell>();
            _OptionNames = new List <string>();
            _baseName    = multiple.BaseName;
            _CellType    = CellType.Multiple;

            foreach (Cell c in multiple.CellOptions)
            {
                AddCellToOptions(c, cells, false);
            }

            // set selected cell to the first item in the list of cells
            _SelectedCell = _CellOptions[0];
        }
示例#2
0
        public MultipleCell(MultipleCell multiple, List<Cell> cells) : base(multiple, false)
        {
            _CellOptions = new List<Cell>();
            _OptionNames = new List<string>();
            _baseName = multiple.BaseName;
            _CellType = CellType.Multiple;

            foreach (Cell c in multiple.CellOptions)
            {
                AddCellToOptions(c, cells, false);
            }

            // set selected cell to the first item in the list of cells
            _SelectedCell = _CellOptions[0];
        }
示例#3
0
        public void CheckAndUpdateMultipleDependency(Cell cell, MultipleCell mc)
        {
            int row = mc.RowIndex;

            List <CCell> calcCells = mc.CellOptions.OfType <CCell>().Select(c => c).ToList();

            foreach (CCell cc in calcCells)
            {
                if (cc.IsDependency(cell))
                {
                    cc.Dependencies[cell] = cell.ValueChanged;
                    cc.CheckDependencies();
                }
            }
        }
示例#4
0
        public void CheckAndUpdateMultipleDependency(Cell cell, MultipleCell mc)
        {
            int row = mc.RowIndex;

            List<CCell> calcCells = mc.CellOptions.OfType<CCell>().Select(c => c).ToList();

            foreach (CCell cc in calcCells)
            {
                if (cc.IsDependency(cell))
                {
                    cc.Dependencies[cell] = cell.ValueChanged;
                    cc.CheckDependencies();
                }
            }
        }
示例#5
0
        public void AddRow()
        {
            int nextRow = _Cells.Count;

            // check each cell

            List <Cell> cells = new List <Cell>();

            foreach (Cell c in _Cells[nextRow - 1])
            {
                if (c.CellType == CellType.C)
                {
                    CCell cc = c as CCell;

                    List <string> names = cc.ConnectionInfo.Split(new char[] { '(', ')', '+', '-', '*', '/', '^' }).ToList();

                    // need for TryParse
                    double n;

                    List <string> dependencyNamesPossibleDupes = new List <string>(); /* = (from name in names
                                                                                       * where name.Length > 0 &&
                                                                                       * !double.TryParse(name, out n)     // make sure the value isn't an integer
                                                                                       * select name).ToList(); */


                    foreach (string name in names)
                    {
                        if (name.Length > 0 && !double.TryParse(name, out n))
                        {
                            dependencyNamesPossibleDupes.Add(name);
                        }
                    }

                    // quicker way to get distinct values
                    HashSet <string> dependencyNames = new HashSet <string>(dependencyNamesPossibleDupes);

                    //List<string> dependencyNames = dependencyNamesPossibleDupes.Distinct().ToList();


                    List <Cell> dependencies = new List <Cell>();

                    foreach (string name in dependencyNames)
                    {
                        Cell dependency = cells.First(x => x.Label == name);

                        if (dependency != null)
                        {
                            dependencies.Add(dependency);
                        }
                    }

                    CCell copyWithCorrectRow = new CCell(cc, dependencies);
                    _CalculationCells.Add(copyWithCorrectRow);
                    cells.Add(copyWithCorrectRow);
                }
                else if (c.CellType == CellType.W)
                {
                    WCell wc = c as WCell;
                    cells.Add(new WCell(wc));
                }
                else if (c.CellType == CellType.K)
                {
                    KCell kc = c as KCell;

                    KCell kcToAdd = new KCell(kc);

                    if (kcToAdd.KConnectionType == KConnection.AUTO)
                    {
                        kcToAdd.Value = kc.Value + 1;
                    }
                    if (kcToAdd.KConnectionType == KConnection.DITTO)
                    {
                        kcToAdd.KValue = kc.KValue;
                    }
                    cells.Add(kcToAdd);
                }
                else if (c.CellType == CellType.M)
                {
                    MCell mc = c as MCell;
                    cells.Add(new MCell(mc));
                }
                else if (c.CellType == CellType.Multiple)
                {
                    MultipleCell multiple = c as MultipleCell;
                    cells.Add(new MultipleCell(multiple, cells));
                }
                else if (c.CellType == CellType.NewScreen)
                {
                    NewScreen ns = c as NewScreen;
                    cells.Add(new NewScreen(ns));
                }
            }
            _Cells.Add(cells);
        }