Exemple #1
0
        /// <summary>
        /// Recreates the <see cref="ITransBox"/>es for the current selection.
        /// </summary>
        /// <param name="camera">The camera describing the view area.</param>
        void UpdateTransBoxes(ICamera2D camera)
        {
            SelectedTransBox = null;
            UnderCursor      = null;

            // Clear the old boxes
            _transBoxes.Clear();

            if (_items.Count <= 0)
            {
                // Nothing selected
                return;
            }
            else if (_items.Count == 1)
            {
                // Only one selected
                var item = _items.FirstOrDefault();
                if (item == null)
                {
                    Debug.Fail("How did this happen?");
                    Clear(camera);
                    return;
                }

                var transBoxes = TransBox.SurroundEntity(this, item, camera);
                _transBoxes.AddRange(transBoxes);
            }
            else
            {
                // Multiple selected
                var min    = new Vector2(Items.Min(x => x.Position.X), Items.Min(x => x.Position.Y));
                var max    = new Vector2(Items.Max(x => x.Max.X), Items.Max(x => x.Max.Y));
                var center = min + ((max - min) / 2f).Round();

                var tb = new MoveManyTransBox(this, _items, center, camera);
                _transBoxes.Add(tb);
            }
        }
Exemple #2
0
        /// <summary>
        /// Recreates the <see cref="ITransBox"/>es for the current selection.
        /// </summary>
        /// <param name="camera">The camera describing the view area.</param>
        void UpdateTransBoxes(ICamera2D camera)
        {
            SelectedTransBox = null;
            UnderCursor = null;

            // Clear the old boxes
            _transBoxes.Clear();

            if (_items.Count <= 0)
            {
                // Nothing selected
                return;
            }
            else if (_items.Count == 1)
            {
                // Only one selected
                var item = _items.FirstOrDefault();
                if (item == null)
                {
                    Debug.Fail("How did this happen?");
                    Clear(camera);
                    return;
                }

                var transBoxes = TransBox.SurroundEntity(this, item, camera);
                _transBoxes.AddRange(transBoxes);
            }
            else
            {
                // Multiple selected
                var min = new Vector2(Items.Min(x => x.Position.X), Items.Min(x => x.Position.Y));
                var max = new Vector2(Items.Max(x => x.Max.X), Items.Max(x => x.Max.Y));
                var center = min + ((max - min) / 2f).Round();

                var tb = new MoveManyTransBox(this, _items, center, camera);
                _transBoxes.Add(tb);
            }
        }