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

Commit dfd1c1e

Browse files
Merge branch 'master' of github.com:icsharpcode/SharpDevelop
2 parents 7e532c4 + 8384a17 commit dfd1c1e

39 files changed

Lines changed: 1139 additions & 195 deletions

src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormsDesigner/CSharpDesignerGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void SaveInitializeComponents(CodeMemberMethod codeMethod)
182182

183183
string newline = DocumentUtilities.GetLineTerminator(script.OriginalDocument, bodyRegion.BeginLine);
184184
string indentation = DocumentUtilities.GetIndentation(script.OriginalDocument, bodyRegion.BeginLine);
185-
string code = "{" + newline + GenerateInitializeComponents(codeMethod, indentation, newline) + indentation + "}";
185+
string code = "{" + newline + GenerateInitializeComponents(codeMethod, indentation, newline) + newline + indentation + "}";
186186

187187
int startOffset = script.GetCurrentOffset(bodyRegion.Begin);
188188
int endOffset = script.GetCurrentOffset(bodyRegion.End);

src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompletionItemList.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ public override void Complete(CompletionContext context, ICompletionItem item)
8383
XamlCompletionItem cItem = item as XamlCompletionItem;
8484

8585
if (xamlContext.Description == XamlContextDescription.InTag) {
86-
context.Editor.Document.Insert(context.EndOffset, "=\"\"");
87-
context.CompletionCharHandled = context.CompletionChar == '=';
88-
context.Editor.Caret.Offset--;
89-
new XamlCodeCompletionBinding().CtrlSpace(context.Editor);
86+
if (cItem.Entity.SymbolKind == SymbolKind.Property || cItem.Entity.SymbolKind == SymbolKind.Event) {
87+
context.Editor.Document.Insert(context.EndOffset, "=\"\"");
88+
context.CompletionCharHandled = context.CompletionChar == '=';
89+
context.Editor.Caret.Offset--;
90+
new XamlCodeCompletionBinding().CtrlSpace(context.Editor);
91+
}
9092
} else if (xamlContext.Description == XamlContextDescription.InMarkupExtension && !string.IsNullOrEmpty(xamlContext.RawAttributeValue)) {
9193
string valuePart = xamlContext.RawAttributeValue.Substring(0, xamlContext.ValueStartOffset);
9294
AttributeValue value = MarkupExtensionParser.ParseValue(valuePart);

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/RotateThumb.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
3232
{
3333
public class RotateThumb : ResizeThumb
3434
{
35-
// private double initialAngle;
36-
// private RotateTransform rotateTransform;
37-
// private Vector startVector;
38-
// private Point centerPoint;
39-
// private Control designerItem;
40-
// private Panel canvas;
41-
// private AdornerPanel parent;
42-
4335
static RotateThumb()
4436
{
4537
DefaultStyleKeyProperty.OverrideMetadata(typeof(RotateThumb), new FrameworkPropertyMetadata(typeof(RotateThumb)));

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@
2626

2727
namespace ICSharpCode.WpfDesign.Designer.Controls
2828
{
29-
/// <summary>
30-
/// Display height of the element.
31-
/// </summary>
32-
class HeightDisplay : Control
33-
{
34-
static HeightDisplay()
35-
{
36-
DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
37-
}
38-
}
29+
/// <summary>
30+
/// Display height of the element.
31+
/// </summary>
32+
class HeightDisplay : Control
33+
{
34+
static HeightDisplay()
35+
{
36+
DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
37+
}
38+
}
3939

40-
/// <summary>
41-
/// Display width of the element.
42-
/// </summary>
43-
class WidthDisplay : Control
44-
{
45-
static WidthDisplay()
46-
{
47-
DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
48-
}
49-
}
40+
/// <summary>
41+
/// Display width of the element.
42+
/// </summary>
43+
class WidthDisplay : Control
44+
{
45+
static WidthDisplay()
46+
{
47+
DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
48+
}
49+
}
5050
}

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,55 +30,55 @@ public class ContentControlInitializer : DefaultInitializer
3030
{
3131
public override void InitializeDefaults(DesignItem item)
3232
{
33-
//Not every Content Control can have a text as Content (e.g. ZoomBox of WPF Toolkit)
34-
if (item.Component is Button)
35-
{
33+
//Not every Content Control can have a text as Content (e.g. ZoomBox of WPF Toolkit)
34+
if (item.Component is Button)
35+
{
3636
DesignItemProperty contentProperty = item.Properties["Content"];
37-
if (contentProperty.ValueOnInstance == null)
38-
{
37+
if (contentProperty.ValueOnInstance == null)
38+
{
3939
contentProperty.SetValue(item.ComponentType.Name);
4040
}
4141
}
4242

43-
DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
44-
if (verticalAlignmentProperty.ValueOnInstance == null)
45-
{
46-
verticalAlignmentProperty.SetValue(VerticalAlignment.Center);
47-
}
43+
DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
44+
if (verticalAlignmentProperty.ValueOnInstance == null)
45+
{
46+
verticalAlignmentProperty.SetValue(VerticalAlignment.Center);
47+
}
4848

49-
DesignItemProperty horizontalAlignmentProperty = item.Properties["HorizontalAlignment"];
50-
if (horizontalAlignmentProperty.ValueOnInstance == null)
51-
{
52-
horizontalAlignmentProperty.SetValue(HorizontalAlignment.Center);
53-
}
49+
DesignItemProperty horizontalAlignmentProperty = item.Properties["HorizontalAlignment"];
50+
if (horizontalAlignmentProperty.ValueOnInstance == null)
51+
{
52+
horizontalAlignmentProperty.SetValue(HorizontalAlignment.Center);
53+
}
5454
}
5555
}
5656

5757
[ExtensionFor(typeof(TextBlock))]
58-
public class TextBlockInitializer : DefaultInitializer
59-
{
60-
public override void InitializeDefaults(DesignItem item)
61-
{
62-
DesignItemProperty textProperty = item.Properties["Text"];
63-
if (textProperty.ValueOnInstance == null || textProperty.ValueOnInstance.ToString() == "")
64-
{
65-
textProperty.SetValue(item.ComponentType.Name);
66-
}
58+
public class TextBlockInitializer : DefaultInitializer
59+
{
60+
public override void InitializeDefaults(DesignItem item)
61+
{
62+
DesignItemProperty textProperty = item.Properties["Text"];
63+
if (textProperty.ValueOnInstance == null || textProperty.ValueOnInstance.ToString() == "")
64+
{
65+
textProperty.SetValue(item.ComponentType.Name);
66+
}
6767

68-
DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
69-
if (verticalAlignmentProperty.ValueOnInstance == null)
70-
{
71-
verticalAlignmentProperty.SetValue(VerticalAlignment.Center);
72-
}
68+
DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
69+
if (verticalAlignmentProperty.ValueOnInstance == null)
70+
{
71+
verticalAlignmentProperty.SetValue(VerticalAlignment.Center);
72+
}
7373

74-
DesignItemProperty horizontalAlignmentProperty = item.Properties["HorizontalAlignment"];
75-
if (horizontalAlignmentProperty.ValueOnInstance == null)
76-
{
77-
horizontalAlignmentProperty.SetValue(HorizontalAlignment.Center);
78-
}
79-
}
74+
DesignItemProperty horizontalAlignmentProperty = item.Properties["HorizontalAlignment"];
75+
if (horizontalAlignmentProperty.ValueOnInstance == null)
76+
{
77+
horizontalAlignmentProperty.SetValue(HorizontalAlignment.Center);
78+
}
79+
}
8080
}
81-
81+
8282
[ExtensionFor(typeof(HeaderedContentControl), OverrideExtension = typeof(ContentControlInitializer))]
8383
public class HeaderedContentControlInitializer : DefaultInitializer
8484
{
@@ -96,7 +96,7 @@ public override void InitializeDefaults(DesignItem item)
9696
}
9797
}
9898

99-
[ExtensionFor(typeof(Shape))]
99+
[ExtensionFor(typeof(Shape))]
100100
public class ShapeInitializer : DefaultInitializer
101101
{
102102
public override void InitializeDefaults(DesignItem item)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.RightClickMultipleItemsContextMenu"
2+
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer"
5+
>
6+
<MenuItem Header="{Binding WrapInCanvas, Source={x:Static Translation:Translations.Instance}}" Click="Click_WrapInCanvas" />
7+
<MenuItem Header="{Binding WrapInGrid, Source={x:Static Translation:Translations.Instance}}" Click="Click_WrapInGrid" />
8+
</ContextMenu>

src/AddIns/Misc/PackageManagement/Project/Src/SettingsFactory.cs renamed to src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickMultipleItemsContextMenu.xaml.cs

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,42 @@
1717
// DEALINGS IN THE SOFTWARE.
1818

1919
using System;
20-
using NuGet;
20+
using System.Collections.Generic;
21+
using System.Linq;
22+
using System.Text;
23+
using System.Windows;
24+
using System.Windows.Controls;
25+
using System.Windows.Data;
26+
using System.Windows.Documents;
27+
using System.Windows.Input;
28+
using System.Windows.Media;
29+
using System.Windows.Media.Imaging;
30+
using System.Windows.Navigation;
31+
using System.Windows.Shapes;
32+
using ICSharpCode.WpfDesign.PropertyGrid;
33+
using ICSharpCode.WpfDesign.Designer.Xaml;
2134

22-
namespace ICSharpCode.PackageManagement
35+
namespace ICSharpCode.WpfDesign.Designer.Extensions
2336
{
24-
public class SettingsFactory : ISettingsFactory
37+
public partial class RightClickMultipleItemsContextMenu
2538
{
26-
public ISettings CreateSettings(string directory)
39+
private DesignItem designItem;
40+
41+
public RightClickMultipleItemsContextMenu(DesignItem designItem)
2742
{
28-
var fileSystem = new PhysicalFileSystem(directory);
29-
return new Settings(fileSystem);
43+
this.designItem = designItem;
44+
45+
InitializeComponent();
46+
}
47+
48+
void Click_WrapInCanvas(object sender, System.Windows.RoutedEventArgs e)
49+
{
50+
ModelTools.WrapItemsNewContainer(this.designItem.Services.Selection.SelectedItems, typeof(Canvas));
51+
}
52+
53+
void Click_WrapInGrid(object sender, System.Windows.RoutedEventArgs e)
54+
{
55+
ModelTools.WrapItemsNewContainer(this.designItem.Services.Selection.SelectedItems, typeof(Grid));
3056
}
3157
}
3258
}

src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeSettingsFactory.cs renamed to src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickMultipleItemsContextMenuExtension.cs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,38 @@
1717
// DEALINGS IN THE SOFTWARE.
1818

1919
using System;
20-
using ICSharpCode.PackageManagement;
21-
using ICSharpCode.PackageManagement.Design;
22-
using NuGet;
20+
using System.Windows;
21+
using System.Windows.Media;
22+
using System.Windows.Shapes;
2323

24-
namespace PackageManagement.Tests.Helpers
24+
using ICSharpCode.WpfDesign.Adorners;
25+
using ICSharpCode.WpfDesign.Extensions;
26+
using ICSharpCode.WpfDesign.Designer;
27+
28+
namespace ICSharpCode.WpfDesign.Designer.Extensions
2529
{
26-
public class FakeSettingsFactory : ISettingsFactory
30+
/// <summary>
31+
///
32+
/// </summary>
33+
[ExtensionServer(typeof(MultipleSelectedExtensionServer))]
34+
[ExtensionFor(typeof(UIElement))]
35+
public class RightClickMultipleItemsContextMenuExtension : SelectionAdornerProvider
2736
{
28-
public FakeSettings FakeSettings = new FakeSettings();
29-
public string DirectoryPassedToCreateSettings;
37+
DesignPanel panel;
38+
39+
protected override void OnInitialized()
40+
{
41+
base.OnInitialized();
42+
43+
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
44+
panel.ContextMenu = new RightClickMultipleItemsContextMenu(ExtendedItem);
45+
}
3046

31-
public ISettings CreateSettings(string directory)
47+
protected override void OnRemove()
3248
{
33-
DirectoryPassedToCreateSettings = directory;
34-
return FakeSettings;
49+
panel.ContextMenu = null;
50+
51+
base.OnRemove();
3552
}
3653
}
3754
}

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,10 @@ public override void BeforeSetPosition(PlacementOperation operation)
115115
if (Snap(horizontalInput, horizontalMap, Accuracy, out drawLines, out delta)) {
116116

117117
if (operation.Type == PlacementType.Resize) {
118-
if (info.ResizeThumbAlignment.Vertical == VerticalAlignment.Top) {
119-
bounds.Y += delta;
120-
bounds.Height = Math.Max(0, bounds.Height - delta);
121-
} else {
122-
bounds.Height = Math.Max(0, bounds.Height + delta);
118+
if (info.ResizeThumbAlignment != null && info.ResizeThumbAlignment.Value.Vertical == VerticalAlignment.Top) {
119+
bounds.Y += delta;
123120
}
121+
bounds.Height = Math.Max(0, bounds.Height - delta);
124122
info.Bounds = bounds;
125123
} else {
126124
foreach (var item in operation.PlacedItems) {
@@ -138,12 +136,10 @@ public override void BeforeSetPosition(PlacementOperation operation)
138136
if (Snap(verticalInput, verticalMap, Accuracy, out drawLines, out delta)) {
139137

140138
if (operation.Type == PlacementType.Resize) {
141-
if (info.ResizeThumbAlignment.Horizontal == HorizontalAlignment.Left) {
142-
bounds.X += delta;
143-
bounds.Width = Math.Max(0, bounds.Width - delta);
144-
} else {
145-
bounds.Width = Math.Max(0, bounds.Width + delta);
139+
if (info.ResizeThumbAlignment != null && info.ResizeThumbAlignment.Value.Horizontal == HorizontalAlignment.Left) {
140+
bounds.X += delta;
146141
}
142+
bounds.Width = Math.Max(0, bounds.Width - delta);
147143
info.Bounds = bounds;
148144
} else {
149145
foreach (var item in operation.PlacedItems) {

0 commit comments

Comments
 (0)