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

Commit dae26c3

Browse files
Merge branch 'master' of github.com:icsharpcode/SharpDevelop
2 parents b2bdd81 + 2d27f61 commit dae26c3

8 files changed

Lines changed: 118 additions & 38 deletions

File tree

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -377,28 +377,35 @@ void DesignPanel_KeyDown(object sender, KeyEventArgs e)
377377
placementOp = PlacementOperation.Start(Context.Services.Selection.SelectedItems, PlacementType.Move);
378378
}
379379

380+
switch (e.Key) {
381+
case Key.Left:
382+
dx += Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1;
383+
break;
384+
case Key.Up:
385+
dy += Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1;
386+
break;
387+
case Key.Right:
388+
dx += Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1;
389+
break;
390+
case Key.Down:
391+
dy += Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1;
392+
break;
393+
}
380394

381-
dx = (e.Key == Key.Left) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0;
382-
dy = (e.Key == Key.Up) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0;
383-
dx = (e.Key == Key.Right) ? Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1 : (dx != 0 ? dx : 0);
384-
dy = (e.Key == Key.Down) ? Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1 : (dy != 0 ? dy : 0);
385-
double left, top;
386395
foreach (PlacementInformation info in placementOp.PlacedItems)
387396
{
388-
//Let canvas position preceed bounds definition since there can be a discrepancy between them.
389-
left = IsPropertySet(info.Item.View,Canvas.LeftProperty)?(double)info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).ValueOnInstance: info.OriginalBounds.Left;
390-
391-
top = IsPropertySet(info.Item.View, Canvas.TopProperty) ? (double)info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).ValueOnInstance : info.OriginalBounds.Top;
397+
var bounds = info.OriginalBounds;
398+
392399
if (!Keyboard.IsKeyDown(Key.LeftCtrl)) {
393-
info.Bounds = new Rect(left + dx,
394-
top + dy,
395-
info.OriginalBounds.Width,
396-
info.OriginalBounds.Height);
400+
info.Bounds = new Rect(bounds.Left + dx,
401+
bounds.Top + dy,
402+
bounds.Width,
403+
bounds.Height);
397404
} else {
398-
info.Bounds = new Rect(left,
399-
top,
400-
info.OriginalBounds.Width + dx,
401-
info.OriginalBounds.Height + dy);
405+
info.Bounds = new Rect(bounds.Left,
406+
bounds.Top,
407+
bounds.Width + dx,
408+
bounds.Height + dy);
402409
}
403410
placementOp.CurrentContainerBehavior.SetPosition(info);
404411
}

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

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,32 @@ protected override void OnInitialized()
5858
extendedView = (FrameworkElement)this.ExtendedItem.View;
5959
}
6060

