public void GeneralMouseMove <T>(MouseEventObjectType type, object sender, MouseEventArgs e)
        {
            if (mouseHandlingMode == ZoomAndPan.MouseHandlingMode.DraggingObjects)
            {
                if (mouseButtonDown == MouseButton.Left)
                {
                    UIElement parentCanvas = ParentalFinder.FindParent <Canvas>(myCoUserControl);

                    Point  curContentPoint     = e.GetPosition(parentCanvas);
                    Vector rectangleDragVector = curContentPoint - origContentMouseDownPoint;

                    origContentMouseDownPoint = curContentPoint;

                    bool shift = ((Keyboard.Modifiers & ModifierKeys.Shift) != 0);
                    bool ctrl  = ((Keyboard.Modifiers & ModifierKeys.Control) != 0);
                    bool alt   = ((Keyboard.Modifiers & ModifierKeys.Alt) != 0);

                    if (sender is FrameworkElement)
                    {
                        FrameworkElement fwe = (FrameworkElement)sender;

                        if (fwe.DataContext is IMainVmInterface)
                        {
                            IMainVmInterface mvm = (IMainVmInterface)fwe.DataContext;

                            T obj = (T)fwe.DataContext;

                            mvm.MainVm.MouseMove(type, obj, rectangleDragVector, shift, ctrl, alt);
                        }
                    }

                    e.Handled = true;
                }
            }
        }
예제 #2
0
        private void Shape_MouseUp(object sender, MouseButtonEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            if (parentControl != null)
            {
                if (DataContext is ObjectFactoryPropertiesViewModel)
                {
                    parentControl.GeneralMouse <ObjectFactoryPropertiesViewModel>(false, MouseEventObjectType.objectFactory, sender, e);
                    return;
                }
            }
        }
예제 #3
0
        private void AnchorA_MouseUp(object sender, MouseButtonEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            if (parentControl != null)
            {
                if (DataContext is FlameEmitterPropertiesViewModel)
                {
                    parentControl.GeneralMouse <FlameEmitterPropertiesViewModel>(false, MouseEventObjectType.flameEmitterSystem, sender, e);
                    return;
                }
            }
        }
