Browse Source

Revert "Merge remote-tracking branch 'remotes/origin/master' into WpfDesignerPartialPanelSelectionHandler"

This reverts commit 352d2dcaca, reversing
changes made to aa59343fa8.
pull/521/head
tbulle 11 years ago
parent
commit
d690ae5280
  1. BIN
      data/templates/packages/Modernizr.2.5.3.nupkg
  2. BIN
      data/templates/packages/jQuery.1.7.2.nupkg
  3. 1
      src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj
  4. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs
  5. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs
  6. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  7. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
  8. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs
  9. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SizeDisplayExtension.cs
  10. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs
  11. 220
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
  12. 225
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs
  13. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs
  14. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs
  15. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs
  16. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs
  17. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
  18. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs
  19. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  20. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
  21. 39
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
  22. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/HierarchyTests.cs
  23. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs
  24. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/SelectionTests.cs
  25. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
  26. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
  27. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs
  28. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs
  29. 35
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
  30. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
  31. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
  32. 79
      src/AddIns/Misc/PackageManagement/Project/Src/InstalledPackageViewModel.cs
  33. 89
      src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs
  34. 64
      src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSources.cs
  35. 26
      src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSourcesView.xaml
  36. 88
      src/AddIns/Misc/PackageManagement/Test/Src/CodeGeneratorTests.cs
  37. 120
      src/AddIns/Misc/PackageManagement/Test/Src/ProjectTemplatePackageRepositoryCacheTests.cs
  38. 103
      src/AddIns/Misc/PackageManagement/Test/Src/RegisteredProjectTemplatePackageSourcesTests.cs

BIN
data/templates/packages/Modernizr.2.5.3.nupkg

Binary file not shown.

BIN
data/templates/packages/jQuery.1.7.2.nupkg

Binary file not shown.

1
src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj

@ -54,7 +54,6 @@
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Design" /> <Reference Include="System.Design" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Design" /> <Reference Include="System.Drawing.Design" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml"> <Reference Include="System.Xaml">

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs

