Ejemplo n.º 1
0
        public void TestInsertInsertsItemAtIndex()
        {
            bindableStringList.Add("0");
            bindableStringList.Add("2");

            bindableStringList.Insert(1, "1");

            Assert.Multiple(() =>
            {
                Assert.AreEqual("0", bindableStringList[0]);
                Assert.AreEqual("1", bindableStringList[1]);
                Assert.AreEqual("2", bindableStringList[2]);
            });
        }
Ejemplo n.º 2
0
        private PathControlPoint addControlPoint(Vector2 position)
        {
            position -= HitObject.Position;

            int   insertionIndex = 0;
            float minDistance    = float.MaxValue;

            for (int i = 0; i < controlPoints.Count - 1; i++)
            {
                float dist = new Line(controlPoints[i].Position, controlPoints[i + 1].Position).DistanceToPoint(position);

                if (dist < minDistance)
                {
                    insertionIndex = i + 1;
                    minDistance    = dist;
                }
            }

            var pathControlPoint = new PathControlPoint {
                Position = position
            };

            // Move the control points from the insertion index onwards to make room for the insertion
            controlPoints.Insert(insertionIndex, pathControlPoint);

            HitObject.SnapTo(snapProvider);

            return(pathControlPoint);
        }
Ejemplo n.º 3
0
        private int addControlPoint(Vector2 position)
        {
            position -= HitObject.Position;

            int   insertionIndex = 0;
            float minDistance    = float.MaxValue;

            for (int i = 0; i < controlPoints.Count - 1; i++)
            {
                float dist = new Line(controlPoints[i].Position.Value, controlPoints[i + 1].Position.Value).DistanceToPoint(position);

                if (dist < minDistance)
                {
                    insertionIndex = i + 1;
                    minDistance    = dist;
                }
            }

            // Move the control points from the insertion index onwards to make room for the insertion
            controlPoints.Insert(insertionIndex, new PathControlPoint {
                Position = { Value = position }
            });

            return(insertionIndex);
        }
Ejemplo n.º 4
0
        private void beatmapsChanged(IRealmCollection <BeatmapSetInfo> sender, ChangeSet changes, Exception error)
        {
            if (changes == null)
            {
                beatmapSets.Clear();
                // must use AddRange to avoid RearrangeableList sort overhead per add op.
                beatmapSets.AddRange(sender.Select(b => b.ToLive(realm)));
                return;
            }

            foreach (int i in changes.InsertedIndices)
            {
                beatmapSets.Insert(i, sender[i].ToLive(realm));
            }

            foreach (int i in changes.DeletedIndices.OrderByDescending(i => i))
            {
                beatmapSets.RemoveAt(i);
            }
        }
Ejemplo n.º 5
0
        public ControlPointGroup GroupAt(double time, bool addIfNotExisting = false)
        {
            var newGroup = new ControlPointGroup(time);

            int i = groups.BinarySearch(newGroup);

            if (i >= 0)
            {
                return(groups[i]);
            }

            if (addIfNotExisting)
            {
                newGroup.ItemAdded   += groupItemAdded;
                newGroup.ItemRemoved += groupItemRemoved;

                groups.Insert(~i, newGroup);
                return(newGroup);
            }

            return(null);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Change the position of a <see cref="BeatmapSetInfo"/> in the current playlist.
 /// </summary>
 /// <param name="beatmapSetInfo">The beatmap to move.</param>
 /// <param name="index">The new position.</param>
 public void ChangeBeatmapSetPosition(BeatmapSetInfo beatmapSetInfo, int index)
 {
     beatmapSets.Remove(beatmapSetInfo);
     beatmapSets.Insert(index, beatmapSetInfo);
 }