Пример #1
0
        /// <summary>
        /// When an object in the InfoPannel is clicked set it to the focus of the screen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListObjectFocusOnMouseDown(object sender, MouseButtonEventArgs e)
        {
            // Get the sending object's view model from it's data context
            InterstellaObjectViewModel SenderVM = ((Ellipse)sender).DataContext as InterstellaObjectViewModel;

            // Set the view canvas page to focus on this object
            CanvasPageViewModel.FocusOnObject(SenderVM);
        }
Пример #2
0
        /// <summary>
        /// When an object is right clicked allow the user to edit the infomation of that object
        /// using the hover data entry box
        /// </summary>
        private void EditObjectOnRightClick(object sender, MouseButtonEventArgs e)
        {
            // Get the view model of the clicked object
            InterstellaObjectViewModel SenderAsVm = ((Ellipse)sender).DataContext as InterstellaObjectViewModel;

            //Pause System
            CanvasPageViewModel.Instance.SystemRunning = false;

            // Open the data entry box with the sending object's VM
            CanvasPageViewModel.Instance.OpenDataEntryBox.Execute(SenderAsVm);
        }
Пример #3
0
 /// <summary>
 /// When object is left clicked;
 /// IF SHIFT Down: When an Object is Left-Clicked focus on this object, by putting it at the centre cavnas
 /// ELSE: start a drag to add velocity
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ObjectLeftClicked(object sender, MouseButtonEventArgs e)
 {
     // If the shift key is currently down
     if (_KeysDown.Contains(Key.LeftShift))
     {
         InterstellaObjectViewModel ObjectVm = (InterstellaObjectViewModel)((Ellipse)sender).DataContext;
         CanvasPageViewModel.FocusOnObject(ObjectVm);
     }
     else
     {
         // flag a drag event as active and set the dragged object to be the one that was clicked
         _DragActive    = true;
         _DraggedObject = ((Ellipse)sender).DataContext as InterstellaObjectViewModel;
     }
 }
Пример #4
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;
            }
        }