コード例 #1
0
 public void LineStringSnapStart(ref SnapResult snapResult, ILineString lineString)
 {
     snapResult = new SnapResult(lineString.Coordinates[0], null, null, lineString, 0, 0)
     {
         Rule = this
     };
 }
コード例 #2
0
        public static SnapResult Snap(List <GameObject> roots, Config snapConfig)
        {
            float      minSnapDistance = float.MaxValue;
            SnapResult bestResult      = new SnapResult(SnapFailReson.NoDestinationFound);

            foreach (var root in roots)
            {
                var snapResult = CalculateSnapResult(root, snapConfig);

                if (snapResult.FailReason == SnapFailReson.MaxObjectsExceeded)
                {
                    return(snapResult);
                }
                else if (snapResult.FailReason == SnapFailReson.None)
                {
                    if (snapResult.SnapDistance < minSnapDistance)
                    {
                        minSnapDistance = snapResult.SnapDistance;
                        bestResult      = snapResult;
                    }
                }
            }

            if (bestResult.Success)
            {
                ObjectSnap.Snap(roots, bestResult.SnapPivot, bestResult.SnapDestination);
            }
            return(bestResult);
        }
コード例 #3
0
        /// <summary>
        /// Update snapping
        /// </summary>
        /// <param name="sourceLayer"></param>
        /// The layer of feature.
        /// <param name="feature"></param>
        /// Feature that is snapped. Feature is not always available.
        /// <param name="geometry"></param>
        /// actual geometry of the feature that is snapped.
        /// <param name="worldPosition"></param>
        /// <param name="trackerIndex"></param>
        public SnapResult ExecuteLayerSnapRules(ILayer sourceLayer, IFeature feature, IGeometry geometry,
                                                ICoordinate worldPosition, int trackerIndex)
        {
            var snapRules = sourceLayer.FeatureEditor.SnapRules;

            SnapResult = null;
            for (int i = 0; i < snapRules.Count; i++)
            {
                ISnapRule rule = snapRules[i];
                ExecuteSnapRule(rule, feature, geometry, null, worldPosition, trackerIndex);
                if (null != SnapResult)
                {
                    break;
                }
                // If snapping failed for the last rule and snapping is obligatory
                // any position is valid
                // todo add rule with SnapRole.Free?
                if ((!rule.Obligatory) && (i == snapRules.Count - 1))
                {
                    SnapResult = new SnapResult(worldPosition, null, sourceLayer, null, -1, -1)
                    {
                        Rule = rule
                    };
                }
            }
            if (0 == snapRules.Count)
            {
                SnapResult = new SnapResult(worldPosition, null, sourceLayer, null, -1, -1);
            }
            return(SnapResult);
        }
コード例 #4
0
        public override void Stop(SnapResult snapResult)
        {
            var networkLocation = (INetworkLocation)SourceFeature;

            if (null == networkLocation)
            {
                return;
            }

            var branch = snapResult.SnappedFeature as IBranch;

            if (null == branch)
            {
                return;
            }

            var network = Network ?? branch.Network; // network must e known

            if (network == null)
            {
                return;
            }

            if (networkLocation.Branch != branch)
            {
                networkLocation.Branch = branch;
            }
            // todo move update distance to AddBranchFeatureToNearestBranch?
            var distanceInGeometryLength    = GeometryHelper.Distance((ILineString)networkLocation.Branch.Geometry, TargetFeature.Geometry.Coordinates[0]);
            var distanceInCalculationLength = NetworkHelper.CalculationChainage(branch, distanceInGeometryLength);

            networkLocation.Chainage = BranchFeature.SnapChainage(networkLocation.Branch.Length, distanceInCalculationLength);
        }
