ApplyTransform() public static method

public static ApplyTransform ( DesignItem designItem, Transform transform, bool relative = true ) : void
designItem DesignItem
transform System.Windows.Media.Transform
relative bool
return void
        public DesignSurface()
        {
            //TODO: this is for converters (see PropertyGrid)
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            this.AddCommandHandler(ApplicationCommands.Undo, Undo, CanUndo);
            this.AddCommandHandler(ApplicationCommands.Redo, Redo, CanRedo);
            this.AddCommandHandler(ApplicationCommands.Copy, Copy, CanCopyOrCut);
            this.AddCommandHandler(ApplicationCommands.Cut, Cut, CanCopyOrCut);
            this.AddCommandHandler(ApplicationCommands.Delete, Delete, CanDelete);
            this.AddCommandHandler(ApplicationCommands.Paste, Paste, CanPaste);
            this.AddCommandHandler(ApplicationCommands.SelectAll, SelectAll, CanSelectAll);

            this.AddCommandHandler(Commands.AlignTopCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Top), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignMiddleCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.VerticalMiddle), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignBottomCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Bottom), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignLeftCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Left), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignCenterCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.HorizontalMiddle), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignRightCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Right), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);

            this.AddCommandHandler(Commands.RotateLeftCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(-90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);
            this.AddCommandHandler(Commands.RotateRightCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);

            _sceneContainer = new Border()
            {
                AllowDrop = false, UseLayoutRounding = true
            };
            _sceneContainer.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal);

            _designPanel = new DesignPanel()
            {
                Child = _sceneContainer, DesignSurface = this
            };
        }
Example #2
0
        public DesignSurface()
        {
            //Propertygrid should show no inherited Datacontext!
            this.DataContext = null;

            this.AddCommandHandler(ApplicationCommands.Undo, Undo, CanUndo);
            this.AddCommandHandler(ApplicationCommands.Redo, Redo, CanRedo);
            this.AddCommandHandler(ApplicationCommands.Copy, Copy, CanCopyOrCut);
            this.AddCommandHandler(ApplicationCommands.Cut, Cut, CanCopyOrCut);
            this.AddCommandHandler(ApplicationCommands.Delete, Delete, CanDelete);
            this.AddCommandHandler(ApplicationCommands.Paste, Paste, CanPaste);
            this.AddCommandHandler(ApplicationCommands.SelectAll, SelectAll, CanSelectAll);

            this.AddCommandHandler(Commands.AlignTopCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Top), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignMiddleCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.VerticalMiddle), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignBottomCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Bottom), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignLeftCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Left), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignCenterCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.HorizontalMiddle), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.AlignRightCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Right), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);

            this.AddCommandHandler(Commands.RotateLeftCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(-90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);
            this.AddCommandHandler(Commands.RotateRightCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);

            this.AddCommandHandler(Commands.StretchToSameWidthCommand, () => ModelTools.StretchItems(this.DesignContext.Services.Selection.SelectedItems, StretchDirection.Width), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
            this.AddCommandHandler(Commands.StretchToSameHeightCommand, () => ModelTools.StretchItems(this.DesignContext.Services.Selection.SelectedItems, StretchDirection.Height), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);

            _sceneContainer = new Border()
            {
                AllowDrop = false, UseLayoutRounding = true
            };
            _sceneContainer.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal);

            _designPanel = new DesignPanel()
            {
                Child = _sceneContainer, DesignSurface = this
            };
        }