Esempio n. 1
0
        GetRowIDsToAverageForEdges
        (
            GroupInfo oGroup,
            CollapsedGroupAttributes oCollapsedGroupAttributes,
            Int32 iAnchorVertexIndex
        )
        {
            Debug.Assert(oGroup != null);
            Debug.Assert(oCollapsedGroupAttributes != null);
            Debug.Assert(iAnchorVertexIndex >= 0);

            List <Int32> oRowIDsOfRowsToAverage = new List <Int32>();

            String sAnchorVertexName;

            if (oCollapsedGroupAttributes.TryGetValue(

                    CollapsedGroupAttributeKeys.GetAnchorVertexNameKey(
                        iAnchorVertexIndex),

                    out sAnchorVertexName))
            {
                // The group's vertices are the span vertices.  Loop through them.

                foreach (IVertex oVertex in oGroup.Vertices)
                {
                    // We need to find the edge that is incident to the specified
                    // anchor vertex.

                    foreach (IEdge oIncidentEdge in oVertex.IncidentEdges)
                    {
                        IVertex oAdjacentVertex =
                            oIncidentEdge.GetAdjacentVertex(oVertex);

                        if (oAdjacentVertex.Name == sAnchorVertexName)
                        {
                            // The row ID is stored in the edge's Tag, as long as
                            // the edge row isn't hidden.

                            if (oIncidentEdge.Tag is Int32)
                            {
                                oRowIDsOfRowsToAverage.Add(
                                    (Int32)oIncidentEdge.Tag);
                            }

                            break;
                        }
                    }
                }
            }

            return(oRowIDsOfRowsToAverage);
        }
Esempio n. 2
0
        GetReadColorAndShapeFlags
        (
            IVertex oVertex,
            GroupInfo oGroup,
            ReadWorkbookContext oReadWorkbookContext,
            out Boolean bReadColorFromGroup,
            out Boolean bReadShapeFromGroup
        )
        {
            Debug.Assert(oVertex != null);
            Debug.Assert(oReadWorkbookContext != null);
            AssertValid();

            // Assume that the settings specified in the context object will be
            // used.

            bReadColorFromGroup = oReadWorkbookContext.ReadVertexColorFromGroups;
            bReadShapeFromGroup = oReadWorkbookContext.ReadVertexShapeFromGroups;

            if (oGroup.CollapsedAttributes != null)
            {
                CollapsedGroupAttributes oCollapsedGroupAttributes =
                    CollapsedGroupAttributes.FromString(
                        oGroup.CollapsedAttributes);

                String sHeadVertexName;

                if (
                    oCollapsedGroupAttributes.GetGroupType() ==
                    CollapsedGroupAttributeValues.FanMotifType
                    &&
                    oCollapsedGroupAttributes.TryGetValue(
                        CollapsedGroupAttributeKeys.HeadVertexName,
                        out sHeadVertexName)
                    &&
                    oVertex.Name == sHeadVertexName
                    )
                {
                    // The shape of a fan motif's head vertex should never be
                    // changed.  Do not get it from the group.

                    bReadShapeFromGroup = false;
                }
            }
        }
