Ejemplo n.º 1
0
        /// <summary>
        /// On Mouse Up over object if a new object has been dropped put this into orbit around this object
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OjectMouseUp(object sender, MouseButtonEventArgs e)
        {
            // Get the view model of the object that mouse was releasd over
            InterstellaObjectViewModel SenderVM = ((Ellipse)sender).DataContext as InterstellaObjectViewModel;

            // If drag is active, and object overwhich the mouse was released is not the same as the drag object
            if (_DragActive && SenderVM != _DraggedObject)
            {
                // Calculate the velocity require of the drag object to orbit the other
                Vector OrbitVelocity = CanvasPageViewModel.GetOrbitVelocity(_DraggedObject.InterstellaObject, SenderVM.InterstellaObject);

                //set the object's velocity to the calculated above, and end the drag operation
                _DraggedObject.SetObjectVelocity(OrbitVelocity);
                _DragActive = false;
            }
        }