Class that converts alpha values between those used in the Excel workbook and those used in the NodeXL graph.
Inheritance: NumericValueConverterBase
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
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 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();
        }
    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);
    }
Esempio n. 5
0
        //*************************************************************************
        //  Constructor: WorksheetReaderBase()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="WorksheetReaderBase" />
        /// class.
        /// </summary>
        //*************************************************************************

        public WorksheetReaderBase()
        {
            m_oAlphaConverter = new AlphaConverter();

            // AssertValid();
        }
 SetUp()
 {
     m_oAlphaConverter = new AlphaConverter();
 }
        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;

                VertexRadiusConverter oVertexRadiusConverter =
                    new VertexRadiusConverter();

                AlphaConverter oAlphaConverter = new AlphaConverter();

                foreach (IVertex oVertex in m_oNodeXLControl.SelectedVertices)
                {
                    SetValue <Color>(oVertex, ReservedMetadataKeys.PerColor,
                                     m_oEditedVertexAttributes.Color);

                    SetValue <VertexShape>(oVertex,
                                           ReservedMetadataKeys.PerVertexShape,
                                           m_oEditedVertexAttributes.Shape);

                    SetSingleValue(oVertex, ReservedMetadataKeys.PerVertexRadius,
                                   m_oEditedVertexAttributes.Radius, oVertexRadiusConverter);

                    SetSingleValue(oVertex, ReservedMetadataKeys.PerAlpha,
                                   m_oEditedVertexAttributes.Alpha, oAlphaConverter);

                    if (m_oEditedVertexAttributes.Visibility.HasValue)
                    {
                        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);
                        }
                    }

                    SetStringValue(oVertex, ReservedMetadataKeys.PerVertexLabel,
                                   m_oEditedVertexAttributes.Label);

                    SetValue <Color>(oVertex,
                                     ReservedMetadataKeys.PerVertexLabelFillColor,
                                     m_oEditedVertexAttributes.LabelFillColor);

                    SetValue <VertexLabelPosition>(oVertex,
                                                   ReservedMetadataKeys.PerVertexLabelPosition,
                                                   m_oEditedVertexAttributes.LabelPosition);

                    SetStringValue(oVertex, ReservedMetadataKeys.PerVertexToolTip,
                                   m_oEditedVertexAttributes.ToolTip);

                    SetValue <Boolean>(oVertex,
                                       ReservedMetadataKeys.LockVertexLocation,
                                       m_oEditedVertexAttributes.Locked);

                    SetValue <Boolean>(oVertex, ReservedMetadataKeys.Marked,
                                       m_oEditedVertexAttributes.Marked);
                }

                m_oNodeXLControl.DrawGraph();

                this.UseWaitCursor = false;
            }

            DialogResult = DialogResult.OK;
            this.Close();
        }
    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);
    }
    //*************************************************************************
    //  Constructor: WorksheetReaderBase()
    //
    /// <summary>
    /// Initializes a new instance of the <see cref="WorksheetReaderBase" />
    /// class.
    /// </summary>
    //*************************************************************************

    public WorksheetReaderBase()
    {
        m_oAlphaConverter = new AlphaConverter();

        // AssertValid();
    }