61+
public override Rect GetPosition(PlacementOperation operation, DesignItem item)
62+
{
63+
UIElement child = item.View;
64+
65+
if (child == null)
66+
return Rect.Empty;
67+
68+
double x, y;
69+
70+
if (IsPropertySet(child, Canvas.LeftProperty) || !IsPropertySet(child, Canvas.RightProperty)) {
71+
x = GetCanvasProperty(child, Canvas.LeftProperty);
72+
} else {
73+
x = extendedComponent.ActualWidth - GetCanvasProperty(child, Canvas.RightProperty) - child.RenderSize.Width;
74+
}
75+
76+
77+
if (IsPropertySet(child, Canvas.TopProperty) || !IsPropertySet(child, Canvas.BottomProperty)) {
78+
y = GetCanvasProperty(child, Canvas.TopProperty);
79+
} else {
80+
y = extendedComponent.ActualHeight - GetCanvasProperty(child, Canvas.BottomProperty) - child.RenderSize.Height;
81+
}
82+
83+
var p = new Point(x, y);
84+
return new Rect(p, child.RenderSize);
85+
}
86+
6187
public override void SetPosition(PlacementInformation info)
6288
{
6389
base.SetPosition(info);
@@ -66,28 +92,26 @@ public override void SetPosition(PlacementInformation info)
6692
UIElement child = info.Item.View;
6793
Rect newPosition = info.Bounds;
6894

69-
if (IsPropertySet(child, Canvas.RightProperty))
70-
{
95+
if (IsPropertySet(child, Canvas.LeftProperty) || !IsPropertySet(child, Canvas.RightProperty)) {
96+
if (newPosition.Left != GetCanvasProperty(child, Canvas.LeftProperty)) {
97+
info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(newPosition.Left);
98+
}
99+
} else {
71100
var newR = extendedComponent.ActualWidth - newPosition.Right;
72101
if (newR != GetCanvasProperty(child, Canvas.RightProperty))
73102
info.Item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(newR);
74103
}
75-
else if (newPosition.Left != GetCanvasProperty(child, Canvas.LeftProperty))
76-
{
77-
info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(newPosition.Left);
78-
}
79104

80105

81-
if (IsPropertySet(child, Canvas.BottomProperty))
82-
{
106+
if (IsPropertySet(child, Canvas.TopProperty) || !IsPropertySet(child, Canvas.BottomProperty)) {
107+
if (newPosition.Top != GetCanvasProperty(child, Canvas.TopProperty)) {
108+
info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(newPosition.Top);
109+
}
110+
} else {
83111
var newB = extendedComponent.ActualHeight - newPosition.Bottom;
84112
if (newB != GetCanvasProperty(child, Canvas.BottomProperty))
85113
info.Item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(newB);
86114
}
87-
else if (newPosition.Top != GetCanvasProperty(child, Canvas.TopProperty))
88-
{
89-
info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(newPosition.Top);
90-
}
91115

92116
if (info.Item == Services.Selection.PrimarySelection)
93117
{

src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
using System;
2020
using System.Collections.Generic;
21+
using System.Linq;
22+
2123
using NuGet;
2224

2325
namespace ICSharpCode.PackageManagement.Design
@@ -36,6 +38,8 @@ public List<KeyValuePair<string, string>> DisabledPackageSources
3638
public Dictionary<string, IList<KeyValuePair<string, string>>> Sections
3739
= new Dictionary<string, IList<KeyValuePair<string, string>>>();
3840

41+
public const string ConfigSectionName = "config";
42+
3943
public FakeSettings()
4044
{
4145
Sections.Add(RegisteredPackageSourceSettings.PackageSourcesSectionName, PackageSources);
@@ -200,7 +204,11 @@ public bool IsPackageRestoreSectionDeleted {
200204

201205
public string GetValue(string section, string key, bool isPath)
202206
{
203-
throw new NotImplementedException();
207+
if (Sections.ContainsKey(section)) {
208+
var matchedSection = Sections[section];
209+
return matchedSection.FirstOrDefault(item => item.Key == key).Value;
210+
}
211+
return null;
204212
}
205213

206214
public IList<KeyValuePair<string, string>> GetValues(string section, bool isPath)
@@ -212,5 +220,12 @@ public IList<SettingValue> GetSettingValues(string section, bool isPath)
212220
{
213221
throw new NotImplementedException();
214222
}
223+
224+
public void SetRepositoryPathSetting(string fullPath)
225+
{
226+
var items = new List<KeyValuePair<string, string>> ();
227+
items.Add (new KeyValuePair<string, string>("repositoryPath", fullPath));
228+
Sections.Add(ConfigSectionName, items);
229+
}
215230
}
216231
}

src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,10 @@ void RecentPackagesCollectionChanged(object sender, NotifyCollectionChangedEvent
9595
{
9696
properties.SetList(RecentPackagesPropertyName, recentPackages);
9797
}
98+
99+
public string GetCustomPackagesDirectory()
100+
{
101+
return registeredPackageSourceSettings.Settings.GetRepositoryPath();
102+
}
98103
}
99104
}

src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,9 @@ void ResetPackageSources()
204204
packageSources = null;
205205
}
206206
}
207+
208+
public ISettings Settings {
209+
get { return settings; }
210+
}
207211
}
208212
}

