//************************************************************************* // Constructor: ReadWorkbookContext() // /// <summary> /// Initializes a new instance of the <see cref="ReadWorkbookContext" /> /// class. /// </summary> //************************************************************************* public ReadWorkbookContext() { m_bIgnoreVertexLocations = true; m_bFillIDColumns = false; m_bPopulateVertexWorksheet = false; m_bReadEdgeWeights = false; m_bReadGroups = false; m_bReadVertexColorFromGroups = true; m_bReadVertexShapeFromGroups = true; m_bReadVertexLabels = false; m_bReadEdgeLabels = false; m_bReadGroupLabels = false; m_bReadVertexImages = false; m_oDefaultVertexImageSize = new Nullable <Single>(); m_eDefaultVertexShape = VertexShape.Disk; m_bReadAllEdgeAndVertexColumns = false; m_oGraphRectangle = Rectangle.FromLTRB(0, 0, 100, 100); m_oColorConverter2 = new ColorConverter2(); m_oBooleanConverter = new BooleanConverter(); m_oFontSizeConverter = new FontSizeConverter(); m_oEdgeWidthConverter = new EdgeWidthConverter(); m_oEdgeStyleConverter = new EdgeStyleConverter(); m_oVertexRadiusConverter = new VertexRadiusConverter(); m_oVertexLocationConverter = new VertexLocationConverter(m_oGraphRectangle); m_oVertexNameDictionary = new Dictionary <String, IVertex>(); m_oEdgeRowIDDictionary = new Dictionary <Int32, IIdentityProvider>(); m_oVertexRowIDDictionary = new Dictionary <Int32, IIdentityProvider>(); AssertValid(); }
ReadWidth ( ExcelTableReader.ExcelTableRow oRow, EdgeWidthConverter oEdgeWidthConverter, IEdge oEdge ) { Debug.Assert(oRow != null); Debug.Assert(oEdgeWidthConverter != null); AssertValid(); String sWidth; if (!oRow.TryGetNonEmptyStringFromCell(EdgeTableColumnNames.Width, out sWidth)) { return; } Single fWidth; if (!Single.TryParse(sWidth, out fWidth)) { Range oInvalidCell = oRow.GetRangeForCell( EdgeTableColumnNames.Width); OnWorkbookFormatError(String.Format( "The cell {0} contains an invalid width. The edge width," + " 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), EdgeWidthConverter.MinimumWidthWorkbook, EdgeWidthConverter.MaximumWidthWorkbook ), oInvalidCell ); } oEdge.SetValue(ReservedMetadataKeys.PerEdgeWidth, oEdgeWidthConverter.WorkbookToGraph(fWidth)); }
//************************************************************************* // Constructor: ReadWorkbookContext() // /// <summary> /// Initializes a new instance of the <see cref="ReadWorkbookContext" /> /// class. /// </summary> //************************************************************************* public ReadWorkbookContext() { m_bIgnoreVertexLocations = true; m_bFillIDColumns = false; m_bPopulateVertexWorksheet = false; m_bReadEdgeWeights = false; m_bReadGroups = false; m_bReadVertexColorFromGroups = true; m_bReadVertexShapeFromGroups = true; m_bReadVertexLabels = false; m_bReadEdgeLabels = false; m_bReadGroupLabels = false; m_bReadVertexImages = false; m_oDefaultVertexImageSize = new Nullable<Single>(); m_eDefaultVertexShape = VertexShape.Disk; m_bReadAllEdgeAndVertexColumns = false; m_oGraphRectangle = Rectangle.FromLTRB(0, 0, 100, 100); m_oColorConverter2 = new ColorConverter2(); m_oBooleanConverter = new BooleanConverter(); m_oFontSizeConverter = new FontSizeConverter(); m_oEdgeWidthConverter = new EdgeWidthConverter(); m_oEdgeStyleConverter = new EdgeStyleConverter(); m_oVertexRadiusConverter = new VertexRadiusConverter(); m_oVertexLocationConverter = new VertexLocationConverter(m_oGraphRectangle); m_oVertexNameDictionary = new Dictionary<String, IVertex>(); m_oEdgeRowIDDictionary = new Dictionary<Int32, IIdentityProvider>(); m_oVertexRowIDDictionary = new Dictionary<Int32, IIdentityProvider>(); AssertValid(); }
TransferToGraphDrawer ( GraphDrawer graphDrawer ) { Debug.Assert(graphDrawer != null); AssertValid(); this.LabelUserSettings.TransferToGraphDrawer(graphDrawer); graphDrawer.BackColor = WpfGraphicsUtil.ColorToWpfColor(this.BackColor); if (!String.IsNullOrEmpty(this.BackgroundImageUri)) { graphDrawer.BackgroundImage = (new WpfImageUtil()).GetImageSynchronousIgnoreDpi( this.BackgroundImageUri); } else { graphDrawer.BackgroundImage = null; } EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer; VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer; EdgeWidthConverter oEdgeWidthConverter = new EdgeWidthConverter(); AlphaConverter oAlphaConverter = new AlphaConverter(); oEdgeDrawer.Width = oEdgeWidthConverter.WorkbookToGraph(this.EdgeWidth); oEdgeDrawer.Color = WpfGraphicsUtil.ColorToWpfColor( Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte( this.EdgeAlpha), this.EdgeColor) ); oEdgeDrawer.CurveStyle = this.EdgeCurveStyle; oEdgeDrawer.BezierDisplacementFactor = this.EdgeBezierDisplacementFactor; oEdgeDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor( this.SelectedEdgeColor); oEdgeDrawer.RelativeArrowSize = this.RelativeArrowSize; oVertexDrawer.Shape = this.VertexShape; oVertexDrawer.Radius = (new VertexRadiusConverter()).WorkbookToGraph( this.VertexRadius); oVertexDrawer.Effect = this.VertexEffect; oVertexDrawer.RelativeOuterGlowSize = this.VertexRelativeOuterGlowSize; oVertexDrawer.Color = WpfGraphicsUtil.ColorToWpfColor( Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte( this.VertexAlpha), this.VertexColor) ); oVertexDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor( this.SelectedVertexColor); }
SetUp() { m_oEdgeWidthConverter = new EdgeWidthConverter(); }
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 edges' metadata. if (!m_oEditedEdgeAttributes.WorkbookMustBeReread) { this.UseWaitCursor = true; EdgeWidthConverter oEdgeWidthConverter = new EdgeWidthConverter(); EdgeStyleConverter oEdgeStyleConverter = new EdgeStyleConverter(); AlphaConverter oAlphaConverter = new AlphaConverter(); FontSizeConverter oFontSizeConverter = new FontSizeConverter(); foreach (IEdge oEdge in m_oNodeXLControl.SelectedEdges) { SetValue <Color>(oEdge, ReservedMetadataKeys.PerColor, m_oEditedEdgeAttributes.Color); SetSingleValue(oEdge, ReservedMetadataKeys.PerEdgeWidth, m_oEditedEdgeAttributes.Width, oEdgeWidthConverter); SetValue <EdgeStyle>(oEdge, ReservedMetadataKeys.PerEdgeStyle, m_oEditedEdgeAttributes.Style); SetSingleValue(oEdge, ReservedMetadataKeys.PerAlpha, m_oEditedEdgeAttributes.Alpha, oAlphaConverter); if (m_oEditedEdgeAttributes.Visibility.HasValue) { Debug.Assert(m_oEditedEdgeAttributes.Visibility.Value == EdgeWorksheetReader.Visibility.Hide); oEdge.SetValue(ReservedMetadataKeys.Visibility, VisibilityKeyValue.Hidden); } SetStringValue(oEdge, ReservedMetadataKeys.PerEdgeLabel, m_oEditedEdgeAttributes.Label); SetValue <Color>(oEdge, ReservedMetadataKeys.PerEdgeLabelTextColor, m_oEditedEdgeAttributes.LabelTextColor); if (m_oEditedEdgeAttributes.LabelFontSize.HasValue) { oEdge.SetValue(ReservedMetadataKeys.PerEdgeLabelFontSize, oFontSizeConverter.WorkbookToGraph( m_oEditedEdgeAttributes.LabelFontSize.Value)); } } m_oNodeXLControl.DrawGraph(); this.UseWaitCursor = false; } DialogResult = DialogResult.OK; this.Close(); }
ReadWidth ( ExcelTableReader.ExcelTableRow oRow, EdgeWidthConverter oEdgeWidthConverter, IEdge oEdge ) { Debug.Assert(oRow != null); Debug.Assert(oEdgeWidthConverter != null); AssertValid(); String sWidth; if ( !oRow.TryGetNonEmptyStringFromCell(EdgeTableColumnNames.Width, out sWidth) ) { return; } Single fWidth; if ( !Single.TryParse(sWidth, out fWidth) ) { Range oInvalidCell = oRow.GetRangeForCell( EdgeTableColumnNames.Width); OnWorkbookFormatError( String.Format( "The cell {0} contains an invalid width. The edge width," + " 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), EdgeWidthConverter.MinimumWidthWorkbook, EdgeWidthConverter.MaximumWidthWorkbook ), oInvalidCell ); } oEdge.SetValue(ReservedMetadataKeys.PerEdgeWidth, oEdgeWidthConverter.WorkbookToGraph(fWidth) ); }
TransferToGraphDrawer ( GraphDrawer graphDrawer ) { Debug.Assert(graphDrawer != null); AssertValid(); this.LabelUserSettings.TransferToGraphDrawer(graphDrawer); graphDrawer.BackColor = WpfGraphicsUtil.ColorToWpfColor(this.BackColor); if ( !String.IsNullOrEmpty(this.BackgroundImageUri) ) { graphDrawer.BackgroundImage = ( new WpfImageUtil() ).GetImageSynchronousIgnoreDpi( this.BackgroundImageUri); } else { graphDrawer.BackgroundImage = null; } EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer; VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer; EdgeWidthConverter oEdgeWidthConverter = new EdgeWidthConverter(); AlphaConverter oAlphaConverter = new AlphaConverter(); oEdgeDrawer.Width = oEdgeWidthConverter.WorkbookToGraph(this.EdgeWidth); oEdgeDrawer.Color = WpfGraphicsUtil.ColorToWpfColor( Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte( this.EdgeAlpha), this.EdgeColor) ); oEdgeDrawer.CurveStyle = this.EdgeCurveStyle; oEdgeDrawer.BezierDisplacementFactor = this.EdgeBezierDisplacementFactor; oEdgeDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor( this.SelectedEdgeColor); oEdgeDrawer.RelativeArrowSize = this.RelativeArrowSize; oVertexDrawer.Shape = this.VertexShape; oVertexDrawer.Radius = ( new VertexRadiusConverter() ).WorkbookToGraph( this.VertexRadius); oVertexDrawer.Effect = this.VertexEffect; oVertexDrawer.RelativeOuterGlowSize = this.VertexRelativeOuterGlowSize; oVertexDrawer.Color = WpfGraphicsUtil.ColorToWpfColor( Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte( this.VertexAlpha), this.VertexColor) ); oVertexDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor( this.SelectedVertexColor); }