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 }; }
protected override void OnInitialized() { base.OnInitialized(); panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel; panel.ContextMenu = new RightClickContextMenu(ExtendedItem); }
protected override void OnInitialized() { base.OnInitialized(); contextMenu = new WrapItemsContextMenu(ExtendedItem); panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel; if (panel != null) panel.AddContextMenu(contextMenu); }
public DesignSurface() { InitializeComponent(); 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); #if DEBUG || CODE_ANALYSIS if (_designPanel == null) { Environment.FailFast("designpanel should be initialized earlier"); // Fake call to DesignPanel constructor because FxCop doesn't look inside XAML files // and we'd get tons of warnings about uncalled private code. _designPanel = new DesignPanel(); } #endif }
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 }; }
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); _sceneContainer = new Border() { AllowDrop = false, UseLayoutRounding = true }; _sceneContainer.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal); _designPanel = new DesignPanel() { Child = _sceneContainer }; }