Exemplo n.º 1
0
 public FormulaFunction(CellVertex formulaVertex, Expression expression) : base(formulaVertex)
 {
     Name.IsFunction = true;
     Expression      = expression;
     Parameters      = expression.GetLeafsOfType <InputReference>().ToArray();
     ReturnType      = expression.GetCellType();
 }
Exemplo n.º 2
0
        private const int VERTEX_BOX      = 60; // width and height of a vertex including spacing

        public static DColor GetClassificationColor(this CellVertex cellVertex)
        {
            if (cellVertex.IsExternal)
            {
                return(_externalNodeColor);
            }

            switch (cellVertex.Classification)
            {
            case Classification.InputField:
                return(_inputNodeColor);

            case Classification.Constant:
                return(_constantNodeColor);

            case Classification.OutputField:
                return(_outputNodeColor);

            case Classification.Formula:
                return(_formulaNodeColor);

            default:
                return(DColor.Transparent);
            }
        }
Exemplo n.º 3
0
        public static NodeViewModel FormatCellVertex(this CellVertex cellVertex, double posX, double posY)
        {
            var size = cellVertex.Classification == Classification.OutputField ? 40 : Math.Min(55, cellVertex.Parents.Count * 4 + 25);
            var node = new NodeViewModel
            {
                ID              = _nodeCounter++,
                Content         = cellVertex,
                ContentTemplate = new DataTemplate(),
                UnitWidth       = size,
                UnitHeight      = size,
                OffsetX         = posX,
                OffsetY         = posY,
                ZIndex          = 10000,
                Annotations     = new AnnotationCollection
                {
                    new AnnotationEditorViewModel
                    {
                        Offset = new Point(0, 0),
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Bottom,
                        Content             = cellVertex.Name == null ? cellVertex.StringAddress : (string)cellVertex.Name,
                        ViewTemplate        = cellVertex.Name == null ? _redLabelTemplate : _normalLabelTemplate,
                        UnitWidth           = 200
                    }
                }
            };

            switch (cellVertex.Classification)
            {
            case Classification.InputField:
                node.Shape      = _inputShape;
                node.ShapeStyle = _inputShapeStyle;
                break;

            case Classification.Constant:
                node.Shape      = _constantShape;
                node.ShapeStyle = _constantShapeStyle;
                break;

            case Classification.Formula:
                node.Shape      = _formulaShape;
                node.ShapeStyle = _formulaShapeStyle;
                break;

            case Classification.OutputField:
                node.Shape      = _outputShape;
                node.ShapeStyle = _outputShapeStyle;
                break;
            }
            SetNodeConstraints(node);
            cellVertex.Node = node;
            return(node);
        }
Exemplo n.º 4
0
 public Cell(Cell parent, CellVertex index, Vertex[] vertices)
 {
     this.index  = index;
     this.parent = parent;
     level       = parent.level + 1;
     tree        = parent.tree;
     uid         = tree.getCellUID;
     //vertices = new Vertex[CellVerticesNumber];
     children = null;
     data     = new TCellData();
     tree.cells.Add(this);
     this.vertices = vertices;
 }
Exemplo n.º 5
0
 public void SetExpectedValue(CellVertex vertex)
 {
     if (vertex == null)
     {
         ExpectedValue     = null;
         ExpectedValueType = CellType.Unknown;
     }
     else
     {
         ExpectedValue     = vertex.Value;
         ExpectedValueType = vertex.CellType;
     }
 }
Exemplo n.º 6
0
        public OutputFieldFunction(CellVertex outputFieldVertex, Statement[] statements) : base(outputFieldVertex)
        {
            Name.IsOutputField = true;
            Statements         = statements;

            var statementVariableNames = Statements.Select(statement => statement.VariableName.ToString()).ToHashSet();

            Parameters = Statements
                         .OfType <FunctionInvocationStatement>()
                         .SelectMany(statement => statement.Parameters)
                         .Where(inputReference => !statementVariableNames.Contains(inputReference.VariableName.ToString()))
                         .ToArray();

            ReturnType = statements.Last().VariableType;
        }
Exemplo n.º 7
0
 protected CellFunction(CellVertex vertex)
 {
     Name = vertex.Name.Copy();
 }
Exemplo n.º 8
0
 public InputReference(CellVertex cellVertex) : base(cellVertex.Name)
 {
     InputType = cellVertex.CellType;
 }
Exemplo n.º 9
0
 public GlobalCellReference(CellVertex cellVertex) : base(cellVertex)
 {
     ReferencedVertex = cellVertex;
 }
Exemplo n.º 10
0
 public static NodeViewModel FormatCellVertex(this CellVertex cellVertex, Graph graph)
 {
     return(FormatCellVertex(cellVertex,
                             Array.IndexOf(graph.PopulatedColumns, cellVertex.Address.col) * VERTEX_BOX + DIAGRAM_PADDING,
                             Array.IndexOf(graph.PopulatedRows, cellVertex.Address.row) * VERTEX_BOX + DIAGRAM_PADDING));
 }
Exemplo n.º 11
0
 public void StyleBorderByClassification(CellVertex cellVertex, IBorders borderStyle)
 {
     borderStyle.ColorRGB  = cellVertex.GetClassificationColor();
     borderStyle.LineStyle = cellVertex.Classification == Classification.None ? ExcelLineStyle.None : ExcelLineStyle.Thick;
 }