Ejemplo n.º 1
0
        public object Visit(Cell n)
        {
            var root = new XElement("Cell");
            root.Add("ID", n.Id);
            root.Add("Content", NullCheck(n.Content));
            root.Add("Location", NullCheck(n.Location));

            return root;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the sanitycells acordingly
        /// </summary>
        /// <param name="firstSelectedCell"></param>
        private void SetSanityToggleButtons(Cell firstSelectedCell)
        {
            //set SanityValue cell toggle button
            if (firstSelectedCell != null &&
                DataModel.Instance.CurrentWorkbook.SanityValueCells.Contains(firstSelectedCell))
            {
                sanityValueCellToggleButton.Checked = true;
            }
            else
            {
                sanityValueCellToggleButton.Checked = false;
            }

            //set sanityConstraint cell toggle button
            if (firstSelectedCell != null &&
                DataModel.Instance.CurrentWorkbook.SanityConstraintCells.Contains(firstSelectedCell))
            {
                sanityConstraintCellToggleButton.Checked = true;
            }
            else
            {
                sanityConstraintCellToggleButton.Checked = false;
            }

            //set sanityExplanation cell toggle button
            if (firstSelectedCell != null &&
                DataModel.Instance.CurrentWorkbook.SanityExplanationCells.Contains(firstSelectedCell))
            {
                sanityExplanationCellToggleButton.Checked = true;
            }
            else
            {
                sanityExplanationCellToggleButton.Checked = false;
            }

            //set sanityChecking cell toggle button
            if (firstSelectedCell != null &&
                DataModel.Instance.CurrentWorkbook.SanityCheckingCells.Contains(firstSelectedCell))
            {
                sanityCheckingCellToggleButton.Checked = true;
            }
            else
            {
                sanityCheckingCellToggleButton.Checked = false;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the toggle Buttons of the cells acordingly
        /// </summary>
        /// <param name="firstSelectedCell">First checked cell</param>
        private void SetCellToggleButtons(Cell firstSelectedCell)
        {
            //set input cell toggle button
            if (firstSelectedCell != null && DataModel.Instance.CurrentWorkbook.InputCells.Contains(firstSelectedCell))
            {
                inputCellToggleButton.Checked = true;
            }
            else
            {
                inputCellToggleButton.Checked = false;
            }

            //set intermediate cell toggle button
            if (firstSelectedCell != null &&
                DataModel.Instance.CurrentWorkbook.IntermediateCells.Contains(firstSelectedCell))
            {
                intermediateCellToggleButton.Checked = true;
            }
            else
            {
                intermediateCellToggleButton.Checked = false;
            }

            //set output cell toggle button
            if (firstSelectedCell != null && DataModel.Instance.CurrentWorkbook.OutputCells.Contains(firstSelectedCell))
            {
                resultCellToggleButton.Checked = true;
            }
            else
            {
                resultCellToggleButton.Checked = false;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the first selected cells in the current workbook
        /// </summary>
        /// <param name="wb">workbook model</param>
        /// <returns>List of Cell or null if no cell is selected</returns>
        public Cell GetFirstSelectedCell(WorkbookModel wb)
        {
            Range selectedCell = (wb.Workbook.Application.Selection as Range).Cells.Cells[1] as Range;
            String currentLocation = "=" + (selectedCell.Parent as Worksheet).Name as String + "!" + selectedCell.Address as String;


            var resultCell = new Cell()
            {
                Id = Convert.ToInt32(selectedCell.ID),
                Location = GetUserCellName(wb, currentLocation),
                SifLocation = GetSIFCellName(wb, currentLocation),
                Content = selectedCell.Formula as String
            };
            // Take the first cell and return it.
            return resultCell;

        }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds automatic cells to the cell definitions list.
        /// </summary>
        /// <param name="root">XML List of cells</param>
        /// <param name="targetCollection">Target collection e.g. input cells, intermediate cells, or result cells</param>
        /// <param name="cellType">Class of the cell type</param>
        private void ParseCells(XElement root, ObservableCollection<Cell> targetCollection, Type cellType)
        {
            /*(from p in root.Elements(XName.Get("cell"))
             select new Cell(p, this.Workbook).ToCellType(cellType)).ToList().ForEach(p => { if (!targetCollection.Contains(p)) targetCollection.Add(p); });*/

            var cellElements = root.Elements(XName.Get("cell"));
            if (cellElements != null)
            {
                foreach (var element in cellElements)
                {
                    var cell = new Cell(element, this.workbook);
                    if (cellType == typeof(InputCell))
                    {
                        var list = new List<Cell>();
                        list.Add(cell);
                        this.DefineInputCell(list, CellDefinitionOption.Define);
                    }
                    else if (cellType == typeof(IntermediateCell))
                    {
                        var list = new List<Cell>();
                        list.Add(cell);
                        this.DefineIntermediateCell(list, CellDefinitionOption.Define);
                    }
                    else if (cellType == typeof(OutputCell))
                    {
                        var list = new List<Cell>();
                        list.Add(cell);
                        this.DefineOutputCell(list, CellDefinitionOption.Define);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the selected cells in the current workbook
        /// </summary>
        /// <param name="wb">workbook model</param>
        /// <returns>List of Cell</returns>
        public List<Cell> GetSelectedCells(WorkbookModel wb)
        {
            var cellList = new List<Cell>();

            Range selectedCells = (wb.Workbook.Application.Selection as Range).Cells;

            Debug.WriteLine("SELECTED CELLS: Creating List ...");
            DateTime start = DateTime.Now;

            foreach (var c in selectedCells.Cells)
            {
                var currentCell = c as Range;
                String currentLocation = "=" + (currentCell.Parent as Worksheet).Name as String + "!" + currentCell.Address as String;
                var selectedCell = new Cell()
                {
                    Id = Convert.ToInt32(currentCell.ID),
                    Location = GetUserCellName(wb, currentLocation),
                    SifLocation = GetSIFCellName(wb, currentLocation),
                    Content = currentCell.Formula as String
                };

                cellList.Add(selectedCell);
            }

            Debug.WriteLine("SELECTED CELLS: List created! Time: " + (DateTime.Now - start).ToString() + ", Items: " + cellList.Count);
            return cellList;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Converts the cell to a normal cell (not involved in a scenario)
 /// </summary>
 /// <returns></returns>
 public Cell ToCell()
 {
     var cell = new Cell()
     {
         Id = Id,
         Content = Content,
         Location = Location,
         SifLocation = SifLocation
     };
     return cell;
 }
Ejemplo n.º 8
0
 public object Visit(Cell n)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Adds automatic cells to the cell definitions list.
        /// </summary>
        /// <param name="root">XML List of cells</param>
        /// <param name="targetCollection">Target collection e.g. input cells, intermediate cells, or result cells</param>
        /// <param name="cellType">Class of the cell type</param>
        private void ParseCells(XElement root, ObservableCollection<Cell> targetCollection, Type cellType)
        {

            var cellElements = root.Elements(XName.Get("cell"));
            if (cellElements != null)
            {
                foreach (var element in cellElements)
                {
                    var cell = new Cell(element, this.workbook);
                    if (cellType == typeof(InputCell))
                    {
                        var list = new List<Cell>();
                        list.Add(cell);
                        this.DefineInputCell(list, CellDefinitionOption.Define);
                    }
                    else if (cellType == typeof(IntermediateCell))
                    {
                        var list = new List<Cell>();
                        list.Add(cell);
                        this.DefineIntermediateCell(list, CellDefinitionOption.Define);
                    }
                    else if (cellType == typeof(OutputCell))
                    {
                        var list = new List<Cell>();
                        list.Add(cell);
                        this.DefineOutputCell(list, CellDefinitionOption.Define);
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public Cell ToCell()
 {
     var cell = new Cell()
     {
         Id = this.Id,
         Content = this.Content,
         Location = this.Location,
         SifLocation = this.SifLocation
     };
     return cell;
 }