@ -45,7 +45,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public static readonly DependencyProperty ResizeThumbVisibleProperty public static readonly DependencyProperty ResizeThumbVisibleProperty
= DependencyProperty.Register("ResizeThumbVisible", typeof(bool), typeof(ResizeThumb), new FrameworkPropertyMetadata(true)); = DependencyProperty.Register("ResizeThumbVisible", typeof(bool), typeof(ResizeThumb), new FrameworkPropertyMetadata(true));
public PlacementAlignment Alignment; internal PlacementAlignment Alignment;
static ResizeThumb() static ResizeThumb()
{ {

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

@ -29,7 +29,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary> /// <summary>
/// Display height of the element. /// Display height of the element.
/// </summary> /// </summary>
public class HeightDisplay : Control class HeightDisplay : Control
{ {
static HeightDisplay() static HeightDisplay()
{ {
@ -40,7 +40,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary> /// <summary>
/// Display width of the element. /// Display width of the element.
/// </summary> /// </summary>
public class WidthDisplay : Control class WidthDisplay : Control
{ {
static WidthDisplay() static WidthDisplay()
{ {

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

@ -112,14 +112,11 @@ namespace ICSharpCode.WpfDesign.Designer
bool continueHitTest = true; bool continueHitTest = true;
HitTestFilterCallback filterBehavior = CustomHitTestFilterBehavior ?? FilterHitTestInvisibleElements;
CustomHitTestFilterBehavior = null;
hitTestElements.Clear(); hitTestElements.Clear();
if (testAdorners) { if (testAdorners) {
RunHitTest( RunHitTest(
_adornerLayer, mousePosition, filterBehavior, _adornerLayer, mousePosition, FilterHitTestInvisibleElements,
delegate(HitTestResult result) { delegate(HitTestResult result) {
if (result != null && result.VisualHit != null && result.VisualHit is Visual) { if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit); DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
@ -141,7 +138,7 @@ namespace ICSharpCode.WpfDesign.Designer
if (continueHitTest && testDesignSurface) { if (continueHitTest && testDesignSurface) {
RunHitTest( RunHitTest(
this.Child, mousePosition, filterBehavior, this.Child, mousePosition, FilterHitTestInvisibleElements,
delegate(HitTestResult result) { delegate(HitTestResult result) {
if (result != null && result.VisualHit != null && result.VisualHit is Visual) { if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit); DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
@ -213,8 +210,6 @@ namespace ICSharpCode.WpfDesign.Designer
#region Properties #region Properties
//Set custom HitTestFilterCallbak
public HitTestFilterCallback CustomHitTestFilterBehavior { get; set; }
/// <summary> /// <summary>
/// Gets/Sets the design context. /// Gets/Sets the design context.
/// </summary> /// </summary>

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs

@ -31,19 +31,6 @@ namespace ICSharpCode.WpfDesign.Designer
{ {
public static class ExtensionMethods public static class ExtensionMethods
{ {
public static bool AnyIsInNamespace(this Type type, string namespacestr)
{
Type t = type;
while (t!=null)
{
if (t.Namespace.Equals(namespacestr))
return true;
t = t.BaseType;
}
return false;
}
public static double Coerce(this double value, double min, double max) public static double Coerce(this double value, double min, double max)
{ {
return Math.Max(Math.Min(value, max), min); return Math.Max(Math.Min(value, max), min);

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// </summary> /// </summary>
[ExtensionServer(typeof(OnlyOneItemSelectedExtensionServer))] [ExtensionServer(typeof(OnlyOneItemSelectedExtensionServer))]
[ExtensionFor(typeof (FrameworkElement))] [ExtensionFor(typeof (FrameworkElement))]
public class QuickOperationMenuExtension : PrimarySelectionAdornerProvider class QuickOperationMenuExtension : PrimarySelectionAdornerProvider
{ {
private QuickOperationMenu _menu; private QuickOperationMenu _menu;
private KeyBinding _keyBinding; private KeyBinding _keyBinding;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SizeDisplayExtension.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// Display Height/Width on the primary selection /// Display Height/Width on the primary selection
/// </summary> /// </summary>
[ExtensionFor(typeof(UIElement))] [ExtensionFor(typeof(UIElement))]
public class SizeDisplayExtension : PrimarySelectionAdornerProvider class SizeDisplayExtension : PrimarySelectionAdornerProvider
{ {
HeightDisplay _heightDisplay; HeightDisplay _heightDisplay;
WidthDisplay _widthDisplay; WidthDisplay _widthDisplay;

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs

@ -40,11 +40,10 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
} }
public static readonly DependencyProperty RootProperty = public static readonly DependencyProperty RootProperty =
DependencyProperty.Register("Root", typeof(IOutlineNode), typeof(Outline)); DependencyProperty.Register("Root", typeof(OutlineNode), typeof(Outline));
public IOutlineNode Root public OutlineNode Root {
{ get { return (OutlineNode)GetValue(RootProperty); }
get { return (IOutlineNode)GetValue(RootProperty); }
set { SetValue(RootProperty, value); } set { SetValue(RootProperty, value); }
} }

220
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs

@ -34,45 +34,138 @@ using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer.OutlineView namespace ICSharpCode.WpfDesign.Designer.OutlineView
{ {
public interface IOutlineNode public class OutlineNode : INotifyPropertyChanged
{ {
ISelectionService SelectionService { get; } //Used to check if element can enter other containers
bool IsExpanded { get; set; } public static PlacementType DummyPlacementType;
DesignItem DesignItem { get; set; }
bool IsSelected { get; set; }
bool IsDesignTimeVisible { get; set; }
bool IsDesignTimeLocked { get; }
string Name { get; }
bool CanInsert(IEnumerable<IOutlineNode> nodes, IOutlineNode after, bool copy);
void Insert(IEnumerable<IOutlineNode> nodes, IOutlineNode after, bool copy);
ObservableCollection<IOutlineNode> Children{ get; }
}
public class OutlineNode: OutlineNodeBase static OutlineNode()
{
DummyPlacementType = PlacementType.Register("DummyPlacement");
}
public static OutlineNode Create(DesignItem designItem)
{ {
OutlineNode node;
if (!outlineNodes.TryGetValue(designItem, out node)) {
node = new OutlineNode(designItem);
outlineNodes[designItem] = node;
}
return node;
}
//TODO: Reset with DesignContext //TODO: Reset with DesignContext
static Dictionary<DesignItem, IOutlineNode> outlineNodes = new Dictionary<DesignItem, IOutlineNode>(); static Dictionary<DesignItem, OutlineNode> outlineNodes = new Dictionary<DesignItem, OutlineNode>();
protected OutlineNode(DesignItem designitem): base(designitem) OutlineNode(DesignItem designItem)
{ {
DesignItem = designItem;
UpdateChildren(); UpdateChildren();
var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance;
if (hidden != null && (bool) hidden == true) {
this._isDesignTimeVisible = false;
((FrameworkElement) this.DesignItem.Component).Visibility = Visibility.Hidden;
}
var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance;
if (locked != null && (bool) locked == true) {
this._isDesignTimeLocked = true;
}
//TODO
DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged);
DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged);
SelectionService.SelectionChanged += new EventHandler<DesignItemCollectionEventArgs>(Selection_SelectionChanged); SelectionService.SelectionChanged += new EventHandler<DesignItemCollectionEventArgs>(Selection_SelectionChanged);
} }
static OutlineNode() public DesignItem DesignItem { get; private set; }
public ISelectionService SelectionService {
get { return DesignItem.Services.Selection; }
}
bool isExpanded = true;
public bool IsExpanded {
get {
return isExpanded;
}
set {
isExpanded = value;
RaisePropertyChanged("IsExpanded");
}
}
bool isSelected;
public bool IsSelected {
get {
return isSelected;
}
set {
if (isSelected != value) {
isSelected = value;
SelectionService.SetSelectedComponents(new[] { DesignItem },
value ? SelectionTypes.Add : SelectionTypes.Remove);
RaisePropertyChanged("IsSelected");
}
}
}
bool _isDesignTimeVisible = true;
public bool IsDesignTimeVisible
{ {
DummyPlacementType = PlacementType.Register("DummyPlacement"); get {
return _isDesignTimeVisible;
}
set {
_isDesignTimeVisible = value;
var ctl = DesignItem.Component as UIElement;
ctl.Visibility = _isDesignTimeVisible ? Visibility.Visible : Visibility.Hidden;
RaisePropertyChanged("IsDesignTimeVisible");
if (!value)
DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).SetValue(true);
else
DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).Reset();
}
} }
public static IOutlineNode Create(DesignItem designItem) bool _isDesignTimeLocked = false;
public bool IsDesignTimeLocked
{ {
IOutlineNode node; get {
if (!outlineNodes.TryGetValue(designItem, out node)) { return _isDesignTimeLocked;
node = new OutlineNode(designItem); }
outlineNodes[designItem] = node; set {
_isDesignTimeLocked = value;
((XamlDesignItem)DesignItem).IsDesignTimeLocked = _isDesignTimeLocked;
RaisePropertyChanged("IsDesignTimeLocked");
// if (value)
// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).SetValue(true);
// else
// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset();
}
}
ObservableCollection<OutlineNode> children = new ObservableCollection<OutlineNode>();
public ObservableCollection<OutlineNode> Children {
get { return children; }
}
public string Name {
get {
if (string.IsNullOrEmpty(DesignItem.Name)) {
return DesignItem.ComponentType.Name;
}
return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")";
} }
return node;
} }
void Selection_SelectionChanged(object sender, DesignItemCollectionEventArgs e) void Selection_SelectionChanged(object sender, DesignItemCollectionEventArgs e)
@ -80,7 +173,19 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
IsSelected = DesignItem.Services.Selection.IsComponentSelected(DesignItem); IsSelected = DesignItem.Services.Selection.IsComponentSelected(DesignItem);
} }
protected override void UpdateChildren() void DesignItem_NameChanged(object sender, EventArgs e)
{
RaisePropertyChanged("Name");
}
void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == DesignItem.ContentPropertyName) {
UpdateChildren();
}
}
void UpdateChildren()
{ {
Children.Clear(); Children.Clear();
@ -88,7 +193,8 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
var content = DesignItem.ContentProperty; var content = DesignItem.ContentProperty;
if (content.IsCollection) { if (content.IsCollection) {
UpdateChildrenCore(content.CollectionElements); UpdateChildrenCore(content.CollectionElements);
} else { }
else {
if (content.Value != null) { if (content.Value != null) {
UpdateChildrenCore(new[] { content.Value }); UpdateChildrenCore(new[] { content.Value });
} }
@ -102,12 +208,16 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
if (ModelTools.CanSelectComponent(item)) { if (ModelTools.CanSelectComponent(item)) {
var node = OutlineNode.Create(item); var node = OutlineNode.Create(item);
Children.Add(node); Children.Add(node);
} else { }
else
{
var content = item.ContentProperty; var content = item.ContentProperty;
if (content != null) { if (content != null)
{
if (content.IsCollection) { if (content.IsCollection) {
UpdateChildrenCore(content.CollectionElements); UpdateChildrenCore(content.CollectionElements);
} else { }
else {
if (content.Value != null) { if (content.Value != null) {
UpdateChildrenCore(new[] { content.Value }); UpdateChildrenCore(new[] { content.Value });
} }
@ -116,5 +226,57 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
} }
} }
} }
public bool CanInsert(IEnumerable<OutlineNode> nodes, OutlineNode after, bool copy)
{
var placementBehavior = DesignItem.GetBehavior<IPlacementBehavior>();
if (placementBehavior == null)
return false;
var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType);
if (operation != null) {
bool canEnter = placementBehavior.CanEnterContainer(operation, true);
operation.Abort();
return canEnter;
}
return false;
}
public void Insert(IEnumerable<OutlineNode> nodes, OutlineNode after, bool copy)
{
using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) {
if (copy) {
nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList();
} else {
foreach (var node in nodes) {
node.DesignItem.Remove();
}
}
var index = after == null ? 0 : Children.IndexOf(after) + 1;
var content = DesignItem.ContentProperty;
if (content.IsCollection) {
foreach (var node in nodes) {
content.CollectionElements.Insert(index++, node.DesignItem);
}
} else {
content.SetValue(nodes.First().DesignItem);
}
moveTransaction.Commit();
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
} }
} }

225
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs

@ -1,225 +0,0 @@
/*
* Created by SharpDevelop.
* User: trubra
* Date: 2014-01-28
* Time: 10:09
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Linq;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
/// <summary>
/// Description of OutlineNodeBase.
/// </summary>
public abstract class OutlineNodeBase : INotifyPropertyChanged, IOutlineNode
{
protected abstract void UpdateChildren();
//Used to check if element can enter other containers
protected static PlacementType DummyPlacementType;
protected OutlineNodeBase(DesignItem designItem)
{
DesignItem = designItem;
var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance;
if (hidden != null && (bool)hidden) {
_isDesignTimeVisible = false;
((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden;
}
var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance;
if (locked != null && (bool)locked) {
_isDesignTimeLocked = true;
}
//TODO
DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged);
DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged);
}
public DesignItem DesignItem { get; set; }
public ISelectionService SelectionService
{
get { return DesignItem.Services.Selection; }
}
bool isExpanded = true;
public bool IsExpanded
{
get
{
return isExpanded;
}
set
{
isExpanded = value;
RaisePropertyChanged("IsExpanded");
}
}
bool isSelected;
public bool IsSelected
{
get
{
return isSelected;
}
set
{
if (isSelected != value) {
isSelected = value;
SelectionService.SetSelectedComponents(new[] { DesignItem },
value ? SelectionTypes.Add : SelectionTypes.Remove);
RaisePropertyChanged("IsSelected");
}
}
}
bool _isDesignTimeVisible = true;
public bool IsDesignTimeVisible
{
get
{
return _isDesignTimeVisible;
}
set
{
_isDesignTimeVisible = value;
var ctl = DesignItem.Component as UIElement;
if(ctl!=null)
ctl.Visibility = _isDesignTimeVisible ? Visibility.Visible : Visibility.Hidden;
RaisePropertyChanged("IsDesignTimeVisible");
if (!value)
DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).SetValue(true);
else
DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).Reset();
}
}
bool _isDesignTimeLocked = false;
public bool IsDesignTimeLocked
{
get
{
return _isDesignTimeLocked;
}
set
{
_isDesignTimeLocked = value;
((XamlDesignItem)DesignItem).IsDesignTimeLocked = _isDesignTimeLocked;
RaisePropertyChanged("IsDesignTimeLocked");
// if (value)
// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).SetValue(true);
// else
// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset();
}
}
ObservableCollection<IOutlineNode> children = new ObservableCollection<IOutlineNode>();
public ObservableCollection<IOutlineNode> Children
{
get { return children; }
}
public string Name
{
get
{
if (string.IsNullOrEmpty(DesignItem.Name)) {
return DesignItem.ComponentType.Name;
}
return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")";
}
}
void DesignItem_NameChanged(object sender, EventArgs e)
{
RaisePropertyChanged("Name");
}
void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == DesignItem.ContentPropertyName) {
UpdateChildren();
}
}
public bool CanInsert(IEnumerable<IOutlineNode> nodes, IOutlineNode after, bool copy)
{
var placementBehavior = DesignItem.GetBehavior<IPlacementBehavior>();
if (placementBehavior == null)
return false;
var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType);
if (operation != null) {
bool canEnter = placementBehavior.CanEnterContainer(operation, true);
operation.Abort();
return canEnter;
}
return false;
}
public virtual void Insert(IEnumerable<IOutlineNode> nodes, IOutlineNode after, bool copy)
{
using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList()))
{
if (copy) {
nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList();
} else {
foreach (var node in nodes) {
node.DesignItem.Remove();
}
}
var index = after == null ? 0 : Children.IndexOf(after) + 1;
var content = DesignItem.ContentProperty;
if (content.IsCollection) {
foreach (var node in nodes) {
content.CollectionElements.Insert(index++, node.DesignItem);
}
} else {
content.SetValue(nodes.First().DesignItem);
}
moveTransaction.Commit();
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
}

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs

@ -28,30 +28,30 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
protected override bool CanInsert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy) protected override bool CanInsert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
{ {
UpdateCustomNodes(items); UpdateCustomNodes(items);
return (target.DataContext as IOutlineNode).CanInsert(_customOutlineNodes, return (target.DataContext as OutlineNode).CanInsert(_customOutlineNodes,
after == null ? null : after.DataContext as IOutlineNode, copy); after == null ? null : after.DataContext as OutlineNode, copy);
} }
protected override void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy) protected override void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
{ {
UpdateCustomNodes(items); UpdateCustomNodes(items);
(target.DataContext as IOutlineNode).Insert(_customOutlineNodes, (target.DataContext as OutlineNode).Insert(_customOutlineNodes,
after == null ? null : after.DataContext as IOutlineNode, copy); after == null ? null : after.DataContext as OutlineNode, copy);
} }
// Need to do this through a seperate List since previously LINQ queries apparently disconnected DataContext;bug in .NET 4.0 // Need to do this through a seperate List since previously LINQ queries apparently disconnected DataContext;bug in .NET 4.0
private List<IOutlineNode> _customOutlineNodes; private List<OutlineNode> _customOutlineNodes;
void UpdateCustomNodes(IEnumerable<DragTreeViewItem> items) void UpdateCustomNodes(IEnumerable<DragTreeViewItem> items)
{ {
_customOutlineNodes = new List<IOutlineNode>(); _customOutlineNodes = new List<OutlineNode>();
foreach (var item in items) foreach (var item in items)
_customOutlineNodes.Add(item.DataContext as IOutlineNode); _customOutlineNodes.Add(item.DataContext as OutlineNode);
} }
public override bool ShouldItemBeVisible(DragTreeViewItem dragTreeViewitem) public override bool ShouldItemBeVisible(DragTreeViewItem dragTreeViewitem)
{ {
var node = dragTreeViewitem.DataContext as IOutlineNode; var node = dragTreeViewitem.DataContext as OutlineNode;
return string.IsNullOrEmpty(Filter) || node.Name.ToLower().Contains(Filter.ToLower()); return string.IsNullOrEmpty(Filter) || node.Name.ToLower().Contains(Filter.ToLower());
} }
@ -60,7 +60,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{ {
base.SelectOnly(item); base.SelectOnly(item);
var node = item.DataContext as IOutlineNode; var node = item.DataContext as OutlineNode;
var surface = node.DesignItem.View.TryFindParent<DesignSurface>(); var surface = node.DesignItem.View.TryFindParent<DesignSurface>();
if (surface != null) if (surface != null)

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs

@ -64,7 +64,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
if(control!=null){ if(control!=null){
TypeMappings.TryGetValue(control.GetType(), out _type); TypeMappings.TryGetValue(control.GetType(), out _type);
if (_type != null) { if (_type != null) {
IOutlineNode node = OutlineNode.Create(item); OutlineNode node = OutlineNode.Create(item);
Outline.Root = node; Outline.Root = node;
PropertyGridView.PropertyGrid.SelectedItems = item.Services.Selection.SelectedItems; PropertyGridView.PropertyGrid.SelectedItems = item.Services.Selection.SelectedItems;
} }

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs

@ -35,19 +35,7 @@ using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{ {
public interface IPropertyGrid public class PropertyGrid : INotifyPropertyChanged
{
IEnumerable<DesignItem> SelectedItems { get; set; }
Dictionary<MemberDescriptor, PropertyNode> NodeFromDescriptor { get; }
DesignItem SingleItem { get; }
string Name { get; set; }
string OldName { get; }
bool IsNameCorrect { get; set; }
bool ReloadActive { get; }
event EventHandler AggregatePropertiesUpdated;
event PropertyChangedEventHandler PropertyChanged;
}
public class PropertyGrid : INotifyPropertyChanged, IPropertyGrid
{ {
public PropertyGrid() public PropertyGrid()
{ {
@ -67,13 +55,9 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
Dictionary<MemberDescriptor, PropertyNode> nodeFromDescriptor = new Dictionary<MemberDescriptor, PropertyNode>(); Dictionary<MemberDescriptor, PropertyNode> nodeFromDescriptor = new Dictionary<MemberDescriptor, PropertyNode>();
public Dictionary<MemberDescriptor, PropertyNode> NodeFromDescriptor { get { return nodeFromDescriptor; } }
public CategoriesCollection Categories { get; private set; } public CategoriesCollection Categories { get; private set; }
public PropertyNodeCollection Events { get; private set; } public PropertyNodeCollection Events { get; private set; }
public event EventHandler AggregatePropertiesUpdated;
private PropertyGridGroupMode _groupMode; private PropertyGridGroupMode _groupMode;
public PropertyGridGroupMode GroupMode public PropertyGridGroupMode GroupMode
@ -236,8 +220,6 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
} }
} finally { } finally {
reloadActive = false; reloadActive = false;
if (AggregatePropertiesUpdated != null)
AggregatePropertiesUpdated(this, EventArgs.Empty);
} }
} }

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs

@ -42,13 +42,10 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyGridView), new FrameworkPropertyMetadata(typeof(PropertyGridView))); DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyGridView), new FrameworkPropertyMetadata(typeof(PropertyGridView)));
} }
public PropertyGridView() : this(null)
{
}
public PropertyGridView(IPropertyGrid pg) public PropertyGridView()
{ {
PropertyGrid = pg??new PropertyGrid(); PropertyGrid = new PropertyGrid();
DataContext = PropertyGrid; DataContext = PropertyGrid;
} }
@ -64,7 +61,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
static PropertyContextMenu propertyContextMenu = new PropertyContextMenu(); static PropertyContextMenu propertyContextMenu = new PropertyContextMenu();
public IPropertyGrid PropertyGrid { get; private set; } public PropertyGrid PropertyGrid { get; private set; }
public static readonly DependencyProperty FirstColumnWidthProperty = public static readonly DependencyProperty FirstColumnWidthProperty =
DependencyProperty.Register("FirstColumnWidth", typeof(double), typeof(PropertyGridView), DependencyProperty.Register("FirstColumnWidth", typeof(double), typeof(PropertyGridView),

21
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs

@ -20,7 +20,6 @@ using System.Windows;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Designer.Controls;
@ -152,31 +151,15 @@ namespace ICSharpCode.WpfDesign.Designer.Services
protected virtual DesignItem CreateItem(DesignContext context) protected virtual DesignItem CreateItem(DesignContext context)
{ {
object newInstance = context.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory(componentType, null); object newInstance = context.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory(componentType, null);
DesignItem item = context.Services.Component.RegisterComponentForDesigner(newInstance, componentType); DesignItem item = context.Services.Component.RegisterComponentForDesigner(newInstance);
changeGroup = item.OpenGroup("Drop Control"); changeGroup = item.OpenGroup("Drop Control");
context.Services.ExtensionManager.ApplyDefaultInitializers(item); context.Services.ExtensionManager.ApplyDefaultInitializers(item);
return item; return item;
} }
public static bool AddItemWithCustomSizePosition(DesignItem container, Type createdItem, Size size, Point position)
{
CreateComponentTool cct = new CreateComponentTool(createdItem);
return AddItemWithCustomSize(container, cct.CreateItem(container.Context), position, size);
}
public static bool AddItemWithDefaultSize(DesignItem container, Type createdItem, Size size)
{
CreateComponentTool cct = new CreateComponentTool(createdItem);
return AddItemWithCustomSize(container, cct.CreateItem(container.Context), new Point(0, 0), size);
}
internal static bool AddItemWithDefaultSize(DesignItem container, DesignItem createdItem, Point position) internal static bool AddItemWithDefaultSize(DesignItem container, DesignItem createdItem, Point position)
{ {
return AddItemWithCustomSize(container, createdItem, position, ModelTools.GetDefaultSize(createdItem)); var size = ModelTools.GetDefaultSize(createdItem);
}
internal static bool AddItemWithCustomSize(DesignItem container, DesignItem createdItem, Point position, Size size)
{
PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents( PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents(
container, container,
new DesignItem[] { createdItem }, new DesignItem[] { createdItem },

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Services namespace ICSharpCode.WpfDesign.Designer.Services
{ {
// See IToolService for description. // See IToolService for description.
@ -37,11 +37,6 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}); });
} }
public HitTestFilterCallback DesignPanelHitTestFilterCallback
{
set{ _designPanel.CustomHitTestFilterBehavior = value; }
}
public void Dispose() public void Dispose()
{ {
if (_designPanel != null) { if (_designPanel != null) {

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -91,7 +91,6 @@
</Compile> </Compile>
<Compile Include="Extensions\RenderTransformOriginExtension.cs" /> <Compile Include="Extensions\RenderTransformOriginExtension.cs" />
<Compile Include="Extensions\RightClickContextMenuExtension.cs" /> <Compile Include="Extensions\RightClickContextMenuExtension.cs" />
<Compile Include="OutlineView\OutlineNodeBase.cs" />
<Compile Include="Extensions\RightClickMultipleItemsContextMenuExtension.cs" /> <Compile Include="Extensions\RightClickMultipleItemsContextMenuExtension.cs" />
<Compile Include="Extensions\RightClickMultipleItemsContextMenu.xaml.cs"> <Compile Include="Extensions\RightClickMultipleItemsContextMenu.xaml.cs">
<DependentUpon>RightClickMultipleItemsContextMenu.xaml</DependentUpon> <DependentUpon>RightClickMultipleItemsContextMenu.xaml</DependentUpon>

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs

@ -21,7 +21,7 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Windows.Markup; using System.Windows.Markup;
using System.Windows; using System.Windows;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.XamlDom; using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer.Xaml namespace ICSharpCode.WpfDesign.Designer.Xaml
@ -68,7 +68,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
return site; return site;
} }
public DesignItem RegisterComponentForDesigner(object component, Type basetype = null) public DesignItem RegisterComponentForDesigner(object component)
{ {
if (component == null) { if (component == null) {
component = new NullExtension(); component = new NullExtension();
@ -76,10 +76,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
component = new TypeExtension((Type)component); component = new TypeExtension((Type)component);
} }
object baseobject = basetype != null && component.GetType()!=basetype ? CustomInstanceFactory.CreateObjectInstance(basetype, null) : null; XamlDesignItem item = new XamlDesignItem(_context.Document.CreateObject(component), _context);
XamlObject xamlobj = _context.Document.CreateObject(component, baseobject);
XamlDesignItem item = new XamlDesignItem(xamlobj, _context);
_sites.Add(component, item); _sites.Add(component, item);
if (ComponentRegistered != null) { if (ComponentRegistered != null) {
ComponentRegistered(this, new DesignItemEventArgs(item)); ComponentRegistered(this, new DesignItemEventArgs(item));

39
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs

@ -668,52 +668,31 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
} }
[Test] [Test]
public void AddNativeTypeAsResource(object component, string expectedXamlValue) public void AddStringAsResource()
{ {
DesignItem textBlock = CreateCanvasContext("<TextBlock/>"); DesignItem textBlock = CreateCanvasContext("<TextBlock/>");
DesignItem canvas = textBlock.Parent; DesignItem canvas = textBlock.Parent;
DesignItemProperty canvasResources = canvas.Properties.GetProperty("Resources"); DesignItemProperty canvasResources = canvas.Properties.GetProperty("Resources");
DesignItem componentItem = canvas.Services.Component.RegisterComponentForDesigner(component); DesignItem str = canvas.Services.Component.RegisterComponentForDesigner("stringresource 1");
componentItem.Key = "res1"; str.Key = "str1";
Assert.IsTrue(canvasResources.IsCollection); Assert.IsTrue(canvasResources.IsCollection);
canvasResources.CollectionElements.Add(componentItem); canvasResources.CollectionElements.Add(str);
DesignItemProperty prop = textBlock.Properties[TextBlock.TagProperty];
prop.SetValue(new StaticResourceExtension());
prop.Value.Properties["ResourceKey"].SetValue("res1");
string typeName = component.GetType().Name; textBlock.Properties[TextBlock.TextProperty].SetValue(new StaticResourceExtension());
DesignItemProperty prop = textBlock.Properties[TextBlock.TextProperty];
prop.Value.Properties["ResourceKey"].SetValue("str1");
string expectedXaml = "<Canvas.Resources>\n" + string expectedXaml = "<Canvas.Resources>\n" +
" <Controls0:" + typeName + " x:Key=\"res1\">" + expectedXamlValue + "</Controls0:" + typeName + ">\n" + " <Controls0:String x:Key=\"str1\">stringresource 1</Controls0:String>\n" +
"</Canvas.Resources>\n" + "</Canvas.Resources>\n" +
"<TextBlock Tag=\"{StaticResource ResourceKey=res1}\" />"; "<TextBlock Text=\"{StaticResource ResourceKey=str1}\" />";
AssertCanvasDesignerOutput(expectedXaml, textBlock.Context, "xmlns:Controls0=\"clr-namespace:System;assembly=mscorlib\""); AssertCanvasDesignerOutput(expectedXaml, textBlock.Context, "xmlns:Controls0=\"clr-namespace:System;assembly=mscorlib\"");
AssertLog(""); AssertLog("");
} }
[Test]
public void AddStringAsResource()
{
AddNativeTypeAsResource("stringresource 1", "stringresource 1");
}
[Test]
public void AddDoubleAsResource()
{
AddNativeTypeAsResource(0.0123456789d, "0.0123456789");
}
[Test]
public void AddInt32AsResource()
{
const int i = 123;
AddNativeTypeAsResource(i, "123");
}
} }
public class MyMultiConverter : IMultiValueConverter public class MyMultiConverter : IMultiValueConverter

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/HierarchyTests.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView
public class HierarchyTests : ModelTestHelper public class HierarchyTests : ModelTestHelper
{ {
private DesignItem _grid; private DesignItem _grid;
private IOutlineNode _outline; private OutlineNode _outline;
[TestFixtureSetUp] [TestFixtureSetUp]
public void Intialize() public void Intialize()

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs

@ -26,15 +26,15 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView
public class CollectionElementsInsertTests : ModelTestHelper public class CollectionElementsInsertTests : ModelTestHelper
{ {
private DesignItem _grid; private DesignItem _grid;
private IOutlineNode _outline; private OutlineNode _outline;
private DesignItem _gridButton; private DesignItem _gridButton;
private DesignItem _stackPanel; private DesignItem _stackPanel;
private DesignItem _stackPanelButton; private DesignItem _stackPanelButton;
private IOutlineNode _gridButtonNode; private OutlineNode _gridButtonNode;
private IOutlineNode _stackPanelNode; private OutlineNode _stackPanelNode;
private IOutlineNode _stackPanelButtonNode; private OutlineNode _stackPanelButtonNode;
[SetUp] [SetUp]
public void Intialize() public void Intialize()
@ -162,15 +162,15 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView
public class ContentControlInsertTests : ModelTestHelper public class ContentControlInsertTests : ModelTestHelper
{ {
private DesignItem _grid; private DesignItem _grid;
private IOutlineNode _outline; private OutlineNode _outline;
private DesignItem _gridButton; private DesignItem _gridButton;
private DesignItem _stackPanel; private DesignItem _stackPanel;
private DesignItem _stackPanelImage; private DesignItem _stackPanelImage;
private IOutlineNode _gridButtonNode; private OutlineNode _gridButtonNode;
private IOutlineNode _stackPanelNode; private OutlineNode _stackPanelNode;
private IOutlineNode _stackPanelImageNode; private OutlineNode _stackPanelImageNode;
[SetUp] [SetUp]
public void Intialize() public void Intialize()

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/SelectionTests.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView
public class SelectionTests : ModelTestHelper public class SelectionTests : ModelTestHelper
{ {
private DesignItem _grid; private DesignItem _grid;
private IOutlineNode _outline; private OutlineNode _outline;
[SetUp] [SetUp]
public void Intialize() public void Intialize()

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs

@ -158,14 +158,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// <summary> /// <summary>
/// Create an XamlObject from the instance. /// Create an XamlObject from the instance.
/// </summary> /// </summary>
public XamlObject CreateObject(object instance, object baseobject=null) public XamlObject CreateObject(object instance)
{ {
object obj = instance; return (XamlObject)CreatePropertyValue(instance, null);
if (baseobject != null && instance.GetType() != baseobject.GetType())
obj = baseobject;
XamlObject xamlobj = (XamlObject)CreatePropertyValue(obj, null);
xamlobj.Instance = instance;
return xamlobj;
} }
/// <summary> /// <summary>
@ -198,7 +193,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XmlElement xml = _xmlDoc.CreateElement(prefix, elementType.Name, ns); XmlElement xml = _xmlDoc.CreateElement(prefix, elementType.Name, ns);
if (hasStringConverter && (XamlObject.GetContentPropertyName(elementType) != null || IsNativeType(instance))) { if (hasStringConverter && XamlObject.GetContentPropertyName(elementType) != null) {
xml.InnerText = c.ConvertToInvariantString(instance); xml.InnerText = c.ConvertToInvariantString(instance);
} else if (instance is Brush && forProperty != null) { // TODO: this is a hacky fix, because Brush Editor doesn't } else if (instance is Brush && forProperty != null) { // TODO: this is a hacky fix, because Brush Editor doesn't
// edit Design Items and so we have no XML, only the Brush // edit Design Items and so we have no XML, only the Brush
@ -219,6 +214,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
} }
} }
} }
} else if (instance is string) {
xml.InnerText = (string)instance;
} }
return new XamlObject(this, xml, elementType, instance); return new XamlObject(this, xml, elementType, instance);
@ -277,10 +274,5 @@ namespace ICSharpCode.WpfDesign.XamlDom
return prefix; return prefix;
} }
bool IsNativeType(object instance)
{
return instance.GetType().Assembly == typeof(String).Assembly;
}
} }
} }

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

@ -287,7 +287,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// </summary> /// </summary>
public object Instance { public object Instance {
get { return instance; } get { return instance; }
internal set { instance = value; }
} }
/// <summary> /// <summary>

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs

@ -48,18 +48,7 @@ namespace ICSharpCode.WpfDesign.Extensions
/// <summary> /// <summary>
/// Creates an instance of the specified type, passing the specified arguments to its constructor. /// Creates an instance of the specified type, passing the specified arguments to its constructor.
/// </summary> /// </summary>
/// <param name="type"></param>
/// <param name="arguments"></param>
/// <returns></returns>
public virtual object CreateInstance(Type type, params object[] arguments) public virtual object CreateInstance(Type type, params object[] arguments)
{
return CreateObjectInstance(type, arguments);
}
/// <summary>
/// Creates an instance of the specified type, passing the specified arguments to its constructor.
/// </summary>
public static object CreateObjectInstance(Type type, params object[] arguments)
{ {
var instance = Activator.CreateInstance(type, arguments); var instance = Activator.CreateInstance(type, arguments);
var uiElement = instance as UIElement; var uiElement = instance as UIElement;

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs

@ -17,7 +17,6 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Collections.Generic;
namespace ICSharpCode.WpfDesign.Extensions namespace ICSharpCode.WpfDesign.Extensions
{ {
@ -29,7 +28,6 @@ namespace ICSharpCode.WpfDesign.Extensions
{ {
Type _designedItemType; Type _designedItemType;
Type _overrideExtension; Type _overrideExtension;
List<Type> _overrideExtensions = new List<Type>();
/// <summary> /// <summary>
/// Gets the type of the item that is designed using this extension. /// Gets the type of the item that is designed using this extension.
@ -38,18 +36,6 @@ namespace ICSharpCode.WpfDesign.Extensions
get { return _designedItemType; } get { return _designedItemType; }
} }
/// <summary>
/// Gets/Sets the types of another extension that this extension is overriding.
/// </summary>
public Type[] OverrideExtensions
{
get { return _overrideExtensions.ToArray(); }
set
{
_overrideExtensions.AddRange(value);
}
}
/// <summary> /// <summary>
/// Gets/Sets the type of another extension that this extension is overriding. /// Gets/Sets the type of another extension that this extension is overriding.
/// </summary> /// </summary>
@ -61,8 +47,6 @@ namespace ICSharpCode.WpfDesign.Extensions
if (!typeof(Extension).IsAssignableFrom(value)) { if (!typeof(Extension).IsAssignableFrom(value)) {
throw new ArgumentException("OverrideExtension must specify the type of an Extension."); throw new ArgumentException("OverrideExtension must specify the type of an Extension.");
} }
if(!_overrideExtensions.Contains(value))
_overrideExtensions.Add(value);
} }
} }
} }

35
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs

@ -64,19 +64,13 @@ namespace ICSharpCode.WpfDesign.Extensions
{ {
internal readonly Type ExtensionType; internal readonly Type ExtensionType;
internal readonly ExtensionServer Server; internal readonly ExtensionServer Server;
internal readonly List<Type> OverriddenExtensionTypes = new List<Type>(); internal readonly Type OverriddenExtensionType;
public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType) public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType)
{ {
this.ExtensionType = extensionType; this.ExtensionType = extensionType;
this.Server = server; this.Server = server;
this.OverriddenExtensionTypes.Add(overriddenExtensionType); this.OverriddenExtensionType = overriddenExtensionType;
}
public ExtensionEntry(Type extensionType, ExtensionServer server, List<Type> overriddenExtensionTypes)
{
this.ExtensionType = extensionType;
this.Server = server;
this.OverriddenExtensionTypes= overriddenExtensionTypes;
} }
} }
@ -93,18 +87,23 @@ namespace ICSharpCode.WpfDesign.Extensions
List<ExtensionEntry> GetExtensionEntries(Type extendedItemType) List<ExtensionEntry> GetExtensionEntries(Type extendedItemType)
{ {
List<ExtensionEntry> result = new List<ExtensionEntry>(); List<ExtensionEntry> result;
List<Type> overriddenExtensions = new List<Type>(); if (extendedItemType.BaseType != null)
IEnumerable<ExtensionEntry> ie = _extensions.Where(x => x.Key.IsAssignableFrom(extendedItemType)).SelectMany(x => x.Value); result = GetExtensionEntries(extendedItemType.BaseType);
foreach (ExtensionEntry entry in ie) { else
if (!overriddenExtensions.Contains(entry.ExtensionType)) { result = new List<ExtensionEntry>();
overriddenExtensions.AddRange(entry.OverriddenExtensionTypes);
List<ExtensionEntry> list;
result.RemoveAll(x => overriddenExtensions.Contains(x.ExtensionType)); if (_extensions.TryGetValue(extendedItemType, out list)) {
foreach (ExtensionEntry entry in list) {
if (entry.OverriddenExtensionType != null) {
result.RemoveAll(delegate(ExtensionEntry oldEntry) {
return oldEntry.ExtensionType == entry.OverriddenExtensionType;
});
}
result.Add(entry); result.Add(entry);
} }
} }
return result; return result;
} }
@ -185,7 +184,7 @@ namespace ICSharpCode.WpfDesign.Extensions
foreach (ExtensionForAttribute designerFor in extensionForAttributes) { foreach (ExtensionForAttribute designerFor in extensionForAttributes) {
ExtensionServer server = GetServerForExtension(type); ExtensionServer server = GetServerForExtension(type);
AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtensions.ToList())); AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtension));
} }
} }
} }

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs

@ -122,7 +122,7 @@ namespace ICSharpCode.WpfDesign
DesignItem GetDesignItem(object component); DesignItem GetDesignItem(object component);
/// <summary>Registers a component for usage in the designer.</summary> /// <summary>Registers a component for usage in the designer.</summary>
DesignItem RegisterComponentForDesigner(object component, Type basetype=null); DesignItem RegisterComponentForDesigner(object component);
/// <summary>Event raised whenever a component is registered</summary> /// <summary>Event raised whenever a component is registered</summary>
event EventHandler<DesignItemEventArgs> ComponentRegistered; event EventHandler<DesignItemEventArgs> ComponentRegistered;

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs

@ -21,7 +21,6 @@ using System.Collections.Generic;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
@ -54,10 +53,6 @@ namespace ICSharpCode.WpfDesign
/// </summary> /// </summary>
public interface IToolService public interface IToolService
{ {
/// <summary>
/// Set custom HitTestFilterCallback for DesignPanel
/// </summary>
HitTestFilterCallback DesignPanelHitTestFilterCallback{ set; }
/// <summary> /// <summary>
/// Gets the 'pointer' tool. /// Gets the 'pointer' tool.
/// The pointer tool is the default tool for selecting and moving elements. /// The pointer tool is the default tool for selecting and moving elements.
@ -82,10 +77,6 @@ namespace ICSharpCode.WpfDesign
public interface IDesignPanel : IInputElement public interface IDesignPanel : IInputElement
{ {
/// <summary> /// <summary>
/// Set a custom filter callback so that any element can be filtered out
/// </summary>
HitTestFilterCallback CustomHitTestFilterBehavior { get; set; }
/// <summary>
/// Gets the design context used by the DesignPanel. /// Gets the design context used by the DesignPanel.
/// </summary> /// </summary>
DesignContext Context { get; } DesignContext Context { get; }

79
src/AddIns/Misc/PackageManagement/Project/Src/InstalledPackageViewModel.cs

@ -1,79 +0,0 @@
// 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 NuGet;
namespace ICSharpCode.PackageManagement
{
public class InstalledPackageViewModel : PackageViewModel
{
public InstalledPackageViewModel(
IPackageViewModelParent parent,
IPackageFromRepository package,
SelectedProjectsForInstalledPackages selectedProjects,
IPackageManagementEvents packageManagementEvents,
IPackageActionRunner actionRunner,
ILogger logger)
: base(parent, package, selectedProjects, packageManagementEvents, actionRunner, logger)
{
}
public override IList<ProcessPackageAction> GetProcessPackageActionsForSelectedProjects(
IList<IPackageManagementSelectedProject> selectedProjects)
{
var actions = new List<ProcessPackageAction>();
foreach (IPackageManagementSelectedProject selectedProject in selectedProjects) {
ProcessPackageAction action = CreatePackageAction(selectedProject);
if (action != null) {
actions.Add(action);
}
}
return actions;
}
ProcessPackageAction CreatePackageAction(IPackageManagementSelectedProject selectedProject)
{
if (selectedProject.IsSelected) {
return base.CreateInstallPackageAction(selectedProject);
}
return CreateUninstallPackageActionForSelectedProject(selectedProject);
}
ProcessPackageAction CreateUninstallPackageActionForSelectedProject(IPackageManagementSelectedProject selectedProject)
{
ProcessPackageAction action = base.CreateUninstallPackageAction(selectedProject);
if (IsPackageInstalled(action.Project)) {
return action;
}
return null;
}
bool IsPackageInstalled(IPackageManagementProject project)
{
IPackage package = GetPackage();
return project.IsPackageInstalled(package);
}
protected override bool AnyProjectsSelected(IList<IPackageManagementSelectedProject> projects)
{
return true;
}
}
}

89
src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs

@ -1,89 +0,0 @@
// 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 NuGet;
namespace ICSharpCode.PackageManagement
{
/// <summary>
/// Supports a configurable set of package repositories for project templates that can be
/// different to the registered package repositories used with the Add Package Reference dialog.
/// </summary>
public class ProjectTemplatePackageRepositoryCache : IPackageRepositoryCache
{
IPackageRepositoryCache packageRepositoryCache;
RegisteredProjectTemplatePackageSources registeredPackageSources;
/// <summary>
/// Creates a new instance of the ProjectTemplatePackageRepositoryCache.
/// </summary>
/// <param name="packageRepositoryCache">The main package repository cache used
/// with the Add Package Reference dialog.</param>
public ProjectTemplatePackageRepositoryCache(
IPackageRepositoryCache packageRepositoryCache,
RegisteredProjectTemplatePackageSources registeredPackageSources)
{
this.packageRepositoryCache = packageRepositoryCache;
this.registeredPackageSources = registeredPackageSources;
}
public IRecentPackageRepository RecentPackageRepository {
get { throw new NotImplementedException(); }
}
public IPackageRepository CreateAggregateRepository()
{
IEnumerable<IPackageRepository> repositories = GetRegisteredPackageRepositories();
return CreateAggregateRepository(repositories);
}
IEnumerable<IPackageRepository> GetRegisteredPackageRepositories()
{
foreach (PackageSource packageSource in GetEnabledPackageSources()) {
yield return CreateRepository(packageSource.Source);
}
}
public IEnumerable<PackageSource> GetEnabledPackageSources()
{
return registeredPackageSources.PackageSources.GetEnabledPackageSources();
}
public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem)
{
throw new NotImplementedException();
}
public IRecentPackageRepository CreateRecentPackageRepository(IList<RecentPackageInfo> recentPackages, IPackageRepository aggregateRepository)
{
throw new NotImplementedException();
}
public IPackageRepository CreateAggregateRepository(IEnumerable<IPackageRepository> repositories)
{
return packageRepositoryCache.CreateAggregateRepository(repositories);
}
public IPackageRepository CreateRepository(string packageSource)
{
return packageRepositoryCache.CreateRepository(packageSource);
}
}
}

64
src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSources.cs

@ -1,64 +0,0 @@
// 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 NuGet;
namespace ICSharpCode.PackageManagement
{
public class RegisteredProjectTemplatePackageSources
{
RegisteredPackageSourceSettings registeredPackageSourceSettings;
public RegisteredProjectTemplatePackageSources()
: this(new PackageManagementPropertyService(), new SettingsFactory())
{
}
public RegisteredProjectTemplatePackageSources(
IPropertyService propertyService,
ISettingsFactory settingsFactory)
{
GetRegisteredPackageSources(propertyService, settingsFactory);
}
void GetRegisteredPackageSources(IPropertyService propertyService, ISettingsFactory settingsFactory)
{
ISettings settings = CreateSettings(propertyService, settingsFactory);
PackageSource defaultPackageSource = CreateDefaultPackageSource(propertyService);
registeredPackageSourceSettings = new RegisteredPackageSourceSettings(settings, defaultPackageSource);
}
ISettings CreateSettings(IPropertyService propertyService, ISettingsFactory settingsFactory)
{
var settingsFileName = new ProjectTemplatePackagesSettingsFileName(propertyService);
return settingsFactory.CreateSettings(settingsFileName.Directory);
}
PackageSource CreateDefaultPackageSource(IPropertyService propertyService)
{
var defaultPackageSource = new DefaultProjectTemplatePackageSource(propertyService);
return defaultPackageSource.PackageSource;
}
public RegisteredPackageSources PackageSources {
get { return registeredPackageSourceSettings.PackageSources; }
}
}
}

26
src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSourcesView.xaml

@ -1,26 +0,0 @@
<gui:OptionPanel
x:Class="ICSharpCode.PackageManagement.RegisteredProjectTemplatePackageSourcesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pm="clr-namespace:ICSharpCode.PackageManagement"
xmlns:pmd="clr-namespace:ICSharpCode.PackageManagement.Design"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300"
Height="300">
<Grid x:Name="MainGrid">
<Grid.Resources>
<pm:PackageManagementViewModels x:Key="ViewModels"/>
</Grid.Resources>
<Grid.DataContext>
<Binding Source="{StaticResource ViewModels}" Path="RegisteredProjectTemplatePackageSourcesViewModel"/>
</Grid.DataContext>
<pm:RegisteredPackageSourcesUserControl/>
</Grid>
</gui:OptionPanel>

88
src/AddIns/Misc/PackageManagement/Test/Src/CodeGeneratorTests.cs

@ -1,88 +0,0 @@
// 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 ICSharpCode.NRefactory.Ast;
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
//using NUnit.Framework;
//
//namespace PackageManagement.Tests
//{
// [TestFixture]
// public class CodeGeneratorTests
// {
// CSharpCodeGenerator codeGenerator;
//
// void CreateCodeGenerator()
// {
// codeGenerator = new CSharpCodeGenerator();
// }
//
// [Test]
// public void GenerateCode_Field_CreatesField()
// {
// CreateCodeGenerator();
// var field = new FieldDeclaration(new List<AttributeSection>());
// field.TypeReference = new TypeReference("MyClass");
// field.Modifier = Modifiers.Public;
// field.Fields.Add(new VariableDeclaration("myField"));
//
// string code = codeGenerator.GenerateCode(field, String.Empty);
//
// string expectedCode = "public MyClass myField;\r\n";
//
// Assert.AreEqual(expectedCode, code);
// }
//
// [Test]
// public void GenerateCode_Method_CreatesMethod()
// {
// CreateCodeGenerator();
// var method = new MethodDeclaration();
// method.Name = "MyMethod";
// method.TypeReference = new TypeReference("MyReturnType");
// method.Modifier = Modifiers.Public;
// method.Body = new BlockStatement();
//
// string code = codeGenerator.GenerateCode(method, String.Empty);
//
// string expectedCode =
// "public MyReturnType MyMethod()\r\n" +
// "{\r\n" +
// "}\r\n";
//
// Assert.AreEqual(expectedCode, code);
// }
//
// [Test]
// public void GenerateCode_InterfaceMethodDeclaration_CreatesMethod()
// {
// CreateCodeGenerator();
// var method = new MethodDeclaration();
// method.Name = "MyMethod";
// method.TypeReference = new TypeReference("MyReturnType");
//
// string code = codeGenerator.GenerateCode(method, String.Empty);
//
// string expectedCode = "MyReturnType MyMethod();\r\n";
//
// Assert.AreEqual(expectedCode, code);
// }
// }
//}

120
src/AddIns/Misc/PackageManagement/Test/Src/ProjectTemplatePackageRepositoryCacheTests.cs

@ -1,120 +0,0 @@
// 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 ICSharpCode.PackageManagement;
using ICSharpCode.PackageManagement.Design;
using NuGet;
using NUnit.Framework;
using PackageManagement.Tests.Helpers;
namespace PackageManagement.Tests
{
[TestFixture]
public class ProjectTemplatePackageRepositoryCacheTests
{
ProjectTemplatePackageRepositoryCache cache;
FakePackageRepositoryFactory fakeMainCache;
RegisteredProjectTemplatePackageSources registeredPackageSources;
FakeSettingsFactory fakeSettingsFactory;
void CreateCache()
{
fakeMainCache = new FakePackageRepositoryFactory();
var propertyService = new FakePropertyService();
fakeSettingsFactory = new FakeSettingsFactory();
registeredPackageSources = new RegisteredProjectTemplatePackageSources(propertyService, fakeSettingsFactory);
cache = new ProjectTemplatePackageRepositoryCache(fakeMainCache, registeredPackageSources);
}
void ClearRegisteredPackageSources()
{
registeredPackageSources.PackageSources.Clear();
}
void AddRegisteredPackageSource(PackageSource packageSource)
{
registeredPackageSources.PackageSources.Add(packageSource);
}
void AddRegisteredPackageSource(string url, string name)
{
var packageSource = new PackageSource(url, name);
AddRegisteredPackageSource(packageSource);
}
FakePackageRepository AddRegisteredPackageRepository(string packageSourceUrl, string packageSourceName)
{
var packageSource = new PackageSource(packageSourceUrl, packageSourceName);
AddRegisteredPackageSource(packageSource);
FakePackageRepository fakeRepository = new FakePackageRepository();
fakeMainCache.FakePackageRepositories.Add(packageSource.Source, fakeRepository);
return fakeRepository;
}
[Test]
public void CreateAggregateRepository_OneRegisteredPackageSource_CreatesAggregrateRepositoryUsingMainCache()
{
CreateCache();
ClearRegisteredPackageSources();
AddRegisteredPackageSource("http://sharpdevelop.com", "Test");
IPackageRepository repository = cache.CreateAggregateRepository();
IPackageRepository expectedRepository = fakeMainCache.FakeAggregateRepository;
Assert.AreEqual(expectedRepository, repository);
}
[Test]
public void CreateAggregateRepository_TwoRegisteredPackageSources_CreatesRepositoriesForRegisteredPackageSources()
{
CreateCache();
ClearRegisteredPackageSources();
FakePackageRepository fakeRepository1 = AddRegisteredPackageRepository("http://sharpdevelop.com", "Test");
FakePackageRepository fakeRepository2 = AddRegisteredPackageRepository("http://test", "Test2");
IPackageRepository repository = cache.CreateAggregateRepository();
IEnumerable<IPackageRepository> repositories = fakeMainCache.RepositoriesPassedToCreateAggregateRepository;
var expectedRepositories = new List<IPackageRepository>();
expectedRepositories.Add(fakeRepository1);
expectedRepositories.Add(fakeRepository2);
Assert.AreEqual(expectedRepositories, repositories);
}
[Test]
public void CreateAggregatePackageRepository_TwoRegisteredPackageSourcesButOneDisabled_ReturnsAggregateRepositoryCreatedWithOnlyEnabledPackageSource()
{
CreateCache();
ClearRegisteredPackageSources();
FakePackageRepository fakeRepository1 = AddRegisteredPackageRepository("http://sharpdevelop.com", "Test");
FakePackageRepository fakeRepository2 = AddRegisteredPackageRepository("http://test", "Test2");
registeredPackageSources.PackageSources[0].IsEnabled = false;
IPackageRepository repository = cache.CreateAggregateRepository();
IEnumerable<IPackageRepository> repositories = fakeMainCache.RepositoriesPassedToCreateAggregateRepository;
var expectedRepositories = new List<IPackageRepository>();
expectedRepositories.Add(fakeRepository2);
Assert.AreEqual(expectedRepositories, repositories);
}
}
}

103
src/AddIns/Misc/PackageManagement/Test/Src/RegisteredProjectTemplatePackageSourcesTests.cs

@ -1,103 +0,0 @@
// 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 ICSharpCode.PackageManagement;
using ICSharpCode.PackageManagement.Design;
using NuGet;
using NUnit.Framework;
using PackageManagement.Tests.Helpers;
namespace PackageManagement.Tests
{
[TestFixture]
public class RegisteredProjectTemplatePackageSourcesTests
{
RegisteredProjectTemplatePackageSources registeredPackageSources;
FakeSettingsFactory fakeSettingsFactory;
FakePropertyService CreatePropertyService()
{
return new FakePropertyService();
}
void CreateRegisteredPackageSources(List<PackageSource> packageSources, FakePropertyService propertyService)
{
fakeSettingsFactory = new FakeSettingsFactory();
fakeSettingsFactory.FakeSettings.AddFakePackageSources(packageSources);
registeredPackageSources =
new RegisteredProjectTemplatePackageSources(
propertyService,
fakeSettingsFactory);
}
[Test]
public void PackageSources_NoPredefinedPackageSources_DefaultPackageSourceCreated()
{
FakePropertyService propertyService = CreatePropertyService();
propertyService.DataDirectory = @"d:\sharpdevelop\data";
var packageSources = new List<PackageSource>();
CreateRegisteredPackageSources(packageSources, propertyService);
RegisteredPackageSources actualPackageSources =
registeredPackageSources.PackageSources;
var expectedPackageSources = new PackageSource[] {
new PackageSource(@"d:\sharpdevelop\data\templates\packages", "Default")
};
PackageSourceCollectionAssert.AreEqual(expectedPackageSources, actualPackageSources);
}
[Test]
public void PackageSources_OnePredefinedPackageSource_RegisteredPackageSourceIsPredefinedPackageSource()
{
FakePropertyService propertyService = CreatePropertyService();
propertyService.DataDirectory = @"d:\sharpdevelop\data";
var expectedPackageSources = new List<PackageSource>();
expectedPackageSources.Add(new PackageSource("http://sharpdevelop", "Test"));
CreateRegisteredPackageSources(expectedPackageSources, propertyService);
RegisteredPackageSources actualPackageSources =
registeredPackageSources.PackageSources;
PackageSourceCollectionAssert.AreEqual(expectedPackageSources, actualPackageSources);
}
[Test]
public void PackageSources_NoPredefinedPackageSources_PackageSourceConfigLookedForInUserFolder()
{
FakePropertyService propertyService = CreatePropertyService();
propertyService.DataDirectory = @"d:\sharpdevelop\data";
propertyService.ConfigDirectory = @"c:\Users\test\AppData\ICSharpCode\SharpDevelop4.1";
var packageSources = new List<PackageSource>();
CreateRegisteredPackageSources(packageSources, propertyService);
IEnumerable<PackageSource> actualPackageSources =
registeredPackageSources.PackageSources;
string directory = fakeSettingsFactory.DirectoryPassedToCreateSettings;
string expectedDirectory = @"c:\Users\test\AppData\ICSharpCode\SharpDevelop4.1\templates";
Assert.AreEqual(expectedDirectory, directory);
}
}
}
Loading…
Cancel
Save