Exemplo n.º 1
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.HitTest (ref BoundingRect, bool)"/>
        /// </summary>
        /// <param name="Rect"></param>
        /// <param name="IncludeControlPoints"></param>
        /// <returns></returns>
        public override bool HitTest(ref BoundingRect Rect, bool IncludeControlPoints)
        {
            Angle    majorang = majorAxis.Angle;
            double   radiusx  = majorAxis.Length;
            double   radiusy  = minorAxis.Length;
            ClipRect clr      = new ClipRect(ref Rect);

            if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, 0, right, top))
            {
                return(true);
            }
            if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, 1, top, left))
            {
                return(true);
            }
            if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, 2, left, bottom))
            {
                return(true);
            }
            if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, 3, bottom, right))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public override Widget build(BuildContext context)
        {
            Widget child = new SizedBox(
                width: widget.count * widget.size + (widget.count - 1) * widget.space,
                height: widget.size,
                child: new CustomPaint(
                    painter: _createPainer()
                    )


                );

            if (widget.layout == PageIndicatorLayout.SCALE ||
                widget.layout == PageIndicatorLayout.COLOR)
            {
                child = new ClipRect(
                    child: child


                    );
            }

            return(new IgnorePointer(
                       child: child


                       ));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.HitTest (Projection, BoundingRect, bool)"/>
 /// </summary>
 /// <param name="projection"></param>
 /// <param name="rect"></param>
 /// <param name="onlyInside"></param>
 /// <returns></returns>
 public override bool HitTest(Projection projection, BoundingRect rect, bool onlyInside)
 {
     if (onlyInside)
     {
         return(projection.ProjectUnscaled(startPoint) <= rect && projection.ProjectUnscaled(endPoint) <= rect);
     }
     else
     {
         ClipRect clr = new ClipRect(ref rect);
         return(clr.LineHitTest(projection.ProjectUnscaled(startPoint), projection.ProjectUnscaled(endPoint)));
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Constructs a line passing through <paramref name="location"/> with the provided <paramref name="direction"/> clipped by the
        /// rectangle <paramref name="clippedBy"/>
        /// </summary>
        /// <param name="location">Point on the (extension of the) line </param>
        /// <param name="direction">Direction of the line</param>
        /// <param name="clippedBy">Clipping rectangle</param>
        public Line2D(GeoPoint2D location, GeoVector2D direction, BoundingRect clippedBy)
        {
            direction.Norm(); // ist ja ne Kopie
            // das geht aber eleganter, oder?
            GeoPoint2D c = Geometry.DropPL(clippedBy.GetCenter(), location, direction);
            double     l = clippedBy.Width + clippedBy.Height;

            startPoint = c + l * direction;
            endPoint   = c - l * direction;
            ClipRect clr = new ClipRect(ref clippedBy);

            clr.ClipLine(ref startPoint, ref endPoint);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Overrides <see cref="CADability.GeoObject.IGeoObjectImpl.HitTest (Projection, BoundingRect, bool)"/>
 /// </summary>
 /// <param name="projection"></param>
 /// <param name="rect"></param>
 /// <param name="onlyInside"></param>
 /// <returns></returns>
 public override bool HitTest(Projection projection, BoundingRect rect, bool onlyInside)
 {
     if (onlyInside)
     {
         return(projection.ProjectUnscaled(location) <= rect && projection.ProjectUnscaled(location + directionWidth) <= rect &&
                projection.ProjectUnscaled(location + directionHeight) <= rect && projection.ProjectUnscaled(location + directionWidth + directionHeight) <= rect);
     }
     else
     {
         ClipRect clr = new ClipRect(ref rect);
         return(clr.ParallelogramHitTest(projection.ProjectUnscaled(location), projection.ProjectUnscaled(directionWidth), projection.ProjectUnscaled(directionHeight)));
     }
 }
Exemplo n.º 6
0
        public bool HitTest(Vec2 p)
        {
            if (!ClipRect.Contains(p))
            {
                return(false);
            }
            var planeIntersect = PlaneIntersection(new Vec3(p));

            if (planeIntersect == null)
            {
                return(false);
            }
            return(new Rect(Size).Contains(ToLocalCoord(planeIntersect.Value).XY));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 调整大图
        /// </summary>
        void AdjustLargeImage()
        {
            ///获取比例
            double n = LargeBox.Width / ClipRect.Width;

            double left = (double)ClipRect.GetValue(Canvas.LeftProperty);
            double top  = (double)ClipRect.GetValue(Canvas.TopProperty);

            left = -left * n;
            top  = -top * n;

            LargeImage.SetValue(Canvas.LeftProperty, left);
            LargeImage.SetValue(Canvas.TopProperty, top);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.HitTest (ref BoundingRect, bool)"/>
        /// </summary>
        /// <param name="Rect"></param>
        /// <param name="IncludeControlPoints"></param>
        /// <returns></returns>
        public override bool HitTest(ref BoundingRect Rect, bool IncludeControlPoints)
        {
            ClipRect clr = new ClipRect(ref Rect);

            for (int i = 1; i < vertex.Length; ++i)
            {
                GeoPoint2D sp = vertex[i - 1];
                GeoPoint2D ep = vertex[i];
                if (clr.LineHitTest(sp, ep))
                {
                    return(true);
                }
            }
            return(false);
        }
        public override Widget build(BuildContext context)
        {
            float bottomPadding = MediaQuery.of(context).padding.bottom;

            Widget result = new DecoratedBox(
                decoration: new BoxDecoration(
                    border: this.border,
                    color: this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor
                    ),
                child: new SizedBox(
                    height: BottomAppBarUtils._kTabBarHeight + bottomPadding,
                    child: IconTheme.merge( // Default with the inactive state.
                        data: new IconThemeData(
                            color: this.inactiveColor,
                            size: this.iconSize
                            ),
                        child: new DefaultTextStyle( // Default with the inactive state.
                            style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle
                            .copyWith(color: this.inactiveColor),
                            child: new Padding(
                                padding: EdgeInsets.only(bottom: bottomPadding),
                                child: new Row(
                                    crossAxisAlignment: CrossAxisAlignment.end,
                                    children: this._buildTabItems(context)
                                    )
                                )
                            )
                        )
                    )
                );

            if (!this.opaque(context))
            {
                result = new ClipRect(
                    child: new BackdropFilter(
                        filter: ImageFilter.blur(sigmaX: 10.0f, sigmaY: 10.0f),
                        child: result
                        )
                    );
            }

            return(result);
        }
Exemplo n.º 10
0
        public override Widget build(BuildContext context)
        {
            Widget child = new SizedBox(
                width: this.widget.count * this.widget.size + (this.widget.count - 1) * this.widget.space,
                height: this.widget.size,
                child: new CustomPaint(
                    painter: this._createPainter()
                    )
                );

            if (this.widget.layout == PageIndicatorLayout.scale || this.widget.layout == PageIndicatorLayout.color)
            {
                child = new ClipRect(
                    child: child
                    );
            }

            return(new IgnorePointer(
                       child: child
                       ));
        }
Exemplo n.º 11
0
 bool IOctTreeInsertable.HitTest(Projection projection, BoundingRect rect, bool onlyInside)
 {   // kommt dran bei GetObjectsCloseTo
     if (onlyInside)
     {
         return(false);
     }
     else
     {
         ClipRect clr = new ClipRect(ref rect);
         // eine Linie machen, die bestimmt über das rechteck hinaus geht
         GeoPoint2D  sp2d  = projection.ProjectUnscaled(start);
         GeoVector2D dir2d = projection.ProjectUnscaled(dir);
         double      max   = 0.0;
         max = Math.Max(max, sp2d | rect.GetLowerLeft());
         max = Math.Max(max, sp2d | rect.GetLowerRight());
         max = Math.Max(max, sp2d | rect.GetUpperLeft());
         max = Math.Max(max, sp2d | rect.GetUpperRight());
         GeoPoint2D ep2d = sp2d + max * dir2d;
         return(clr.LineHitTest(sp2d, ep2d));
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.HitTest (ref BoundingRect, bool)"/>
        /// </summary>
        /// <param name="Rect"></param>
        /// <param name="IncludeControlPoints"></param>
        /// <returns></returns>
        public override bool HitTest(ref BoundingRect Rect, bool IncludeControlPoints)
        {
            ClipRect clr = new ClipRect(ref Rect);

            if (clr.ArcHitTest(center, radius, 0, new GeoPoint2D(center.x + radius, center.y), new GeoPoint2D(center.x, center.y + radius)))
            {
                return(true);
            }
            if (clr.ArcHitTest(center, radius, 1, new GeoPoint2D(center.x, center.y + radius), new GeoPoint2D(center.x - radius, center.y)))
            {
                return(true);
            }
            if (clr.ArcHitTest(center, radius, 2, new GeoPoint2D(center.x - radius, center.y), new GeoPoint2D(center.x, center.y - radius)))
            {
                return(true);
            }
            if (clr.ArcHitTest(center, radius, 3, new GeoPoint2D(center.x, center.y - radius), new GeoPoint2D(center.x + radius, center.y)))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 13
0
        public override ICurve2D[] GetTangentCurves(GeoVector direction, double umin, double umax, double vmin, double vmax)
        {
            if (Precision.SameDirection(direction, zAxis, false))
            {
                return(new ICurve2D[0]);
            }
            GeoPoint2D  uv    = PositionOf(location + zAxis + (direction ^ zAxis));
            GeoVector2D dir2d = uv.ToVector();

            dir2d.Length = Math.Max(Math.Max(Math.Abs(umax), Math.Abs(umin)), Math.Max(Math.Abs(vmax), Math.Abs(vmin))) * 1.1;
            ClipRect   clr = new ClipRect(umin, umax, vmin, vmax);
            GeoPoint2D sp  = GeoPoint2D.Origin - dir2d;
            GeoPoint2D ep  = GeoPoint2D.Origin + dir2d;

            if (clr.ClipLine(ref sp, ref ep))
            {
                return new ICurve2D[] { new Line2D(sp, ep) }
            }
            ;
            else
            {
                return(new ICurve2D[0]);
            }
        }
Exemplo n.º 14
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            ThemeData     themeData   = Theme.of(context);
            ScaffoldState scaffold    = Scaffold.of(context, nullOk: true);
            ModalRoute    parentRoute = ModalRoute.of(context);

            bool hasDrawer      = scaffold?.hasDrawer ?? false;
            bool hasEndDrawer   = scaffold?.hasEndDrawer ?? false;
            bool canPop         = parentRoute?.canPop ?? false;
            bool useCloseButton = parentRoute is PageRoute && ((PageRoute)parentRoute).fullscreenDialog;

            IconThemeData appBarIconTheme = this.widget.iconTheme ?? themeData.primaryIconTheme;
            TextStyle     centerStyle     = this.widget.textTheme?.title ?? themeData.primaryTextTheme.title;
            TextStyle     sideStyle       = this.widget.textTheme?.body1 ?? themeData.primaryTextTheme.body1;

            if (this.widget.toolbarOpacity != 1.0f)
            {
                float opacity =
                    new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget.toolbarOpacity);
                if (centerStyle?.color != null)
                {
                    centerStyle = centerStyle.copyWith(color: centerStyle.color.withOpacity(opacity));
                }

                if (sideStyle?.color != null)
                {
                    sideStyle = sideStyle.copyWith(color: sideStyle.color.withOpacity(opacity));
                }

                appBarIconTheme = appBarIconTheme.copyWith(
                    opacity: opacity * (appBarIconTheme.opacity ?? 1.0f)
                    );
            }

            Widget leading = this.widget.leading;

            if (leading == null && this.widget.automaticallyImplyLeading)
            {
                if (hasDrawer)
                {
                    leading = new IconButton(
                        icon: new Icon(Icons.menu),
                        onPressed: this._handleDrawerButton,
                        tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip);
                }
                else
                {
                    if (canPop)
                    {
                        leading = useCloseButton ? (Widget) new CloseButton() : new BackButton();
                    }
                }
            }

            if (leading != null)
            {
                leading = new ConstrainedBox(
                    constraints: BoxConstraints.tightFor(width: AppBarUtils._kLeadingWidth),
                    child: leading);
            }

            Widget title = this.widget.title;

            if (title != null)
            {
                title = new DefaultTextStyle(
                    style: centerStyle,
                    softWrap: false,
                    overflow: TextOverflow.ellipsis,
                    child: title);
            }

            Widget actions = null;

            if (this.widget.actions != null && this.widget.actions.isNotEmpty())
            {
                actions = new Row(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: this.widget.actions);
            }
            else if (hasEndDrawer)
            {
                actions = new IconButton(
                    icon: new Icon(Icons.menu),
                    onPressed: this._handleDrawerButtonEnd,
                    tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip);
            }

            Widget toolbar = new NavigationToolbar(
                leading: leading,
                middle: title,
                trailing: actions,
                centerMiddle: this.widget._getEffectiveCenterTitle(themeData).Value,
                middleSpacing: this.widget.titleSpacing);

            Widget appBar = new ClipRect(
                child: new CustomSingleChildLayout(
                    layoutDelegate: new _ToolbarContainerLayout(),
                    child: IconTheme.merge(
                        data: appBarIconTheme,
                        child: new DefaultTextStyle(
                            style: sideStyle,
                            child: toolbar)
                        )
                    )
                );

            if (this.widget.bottom != null)
            {
                appBar = new Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: new List <Widget> {
                    new Flexible(
                        child: new ConstrainedBox(
                            constraints: new BoxConstraints(maxHeight: Constants.kToolbarHeight),
                            child: appBar
                            )
                        ),
                    this.widget.bottomOpacity == 1.0f
                            ? (Widget)this.widget.bottom
                            : new Opacity(
                        opacity: new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget
                                                                                                  .bottomOpacity),
                        child: this.widget.bottom
                        )
                }
                    );
            }

            if (this.widget.primary)
            {
                appBar = new SafeArea(
                    top: true,
                    child: appBar);
            }

            appBar = new Align(
                alignment: Alignment.topCenter,
                child: appBar);

            if (this.widget.flexibleSpace != null)
            {
                appBar = new Stack(
                    fit: StackFit.passthrough,
                    children: new List <Widget> {
                    this.widget.flexibleSpace,
                    appBar
                }
                    );
            }

            Brightness           brightness   = this.widget.brightness ?? themeData.primaryColorBrightness;
            SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark
                ? SystemUiOverlayStyle.light
                : SystemUiOverlayStyle.dark;

            return(new AnnotatedRegion <SystemUiOverlayStyle>(
                       value: overlayStyle,
                       child: new Material(
                           color: this.widget.backgroundColor ?? themeData.primaryColor,
                           elevation: this.widget.elevation,
                           child: appBar
                           )));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.HitTest (ref BoundingRect, bool)"/>
        /// </summary>
        /// <param name="Rect"></param>
        /// <param name="IncludeControlPoints"></param>
        /// <returns></returns>
        public override bool HitTest(ref BoundingRect Rect, bool IncludeControlPoints)
        {
            Angle    majorang = majorAxis.Angle;
            double   radiusx  = majorAxis.Length;
            double   radiusy  = minorAxis.Length;
            ClipRect clr      = new ClipRect(ref Rect);

            if (clr.Contains(startPoint))
            {
                return(true);
            }
            if (clr.Contains(EndPoint))
            {
                return(true);
            }

            for (int q = 0; q < 4; ++q)
            {
                GeoPoint2D ps;
                GeoPoint2D pe;
                switch (q)
                {
                default:     // nur wg. Compiler
                case 0:
                    ps = right;
                    pe = top;
                    break;

                case 1:
                    ps = top;
                    pe = left;
                    break;

                case 2:
                    ps = left;
                    pe = bottom;
                    break;

                case 3:
                    ps = bottom;
                    pe = right;
                    break;
                }
                if (Sweep > 0.0)
                {
                    if (crossingZero)
                    {
                        if (q < startQuad && q > endQuad)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (q < startQuad || q > endQuad)
                        {
                            continue;
                        }
                    }
                    if (crossingZero && startQuad == q && endQuad == q)
                    {   // zwei Tests nötig
                        GeoPoint2D p = endPoint;
                        if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, q, ps, p))
                        {
                            return(true);
                        }
                        p = startPoint;
                        if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, q, p, pe))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (startQuad == q)
                        {
                            ps = startPoint;
                        }
                        if (endQuad == q)
                        {
                            pe = endPoint;
                        }
                        if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, q, ps, pe))
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    if (crossingZero)
                    {
                        if (q < endQuad && q > startQuad)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (q < endQuad || q > startQuad)
                        {
                            continue;
                        }
                    }
                    if (crossingZero && startQuad == q && endQuad == q)
                    {   // zwei Tests nötig
                        GeoPoint2D p = startPoint;
                        if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, q, ps, p))
                        {
                            return(true);
                        }
                        p = endPoint;
                        if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, q, p, pe))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (startQuad == q)
                        {
                            pe = startPoint;
                        }
                        if (endQuad == q)
                        {
                            ps = endPoint;
                        }
                        if (clr.EllipseArcHitTest(center, radiusx, radiusy, majorang, q, ps, pe))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 16
0
        bool IQuadTreeInsertable.HitTest(ref BoundingRect rect, bool includeControlPoints)
        {
            ClipRect clr = new ClipRect(ref rect);

            return(clr.LineHitTest(sp, ep));
        }
Exemplo n.º 17
0
 private static extern bool ClipCursor(ClipRect region);
Exemplo n.º 18
0
 private static extern bool ClipCursor(ClipRect region);
Exemplo n.º 19
0
        Widget _buildLikeCountWidget()
        {
            if (this._likeCount == null)
            {
                return(new Container());
            }
            var likeCount    = this._likeCount.ToString();
            var preLikeCount = this._preLikeCount.ToString();

            int didIndex = 0;

            if (preLikeCount.Length == likeCount.Length)
            {
                for (; didIndex < likeCount.Length; didIndex++)
                {
                    if (likeCount[didIndex] != preLikeCount[didIndex])
                    {
                        break;
                    }
                }
            }

            bool allChange = preLikeCount.Length != likeCount.Length || didIndex == 0;

            Widget result;

            if (this.widget.likeCountAnimationType == LikeCountAnimationType.none ||
                this._likeCount == this._preLikeCount)
            {
                result = this._createLikeCountWidget(this._likeCount, this._isLiked, this._likeCount.ToString());
            }
            else if (this.widget.likeCountAnimationType == LikeCountAnimationType.part &&
                     !allChange)
            {
                var samePart          = likeCount.Substring(0, didIndex);
                var preText           = preLikeCount.Substring(didIndex, preLikeCount.Length);
                var text              = likeCount.Substring(didIndex, likeCount.Length);
                var preSameWidget     = this._createLikeCountWidget(this._preLikeCount, !this._isLiked, samePart);
                var currentSameWidget = this._createLikeCountWidget(this._likeCount, this._isLiked, samePart);
                var preWidget         = this._createLikeCountWidget(this._preLikeCount, !this._isLiked, preText);
                var currentWidget     = this._createLikeCountWidget(this._likeCount, this._isLiked, text);

                result = new AnimatedBuilder(
                    animation: this._likeCountController,
                    builder: (b, w) => new Row(
                        children: new List <Widget> {
                    new Stack(
                        fit: StackFit.passthrough,
                        overflow: Overflow.clip,
                        children: new List <Widget> {
                        new Opacity(
                            child: currentSameWidget,
                            opacity: this._opacityAnimation.value
                            ),
                        new Opacity(
                            child: preSameWidget,
                            opacity: 1 - this._opacityAnimation.value
                            )
                    }
                        ),
                    new Stack(
                        fit: StackFit.passthrough,
                        overflow: Overflow.clip,
                        children: new List <Widget> {
                        new FractionalTranslation(
                            child: currentWidget,
                            translation: this._preLikeCount > this._likeCount
                                            ? this._slideCurrentValueAnimation.value
                                            : -this._slideCurrentValueAnimation.value
                            ),
                        new FractionalTranslation(
                            child: preWidget,
                            translation: this._preLikeCount > this._likeCount
                                            ? this._slidePreValueAnimation.value
                                            : -this._slidePreValueAnimation.value
                            )
                    }
                        )
                }
                        ));
            }
            else
            {
                result = new AnimatedBuilder(
                    animation: this._likeCountController,
                    builder: (b, w) => new Stack(
                        fit: StackFit.passthrough,
                        overflow: Overflow.clip,
                        children: new List <Widget> {
                    new FractionalTranslation(
                        child: this._createLikeCountWidget(this._likeCount, this._isLiked,
                                                           this._likeCount.ToString()),
                        translation: this._preLikeCount > this._likeCount
                                    ? this._slideCurrentValueAnimation.value
                                    : -this._slideCurrentValueAnimation.value
                        ),
                    new FractionalTranslation(
                        child: this._createLikeCountWidget(this._likeCount, !this._isLiked,
                                                           this._preLikeCount.ToString()),
                        translation: this._preLikeCount > this._likeCount
                                    ? this._slidePreValueAnimation.value
                                    : -this._slidePreValueAnimation.value
                        )
                }
                        )
                    );
            }

            result = new ClipRect(
                child: result,
                clipper: new LikeCountClip()
                );

            if (this.widget.likeCountPadding != null)
            {
                result = new Padding(
                    padding: this.widget.likeCountPadding,
                    child: result
                    );
            }

            return(result);
        }
Exemplo n.º 20
0
        public override Widget build(BuildContext context)
        {
            float bottomPadding   = MediaQuery.of(context).padding.bottom;
            Color backgroundColor = CupertinoDynamicColor.resolve(
                this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor,
                context
                );

            BorderSide resolveBorderSide(BorderSide side)
            {
                return(side == BorderSide.none
                    ? side
                    : side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context)));
            }

            Border resolvedBorder = border == null || border.GetType() != typeof(Border)
                ? border
                : new Border(
                top: resolveBorderSide(border.top),
                left: resolveBorderSide(border.left),
                bottom: resolveBorderSide(border.bottom),
                right: resolveBorderSide(border.right)
                );

            Color  inactive = CupertinoDynamicColor.resolve(inactiveColor, context);
            Widget result   = new DecoratedBox(
                decoration: new BoxDecoration(
                    border: resolvedBorder,
                    color: backgroundColor
                    ),
                child: new SizedBox(
                    height: BottomAppBarUtils._kTabBarHeight + bottomPadding,
                    child: IconTheme.merge( // Default with the inactive state.
                        data: new IconThemeData(
                            color: inactiveColor,
                            size: iconSize
                            ),
                        child: new DefaultTextStyle( // Default with the inactive state.
                            style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(color: inactive),
                            child: new Padding(
                                padding: EdgeInsets.only(bottom: bottomPadding),
                                child: new Row(
                                    crossAxisAlignment: CrossAxisAlignment.end,
                                    children: _buildTabItems(context)
                                    )
                                )
                            )
                        )
                    )
                );

            if (!opaque(context))
            {
                result = new ClipRect(
                    child: new BackdropFilter(
                        filter: ImageFilter.blur(sigmaX: 10.0f, sigmaY: 10.0f),
                        child: result
                        )
                    );
            }

            return(result);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.HitTest (ref BoundingRect, bool)"/>
        /// </summary>
        /// <param name="Rect"></param>
        /// <param name="IncludeControlPoints"></param>
        /// <returns></returns>
        public override bool HitTest(ref BoundingRect Rect, bool IncludeControlPoints)
        {
            if (sweep < 0)
            {   // 19.8.15: bin nicht sicher, ob das mit negativem sweep auch geht, deshalb hier umdrehen
                return((new Arc2D(Center, Radius, start + sweep, -sweep)).HitTest(ref Rect, IncludeControlPoints));
            }
            ClipRect clr = new ClipRect(ref Rect);

            int StartQuadrant = start.Quadrant;
            int EndQuadrant   = (start + sweep).Quadrant;
            int numQuads;

            if (sweep < 0.0)
            {
                numQuads = StartQuadrant - EndQuadrant;
            }
            else
            {
                numQuads = EndQuadrant - StartQuadrant;
            }
            if (numQuads < 0)
            {
                numQuads += 4;
            }
            // siehe bei GetExtent, die folgende Abfrage war falsch!
            // if (Math.Abs(sweep) > 2 * Math.PI / 3) numQuads = 4; // mehr als 270°
            if (EndQuadrant == StartQuadrant)
            {   // wenns mehr als halbrum geht, dann ganzrum
                if (Math.Abs(sweep) > Math.PI)
                {
                    numQuads = 4;
                }
            }
            BoundingRect res = BoundingRect.EmptyBoundingRect;
            int          q   = StartQuadrant;

            // im Folgenden die ganz überschrittenen Quadranten betrachten, also ganze Viertelbögen
            for (int i = 1; i < numQuads; ++i) // [hier war < numQuads, es muss aber <= heißen, sonst funktionierts nicht immer]<- das ist falsch, es muss < sein,
            {                                  // ganze Viertelbögen betrachten
                // q startet mit dem StartQuadranten, also zuerst quadranten weiterschalten
                if (sweep < 0.0)
                {
                    q -= 1;
                }
                else
                {
                    q += 1;
                }
                if (q < 0)
                {
                    q += 4;
                }
                if (q > 3)
                {
                    q -= 4;
                }
                switch (q) // Achse zur Rechten betrachten
                {
                case 0:
                    if (clr.ArcHitTest(Center, Radius, 0, new GeoPoint2D(Center.x + Radius, Center.y), new GeoPoint2D(Center.x, Center.y + Radius)))
                    {
                        return(true);
                    }
                    break;

                case 1:
                    if (clr.ArcHitTest(Center, Radius, 1, new GeoPoint2D(Center.x, Center.y + Radius), new GeoPoint2D(Center.x - Radius, Center.y)))
                    {
                        return(true);
                    }
                    break;

                case 2:
                    if (clr.ArcHitTest(Center, Radius, 2, new GeoPoint2D(Center.x - Radius, Center.y), new GeoPoint2D(Center.x, Center.y - Radius)))
                    {
                        return(true);
                    }
                    break;

                case 3:
                    if (clr.ArcHitTest(Center, Radius, 3, new GeoPoint2D(Center.x, Center.y - Radius), new GeoPoint2D(Center.x + Radius, Center.y)))
                    {
                        return(true);
                    }
                    break;
                }
            }
            if (numQuads == 0)
            {   // Start und Ende im selben Quadranten
                // nur das Bogenstück selbst betrachten
                if (sweep > 0.0)
                {
                    if (clr.ArcHitTest(Center, Radius, StartQuadrant % 4, StartPoint, EndPoint))
                    {
                        return(true);
                    }
                }
                else
                {
                    if (clr.ArcHitTest(Center, Radius, StartQuadrant % 4, EndPoint, StartPoint))
                    {
                        return(true);
                    }
                }
            }
            else
            {
                // Start und Ende in verschiedenen Quadranten
                // zwei Abschnitte betrachten
                if (sweep > 0.0)
                {
                    GeoPoint2D p1;
                    switch (StartQuadrant) // Achse zur Rechten betrachten
                    {
                    default:
                    case 0:
                        p1 = new GeoPoint2D(Center.x, Center.y + Radius);
                        break;

                    case 1:
                        p1 = new GeoPoint2D(Center.x - Radius, Center.y);
                        break;

                    case 2:
                        p1 = new GeoPoint2D(Center.x, Center.y - Radius);
                        break;

                    case 3:
                        p1 = new GeoPoint2D(Center.x + Radius, Center.y);
                        break;
                    }
                    if (clr.ArcHitTest(Center, Radius, StartQuadrant % 4, StartPoint, p1))
                    {
                        return(true);
                    }
                    switch (EndQuadrant) // Achse zur Rechten betrachten
                    {
                    default:
                    case 1:
                        p1 = new GeoPoint2D(Center.x, Center.y + Radius);
                        break;

                    case 2:
                        p1 = new GeoPoint2D(Center.x - Radius, Center.y);
                        break;

                    case 3:
                        p1 = new GeoPoint2D(Center.x, Center.y - Radius);
                        break;

                    case 0:
                        p1 = new GeoPoint2D(Center.x + Radius, Center.y);
                        break;
                    }
                    if (clr.ArcHitTest(Center, Radius, EndQuadrant % 4, p1, EndPoint))
                    {
                        return(true);
                    }
                }
                else
                {
                    GeoPoint2D p1;
                    switch (StartQuadrant) // Achse zur Rechten betrachten
                    {
                    default:
                    case 1:
                        p1 = new GeoPoint2D(Center.x, Center.y + Radius);
                        break;

                    case 2:
                        p1 = new GeoPoint2D(Center.x - Radius, Center.y);
                        break;

                    case 3:
                        p1 = new GeoPoint2D(Center.x, Center.y - Radius);
                        break;

                    case 0:
                        p1 = new GeoPoint2D(Center.x + Radius, Center.y);
                        break;
                    }
                    if (clr.ArcHitTest(Center, Radius, StartQuadrant % 4, p1, StartPoint))
                    {
                        return(true);
                    }
                    switch (EndQuadrant) // Achse zur Rechten betrachten
                    {
                    default:
                    case 0:
                        p1 = new GeoPoint2D(Center.x, Center.y + Radius);
                        break;

                    case 1:
                        p1 = new GeoPoint2D(Center.x - Radius, Center.y);
                        break;

                    case 2:
                        p1 = new GeoPoint2D(Center.x, Center.y - Radius);
                        break;

                    case 3:
                        p1 = new GeoPoint2D(Center.x + Radius, Center.y);
                        break;
                    }
                    if (clr.ArcHitTest(Center, Radius, EndQuadrant % 4, EndPoint, p1))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.HitTest (ref BoundingRect, bool)"/>
        /// </summary>
        /// <param name="Rect"></param>
        /// <param name="IncludeControlPoints"></param>
        /// <returns></returns>
        public override bool HitTest(ref BoundingRect Rect, bool IncludeControlPoints)
        {
            ClipRect clr = new ClipRect(ref Rect);

            return(clr.LineHitTest(startPoint, endPoint));
        }
Exemplo n.º 23
0
        private void Run(Utility utility, string[] args)
        {
            // HACK: The engine code assumes that Game.modData is set.
            Game.ModData = modData = utility.ModData;

            var filename = args[1];

            if (!Game.ModData.DefaultFileSystem.Exists(filename))
            {
                throw new IOException($"Couldn't find map {filename} in maps.vol or filesystem.");
            }

            using (var stream = Game.ModData.DefaultFileSystem.Open(filename))
            {
                var tag         = stream.ReadUInt32();         // always 4113
                var unknown     = stream.ReadUInt32();         // always 0
                var lgTileWidth = stream.ReadInt32();
                var tileHeight  = stream.ReadInt32();          // always 64
                var numTileSets = stream.ReadInt32();          // always 512

                // Update map header fields
                // Round height up to nearest power of 2
                var newHeight = tileHeight;
                newHeight -= 1;
                newHeight |= (newHeight >> 1);
                newHeight |= (newHeight >> 2);
                newHeight |= (newHeight >> 4);
                newHeight |= (newHeight >> 8);
                newHeight |= (newHeight >> 16);
                newHeight++;
                var width  = 1 << lgTileWidth;                // Calculate map width
                var height = newHeight;

                map = new Map(modData, modData.DefaultTileSets["default"], width + 2, (int)height + 2)
                {
                    Title       = Path.GetFileNameWithoutExtension(filename),
                    Author      = "OpenOP2",
                    RequiresMod = modData.Manifest.Id,
                };

                var tiles = new List <int>();
                for (var i = 0; i < width * height; i++)
                {
                    var tile = stream.ReadInt32();
                    tiles.Add(tile);
                }

                var clipRect = new ClipRect()
                {
                    X1 = stream.ReadInt32(),
                    Y1 = stream.ReadInt32(),
                    X2 = stream.ReadInt32(),
                    Y2 = stream.ReadInt32(),
                };

                SetBounds(map, width, height);

                // map.SetBounds(new PPos(clipRect.X1, clipRect.Y1), new PPos(width - clipRect.X2, (int)height - clipRect.Y2));
                // map.SetBounds(new PPos(clipRect.X1, clipRect.Y1), new PPos(clipRect.X1 + clipRect.X2, clipRect.Y1 - clipRect.Y2));
                // Read in tileset mappings
                var tileIds             = new List <TileSetInfo>();
                var tilesetStartIndices = new List <uint>();
                var tilesetTileIndex    = 0;
                for (int i = 0; i < numTileSets; i++)
                {
                    var stringLength = stream.ReadInt32();
                    if (stringLength <= 0)
                    {
                        continue;
                    }

                    var tilesetMapping = new TileSetInfo()
                    {
                        TileSetName = stream.ReadASCII(stringLength),
                        NumTiles    = stream.ReadInt32(),
                    };

                    tilesetStartIndices.Add((uint)tilesetTileIndex);
                    tilesetTileIndex += tilesetMapping.NumTiles;

                    tileIds.Add(tilesetMapping);
                }

                var testString = stream.ReadASCII(10);
                if (!testString.StartsWith("TILE SET"))
                {
                    throw new IOException("Couldn't find TILE SET tag.");
                }

                var numMappings = stream.ReadInt32();
                var mappings    = new TileSetMapping[numMappings];
                for (var i = 0; i < numMappings; i++)
                {
                    mappings[i] = new TileSetMapping
                    {
                        TileSetIndex        = stream.ReadInt16(),
                        TileIndex           = stream.ReadInt16(),
                        NumTileReplacements = stream.ReadInt16(),
                        CycleDelay          = stream.ReadInt16(),
                    };
                }

                var numTerrainTypes = stream.ReadInt32();
                var terrains        = new TerrainType[numTerrainTypes];

                stream.Seek(numTerrainTypes * 264, SeekOrigin.Current);

                var checkTag = stream.ReadUInt32();
                if (checkTag != tag)
                {
                    throw new IOException("Format error: Tag did not match header tag.");
                }

                var checkTag2 = stream.ReadInt32();                 // the same all the time?
                var numActors = stream.ReadInt32();                 // I think?

                // TODO: The rest of the tiles
                // Actually place the tiles
                for (var y = 0; y < height; y++)
                {
                    for (var x = 0; x < width; x++)
                    {
                        var tileXUpper = x >> 5;
                        var tileXLower = x & 0x1F;
                        var tileOffset = (((tileXUpper * height) + y) << 5) + tileXLower;
                        var tile       = tiles[tileOffset];

                        var tile2XUpper = tile >> 5;
                        var tile2XLower = tile & 0x1F;

                        // Get the tile mapping index
                        var cellType          = (tile & 0x1F);
                        var tileMappingIndex  = (tile & 0xFFE0) >> 5;
                        var actorMappingIndex = (tile & 0x7FF0000) >> 11;
                        var lava           = (tile & 0x00000001) >> 27;
                        var lavaPossible   = (tile & 0x00000001) >> 28;
                        var expand         = (tile & 0x00000001) >> 29;
                        var microbe        = (tile & 0x00000001) >> 30;
                        var wallOrBuilding = (tile & 0x00000001) >> 31;
                        if (actorMappingIndex != 0 || lavaPossible != 0 || wallOrBuilding != 0)
                        {
                            throw new Exception("Actor mapping was " + actorMappingIndex);
                        }

                        var thisMapping = mappings[tileMappingIndex];
                        var startIndex  = tilesetStartIndices[thisMapping.TileSetIndex];

                        map.Tiles[new CPos(x + 1, y + 1)] = new TerrainTile((ushort)(startIndex + thisMapping.TileIndex), 0);
                    }
                }
            }

            mapPlayers            = new MapPlayers(map.Rules, 0);
            map.PlayerDefinitions = mapPlayers.ToMiniYaml();
            map.FixOpenAreas();

            var dest         = Path.GetFileNameWithoutExtension(args[1]) + ".oramap";
            var mapLocations = Game.ModData.Manifest.MapFolders;
            var userMapPath  = mapLocations.First(mapLocation => mapLocation.Value == "User");
            var targetPath   = Path.Combine(Platform.ResolvePath(userMapPath.Key.Substring(1)), dest);

            map.Save(ZipFileLoader.Create(targetPath));

            Console.WriteLine(targetPath + " saved.");
        }