예제 #1
0
        public void UnselectItem()
        {
            if (_selectedItem != null)
            {
                _selectedItem.Item.PhysicsBody.Disposing -= new EventHandler(PhysicsBody_Disposing);

                // Let overridden versions of the selected items remove any selection visuals
                _selectedItem.Dispose();
            }

            ClearDebugVisuals();

            _selectedItem = null;
            _dragPlane    = null;
            _dragHistory.Clear();
        }
예제 #2
0
        /// <summary>
        /// This is called whenever an item has been clicked on.  It figures out if it's a newly selected item, or the
        /// currently selected item, and updates accordingly
        /// </summary>
        private void ChangeSelectedItem(Tuple <IMapObject, MyHitTestResult> item, Point clickPoint)
        {
            Vector3D offset = item.Item2.Point - item.Item1.PositionWorld;

            if (_selectedItem != null && _selectedItem.Item == item.Item1)
            {
                // They reclicked on the same item.  Just update the camera position
                _selectedItem.Offset = offset;
                return;
            }

            // Remove the old
            UnselectItem();

            // Inform the world, giving them a chance to create selection visuals (and store those visuals in an overridden SelectedItem instance)
            MapObject_ChasePoint_Direct selectedItem = OnItemSelected(item.Item1, offset, clickPoint);

            // Store the new
            _selectedItem = selectedItem;

            // Need to hook to this in case the body is disposed while it is selected
            item.Item1.PhysicsBody.Disposing += new EventHandler(PhysicsBody_Disposing);
        }
        /// <summary>
        /// This is called whenever an item has been clicked on.  It figures out if it's a newly selected item, or the
        /// currently selected item, and updates accordingly
        /// </summary>
        private void ChangeSelectedItem(Tuple<IMapObject, MyHitTestResult> item, Point clickPoint)
        {
            Vector3D offset = item.Item2.Point - item.Item1.PositionWorld;

            if (_selectedItem != null && _selectedItem.Item == item.Item1)
            {
                // They reclicked on the same item.  Just update the camera position
                _selectedItem.Offset = offset;
                return;
            }

            // Remove the old
            UnselectItem();

            // Inform the world, giving them a chance to create selection visuals (and store those visuals in an overridden SelectedItem instance)
            MapObject_ChasePoint_Direct selectedItem = OnItemSelected(item.Item1, offset, clickPoint);

            // Store the new
            _selectedItem = selectedItem;

            // Need to hook to this in case the body is disposed while it is selected
            item.Item1.PhysicsBody.Disposing += new EventHandler(PhysicsBody_Disposing);
        }
        public void UnselectItem()
        {
            if (_selectedItem != null)
            {
                _selectedItem.Item.PhysicsBody.Disposing -= new EventHandler(PhysicsBody_Disposing);

                // Let overridden versions of the selected items remove any selection visuals
                _selectedItem.Dispose();
            }

            ClearDebugVisuals();

            _selectedItem = null;
            _dragPlane = null;
            _dragHistory.Clear();
        }