Esempio n. 3
0
        AddCollapsedGroupAttributesInternal
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            ReadWorkbookContext oReadWorkbookContext,
            ListObject oEdgeTable,
            ListObject oVertexTable,
            GroupInfo[] aoGroups
        )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oReadWorkbookContext != null);
            Debug.Assert(oEdgeTable != null);
            Debug.Assert(oVertexTable != null);
            Debug.Assert(aoGroups != null);
            Debug.Assert(aoGroups.Length > 0);

            // Check whether relevant columns have been autofilled using numerical
            // source columns.

            PerWorkbookSettings oPerWorkbookSettings =
                new PerWorkbookSettings(oWorkbook);

            AutoFillColorColumnResults oVertexColorResults =
                oPerWorkbookSettings.AutoFillWorkbookResults.VertexColorResults;

            Boolean bVertexColorColumnAutoFilled =
                oVertexColorResults.ColumnAutoFilled &&
                !oVertexColorResults.ColumnAutoFilledWithCategories;

            AutoFillColorColumnResults oEdgeColorResults =
                oPerWorkbookSettings.AutoFillWorkbookResults.EdgeColorResults;

            Boolean bEdgeColorColumnAutoFilled =
                oEdgeColorResults.ColumnAutoFilled &&
                !oEdgeColorResults.ColumnAutoFilledWithCategories;

            AutoFillNumericRangeColumnResults oEdgeWidthResults =
                oPerWorkbookSettings.AutoFillWorkbookResults.EdgeWidthResults;

            Boolean bEdgeWidthColumnAutoFilled =
                oEdgeWidthResults.ColumnAutoFilled;

            // Some user settings for autofill may be needed.
            //
            // Note: This is a design bug.  The user's current settings should not
            // be required; everything needed here should come from the autofill
            // results.  The long-term fix is to add a UseLogs property to the
            // AutoFillColorColumnResults class.

            AutoFillUserSettings oAutoFillUserSettings =
                new AutoFillUserSettings();

            ColorColumnAutoFillUserSettings oVertexColorDetails =
                oAutoFillUserSettings.VertexColorDetails;

            ColorColumnAutoFillUserSettings oEdgeColorDetails =
                oAutoFillUserSettings.EdgeColorDetails;

            NumericRangeColumnAutoFillUserSettings oEdgeWidthDetails =
                oAutoFillUserSettings.EdgeWidthDetails;

            // The key is the row ID for each visible row in the vertex table and
            // the value is value of the source column cell in that row that was
            // used to autofill the vertex color column, if it was autofilled.

            Dictionary <Int32, Object> oVertexColorSourceDictionary =
                bVertexColorColumnAutoFilled ?

                GetRowIDDictionary(oVertexTable,
                                   oVertexColorResults.SourceColumnName)
            :
                null;

            // Ditto for edge colors and edge widths.

            Dictionary <Int32, Object> oEdgeColorSourceDictionary =
                bEdgeColorColumnAutoFilled ?

                GetRowIDDictionary(oEdgeTable, oEdgeColorResults.SourceColumnName)
            :
                null;

            Dictionary <Int32, Object> oEdgeWidthSourceDictionary =
                bEdgeWidthColumnAutoFilled ?

                GetRowIDDictionary(oEdgeTable, oEdgeWidthResults.SourceColumnName)
            :
                null;

            // Only motifs need to have attributes added to them.

            foreach (ExcelTemplateGroupInfo oGroup in aoGroups.Where(
                         oGroup => oGroup.CollapsedAttributes != null))
            {
                CollapsedGroupAttributes oCollapsedGroupAttributes =
                    CollapsedGroupAttributes.FromString(
                        oGroup.CollapsedAttributes);

                String sType = oCollapsedGroupAttributes.GetGroupType();

                if (
                    sType == CollapsedGroupAttributeValues.FanMotifType
                    ||
                    sType == CollapsedGroupAttributeValues.DConnectorMotifType
                    ||
                    sType == CollapsedGroupAttributeValues.CliqueMotifType
                    )
                {
                    AddVertexColorAttributeToMotif(oGroup, sType,
                                                   bVertexColorColumnAutoFilled, oVertexColorResults,
                                                   oVertexColorDetails, oVertexColorSourceDictionary,
                                                   oReadWorkbookContext, oCollapsedGroupAttributes);
                }

                if (sType == CollapsedGroupAttributeValues.DConnectorMotifType)
                {
                    Int32 iAnchorVertices;

                    if (oCollapsedGroupAttributes.TryGetValue(
                            CollapsedGroupAttributeKeys.AnchorVertices,
                            out iAnchorVertices))
                    {
                        AddEdgeColorAttributesToDConnectorMotif(oGroup,
                                                                bEdgeColorColumnAutoFilled, oEdgeColorResults,
                                                                oEdgeColorDetails, oEdgeColorSourceDictionary,
                                                                oReadWorkbookContext, oCollapsedGroupAttributes,
                                                                iAnchorVertices);

                        AddEdgeWidthAttributesToDConnectorMotif(oGroup,
                                                                bEdgeWidthColumnAutoFilled, oEdgeWidthResults,
                                                                oEdgeWidthDetails, oEdgeWidthSourceDictionary,
                                                                oReadWorkbookContext, oCollapsedGroupAttributes,
                                                                iAnchorVertices);
                    }
                }

                oGroup.CollapsedAttributes = oCollapsedGroupAttributes.ToString();
            }
        }