コード例 #1
0
        private static void initializeShadow(DependencyObject i, double?value, ShadowDirection direction, bool allowShadows)
        {
            var uiElement = i as UIElement;

            if (uiElement != null && value.HasValue)
            {
                if (!allowShadows)
                {
                    uiElement.Effect = null;
                    return;
                }

                if (value.Value >= 0)
                {
                    if (value == 0)
                    {
                        uiElement.Effect = null;
                    }
                    else
                    {
                        var shadow = ShadowInterpolator.Interpolate(value.Value, direction);
                        uiElement.Effect = shadow;
                    }
                }
            }
        }
コード例 #2
0
        public static DropShadowEffect Interpolate(double level, ShadowDirection direction)
        {
            var blur  = calculateBlur(level);
            var depth = calculateDepth(level);

            return(new DropShadowEffect
            {
                BlurRadius = blur,
                ShadowDepth = depth,
                Direction = direction == ShadowDirection.Down ? 270 : 90,
                Color = shadowColor,
                Opacity = opacity
            });
        }
コード例 #3
0
ファイル: Cap.cs プロジェクト: xleon/mobileapp
        protected Cap(
            CGImage icon,
            Func <nfloat, nfloat> scale,
            nfloat iconHeight,
            nfloat iconWidth,
            ShadowDirection shadowDirection)
        {
            this.shadowDirection = shadowDirection;
            var center = new CGPoint(0, 0);

            var outerPath = new UIBezierPath();

            outerPath.AddArc(center, scale(outerRadius), 0, (nfloat)Math.FullCircle, false);

            Path = outerPath.CGPath;

            var innerPath = new UIBezierPath();

            innerPath.AddArc(center, scale(innerRadius), 0, (nfloat)Math.FullCircle, false);

            var circleLayer = new CAShapeLayer {
                Path = innerPath.CGPath, FillColor = ColorAssets.Background.CGColor
            };

            var imageFrame = new CGRect(
                x: center.X - scale(iconWidth) / 2f,
                y: center.Y - scale(iconHeight) / 2f,
                width: scale(iconWidth),
                height: scale(iconHeight));

            var maskLayer = new CALayer {
                Contents = icon, Frame = new CGRect(0, 0, scale(iconWidth), scale(iconHeight))
            };

            imageLayer = new CALayer {
                Mask = maskLayer, Frame = imageFrame
            };

            circleLayer.AddSublayer(imageLayer);

            AddSublayer(circleLayer);

            ShadowColor   = ColorAssets.Separator.CGColor;
            ShadowRadius  = 0.0f;
            ShadowPath    = Path;
            ShadowOpacity = 1.0f;
        }
コード例 #4
0
 public static void SetDirection(DependencyObject i, ShadowDirection v) => i.Set(DirectionProperty, v);