TransferToGraphDrawer ( GraphDrawer graphDrawer ) { Debug.Assert(graphDrawer != null); AssertValid(); this.LabelUserSettings.TransferToGraphDrawer(graphDrawer); graphDrawer.BackColor = WpfGraphicsUtil.ColorToWpfColor(this.BackColor); EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer; VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer; EdgeWidthConverter oEdgeWidthConverter = new EdgeWidthConverter(); AlphaConverter oAlphaConverter = new AlphaConverter(); oEdgeDrawer.Width = oEdgeWidthConverter.WorkbookToGraph(this.EdgeWidth); oEdgeDrawer.SelectedWidth = oEdgeWidthConverter.WorkbookToGraph(this.SelectedEdgeWidth); oEdgeDrawer.Color = WpfGraphicsUtil.ColorToWpfColor( Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte( this.EdgeAlpha), this.EdgeColor) ); oEdgeDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor( this.SelectedEdgeColor); oEdgeDrawer.RelativeArrowSize = this.RelativeArrowSize; oVertexDrawer.Shape = this.VertexShape; oVertexDrawer.Radius = (new VertexRadiusConverter()).WorkbookToGraph( this.VertexRadius); oVertexDrawer.Color = WpfGraphicsUtil.ColorToWpfColor( Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte( this.VertexAlpha), this.VertexColor) ); oVertexDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor( this.SelectedVertexColor); }
public void TearDown() { m_oAlphaConverter = null; }
public void SetUp() { m_oAlphaConverter = new AlphaConverter(); }
//************************************************************************* // Constructor: AlphaConverterTest() // /// <summary> /// Initializes a new instance of the <see /// cref="AlphaConverterTest" /> class. /// </summary> //************************************************************************* public AlphaConverterTest() { m_oAlphaConverter = null; }
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(); }
GetInitialVertexAttributes() { // AssertValid(); EditedVertexAttributes oInitialVertexAttributes = new EditedVertexAttributes(); // Color. oInitialVertexAttributes.Color = GetInitialAttributeValue <Color>(ReservedMetadataKeys.PerColor); // Shape. oInitialVertexAttributes.Shape = GetInitialAttributeValue <VertexShape>( ReservedMetadataKeys.PerVertexShape); // Radius. Nullable <Single> fInitialRadius = GetInitialAttributeValue <Single>( ReservedMetadataKeys.PerVertexRadius); if (fInitialRadius.HasValue) { // The radius values stored in the vertices are in graph units. // They need to be converted to workbook units. VertexRadiusConverter oVertexRadiusConverter = new VertexRadiusConverter(); oInitialVertexAttributes.Radius = oVertexRadiusConverter.GraphToWorkbook(fInitialRadius.Value); } else { oInitialVertexAttributes.Radius = null; } // Alpha. Nullable <Single> fInitialAlpha = GetInitialAttributeValue <Single>( ReservedMetadataKeys.PerAlpha); if (fInitialAlpha.HasValue) { AlphaConverter oAlphaConverter = new AlphaConverter(); oInitialVertexAttributes.Alpha = oAlphaConverter.GraphToWorkbook( fInitialAlpha.Value); } else { oInitialVertexAttributes.Alpha = null; } // Visibility. oInitialVertexAttributes.Visibility = null; // Label position.. oInitialVertexAttributes.LabelPosition = GetInitialAttributeValue <VertexLabelPosition>( ReservedMetadataKeys.PerVertexLabelPosition); // Locked. oInitialVertexAttributes.Locked = GetInitialAttributeValue <Boolean>( ReservedMetadataKeys.LockVertexLocation); // Marked. oInitialVertexAttributes.Marked = GetInitialAttributeValue <Boolean>(ReservedMetadataKeys.Marked); return(oInitialVertexAttributes); }
//************************************************************************* // Constructor: WorksheetReaderBase() // /// <summary> /// Initializes a new instance of the <see cref="WorksheetReaderBase" /> /// class. /// </summary> //************************************************************************* public WorksheetReaderBase() { m_oAlphaConverter = new AlphaConverter(); // AssertValid(); }
//************************************************************************* // Method: DrawAutoFilledAlphaResults() // /// <summary> /// Draws the results for one autofilled alpha column. /// </summary> /// /// <param name="oDrawingObjects"> /// Objects to draw with. /// </param> /// /// <param name="sSourceColumnName"> /// The name of the source column. /// </param> /// /// <param name="dSourceCalculationNumber1"> /// The actual first source number used in the calculations. /// </param> /// /// <param name="dSourceCalculationNumber2"> /// The actual second source number used in the calculations. /// </param> /// /// <param name="iDecimalPlaces"> /// The number of decimal places displayed in the source column. /// </param> /// /// <param name="dDestinationNumber1"> /// The first number used in the destination column. /// </param> /// /// <param name="dDestinationNumber2"> /// The second number used in the destination column. /// </param> /// /// <param name="oColumnRectangle"> /// Rectangle to draw the results within. /// </param> /// /// <param name="iResultsLeft"> /// Left x-coordinate where the results should be drawn. /// </param> /// /// <param name="iResultsRight"> /// Right x-coordinate where the results should be drawn. /// </param> /// /// <param name="iTop"> /// Top y-coordinate where the results should be drawn. Gets updated. /// </param> //************************************************************************* protected void DrawAutoFilledAlphaResults( DrawingObjects oDrawingObjects, String sSourceColumnName, Double dSourceCalculationNumber1, Double dSourceCalculationNumber2, Int32 iDecimalPlaces, Double dDestinationNumber1, Double dDestinationNumber2, Rectangle oColumnRectangle, Int32 iResultsLeft, Int32 iResultsRight, ref Int32 iTop ) { Debug.Assert(oDrawingObjects != null); Debug.Assert( !String.IsNullOrEmpty(sSourceColumnName) ); Debug.Assert(iDecimalPlaces >= 0); AssertValid(); // The alpha results look like the color results, with the colors set // to black with different alphas. Calculate the colors. AlphaConverter oAlphaConverter = new AlphaConverter(); Int32 iDestinationAlpha1 = (Int32)oAlphaConverter.WorkbookToGraph( (Single)dDestinationNumber1 ); Int32 iDestinationAlpha2 = (Int32)oAlphaConverter.WorkbookToGraph( (Single)dDestinationNumber2 ); Color oDestinationColor1 = Color.FromArgb(iDestinationAlpha1, SystemColors.WindowText); Color oDestinationColor2 = Color.FromArgb(iDestinationAlpha2, SystemColors.WindowText); DrawColorBarResults(oDrawingObjects, sSourceColumnName, "Opacity", dSourceCalculationNumber1, dSourceCalculationNumber2, iDecimalPlaces, oDestinationColor1, oDestinationColor2, oColumnRectangle, iResultsLeft, iResultsRight, ref iTop); }
//************************************************************************* // Method: TransferToGraphDrawer() // /// <summary> /// Transfers the settings to a <see cref="GraphDrawer" />. /// </summary> /// /// <param name="graphDrawer"> /// Graph drawer to transfer the settings to. /// </param> //************************************************************************* public void TransferToGraphDrawer( GraphDrawer graphDrawer ) { Debug.Assert(graphDrawer != null); AssertValid(); this.LabelUserSettings.TransferToGraphDrawer(graphDrawer); graphDrawer.BackColor = WpfGraphicsUtil.ColorToWpfColor(this.BackColor); EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer; VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer; EdgeWidthConverter oEdgeWidthConverter = new EdgeWidthConverter(); AlphaConverter oAlphaConverter = new AlphaConverter(); oEdgeDrawer.Width = oEdgeWidthConverter.WorkbookToGraph(this.EdgeWidth); oEdgeDrawer.SelectedWidth = oEdgeWidthConverter.WorkbookToGraph(this.SelectedEdgeWidth); oEdgeDrawer.Color = WpfGraphicsUtil.ColorToWpfColor( Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte( this.EdgeAlpha), this.EdgeColor) ); oEdgeDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor( this.SelectedEdgeColor); oEdgeDrawer.RelativeArrowSize = this.RelativeArrowSize; oVertexDrawer.Shape = this.VertexShape; oVertexDrawer.Radius = ( new VertexRadiusConverter() ).WorkbookToGraph( this.VertexRadius); oVertexDrawer.Color = WpfGraphicsUtil.ColorToWpfColor( Color.FromArgb(oAlphaConverter.WorkbookToGraphAsByte( this.VertexAlpha), this.VertexColor) ); oVertexDrawer.SelectedColor = WpfGraphicsUtil.ColorToWpfColor( this.SelectedVertexColor); }