Example #1
0
        public void Move(object sender, MouseEventArgs e)
        {
            if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
            {
                return;
            }

            var position = GetRelativePosition(sender, e);
            var skRect   = layer.LayerShape.RenderRectangle;
            var x        = (float)(position.X + _dragOffsetX);
            var y        = (float)(position.Y + _dragOffsetY);

            // TODO: Update the translation
            // if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
            //     layer.LayerShape.SetFromUnscaledRectangle(SKRect.Create(x, y, skRect.Width, skRect.Height), ProfileEditorService.CurrentTime);
            // else
            // {
            //     if (_draggingVertically)
            //         layer.LayerShape.SetFromUnscaledRectangle(SKRect.Create(skRect.Left, y, skRect.Width, skRect.Height), ProfileEditorService.CurrentTime);
            //     else if (_draggingHorizontally)
            //         layer.LayerShape.SetFromUnscaledRectangle(SKRect.Create(x, skRect.Top, skRect.Width, skRect.Height), ProfileEditorService.CurrentTime);
            //     else
            //     {
            //         _draggingHorizontally = Math.Abs(position.X - _dragStart.X) > Math.Abs(position.Y - _dragStart.Y);
            //         _draggingVertically = Math.Abs(position.X - _dragStart.X) < Math.Abs(position.Y - _dragStart.Y);
            //     }
            // }

            ProfileEditorService.UpdateProfilePreview();
        }
Example #2
0
        public void AnchorMove(object sender, MouseEventArgs e)
        {
            if (!_isDragging || !(ProfileEditorService.SelectedProfileElement is Layer layer))
            {
                return;
            }

            var position = GetRelativePosition(sender, e);
            var x        = (float)(position.X + _dragOffsetX);
            var y        = (float)(position.Y + _dragOffsetY);

            layer.LayerShape.SetFromUnscaledAnchor(new SKPoint(x, y), ProfileEditorService.CurrentTime);
            ProfileEditorService.UpdateProfilePreview();
        }
Example #3
0
        private void ApplyShapeResize(SKRect newRect)
        {
            if (!(ProfileEditorService.SelectedProfileElement is Layer layer))
            {
                return;
            }

            // TODO: Apply the translation
            // Store the original position to create an offset for the anchor
            // var original = layer.PositionProperty.CurrentValue;
            // layer.LayerShape.SetFromUnscaledRectangle(newRect, ProfileEditorService.CurrentTime);
            // var updated = layer.PositionProperty.CurrentValue;
            // // Apply the offset to the anchor so it stays in at same spot
            // layer.AnchorPointProperty.SetCurrentValue(new SKPoint(
            //     layer.AnchorPointProperty.CurrentValue.X + (original.X - updated.X),
            //     layer.AnchorPointProperty.CurrentValue.Y + (original.Y - updated.Y)
            // ), ProfileEditorService.CurrentTime);

            // Update the preview
            ProfileEditorService.UpdateProfilePreview();
        }