Example #1
0
        public static void DrawHoldRegionToLane(System.Drawing.Graphics g, IReadOnlyEditorLaneEnvironment env, Hold hold)
        {
            using (var sb = new SolidBrush(Color.FromArgb(200, 200, 175, 90)))
                using (var path = hold.GetGraphicsPath(env))
                    using (var matToLeft = new Matrix())
                        using (var matToRight = new Matrix())
                            using (var matToReset = new Matrix())
                            {
                                var laneWidth = env.LaneUnitWidth * MadcaEnv.LaneCount;
                                g.Clip = new Region(env.LaneRect);
                                matToLeft.Translate(-laneWidth, 0);
                                matToRight.Translate(laneWidth, 0);
                                var leftTimes = 0;

                                try
                                {
                                    g.FillPath(sb, path);
                                }
                                catch (Exception) { }
                                while (path.GetBounds().Right > env.LaneRect.Right)
                                {
                                    path.Transform(matToLeft);
                                    try
                                    {
                                        g.FillPath(sb, path);
                                    }
                                    catch (Exception) { }
                                    leftTimes++;
                                }
                                matToReset.Translate(laneWidth * leftTimes, 0);
                                path.Transform(matToReset);

                                while (path.GetBounds().Left < env.LaneRect.Left)
                                {
                                    path.Transform(matToRight);
                                    try
                                    {
                                        g.FillPath(sb, path);
                                    }
                                    catch (Exception) { }
                                }
                                g.ResetClip();
                            }
        }
Example #2
0
        public static bool Contains(this Hold hold, Point p, IReadOnlyEditorLaneEnvironment env)
        {
            var laneWidth = env.LaneUnitWidth * MadcaEnv.LaneCount;

            var matToLeft = new Matrix();

            matToLeft.Translate(-laneWidth, 0);
            var matToRight = new Matrix();

            matToRight.Translate(laneWidth, 0);
            var leftTimes = 0;

            using (var path = hold.GetGraphicsPath(env))
            {
                if (path.IsVisible(p))
                {
                    return(true);
                }
                while (path.GetBounds().Right > env.LaneRect.Right)
                {
                    path.Transform(matToLeft);
                    if (path.IsVisible(p))
                    {
                        return(true);
                    }
                    leftTimes++;
                }
                var matToReset = new Matrix();
                matToReset.Translate(laneWidth * leftTimes, 0);
                path.Transform(matToReset);

                while (path.GetBounds().Left < env.LaneRect.Left)
                {
                    path.Transform(matToRight);
                    if (path.IsVisible(p))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }