Esempio n. 1
0
        TransferToGraphDrawer
        (
            GraphDrawer graphDrawer
        )
        {
            Debug.Assert(graphDrawer != null);
            AssertValid();

            Font oFont = this.Font;

            System.Windows.Media.Typeface oTypeface =
                WpfGraphicsUtil.FontToTypeface(oFont);

            Double dFontSize = WpfGraphicsUtil.WindowsFormsFontSizeToWpfFontSize(
                oFont.Size);

            VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer;

            oVertexDrawer.SetFont(oTypeface, dFontSize);

            oVertexDrawer.LabelFillColor =
                WpfGraphicsUtil.ColorToWpfColor(this.VertexLabelFillColor);

            oVertexDrawer.LabelPosition      = this.VertexLabelPosition;
            oVertexDrawer.MaximumLabelLength = this.VertexLabelMaximumLength;

            EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer;

            oEdgeDrawer.SetFont(oTypeface, dFontSize);
            oEdgeDrawer.MaximumLabelLength = this.EdgeLabelMaximumLength;
        }
Esempio n. 2
0
        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);
        }
        CreateGraphDrawingContext
        (
            Rectangle oSubgraphRectangle,
            GeneralUserSettings oGeneralUserSettings
        )
        {
            Debug.Assert(oGeneralUserSettings != null);
            AssertValid();

            return(new GraphDrawingContext(
                       WpfGraphicsUtil.RectangleToRect(oSubgraphRectangle), Margin,
                       WpfGraphicsUtil.ColorToWpfColor(oGeneralUserSettings.BackColor)
                       ));
        }
Esempio n. 4
0
        TryGetColorValue
        (
            IMetadataProvider oMetadataProvider,
            String sKey,
            out Color oColor
        )
        {
            Debug.Assert(oMetadataProvider != null);
            AssertValid();

            oColor = Color.FromRgb(0, 0, 0);

            Object oColorAsObject;

            if (!oMetadataProvider.TryGetValue(sKey, out oColorAsObject))
            {
                return(false);
            }

            if (typeof(System.Windows.Media.Color).IsInstanceOfType(
                    oColorAsObject))
            {
                oColor = (System.Windows.Media.Color)oColorAsObject;
            }
            else if (typeof(System.Drawing.Color).IsInstanceOfType(
                         oColorAsObject))
            {
                oColor = WpfGraphicsUtil.ColorToWpfColor(
                    (System.Drawing.Color)oColorAsObject);
            }
            else
            {
                throw new InvalidOperationException(String.Format(

                                                        "The graph, vertex, or edge value with the key \"{0}\" is of"
                                                        + " type {1}.  The expected type is either"
                                                        + " System.Windows.Media.Color or System.Drawing.Color."
                                                        ,
                                                        sKey,
                                                        oColorAsObject.GetType().FullName
                                                        ));
            }

            return(true);
        }
Esempio n. 5
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. 6
0
        TransferToGraphDrawer
        (
            GraphDrawer graphDrawer
        )
        {
            Debug.Assert(graphDrawer != null);
            AssertValid();

            System.Windows.Media.Typeface oTypeface;
            Double dFontSize;

            //***********
            //  Vertex
            //***********

            VertexDrawer oVertexDrawer = graphDrawer.VertexDrawer;

            FontToTypefaceAndFontSize(this.VertexFont,
                                      out oTypeface, out dFontSize);

            oVertexDrawer.SetFont(oTypeface, dFontSize);

            oVertexDrawer.LabelFillColor =
                WpfGraphicsUtil.ColorToWpfColor(this.VertexLabelFillColor);

            oVertexDrawer.LabelPosition      = this.VertexLabelPosition;
            oVertexDrawer.MaximumLabelLength = this.VertexLabelMaximumLength;
            oVertexDrawer.LabelWrapText      = this.VertexLabelWrapText;

            oVertexDrawer.LabelWrapMaxTextWidth =
                this.VertexLabelWrapMaxTextWidth;

            //***********
            //  Edge
            //***********

            EdgeDrawer oEdgeDrawer = graphDrawer.EdgeDrawer;

            FontToTypefaceAndFontSize(this.EdgeFont, out oTypeface, out dFontSize);

            oEdgeDrawer.SetFont(oTypeface, dFontSize);

            oEdgeDrawer.LabelTextColor =
                WpfGraphicsUtil.ColorToWpfColor(this.EdgeLabelTextColor);

            oEdgeDrawer.MaximumLabelLength = this.EdgeLabelMaximumLength;

            //***********
            //  Group
            //***********

            GroupDrawer oGroupDrawer = graphDrawer.GroupDrawer;

            FontToTypefaceAndFontSize(this.GroupFont,
                                      out oTypeface, out dFontSize);

            oGroupDrawer.SetFont(oTypeface, dFontSize);

            oGroupDrawer.LabelTextColor = WpfGraphicsUtil.ColorToWpfColor(

                Color.FromArgb((new AlphaConverter()).WorkbookToGraphAsByte(
                                   this.GroupLabelTextAlpha),

                               this.GroupLabelTextColor)
                );

            oGroupDrawer.LabelPosition = this.GroupLabelPosition;
        }