Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #463 from jogibear9988/master
Browse files Browse the repository at this point in the history
Right Click Context Menu for multiple Selected Items to Wrap them in a Container
  • Loading branch information
dgrunwald committed May 13, 2014
2 parents e4a573d + df4cd4b commit 6585614
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class RotateThumb : ResizeThumb
{
// private double initialAngle;
// private RotateTransform rotateTransform;
// private Vector startVector;
// private Point centerPoint;
// private Control designerItem;
// private Panel canvas;
// private AdornerPanel parent;

static RotateThumb()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(RotateThumb), new FrameworkPropertyMetadata(typeof(RotateThumb)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@

namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Display height of the element.
/// </summary>
class HeightDisplay : Control
{
static HeightDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
}
}
/// <summary>
/// Display height of the element.
/// </summary>
class HeightDisplay : Control
{
static HeightDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
}
}

/// <summary>
/// Display width of the element.
/// </summary>
class WidthDisplay : Control
{
static WidthDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
}
}
/// <summary>
/// Display width of the element.
/// </summary>
class WidthDisplay : Control
{
static WidthDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,55 +30,55 @@ public class ContentControlInitializer : DefaultInitializer
{
public override void InitializeDefaults(DesignItem item)
{
//Not every Content Control can have a text as Content (e.g. ZoomBox of WPF Toolkit)
if (item.Component is Button)
{
//Not every Content Control can have a text as Content (e.g. ZoomBox of WPF Toolkit)
if (item.Component is Button)
{
DesignItemProperty contentProperty = item.Properties["Content"];
if (contentProperty.ValueOnInstance == null)
{
if (contentProperty.ValueOnInstance == null)
{
contentProperty.SetValue(item.ComponentType.Name);
}
}

DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
if (verticalAlignmentProperty.ValueOnInstance == null)
{
verticalAlignmentProperty.SetValue(VerticalAlignment.Center);
}
DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
if (verticalAlignmentProperty.ValueOnInstance == null)
{
verticalAlignmentProperty.SetValue(VerticalAlignment.Center);
}

DesignItemProperty horizontalAlignmentProperty = item.Properties["HorizontalAlignment"];
if (horizontalAlignmentProperty.ValueOnInstance == null)
{
horizontalAlignmentProperty.SetValue(HorizontalAlignment.Center);
}
DesignItemProperty horizontalAlignmentProperty = item.Properties["HorizontalAlignment"];
if (horizontalAlignmentProperty.ValueOnInstance == null)
{
horizontalAlignmentProperty.SetValue(HorizontalAlignment.Center);
}
}
}

[ExtensionFor(typeof(TextBlock))]
public class TextBlockInitializer : DefaultInitializer
{
public override void InitializeDefaults(DesignItem item)
{
DesignItemProperty textProperty = item.Properties["Text"];
if (textProperty.ValueOnInstance == null || textProperty.ValueOnInstance.ToString() == "")
{
textProperty.SetValue(item.ComponentType.Name);
}
public class TextBlockInitializer : DefaultInitializer
{
public override void InitializeDefaults(DesignItem item)
{
DesignItemProperty textProperty = item.Properties["Text"];
if (textProperty.ValueOnInstance == null || textProperty.ValueOnInstance.ToString() == "")
{
textProperty.SetValue(item.ComponentType.Name);
}

DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
if (verticalAlignmentProperty.ValueOnInstance == null)
{
verticalAlignmentProperty.SetValue(VerticalAlignment.Center);
}
DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
if (verticalAlignmentProperty.ValueOnInstance == null)
{
verticalAlignmentProperty.SetValue(VerticalAlignment.Center);
}

DesignItemProperty horizontalAlignmentProperty = item.Properties["HorizontalAlignment"];
if (horizontalAlignmentProperty.ValueOnInstance == null)
{
horizontalAlignmentProperty.SetValue(HorizontalAlignment.Center);
}
}
DesignItemProperty horizontalAlignmentProperty = item.Properties["HorizontalAlignment"];
if (horizontalAlignmentProperty.ValueOnInstance == null)
{
horizontalAlignmentProperty.SetValue(HorizontalAlignment.Center);
}
}
}
[ExtensionFor(typeof(HeaderedContentControl), OverrideExtension = typeof(ContentControlInitializer))]
public class HeaderedContentControlInitializer : DefaultInitializer
{
Expand All @@ -96,7 +96,7 @@ public override void InitializeDefaults(DesignItem item)
}
}

[ExtensionFor(typeof(Shape))]
[ExtensionFor(typeof(Shape))]
public class ShapeInitializer : DefaultInitializer
{
public override void InitializeDefaults(DesignItem item)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.RightClickMultipleItemsContextMenu"
xmlns="https://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer"
>
<MenuItem Header="{Binding WrapInCanvas, Source={x:Static Translation:Translations.Instance}}" Click="Click_WrapInCanvas" />
<MenuItem Header="{Binding WrapInGrid, Source={x:Static Translation:Translations.Instance}}" Click="Click_WrapInGrid" />
</ContextMenu>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.Xaml;

namespace ICSharpCode.WpfDesign.Designer.Extensions
{
public partial class RightClickMultipleItemsContextMenu
{
private DesignItem designItem;

public RightClickMultipleItemsContextMenu(DesignItem designItem)
{
this.designItem = designItem;

InitializeComponent();
}

void Click_WrapInCanvas(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.WrapItemsNewContainer(this.designItem.Services.Selection.SelectedItems, typeof(Canvas));
}

void Click_WrapInGrid(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.WrapItemsNewContainer(this.designItem.Services.Selection.SelectedItems, typeof(Grid));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;

using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer;

namespace ICSharpCode.WpfDesign.Designer.Extensions
{
/// <summary>
///
/// </summary>
[ExtensionServer(typeof(MultipleSelectedExtensionServer))]
[ExtensionFor(typeof(UIElement))]
public class RightClickMultipleItemsContextMenuExtension : SelectionAdornerProvider
{
DesignPanel panel;

protected override void OnInitialized()
{
base.OnInitialized();

panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
panel.ContextMenu = new RightClickMultipleItemsContextMenu(ExtendedItem);
}

protected override void OnRemove()
{
panel.ContextMenu = null;

base.OnRemove();
}
}
}
Loading

0 comments on commit 6585614

Please sign in to comment.