Ejemplo n.º 1
0
        //protected internal override void INTERNAL_OnAttachedToVisualTree()
        //{
        //    ScheduleRedraw();
        //}

        override internal protected void Redraw()
        {
            if (INTERNAL_VisualTreeManager.IsElementInVisualTree(this))
            {
                double xOffsetToApplyBeforeMultiplication;
                double yOffsetToApplyBeforeMultiplication;
                double xOffsetToApplyAfterMultiplication;
                double yOffsetToApplyAfterMultiplication;
                double sizeX;
                double sizeY;
                double horizontalMultiplicator;
                double verticalMultiplicator;
                Size   shapeActualSize;
                Shape.GetShapeInfos(this, out xOffsetToApplyBeforeMultiplication, out yOffsetToApplyBeforeMultiplication, out xOffsetToApplyAfterMultiplication, out yOffsetToApplyAfterMultiplication, out sizeX, out sizeY, out horizontalMultiplicator, out verticalMultiplicator, out shapeActualSize);

                ApplyMarginToFixNegativeCoordinates(new Point());
                if (Stretch == Media.Stretch.None)
                {
                    ApplyMarginToFixNegativeCoordinates(_marginOffsets);
                }

                //todo: size might not perfectly match that of she designer. (so it might be very different from it in big ellipses?)
                INTERNAL_ShapesDrawHelpers.PrepareEllipse(_canvasDomElement, sizeX, sizeY, sizeX / 2 + xOffsetToApplyBeforeMultiplication + xOffsetToApplyAfterMultiplication, sizeY / 2 + yOffsetToApplyBeforeMultiplication + yOffsetToApplyAfterMultiplication);

                //todo: make sure the parameters below are correct.
                Shape.DrawFillAndStroke(this, "evenodd", xOffsetToApplyAfterMultiplication, yOffsetToApplyAfterMultiplication, xOffsetToApplyAfterMultiplication + sizeX, yOffsetToApplyAfterMultiplication + sizeY, horizontalMultiplicator, verticalMultiplicator, xOffsetToApplyBeforeMultiplication, yOffsetToApplyBeforeMultiplication, shapeActualSize);


                //dynamic context = INTERNAL_HtmlDomManager.Get2dCanvasContext(_canvasDomElement);
                //if (fillValue != null || (fillValue is string && !string.IsNullOrWhiteSpace((string)fillValue)))
                //{
                //    context.fill("evenodd"); //note: remember: always fill before stroke, otherwise the filling will hide the stroke.
                //}
                //if (StrokeThickness > 0 && Stroke != null)
                //{
                //    context.stroke();
                //}
            }
        }
Ejemplo n.º 2
0
        internal protected override void DefineInCanvas(Shapes.Path path,
                                                        object canvasDomElement,
                                                        double horizontalMultiplicator,
                                                        double verticalMultiplicator,
                                                        double xOffsetToApplyBeforeMultiplication,
                                                        double yOffsetToApplyBeforeMultiplication,
                                                        double xOffsetToApplyAfterMultiplication,
                                                        double yOffsetToApplyAfterMultiplication,
                                                        Size shapeActualSize)
        {
            string strokeAsString = string.Empty;

            // todo: make sure we want the same behaviour when it is null and when it is a SolidColorBrush (basically, check if null means default value)
            if (path.Stroke == null || path.Stroke is SolidColorBrush)
            {
                // if stroke is null, we want to set it as an empty string, otherwise, it is a SolidColorBrush and we want to get its color.
                if (path.Stroke != null)
                {
                    strokeAsString = ((SolidColorBrush)path.Stroke).INTERNAL_ToHtmlString();
                }
            }
            else
            {
                throw new NotSupportedException("The specified brush is not supported.");
            }
            dynamic context      = INTERNAL_HtmlDomManager.Get2dCanvasContext(canvasDomElement);
            double  actualWidth  = RadiusX * 2; //it's a radius and we want the whole width (basically a "diameter")
            double  actualHeight = RadiusY * 2; //it's a radius and we want the whole height

            INTERNAL_ShapesDrawHelpers.PrepareEllipse(canvasDomElement,
                                                      actualWidth,
                                                      actualHeight,
                                                      Center.X + xOffsetToApplyBeforeMultiplication + xOffsetToApplyAfterMultiplication,
                                                      Center.Y + yOffsetToApplyBeforeMultiplication + yOffsetToApplyAfterMultiplication);
            context.strokeStyle = strokeAsString;
        }