コード例 #5
0
ファイル: SnapUtil.cs プロジェクト: huangxing1989/szcs
        private static void wb_callback(Object sender, WebBrowserDocumentCompletedEventArgs args)
        {
            WebBrowser wb = (WebBrowser)sender;

            if (wb.ReadyState == WebBrowserReadyState.Complete)
            {
                //将浏览器的长宽设置成参数里的长宽
                wb.Width  = para.m_WinWidth;
                wb.Height = para.m_WinHeight;

                int left   = para.m_Left;
                int top    = para.m_Top;
                int width  = para.m_SnapWidth;
                int height = para.m_SnapHeight;

                Bitmap    tmp  = new Bitmap(para.m_WinWidth, para.m_WinHeight);
                Rectangle rect = new Rectangle(0, 0, para.m_WinWidth, para.m_WinHeight);
                wb.DrawToBitmap(tmp, rect);  //进行截图,完整的一张图

                Bitmap    bm  = new Bitmap(width, height);
                Graphics  g   = Graphics.FromImage(bm);
                Rectangle src = new Rectangle(left, top, width, height);
                Rectangle des = new Rectangle(0, 0, width, height);
                g.DrawImage(tmp, des, src, GraphicsUnit.Pixel);

                bm.Save(para.m_Path);              //将截图储存
                SnapUtil.result = new SnapResult(tmp);
            }
        }
コード例 #6
0
        public void LineStringSnapStartEnd(ref double minDistance, ref SnapResult snapResult, ILineString lineString, Coordinate worldPos)
        {
            Coordinate c1 = lineString.Coordinates[0];
            Coordinate location;
            int        snapIndexPrevious;
            int        snapIndexNext;
            double     distance = GeometryHelper.Distance(c1.X, c1.Y, worldPos.X, worldPos.Y);

            if (distance < minDistance)
            {
                location          = c1;
                snapIndexPrevious = 0;
                snapIndexNext     = 0;
                minDistance       = distance;
                snapResult        = new SnapResult(location, null, null, lineString, snapIndexPrevious, snapIndexNext)
                {
                    Rule = this
                };
            }
            Coordinate c2 = lineString.Coordinates[lineString.Coordinates.Length - 1];

            distance = GeometryHelper.Distance(c2.X, c2.Y, worldPos.X, worldPos.Y);
            if (distance >= minDistance)
            {
                return;
            }
            location          = c2;
            snapIndexPrevious = lineString.Coordinates.Length - 1;
            snapIndexNext     = lineString.Coordinates.Length - 1;
            snapResult        = new SnapResult(location, null, null, lineString, snapIndexPrevious, snapIndexNext)
            {
                Rule = this
            };
        }
コード例 #7
0
        public void SnapToLineStringUsingFreeAtObject()
        {
            var mockRepository = new MockRepository();
            var feature        = mockRepository.CreateMock <IFeature>();

            using (mockRepository.Record())
            {
                Expect.Call(feature.Geometry).Return(lineString).Repeat.Any();
            }

            using (mockRepository.Playback())
            {
                var features = new [] { feature };
                var layers   = new[] { new VectorLayer() };

                IPoint   snapSource = new Point(5, 5);
                SnapRule snapRule   = new SnapRule
                {
                    SnapRole     = SnapRole.FreeAtObject,
                    Obligatory   = true,
                    PixelGravity = 40
                };

                SnapResult snapResults = snapRule.Execute(null, features, layers, snapSource, null,
                                                          snapSource.Coordinates[0],
                                                          CreateEnvelope(snapSource, 10),
                                                          0);
                Assert.IsNotNull(snapResults);
                Assert.IsNotNull(snapResults.Location);
                Assert.AreEqual(0, snapResults.Location.Y);
                Assert.AreEqual(5, snapResults.Location.X);
            }
        }
コード例 #8
0
        public override void UpdateTimeAndPosition(SnapResult result)
        {
            switch (PlacementActive)
            {
            case PlacementState.Waiting:
                if (!(result.Time is double snappedTime))
                {
                    return;
                }

                HitObject.OriginalX = ToLocalSpace(result.ScreenSpacePosition).X;
                HitObject.StartTime = snappedTime;
                break;

            case PlacementState.Active:
                Vector2 unsnappedPosition = inputManager.CurrentState.Mouse.Position;
                editablePath.MoveLastVertex(unsnappedPosition);
                break;

            default:
                return;
            }

            // Make sure the up-to-date position is used for outlines.
            Vector2 startPosition = CatchHitObjectUtils.GetStartPosition(HitObjectContainer, HitObject);

            editablePath.Position = nestedOutlineContainer.Position = scrollingPath.Position = startPosition;

            updateHitObjectFromPath();
        }
