示例#1
0
        ReadRadius
        (
            ExcelTableReader.ExcelTableRow oRow,
            VertexRadiusConverter oVertexRadiusConverter,
            IVertex oVertex
        )
        {
            Debug.Assert(oRow != null);
            Debug.Assert(oVertex != null);
            Debug.Assert(oVertexRadiusConverter != null);
            AssertValid();

            String sRadius;

            if (!oRow.TryGetNonEmptyStringFromCell(VertexTableColumnNames.Radius,
                                                   out sRadius))
            {
                return(new Nullable <Single>());
            }

            Single fRadius;

            if (!Single.TryParse(sRadius, out fRadius))
            {
                Range oInvalidCell = oRow.GetRangeForCell(
                    VertexTableColumnNames.Radius);

                OnWorkbookFormatError(String.Format(

                                          "The cell {0} contains an invalid size.  The vertex size,"
                                          + " which is optional, must be a number.  Any number is"
                                          + " acceptable, although {1} is used for any number less than"
                                          + " {1} and {2} is used for any number greater than {2}."
                                          ,
                                          ExcelUtil.GetRangeAddress(oInvalidCell),
                                          VertexRadiusConverter.MinimumRadiusWorkbook,
                                          VertexRadiusConverter.MaximumRadiusWorkbook
                                          ),

                                      oInvalidCell
                                      );
            }

            oVertex.SetValue(ReservedMetadataKeys.PerVertexRadius,
                             oVertexRadiusConverter.WorkbookToGraph(fRadius));

            return(new Nullable <Single>(fRadius));
        }
示例#2
0
        btnOK_Click
        (
            object sender,
            EventArgs e
        )
        {
            AssertValid();

            if (!DoDataExchange(true))
            {
                return;
            }

            // If the caller is going to force the workbook to be reread, there
            // is no point in editing the vertices' metadata.

            if (!m_oEditedVertexAttributes.WorkbookMustBeReread)
            {
                this.UseWaitCursor = true;

                Boolean bApplyColor  = m_oEditedVertexAttributes.Color.HasValue;
                Boolean bApplyShape  = m_oEditedVertexAttributes.Shape.HasValue;
                Boolean bApplyRadius = m_oEditedVertexAttributes.Radius.HasValue;
                Boolean bApplyAlpha  = m_oEditedVertexAttributes.Alpha.HasValue;

                Boolean bApplyVisibility =
                    m_oEditedVertexAttributes.Visibility.HasValue;

                Boolean bApplyLabelPosition =
                    m_oEditedVertexAttributes.LabelPosition.HasValue;

                Boolean bApplyLocked = m_oEditedVertexAttributes.Locked.HasValue;
                Boolean bApplyMarked = m_oEditedVertexAttributes.Marked.HasValue;

                VertexRadiusConverter oVertexRadiusConverter =
                    new VertexRadiusConverter();

                AlphaConverter oAlphaConverter = new AlphaConverter();

                foreach (IVertex oVertex in m_oNodeXLControl.SelectedVertices)
                {
                    if (bApplyColor)
                    {
                        oVertex.SetValue(ReservedMetadataKeys.PerColor,
                                         m_oEditedVertexAttributes.Color.Value);
                    }

                    if (bApplyShape)
                    {
                        oVertex.SetValue(ReservedMetadataKeys.PerVertexShape,
                                         m_oEditedVertexAttributes.Shape.Value);
                    }

                    if (bApplyRadius)
                    {
                        oVertex.SetValue(ReservedMetadataKeys.PerVertexRadius,
                                         oVertexRadiusConverter.WorkbookToGraph(
                                             m_oEditedVertexAttributes.Radius.Value));
                    }

                    if (bApplyAlpha)
                    {
                        oVertex.SetValue(ReservedMetadataKeys.PerAlpha,
                                         oAlphaConverter.WorkbookToGraph(
                                             m_oEditedVertexAttributes.Alpha.Value));
                    }

                    if (bApplyVisibility)
                    {
                        Debug.Assert(m_oEditedVertexAttributes.Visibility.Value ==
                                     VertexWorksheetReader.Visibility.Hide);

                        // Hide the vertex and its incident edges.

                        oVertex.SetValue(ReservedMetadataKeys.Visibility,
                                         VisibilityKeyValue.Hidden);

                        foreach (IEdge oIncidentEdge in oVertex.IncidentEdges)
                        {
                            oIncidentEdge.SetValue(ReservedMetadataKeys.Visibility,
                                                   VisibilityKeyValue.Hidden);
                        }
                    }

                    if (bApplyLabelPosition)
                    {
                        oVertex.SetValue(
                            ReservedMetadataKeys.PerVertexLabelPosition,
                            m_oEditedVertexAttributes.LabelPosition.Value);
                    }

                    if (bApplyLocked)
                    {
                        oVertex.SetValue(ReservedMetadataKeys.LockVertexLocation,
                                         m_oEditedVertexAttributes.Locked.Value);
                    }

                    if (bApplyMarked)
                    {
                        oVertex.SetValue(ReservedMetadataKeys.Marked,
                                         m_oEditedVertexAttributes.Marked.Value);
                    }
                }

                m_oNodeXLControl.DrawGraph();

                this.UseWaitCursor = false;
            }

            DialogResult = DialogResult.OK;
            this.Close();
        }
        //*************************************************************************
        //  Method: ReadRadius()
        //
        /// <summary>
        /// If a radius has been specified for a vertex, sets the vertex's radius.
        /// </summary>
        ///
        /// <param name="oRow">
        /// Row containing the vertex data.
        /// </param>
        ///
        /// <param name="oVertexRadiusConverter">
        /// Object that converts a vertex radius between values used in the Excel
        /// workbook and values used in the NodeXL graph.
        /// </param>
        ///
        /// <param name="oVertex">
        /// Vertex to set the radius on.
        /// </param>
        ///
        /// <returns>
        /// If a radius has been specified for the vertex, the radius in workbook
        /// units is returned.  Otherwise, a Nullable that has no value is
        /// returned.
        /// </returns>
        //*************************************************************************
        protected Nullable<Single> ReadRadius(
            ExcelTableReader.ExcelTableRow oRow,
            VertexRadiusConverter oVertexRadiusConverter,
            IVertex oVertex
            )
        {
            Debug.Assert(oRow != null);
            Debug.Assert(oVertex != null);
            Debug.Assert(oVertexRadiusConverter != null);
            AssertValid();

            String sRadius;

            if ( !oRow.TryGetNonEmptyStringFromCell(VertexTableColumnNames.Radius,
            out sRadius) )
            {
            return ( new Nullable<Single>() );
            }

            Single fRadius;

            if ( !Single.TryParse(sRadius, out fRadius) )
            {
            Range oInvalidCell = oRow.GetRangeForCell(
                VertexTableColumnNames.Radius);

            OnWorkbookFormatError( String.Format(

                "The cell {0} contains an invalid size.  The vertex size,"
                + " which is optional, must be a number.  Any number is"
                + " acceptable, although {1} is used for any number less than"
                + " {1} and {2} is used for any number greater than {2}."
                ,
                ExcelUtil.GetRangeAddress(oInvalidCell),
                VertexRadiusConverter.MinimumRadiusWorkbook,
                VertexRadiusConverter.MaximumRadiusWorkbook
                ),

                oInvalidCell
            );
            }

            oVertex.SetValue( ReservedMetadataKeys.PerVertexRadius,
            oVertexRadiusConverter.WorkbookToGraph(fRadius) );

            return ( new Nullable<Single>(fRadius) );
        }