src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageManagerFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public SharpDevelopPackageManagerFactory()
3232
: this(
3333
new SharpDevelopPackageRepositoryFactory(),
3434
new SharpDevelopProjectSystemFactory(),
35-
new PackageManagementOptions())
35+
PackageManagementServices.Options)
3636
{
3737
}
3838

src/AddIns/Misc/PackageManagement/Project/Src/SolutionPackageRepositoryPath.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ namespace ICSharpCode.PackageManagement
2525
{
2626
public class SolutionPackageRepositoryPath
2727
{
28-
string packagesRelativeDirectory;
2928
ISolution solution;
3029
DefaultPackagePathResolver pathResolver;
3130

3231
public SolutionPackageRepositoryPath(IProject project)
33-
: this(project, new PackageManagementOptions())
32+
: this(project, PackageManagementServices.Options)
3433
{
3534
}
3635

@@ -41,14 +40,18 @@ public SolutionPackageRepositoryPath(IProject project, PackageManagementOptions
4140

4241
public SolutionPackageRepositoryPath(ISolution solution, PackageManagementOptions options)
4342
{
44-
packagesRelativeDirectory = options.PackagesDirectory;
4543
this.solution = solution;
46-
GetSolutionPackageRepositoryPath();
44+
PackageRepositoryPath = GetSolutionPackageRepositoryPath(options);
4745
}
4846

49-
void GetSolutionPackageRepositoryPath()
47+
string GetSolutionPackageRepositoryPath(PackageManagementOptions options)
5048
{
51-
PackageRepositoryPath = Path.Combine(solution.Directory, packagesRelativeDirectory);
49+
string customPath = options.GetCustomPackagesDirectory ();
50+
if (!String.IsNullOrEmpty (customPath)) {
51+
return customPath;
52+
}
53+
54+
return Path.Combine (solution.Directory, options.PackagesDirectory);
5255
}
5356

5457
public string PackageRepositoryPath { get; private set; }

src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryPathTests.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ public class SolutionPackageRepositoryPathTests
3232
{
3333
SolutionPackageRepositoryPath repositoryPath;
3434
IProject testProject;
35-
PackageManagementOptions options;
35+
TestablePackageManagementOptions options;
3636
ISolution solution;
37+
FakeSettings settings;
3738

3839
void CreateSolutionPackageRepositoryPath()
3940
{
@@ -61,6 +62,12 @@ void CreateSolution(string fileName)
6162
void CreateOptions()
6263
{
6364
options = new TestablePackageManagementOptions();
65+
settings = options.FakeSettings;
66+
}
67+
68+
void SolutionNuGetConfigFileHasCustomPackagesPath(string fullPath)
69+
{
70+
settings.SetRepositoryPathSetting(fullPath);
6471
}
6572

6673
[Test]
@@ -109,5 +116,20 @@ public void GetInstallPath_GetInstallPathForPackage_ReturnsPackagePathInsideSolu
109116

110117
Assert.AreEqual(expectedInstallPath, installPath);
111118
}
119+
120+
[Test]
121+
public void PackageRepositoryPath_SolutionHasNuGetFileThatOverridesDefaultPackagesRepositoryPath_OverriddenPathReturned()
122+
{
123+
CreateOptions();
124+
CreateSolution(@"d:\projects\MySolution\MySolution.sln");
125+
options.PackagesDirectory = "Packages";
126+
SolutionNuGetConfigFileHasCustomPackagesPath(@"d:\Team\MyPackages");
127+
CreateSolutionPackageRepositoryPath(solution);
128+
string expectedPath = @"d:\Team\MyPackages";
129+
130+
string path = repositoryPath.PackageRepositoryPath;
131+
132+
Assert.AreEqual(expectedPath, path);
133+
}
112134
}
113135
}

0 commit comments

Comments
 (0)