コード例 #9
0
        public override void OnMouseDown(Coordinate worldPosition, MouseEventArgs e)
        {
            if (VectorLayer == null)
            {
                return;
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            isBusy = true;
            StartDrawing();
            newNetworkFeature = GeometryFactory.CreatePoint(worldPosition);
            ((DataTableFeatureProvider)newNetworkFeatureLayer.DataSource).Clear();
            newNetworkFeatureLayer.DataSource.Add(newNetworkFeature);

            snapResult = MapControl.SnapTool.ExecuteLayerSnapRules(VectorLayer, null, newNetworkFeature, worldPosition, -1); //TODO check: why is this commented out in trunk?
            if (snapResult != null)
            {
                newNetworkFeature.Coordinates[0].X = snapResult.Location.X;
                newNetworkFeature.Coordinates[0].Y = snapResult.Location.Y;
            }

            newNetworkFeatureLayer.Style = MapControl.SnapTool.Failed ? errorNetworkFeatureStyle : networkFeatureStyle;
        }
        public override void UpdatePosition(SnapResult result)
        {
            base.UpdatePosition(result);

            if (PlacementActive)
            {
                if (result.Time is double endTime)
                {
                    HitObject.StartTime = endTime < originalStartTime ? endTime : originalStartTime;
                    HitObject.Duration  = Math.Abs(endTime - originalStartTime);
                }
            }
            else
            {
                if (result.Playfield != null)
                {
                    headPiece.Width = tailPiece.Width = result.Playfield.DrawWidth;
                    headPiece.X     = tailPiece.X = ToLocalSpace(result.ScreenSpacePosition).X;
                }

                if (result.Time is double startTime)
                {
                    originalStartTime = HitObject.StartTime = startTime;
                }
            }
        }
コード例 #11
0
 public void LineStringSnapEnd(ref SnapResult snapResult, ILineString lineString)
 {
     snapResult = new SnapResult(lineString.Coordinates[lineString.Coordinates.Length - 1], null, null, lineString,
                                 lineString.Coordinates.Length - 1, lineString.Coordinates.Length - 1)
     {
         Rule = this
     };
 }
コード例 #12
0
        public override void UpdatePosition(SnapResult result)
        {
            base.UpdatePosition(result);

            if (result.Playfield != null)
            {
                piece.Width    = result.Playfield.DrawWidth;
                piece.Position = ToLocalSpace(result.ScreenSpacePosition);
            }
        }
コード例 #13
0
        public override void UpdatePosition(SnapResult result)
        {
            base.UpdatePosition(result);

            if (result is ManiaSnapResult maniaResult)
            {
                piece.Width    = maniaResult.Column.DrawWidth;
                piece.Position = ToLocalSpace(result.ScreenSpacePosition);
            }
        }
コード例 #14
0
        public void Stop(SnapResult snapResult, bool stayOnSameBranch)
        {
            if (!(SourceFeature is IBranchFeature))
            {
                return;
            }
            if (null != snapResult && null == snapResult.SnappedFeature as IBranch)
            {
                return;
            }

            var branchFeature = (IBranchFeature)SourceFeature;

            if (moving)
            {
                branchFeature.SetBeingMoved(true);
            }

            var tolerance = Layer == null ? Tolerance : MapHelper.ImageToWorld(Layer.Map, 1);

            var      branch  = branchFeature.Branch;
            INetwork network = Network ?? branch.Network; // network must be known

            if (!stayOnSameBranch && branch != null)
            {
                branch.BranchFeatures.Remove(branchFeature);
                branchFeature.Branch = null;
            }

            base.Stop(); // set new geometry

            if (!stayOnSameBranch)
            {
                NetworkHelper.AddBranchFeatureToNearestBranch(network.Branches, branchFeature, tolerance);
            }

            if (moving)
            {
                branchFeature.SetBeingMoved(false);
                moving = false;
            }

            // todo move update distance to AddBranchFeatureToNearestBranch?
            double distance = GeometryHelper.Distance((ILineString)branchFeature.Branch.Geometry, branchFeature.Geometry.Coordinates[0]);

            if (branchFeature.Branch.IsLengthCustom)
            {
                distance *= branchFeature.Branch.Length / branchFeature.Branch.Geometry.Length;
            }
            branchFeature.Chainage = BranchFeature.SnapChainage(branchFeature.Branch.Length, distance);
            if (branchFeature.Geometry.GetType() == typeof(LineString))
            {
                UpdateLineGeometry(branchFeature);
            }
        }
コード例 #15
0
        public static SnapResult Snap(GameObject root, Config snapConfig)
        {
            SnapResult snapResult = CalculateSnapResult(root, snapConfig);

            if (snapResult.Success)
            {
                ObjectSnap.Snap(root, snapResult.SnapPivot, snapResult.SnapDestination);
            }

            return(snapResult);
        }
コード例 #16
0
        public override void UpdatePosition(SnapResult result)
        {
            base.UpdatePosition(result);

            var angle = ScreenSpaceDrawQuad.Centre.GetDegreesFromPosition(result.ScreenSpacePosition);

            HitObject.Angle   = angle;
            piece.Position    = Extensions.GetCircularPosition(0.485f, angle);
            piece.Rotation    = angle;
            distance.Rotation = angle;
        }
コード例 #17
0
        public override void OnMouseMove(Coordinate worldPosition, MouseEventArgs e)
        {
            if (VectorLayer == null)
            {
                return;
            }

            //to avoid listening to the mousewheel in the mean time
            if (!(e.Button == MouseButtons.None || e.Button == MouseButtons.Left))
            {
                return;
            }
            StartDrawing();

            foreach (var layer in Layers)
            {
                if (!isBusy)
                {
                    // If the newNetworkFeatureTool is active but not actual dragging a new NetworkFeature show the snap position.
                    IPoint point = GeometryFactory.CreatePoint(worldPosition);

                    snapResult = MapControl.SnapTool.ExecuteLayerSnapRules(layer, null, point, worldPosition, -1);

                    if (snapResult != null)
                    {
                        break;
                    }
                }
                else
                {
                    IPoint point = GeometryFactory.CreatePoint(worldPosition);
                    snapResult = MapControl.SnapTool.ExecuteLayerSnapRules(layer, null, point, worldPosition, -1);
                    if (snapResult != null)
                    {
                        newNetworkFeature.Coordinates[0].X = snapResult.Location.X;
                        newNetworkFeature.Coordinates[0].Y = snapResult.Location.Y;
                        newNetworkFeatureLayer.Style       = networkFeatureStyle;

                        break;
                    }
                    else
                    {
                        newNetworkFeature.Coordinates[0].X = worldPosition.X;
                        newNetworkFeature.Coordinates[0].Y = worldPosition.Y;
                        newNetworkFeatureLayer.Style       = errorNetworkFeatureStyle;
                    }
                }
            }
            DoDrawing(true);
            StopDrawing();
        }
コード例 #18
0
 public NUnitConstraintResult(IConstraint constraint, object actualValue, SnapResult snapResult)
     : base(constraint, actualValue)
 {
     _snapResult = snapResult;
     if (snapResult.Status == SnapResultStatus.SnapshotsMatch ||
         snapResult.Status == SnapResultStatus.SnapshotUpdated)
     {
         Status = ConstraintStatus.Success;
     }
     else
     {
         Status = ConstraintStatus.Failure;
     }
 }
コード例 #19
0
        public virtual void ProcessRequest(HttpContext context)
        {
            string htmltext = string.Empty;
            string guid     = string.Empty;
            int    ww;
            int    wh;
            int    x;
            int    y;
            int    cw;
            int    ch;

            htmltext = context.Request["HTML"];
            ww       = Convert.ToInt32(context.Request["ww"]);
            wh       = Convert.ToInt32(context.Request["wh"]);
            x        = Convert.ToInt32(context.Request["x"]);
            y        = Convert.ToInt32(context.Request["y"]);
            cw       = Convert.ToInt32(context.Request["cw"]);
            ch       = Convert.ToInt32(context.Request["ch"]);
            guid     = Guid.NewGuid().ToString();

            using (OracleConnection conn = new OracleConnection(context.Cache["ORASTR"].ToString()))
            {
                conn.Open();
                OracleCommand     comm  = conn.CreateCommand();
                OracleParameter[] parms = new OracleParameter[] {
                    new OracleParameter(":GUID", OracleType.VarChar),
                    new OracleParameter(":DATA", OracleType.NClob),
                };
                parms[0].Value = guid;
                parms[1].Value = htmltext;

                comm.CommandText = SQL_INSERT;
                comm.CommandType = CommandType.Text;
                foreach (OracleParameter parm in parms)
                {
                    comm.Parameters.Add(parm);
                }
                comm.ExecuteNonQuery();
            }
            string URL = context.Request.Url.AbsoluteUri.Substring(0, context.Request.Url.AbsoluteUri.IndexOf("SVR/GetSnap.ashx"));
            string url = URL + "Delegate.aspx?q=" + guid + "&w=" + ww + "&h=" + wh;

            string PATH = @"" + context.Server.MapPath(@"~") + context.Cache["CACHEPATH"].ToString() + guid + ".png";

            SnapParams para = new SnapParams(url, PATH, ww, wh, x, y, cw, ch);
            SnapResult res  = SnapUtil.Snap(para);

            context.Response.Write("window.open('" + URL + context.Cache["CACHEURL"].ToString() + guid + ".png')");
        }
コード例 #20
0
        private bool snapToVisibleBlueprints(Vector2 screenSpacePosition, out SnapResult snapResult)
        {
            // check other on-screen objects for snapping/stacking
            var blueprints = BlueprintContainer.SelectionBlueprints.AliveChildren;

            var playfield = PlayfieldAtScreenSpacePosition(screenSpacePosition);

            float snapRadius =
                playfield.GamefieldToScreenSpace(new Vector2(OsuHitObject.OBJECT_RADIUS / 5)).X -
                playfield.GamefieldToScreenSpace(Vector2.Zero).X;

            foreach (var b in blueprints)
            {
                if (b.IsSelected)
                {
                    continue;
                }

                var hitObject = (OsuHitObject)b.HitObject;

                Vector2?snap = checkSnap(hitObject.Position);
                if (snap == null && hitObject.Position != hitObject.EndPosition)
                {
                    snap = checkSnap(hitObject.EndPosition);
                }

                if (snap != null)
                {
                    // only return distance portion, since time is not really valid
                    snapResult = new SnapResult(snap.Value, null, playfield);
                    return(true);
                }

                Vector2?checkSnap(Vector2 checkPos)
                {
                    Vector2 checkScreenPos = playfield.GamefieldToScreenSpace(checkPos);

                    if (Vector2.Distance(checkScreenPos, screenSpacePosition) < snapRadius)
                    {
                        return(checkScreenPos);
                    }

                    return(null);
                }
            }

            snapResult = null;
            return(false);
        }
コード例 #21
0
        public override void UpdateTimeAndPosition(SnapResult result)
        {
            base.UpdateTimeAndPosition(result);

            switch (state)
            {
            case SliderPlacementState.Initial:
                BeginPlacement();
                HitObject.Position = ToLocalSpace(result.ScreenSpacePosition);
                break;

            case SliderPlacementState.Body:
                updateCursor();
                break;
            }
        }
コード例 #22
0
        public void LineStringSnapFreeAtObject(ref double minDistance, ref SnapResult snapResult, IFeature feature, ILineString lineString, Coordinate worldPos)
        {
            int vertexIndex;
            var nearestPoint = GeometryHelper.GetNearestPointAtLine(lineString, worldPos, minDistance, out vertexIndex);

            if (nearestPoint == null)
            {
                return;
            }

            minDistance = GeometryHelper.Distance(nearestPoint.X, nearestPoint.Y, worldPos.X, worldPos.Y);
            snapResult  = new SnapResult(nearestPoint, feature, null, lineString, vertexIndex - 1, vertexIndex)
            {
                Rule = this
            };
        }
コード例 #23
0
        private void ShowSnapResult(SnapResult snapResult)
        {
            var sld = ((DataTableFeatureProvider)snapLayer.DataSource);

            sld.Clear();

            if (null == snapResult)
            {
                return;
            }
            IList <IGeometry> visibleSnaps = snapResult.VisibleSnaps;

            //if (null == visisbleSnaps)
            if (0 == visibleSnaps.Count)
            {
                List <Coordinate> vertices = new List <Coordinate>();
                if (-1 != snapResult.SnapIndexPrevious)
                {
                    vertices.Add(GeometryFactoryEx.CreateCoordinate(snapResult.NearestTarget.Coordinates[snapResult.SnapIndexPrevious].X,
                                                                    snapResult.NearestTarget.Coordinates[snapResult.SnapIndexPrevious].Y));
                }
                vertices.Add(GeometryFactoryEx.CreateCoordinate(snapResult.Location.X, snapResult.Location.Y));
                IGeometry active = GeometryFactory.CreatePoint(snapResult.Location.X, snapResult.Location.Y);

                if (-1 != snapResult.SnapIndexNext)
                {
                    vertices.Add(GeometryFactoryEx.CreateCoordinate(snapResult.NearestTarget.Coordinates[snapResult.SnapIndexNext].X,
                                                                    snapResult.NearestTarget.Coordinates[snapResult.SnapIndexNext].Y));
                }

                if (vertices.Count > 1)
                {
                    ILineString snapLineString = GeometryFactory.CreateLineString(vertices.ToArray());
                    sld.Add(snapLineString);
                }
                sld.Add(active);
            }
            else
            {
                foreach (var snap in visibleSnaps)
                {
                    sld.Add(snap);
                }
            }
        }
コード例 #24
0
ファイル: SnapRule.cs プロジェクト: ghq1254544150/_SharpMap
 public void LineStringSnapFree(ref double minDistance, ref SnapResult snapResult, ILineString lineString, ICoordinate worldPos)
 {
     for (int i = 1; i < lineString.Coordinates.Length; i++)
     {
         ICoordinate c1       = lineString.Coordinates[i - 1];
         ICoordinate c2       = lineString.Coordinates[i];
         double      distance = GeometryHelper.LinePointDistance(c1.X, c1.Y, c2.X, c2.Y,
                                                                 worldPos.X, worldPos.Y);
         if (distance >= minDistance)
         {
             continue;
         }
         minDistance = distance;
         snapResult  = new SnapResult(GeometryFactory.CreateCoordinate(worldPos.X, worldPos.Y), null, null, lineString, i - 1, i)
         {
             Rule = this
         };
     }
 }
コード例 #25
0
ファイル: SnapperCore.cs プロジェクト: zubivan/Snapper
        protected SnapResult Snap(SnapshotId snapshotId, object newSnapshot)
        {
            var currentSnapshot = _snapshotStore.GetSnapshot(snapshotId);

            if (ShouldUpdateSnapshot(currentSnapshot, newSnapshot))
            {
                _snapshotStore.StoreSnapshot(snapshotId, newSnapshot);
                return(SnapResult.SnapshotUpdated(currentSnapshot, newSnapshot));
            }

            if (currentSnapshot == null)
            {
                return(SnapResult.SnapshotDoesNotExist(newSnapshot));
            }

            return(_snapshotComparer.CompareSnapshots(currentSnapshot, newSnapshot)
                ? SnapResult.SnapshotsMatch(currentSnapshot, newSnapshot)
                : SnapResult.SnapshotsDoNotMatch(currentSnapshot, newSnapshot));
        }
コード例 #26
0
 public void PolygonSnapFree(ref double minDistance, ref SnapResult snapResult, IPolygon polygon, Coordinate worldPos)
 {
     for (int i = 1; i < polygon.Coordinates.Length; i++)
     {
         Coordinate c1       = polygon.Coordinates[i - 1];
         Coordinate c2       = polygon.Coordinates[i];
         double     distance = GeometryHelper.LinePointDistance(c1.X, c1.Y, c2.X, c2.Y, worldPos.X, worldPos.Y);
         if (distance >= minDistance)
         {
             continue;
         }
         minDistance = distance;
         snapResult  = new SnapResult(GeometryFactoryEx.CreateCoordinate(worldPos.X, worldPos.Y), null, null, polygon,
                                      i - 1, i)
         {
             Rule = this
         };
     }
 }
コード例 #27
0
        public override void UpdateTimeAndPosition(SnapResult result)
        {
            base.UpdateTimeAndPosition(result);

            if (!(result.Time is double time))
            {
                return;
            }

            switch (PlacementActive)
            {
            case PlacementState.Waiting:
                HitObject.StartTime = time;
                break;

            case PlacementState.Active:
                HitObject.EndTime = time;
                break;
            }
        }
コード例 #28
0
        public override void UpdateTimeAndPosition(SnapResult result)
        {
            base.UpdateTimeAndPosition(result);

            switch (state)
            {
            case SliderPlacementState.Initial:
                BeginPlacement();

                var nearestDifficultyPoint = editorBeatmap.HitObjects.LastOrDefault(h => h.GetEndTime() < HitObject.StartTime)?.DifficultyControlPoint?.DeepClone() as DifficultyControlPoint;

                HitObject.DifficultyControlPoint = nearestDifficultyPoint ?? new DifficultyControlPoint();
                HitObject.Position = ToLocalSpace(result.ScreenSpacePosition);
                break;

            case SliderPlacementState.Body:
                updateCursor();
                break;
            }
        }
コード例 #29
0
        private void GeometrySnapAllTrackers(ref double minDistance, ref SnapResult snapResult, IGeometry geometry,
                                             Coordinate worldPos)
        {
            var coordinates = geometry.Coordinates;

            for (int i = 0; i < coordinates.Length; i++)
            {
                Coordinate c1       = coordinates[i];
                double     distance = GeometryHelper.Distance(c1.X, c1.Y, worldPos.X, worldPos.Y);
                if (distance >= minDistance)
                {
                    continue;
                }
                minDistance = distance;
                snapResult  = new SnapResult(coordinates[i], null, null, geometry, i, i)
                {
                    Rule = this
                };
            }
        }
コード例 #30
0
ファイル: SnapperCore.cs プロジェクト: urig/Snapper
        protected SnapResult Snap(SnapshotId snapshotId, object newSnapshot)
        {
            var currentSnapshot   = _snapshotStore.GetSnapshot(snapshotId);
            var areSnapshotsEqual = currentSnapshot != null &&
                                    _snapshotComparer.CompareSnapshots(currentSnapshot, newSnapshot);

            if (!areSnapshotsEqual && _snapshotUpdateDecider.ShouldUpdateSnapshot())
            {
                _snapshotStore.StoreSnapshot(snapshotId, newSnapshot);
                return(SnapResult.SnapshotUpdated(currentSnapshot, newSnapshot));
            }

            if (currentSnapshot == null)
            {
                return(SnapResult.SnapshotDoesNotExist(newSnapshot));
            }

            return(areSnapshotsEqual
                ? SnapResult.SnapshotsMatch(currentSnapshot, newSnapshot)
                : SnapResult.SnapshotsDoNotMatch(currentSnapshot, newSnapshot));
        }
コード例 #31
0
ファイル: MooseSnap.cs プロジェクト: jaburns/madjam-unity
 bool maybeMoveToSnap(SnapResult snap, Func<Vector2, bool> normalCheck)
 {
     if (!snap.success || !normalCheck(snap.normal)) return false;
     moveToSurfaceCoord(snap.newPos);
     return true;
 }