예제 #4
0
        private void AnchorA_MouseDown(object sender, MouseButtonEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            if (parentControl != null)
            {
                if (DataContext is GunPropertiesViewModel)
                {
                    parentControl.GeneralMouse <GunPropertiesViewModel>(true, MouseEventObjectType.gunSystem, sender, e);
                    return;
                }
            }
        }
        private void AnchorB_MouseMove(object sender, MouseEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouseMove <WeldJointViewModel>(MouseEventObjectType.jointAnchorB, sender, e);
        }
        private void AnchorA_MouseUp(object sender, MouseButtonEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouse <WeldJointViewModel>(false, MouseEventObjectType.jointAnchorA, sender, e);
        }
        public void GeneralMouse <T>(bool down, MouseEventObjectType type, object sender, MouseButtonEventArgs e)
        {
            // We want access to the parent Canvas above the "content" Canvas.
            // The "content" (content it is it's name) Canvas, is the top Canvas of the
            // CompoundObjectUserControl, so the parent canvas is the one above
            // it. We need it to set the focus (why?) and to get the mouse point
            // expressed in the parent coordinate system.
            // Hence, we are not seeking the top most canvas, i.e. the CenteredCanvas
            // specialised Canvas of the main window.
            // By getting access to the "content" Canvas which is the top most canvas
            // of this object, we search immediatly above it to make sure that the found
            // canvas is the one above it.
            // Now, can this be done without knowledge of the content Canvas?
            // Can it, for instance, be assumed that the content Canvas is the first
            // Parent Canvas and the sought Canvas is the second found?
            //
            UIElement parentCanvas = ParentalFinder.FindParent <Canvas>(myCoUserControl);

            parentCanvas.Focus();
            Keyboard.Focus(parentCanvas);

            mouseButtonDown = e.ChangedButton;

            bool shift = ((Keyboard.Modifiers & ModifierKeys.Shift) != 0);
            bool ctrl  = ((Keyboard.Modifiers & ModifierKeys.Control) != 0);
            bool alt   = ((Keyboard.Modifiers & ModifierKeys.Alt) != 0);

            // If the leftClickState of the Main VM is other than none then
            // we do not want to start dragging objects
            if (sender is FrameworkElement)
            {
                FrameworkElement fwe = (FrameworkElement)sender;

                if (fwe.DataContext is T)
                {
                    IMainVmInterface obj = (IMainVmInterface)fwe.DataContext;

                    if (obj.MainVm.LeftClickState == LeftClickState.none)
                    {
                        // If ctrl is held down, we never intent to drag things
                        if (!ctrl && (mouseButtonDown == MouseButton.Left))
                        {
                            if (down)
                            {
                                mouseHandlingMode         = ZoomAndPan.MouseHandlingMode.DraggingObjects;
                                origContentMouseDownPoint = e.GetPosition(parentCanvas);

                                UIElement dragObject = (UIElement)sender;
                                dragObject.CaptureMouse();

                                e.Handled = true;
                            }
                            else
                            {
                                if (mouseHandlingMode == ZoomAndPan.MouseHandlingMode.DraggingObjects)
                                {
                                    mouseButtonDown = e.ChangedButton;

                                    if (mouseButtonDown == MouseButton.Left)
                                    {
                                        mouseHandlingMode = ZoomAndPan.MouseHandlingMode.None;

                                        UIElement rectangle = (UIElement)sender;
                                        rectangle.ReleaseMouseCapture();

                                        e.Handled = true;
                                    }
                                }
                            }
                        }
                    }

                    if (down)
                    {
                        if (obj.MainVm.MouseDown(type, obj, e.ChangedButton, e.GetPosition(myCoUserControl), e.ClickCount, shift, ctrl, alt))
                        {
                            e.Handled = true;
                        }
                    }
                    else
                    {
                        if (obj.MainVm.MouseUp(type, obj, e.ChangedButton, e.GetPosition(myCoUserControl), e.ClickCount, shift, ctrl, alt))
                        {
                            e.Handled = true;
                        }
                    }
                }
            }
        }
        private void AnchorB_MouseMove(object sender, MouseEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouseMove <ReentryFlameEmitterPropertiesViewModel>(MouseEventObjectType.systemAnchorB, sender, e);
        }
예제 #9
0
        private void Shape_MouseUp(object sender, MouseButtonEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouse <LfShapeViewModel>(false, MouseEventObjectType.shape, sender, e);
        }
        private void ShapeBorder_MouseMove(object sender, MouseEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouseMove <IPositionInterface>(MouseEventObjectType.dragableBorder, sender, e);
        }
        private void ShapeBorder_MouseDown(object sender, MouseButtonEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouse <LfPointViewModel>(true, MouseEventObjectType.dragableBorder, sender, e);
        }
        private void DragablePoint_MouseUp(object sender, MouseButtonEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouse <LfDragablePointViewModel>(false, MouseEventObjectType.dragablePoint, sender, e);
        }
예제 #13
0
        private void LowerLimit_MouseUp(object sender, MouseButtonEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouse <PrismaticJointViewModel>(false, MouseEventObjectType.prismJointLowerLimit, sender, e);
        }
예제 #14
0
        private void UpperLimit_MouseMove(object sender, MouseEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouseMove <PrismaticJointViewModel>(MouseEventObjectType.prismJointUpperLimit, sender, e);
        }
예제 #15
0
        private void EllipseBorder_MouseUp(object sender, MouseButtonEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouse <LfStaticCircleViewModel>(false, MouseEventObjectType.dragableBorder, sender, e);
        }
예제 #16
0
        private void AnchorA_MouseMove(object sender, MouseEventArgs e)
        {
            CompoundObjectUserControl parentControl = ParentalFinder.FindParent <CompoundObjectUserControl>(this);

            parentControl.GeneralMouseMove <GunPropertiesViewModel>(MouseEventObjectType.gunSystem, sender, e);
        }