diff --git a/data/templates/packages/Modernizr.2.5.3.nupkg b/data/templates/packages/Modernizr.2.5.3.nupkg
new file mode 100644
index 0000000000..98ade6d191
Binary files /dev/null and b/data/templates/packages/Modernizr.2.5.3.nupkg differ
diff --git a/data/templates/packages/jQuery.1.7.2.nupkg b/data/templates/packages/jQuery.1.7.2.nupkg
new file mode 100644
index 0000000000..033bae95d0
Binary files /dev/null and b/data/templates/packages/jQuery.1.7.2.nupkg differ
diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj b/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj
index 1b41ab422d..366aa3a811 100644
--- a/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj
+++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj
@@ -54,6 +54,7 @@
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs
index 911f7d12bb..7e2dae8f41 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs
@@ -45,7 +45,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public static readonly DependencyProperty ResizeThumbVisibleProperty
= DependencyProperty.Register("ResizeThumbVisible", typeof(bool), typeof(ResizeThumb), new FrameworkPropertyMetadata(true));
- internal PlacementAlignment Alignment;
+ public PlacementAlignment Alignment;
static ResizeThumb()
{
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs
index 8f660b84db..e3fa8bc88f 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs
@@ -26,25 +26,25 @@ using System.Windows.Controls;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
- ///
- /// Display height of the element.
- ///
- class HeightDisplay : Control
- {
- static HeightDisplay()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
- }
- }
+ ///
+ /// Display height of the element.
+ ///
+ public class HeightDisplay : Control
+ {
+ static HeightDisplay()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
+ }
+ }
- ///
- /// Display width of the element.
- ///
- class WidthDisplay : Control
- {
- static WidthDisplay()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
- }
- }
+ ///
+ /// Display width of the element.
+ ///
+ public class WidthDisplay : Control
+ {
+ static WidthDisplay()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
+ }
+ }
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
index 0a5ba978a3..dbfb56eb09 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
@@ -64,14 +64,14 @@ namespace ICSharpCode.WpfDesign.Designer
HitTestFilterBehavior FilterHitTestInvisibleElements(DependencyObject potentialHitTestTarget)
{
UIElement element = potentialHitTestTarget as UIElement;
-
+
if (element != null) {
if (!(element.IsHitTestVisible && element.Visibility == Visibility.Visible)) {
return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
}
var designItem = Context.Services.Component.GetDesignItem(element) as XamlDesignItem;
-
+
if (designItem != null && designItem.IsDesignTimeLocked) {
return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
}
@@ -109,14 +109,17 @@ namespace ICSharpCode.WpfDesign.Designer
return;
}
// First try hit-testing on the adorner layer.
-
+
bool continueHitTest = true;
-
+
+ HitTestFilterCallback filterBehavior = CustomHitTestFilterBehavior ?? FilterHitTestInvisibleElements;
+ CustomHitTestFilterBehavior = null;
hitTestElements.Clear();
if (testAdorners) {
+
RunHitTest(
- _adornerLayer, mousePosition, FilterHitTestInvisibleElements,
+ _adornerLayer, mousePosition, filterBehavior,
delegate(HitTestResult result) {
if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
@@ -138,11 +141,11 @@ namespace ICSharpCode.WpfDesign.Designer
if (continueHitTest && testDesignSurface) {
RunHitTest(
- this.Child, mousePosition, FilterHitTestInvisibleElements,
+ this.Child, mousePosition, filterBehavior,
delegate(HitTestResult result) {
if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
-
+
ViewService viewService = _context.Services.View;
DependencyObject obj = result.VisualHit;
@@ -210,6 +213,8 @@ namespace ICSharpCode.WpfDesign.Designer
#region Properties
+ //Set custom HitTestFilterCallbak
+ public HitTestFilterCallback CustomHitTestFilterBehavior { get; set; }
///
/// Gets/Sets the design context.
///
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
index efc39f6ee1..82e9b5476f 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
@@ -31,6 +31,19 @@ namespace ICSharpCode.WpfDesign.Designer
{
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)
{
return Math.Max(Math.Min(value, max), min);
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs
index 2ca8308f66..c9fdb029a2 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs
@@ -33,7 +33,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
///
[ExtensionServer(typeof(OnlyOneItemSelectedExtensionServer))]
[ExtensionFor(typeof (FrameworkElement))]
- class QuickOperationMenuExtension : PrimarySelectionAdornerProvider
+ public class QuickOperationMenuExtension : PrimarySelectionAdornerProvider
{
private QuickOperationMenu _menu;
private KeyBinding _keyBinding;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SizeDisplayExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SizeDisplayExtension.cs
index 1eec1629ae..caa0eb4cf5 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SizeDisplayExtension.cs
+++ b/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
///
[ExtensionFor(typeof(UIElement))]
- class SizeDisplayExtension : PrimarySelectionAdornerProvider
+ public class SizeDisplayExtension : PrimarySelectionAdornerProvider
{
HeightDisplay _heightDisplay;
WidthDisplay _widthDisplay;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs
index da541a9cf3..43f5702af4 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs
@@ -40,10 +40,11 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
}
public static readonly DependencyProperty RootProperty =
- DependencyProperty.Register("Root", typeof(OutlineNode), typeof(Outline));
+ DependencyProperty.Register("Root", typeof(IOutlineNode), typeof(Outline));
- public OutlineNode Root {
- get { return (OutlineNode)GetValue(RootProperty); }
+ public IOutlineNode Root
+ {
+ get { return (IOutlineNode)GetValue(RootProperty); }
set { SetValue(RootProperty, value); }
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
index 844ebd0d03..261d1b47e5 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
@@ -34,138 +34,45 @@ using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
- public class OutlineNode : INotifyPropertyChanged
+ public interface IOutlineNode
{
- //Used to check if element can enter other containers
- public static PlacementType DummyPlacementType;
-
- 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;
- }
+ ISelectionService SelectionService { get; }
+ bool IsExpanded { get; set; }
+ DesignItem DesignItem { get; set; }
+ bool IsSelected { get; set; }
+ bool IsDesignTimeVisible { get; set; }
+ bool IsDesignTimeLocked { get; }
+ string Name { get; }
+ bool CanInsert(IEnumerable nodes, IOutlineNode after, bool copy);
+ void Insert(IEnumerable nodes, IOutlineNode after, bool copy);
+ ObservableCollection Children{ get; }
+ }
+
+ public class OutlineNode: OutlineNodeBase
+ {
//TODO: Reset with DesignContext
- static Dictionary outlineNodes = new Dictionary();
+ static Dictionary outlineNodes = new Dictionary();
- OutlineNode(DesignItem designItem)
+ protected OutlineNode(DesignItem designitem): base(designitem)
{
- DesignItem = designItem;
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(Selection_SelectionChanged);
}
- 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
+ static OutlineNode()
{
- 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();
- }
+ DummyPlacementType = PlacementType.Register("DummyPlacement");
}
- bool _isDesignTimeLocked = false;
-
- public bool IsDesignTimeLocked
+ public static IOutlineNode Create(DesignItem designItem)
{
- 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 children = new ObservableCollection();
-
- public ObservableCollection Children {
- get { return children; }
- }
-
- public string Name {
- get {
- if (string.IsNullOrEmpty(DesignItem.Name)) {
- return DesignItem.ComponentType.Name;
- }
- return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")";
+ IOutlineNode node;
+ if (!outlineNodes.TryGetValue(designItem, out node)) {
+ node = new OutlineNode(designItem);
+ outlineNodes[designItem] = node;
}
+ return node;
}
void Selection_SelectionChanged(object sender, DesignItemCollectionEventArgs e)
@@ -173,19 +80,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
IsSelected = DesignItem.Services.Selection.IsComponentSelected(DesignItem);
}
- void DesignItem_NameChanged(object sender, EventArgs e)
- {
- RaisePropertyChanged("Name");
- }
-
- void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == DesignItem.ContentPropertyName) {
- UpdateChildren();
- }
- }
-
- void UpdateChildren()
+ protected override void UpdateChildren()
{
Children.Clear();
@@ -193,8 +88,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
var content = DesignItem.ContentProperty;
if (content.IsCollection) {
UpdateChildrenCore(content.CollectionElements);
- }
- else {
+ } else {
if (content.Value != null) {
UpdateChildrenCore(new[] { content.Value });
}
@@ -208,16 +102,12 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
if (ModelTools.CanSelectComponent(item)) {
var node = OutlineNode.Create(item);
Children.Add(node);
- }
- else
- {
+ } else {
var content = item.ContentProperty;
- if (content != null)
- {
+ if (content != null) {
if (content.IsCollection) {
UpdateChildrenCore(content.CollectionElements);
- }
- else {
+ } else {
if (content.Value != null) {
UpdateChildrenCore(new[] { content.Value });
}
@@ -226,57 +116,5 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
}
}
}
-
- public bool CanInsert(IEnumerable nodes, OutlineNode after, bool copy)
- {
- var placementBehavior = DesignItem.GetBehavior();
- 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 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
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs
new file mode 100644
index 0000000000..648b4097ec
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs
@@ -0,0 +1,225 @@
+/*
+ * 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
+{
+ ///
+ /// Description of OutlineNodeBase.
+ ///
+ 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 children = new ObservableCollection();
+
+ public ObservableCollection 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 nodes, IOutlineNode after, bool copy)
+ {
+ var placementBehavior = DesignItem.GetBehavior();
+ 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 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
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs
index ffbd1347aa..30d9a974b5 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs
+++ b/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)
{
UpdateCustomNodes(items);
- return (target.DataContext as OutlineNode).CanInsert(_customOutlineNodes,
- after == null ? null : after.DataContext as OutlineNode, copy);
+ return (target.DataContext as IOutlineNode).CanInsert(_customOutlineNodes,
+ after == null ? null : after.DataContext as IOutlineNode, copy);
}
protected override void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
{
UpdateCustomNodes(items);
- (target.DataContext as OutlineNode).Insert(_customOutlineNodes,
- after == null ? null : after.DataContext as OutlineNode, copy);
+ (target.DataContext as IOutlineNode).Insert(_customOutlineNodes,
+ after == null ? null : after.DataContext as IOutlineNode, copy);
}
// Need to do this through a seperate List since previously LINQ queries apparently disconnected DataContext;bug in .NET 4.0
- private List _customOutlineNodes;
+ private List _customOutlineNodes;
void UpdateCustomNodes(IEnumerable items)
{
- _customOutlineNodes = new List();
+ _customOutlineNodes = new List();
foreach (var item in items)
- _customOutlineNodes.Add(item.DataContext as OutlineNode);
+ _customOutlineNodes.Add(item.DataContext as IOutlineNode);
}
public override bool ShouldItemBeVisible(DragTreeViewItem dragTreeViewitem)
{
- var node = dragTreeViewitem.DataContext as OutlineNode;
+ var node = dragTreeViewitem.DataContext as IOutlineNode;
return string.IsNullOrEmpty(Filter) || node.Name.ToLower().Contains(Filter.ToLower());
}
@@ -60,7 +60,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
base.SelectOnly(item);
- var node = item.DataContext as OutlineNode;
+ var node = item.DataContext as IOutlineNode;
var surface = node.DesignItem.View.TryFindParent();
if (surface != null)
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs
index 420cc02c4e..e592e37cf2 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs
+++ b/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){
TypeMappings.TryGetValue(control.GetType(), out _type);
if (_type != null) {
- OutlineNode node = OutlineNode.Create(item);
+ IOutlineNode node = OutlineNode.Create(item);
Outline.Root = node;
PropertyGridView.PropertyGrid.SelectedItems = item.Services.Selection.SelectedItems;
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs
index 14de050360..872a0cc49c 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs
@@ -35,7 +35,19 @@ using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
- public class PropertyGrid : INotifyPropertyChanged
+ public interface IPropertyGrid
+ {
+ IEnumerable SelectedItems { get; set; }
+ Dictionary 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()
{
@@ -55,9 +67,13 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
Dictionary nodeFromDescriptor = new Dictionary();
+ public Dictionary NodeFromDescriptor { get { return nodeFromDescriptor; } }
+
public CategoriesCollection Categories { get; private set; }
public PropertyNodeCollection Events { get; private set; }
+ public event EventHandler AggregatePropertiesUpdated;
+
private PropertyGridGroupMode _groupMode;
public PropertyGridGroupMode GroupMode
@@ -213,13 +229,15 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
if (selectedItems == null || selectedItems.Count == 0) return;
if (selectedItems.Count == 1) SingleItem = selectedItems[0];
-
+
foreach (var md in GetDescriptors()) {
if (PassesFilter(md.Name))
AddNode(md);
}
} finally {
reloadActive = false;
+ if (AggregatePropertiesUpdated != null)
+ AggregatePropertiesUpdated(this, EventArgs.Empty);
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs
index b80aeb5582..d0435c13e8 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs
@@ -42,13 +42,16 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyGridView), new FrameworkPropertyMetadata(typeof(PropertyGridView)));
}
+ public PropertyGridView() : this(null)
+ {
+ }
- public PropertyGridView()
+ public PropertyGridView(IPropertyGrid pg)
{
- PropertyGrid = new PropertyGrid();
+ PropertyGrid = pg??new PropertyGrid();
DataContext = PropertyGrid;
}
-
+
private Thumb thumb;
public override void OnApplyTemplate()
{
@@ -61,7 +64,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
static PropertyContextMenu propertyContextMenu = new PropertyContextMenu();
- public PropertyGrid PropertyGrid { get; private set; }
+ public IPropertyGrid PropertyGrid { get; private set; }
public static readonly DependencyProperty FirstColumnWidthProperty =
DependencyProperty.Register("FirstColumnWidth", typeof(double), typeof(PropertyGridView),
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
index c066d06222..adb0dc04c9 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
@@ -20,6 +20,7 @@ using System.Windows;
using System;
using System.Diagnostics;
using System.Windows.Input;
+using System.Windows.Controls;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
@@ -151,15 +152,31 @@ namespace ICSharpCode.WpfDesign.Designer.Services
protected virtual DesignItem CreateItem(DesignContext context)
{
object newInstance = context.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory(componentType, null);
- DesignItem item = context.Services.Component.RegisterComponentForDesigner(newInstance);
+ DesignItem item = context.Services.Component.RegisterComponentForDesigner(newInstance, componentType);
changeGroup = item.OpenGroup("Drop Control");
context.Services.ExtensionManager.ApplyDefaultInitializers(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)
{
- var size = ModelTools.GetDefaultSize(createdItem);
+ return AddItemWithCustomSize(container, createdItem, position, ModelTools.GetDefaultSize(createdItem));
+ }
+
+ internal static bool AddItemWithCustomSize(DesignItem container, DesignItem createdItem, Point position, Size size)
+ {
PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents(
container,
new DesignItem[] { createdItem },
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs
index 63a450f196..1837bc404d 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs
@@ -18,7 +18,7 @@
using System;
using System.Windows.Input;
-
+using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Services
{
// See IToolService for description.
@@ -37,6 +37,11 @@ namespace ICSharpCode.WpfDesign.Designer.Services
});
}
+ public HitTestFilterCallback DesignPanelHitTestFilterCallback
+ {
+ set{ _designPanel.CustomHitTestFilterBehavior = value; }
+ }
+
public void Dispose()
{
if (_designPanel != null) {
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
index 8f016aaea9..ebbffae7ed 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
@@ -91,6 +91,7 @@
+
RightClickMultipleItemsContextMenu.xaml
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
index 81fa1cddd3..ba5dac471e 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
@@ -21,7 +21,7 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Windows.Markup;
using System.Windows;
-
+using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer.Xaml
@@ -68,15 +68,18 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
return site;
}
- public DesignItem RegisterComponentForDesigner(object component)
+ public DesignItem RegisterComponentForDesigner(object component, Type basetype = null)
{
if (component == null) {
component = new NullExtension();
} else if (component is Type) {
component = new TypeExtension((Type)component);
}
-
- XamlDesignItem item = new XamlDesignItem(_context.Document.CreateObject(component), _context);
+
+ object baseobject = basetype != null && component.GetType()!=basetype ? CustomInstanceFactory.CreateObjectInstance(basetype, null) : null;
+ XamlObject xamlobj = _context.Document.CreateObject(component, baseobject);
+
+ XamlDesignItem item = new XamlDesignItem(xamlobj, _context);
_sites.Add(component, item);
if (ComponentRegistered != null) {
ComponentRegistered(this, new DesignItemEventArgs(item));
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
index 44d4611df9..b3867622d5 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
@@ -668,31 +668,52 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
}
[Test]
- public void AddStringAsResource()
+ public void AddNativeTypeAsResource(object component, string expectedXamlValue)
{
DesignItem textBlock = CreateCanvasContext("");
DesignItem canvas = textBlock.Parent;
DesignItemProperty canvasResources = canvas.Properties.GetProperty("Resources");
- DesignItem str = canvas.Services.Component.RegisterComponentForDesigner("stringresource 1");
- str.Key = "str1";
+ DesignItem componentItem = canvas.Services.Component.RegisterComponentForDesigner(component);
+ componentItem.Key = "res1";
Assert.IsTrue(canvasResources.IsCollection);
- canvasResources.CollectionElements.Add(str);
+ canvasResources.CollectionElements.Add(componentItem);
+
+ DesignItemProperty prop = textBlock.Properties[TextBlock.TagProperty];
+ prop.SetValue(new StaticResourceExtension());
+ prop.Value.Properties["ResourceKey"].SetValue("res1");
- textBlock.Properties[TextBlock.TextProperty].SetValue(new StaticResourceExtension());
- DesignItemProperty prop = textBlock.Properties[TextBlock.TextProperty];
- prop.Value.Properties["ResourceKey"].SetValue("str1");
+ string typeName = component.GetType().Name;
string expectedXaml = "\n" +
- " stringresource 1\n" +
+ " " + expectedXamlValue + "\n" +
"\n" +
- "";
+ "";
AssertCanvasDesignerOutput(expectedXaml, textBlock.Context, "xmlns:Controls0=\"clr-namespace:System;assembly=mscorlib\"");
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
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/HierarchyTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/HierarchyTests.cs
index fd1e76ea4e..7a0a7cdcb3 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/HierarchyTests.cs
+++ b/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
{
private DesignItem _grid;
- private OutlineNode _outline;
+ private IOutlineNode _outline;
[TestFixtureSetUp]
public void Intialize()
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs
index 542b353bb0..d91fcb011c 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs
+++ b/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
{
private DesignItem _grid;
- private OutlineNode _outline;
+ private IOutlineNode _outline;
private DesignItem _gridButton;
private DesignItem _stackPanel;
private DesignItem _stackPanelButton;
- private OutlineNode _gridButtonNode;
- private OutlineNode _stackPanelNode;
- private OutlineNode _stackPanelButtonNode;
+ private IOutlineNode _gridButtonNode;
+ private IOutlineNode _stackPanelNode;
+ private IOutlineNode _stackPanelButtonNode;
[SetUp]
public void Intialize()
@@ -162,15 +162,15 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView
public class ContentControlInsertTests : ModelTestHelper
{
private DesignItem _grid;
- private OutlineNode _outline;
+ private IOutlineNode _outline;
private DesignItem _gridButton;
private DesignItem _stackPanel;
private DesignItem _stackPanelImage;
- private OutlineNode _gridButtonNode;
- private OutlineNode _stackPanelNode;
- private OutlineNode _stackPanelImageNode;
+ private IOutlineNode _gridButtonNode;
+ private IOutlineNode _stackPanelNode;
+ private IOutlineNode _stackPanelImageNode;
[SetUp]
public void Intialize()
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/SelectionTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/SelectionTests.cs
index 9d3c37d7c5..849687a48b 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/SelectionTests.cs
+++ b/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
{
private DesignItem _grid;
- private OutlineNode _outline;
+ private IOutlineNode _outline;
[SetUp]
public void Intialize()
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
index 01ba32c1cd..2f185ebfeb 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
@@ -1,94 +1,94 @@
-
-
-
- {88DA149F-21B2-48AB-82C4-28FB6BDFD783}
- Debug
- AnyCPU
- Library
- ICSharpCode.WpfDesign.XamlDom
- ICSharpCode.WpfDesign.XamlDom
- False
- False
- 4
- false
- True
- ..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk
- False
- File
- False
- -Microsoft.Globalization#CA1303;-Microsoft.Performance#CA1800
- ..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\
- ..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml
- v4.0
- C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis
- Client
-
-
- true
- Full
- True
- DEBUG;TRACE
- False
-
-
- False
- None
- False
- TRACE
-
-
- False
- Auto
- 4194304
- AnyCPU
- 4096
-
-
-
-
- False
-
-
- False
-
-
-
- 3.5
-
-
-
-
-
- False
-
-
-
-
- GlobalAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ {88DA149F-21B2-48AB-82C4-28FB6BDFD783}
+ Debug
+ AnyCPU
+ Library
+ ICSharpCode.WpfDesign.XamlDom
+ ICSharpCode.WpfDesign.XamlDom
+ False
+ False
+ 4
+ false
+ True
+ ..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk
+ False
+ File
+ False
+ -Microsoft.Globalization#CA1303;-Microsoft.Performance#CA1800
+ ..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\
+ ..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml
+ v4.0
+ C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis
+ Client
+
+
+ true
+ Full
+ True
+ DEBUG;TRACE
+ False
+
+
+ False
+ None
+ False
+ TRACE
+
+
+ False
+ Auto
+ 4194304
+ AnyCPU
+ 4096
+
+
+
+
+ False
+
+
+ False
+
+
+
+ 3.5
+
+
+
+
+
+ False
+
+
+
+
+ GlobalAssemblyInfo.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
index 7a23eabac7..b324fd1bc7 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
@@ -158,9 +158,14 @@ namespace ICSharpCode.WpfDesign.XamlDom
///
/// Create an XamlObject from the instance.
///
- public XamlObject CreateObject(object instance)
+ public XamlObject CreateObject(object instance, object baseobject=null)
{
- return (XamlObject)CreatePropertyValue(instance, null);
+ object obj = instance;
+ if (baseobject != null && instance.GetType() != baseobject.GetType())
+ obj = baseobject;
+ XamlObject xamlobj = (XamlObject)CreatePropertyValue(obj, null);
+ xamlobj.Instance = instance;
+ return xamlobj;
}
///
@@ -193,7 +198,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XmlElement xml = _xmlDoc.CreateElement(prefix, elementType.Name, ns);
- if (hasStringConverter && XamlObject.GetContentPropertyName(elementType) != null) {
+ if (hasStringConverter && (XamlObject.GetContentPropertyName(elementType) != null || IsNativeType(instance))) {
xml.InnerText = c.ConvertToInvariantString(instance);
} 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
@@ -214,8 +219,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
}
- } else if (instance is string) {
- xml.InnerText = (string)instance;
}
return new XamlObject(this, xml, elementType, instance);
@@ -274,5 +277,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
return prefix;
}
+
+ bool IsNativeType(object instance)
+ {
+ return instance.GetType().Assembly == typeof(String).Assembly;
+ }
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
index e8275a34e4..1adaeaaf39 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
@@ -287,6 +287,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
///
public object Instance {
get { return instance; }
+ internal set { instance = value; }
}
///
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs
index 1e8589676b..a01b335e9c 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs
@@ -48,7 +48,18 @@ namespace ICSharpCode.WpfDesign.Extensions
///
/// Creates an instance of the specified type, passing the specified arguments to its constructor.
///
+ ///
+ ///
+ ///
public virtual object CreateInstance(Type type, params object[] arguments)
+ {
+ return CreateObjectInstance(type, arguments);
+ }
+
+ ///
+ /// Creates an instance of the specified type, passing the specified arguments to its constructor.
+ ///
+ public static object CreateObjectInstance(Type type, params object[] arguments)
{
var instance = Activator.CreateInstance(type, arguments);
var uiElement = instance as UIElement;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs
index 73174617fc..b413596204 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.Collections.Generic;
namespace ICSharpCode.WpfDesign.Extensions
{
@@ -28,6 +29,7 @@ namespace ICSharpCode.WpfDesign.Extensions
{
Type _designedItemType;
Type _overrideExtension;
+ List _overrideExtensions = new List();
///
/// Gets the type of the item that is designed using this extension.
@@ -36,6 +38,18 @@ namespace ICSharpCode.WpfDesign.Extensions
get { return _designedItemType; }
}
+ ///
+ /// Gets/Sets the types of another extension that this extension is overriding.
+ ///
+ public Type[] OverrideExtensions
+ {
+ get { return _overrideExtensions.ToArray(); }
+ set
+ {
+ _overrideExtensions.AddRange(value);
+ }
+ }
+
///
/// Gets/Sets the type of another extension that this extension is overriding.
///
@@ -47,6 +61,8 @@ namespace ICSharpCode.WpfDesign.Extensions
if (!typeof(Extension).IsAssignableFrom(value)) {
throw new ArgumentException("OverrideExtension must specify the type of an Extension.");
}
+ if(!_overrideExtensions.Contains(value))
+ _overrideExtensions.Add(value);
}
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
index 21046f321e..35234862ea 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
@@ -64,13 +64,19 @@ namespace ICSharpCode.WpfDesign.Extensions
{
internal readonly Type ExtensionType;
internal readonly ExtensionServer Server;
- internal readonly Type OverriddenExtensionType;
+ internal readonly List OverriddenExtensionTypes = new List();
public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType)
{
this.ExtensionType = extensionType;
this.Server = server;
- this.OverriddenExtensionType = overriddenExtensionType;
+ this.OverriddenExtensionTypes.Add(overriddenExtensionType);
+ }
+ public ExtensionEntry(Type extensionType, ExtensionServer server, List overriddenExtensionTypes)
+ {
+ this.ExtensionType = extensionType;
+ this.Server = server;
+ this.OverriddenExtensionTypes= overriddenExtensionTypes;
}
}
@@ -87,23 +93,18 @@ namespace ICSharpCode.WpfDesign.Extensions
List GetExtensionEntries(Type extendedItemType)
{
- List result;
- if (extendedItemType.BaseType != null)
- result = GetExtensionEntries(extendedItemType.BaseType);
- else
- result = new List();
-
- List list;
- 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;
- });
- }
+ List result = new List();
+ List overriddenExtensions = new List();
+ IEnumerable ie = _extensions.Where(x => x.Key.IsAssignableFrom(extendedItemType)).SelectMany(x => x.Value);
+ foreach (ExtensionEntry entry in ie) {
+ if (!overriddenExtensions.Contains(entry.ExtensionType)) {
+ overriddenExtensions.AddRange(entry.OverriddenExtensionTypes);
+
+ result.RemoveAll(x => overriddenExtensions.Contains(x.ExtensionType));
result.Add(entry);
}
}
+
return result;
}
@@ -184,7 +185,7 @@ namespace ICSharpCode.WpfDesign.Extensions
foreach (ExtensionForAttribute designerFor in extensionForAttributes) {
ExtensionServer server = GetServerForExtension(type);
- AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtension));
+ AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtensions.ToList()));
}
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
index 2f95f1b266..082c32632f 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
@@ -122,7 +122,7 @@ namespace ICSharpCode.WpfDesign
DesignItem GetDesignItem(object component);
/// Registers a component for usage in the designer.
- DesignItem RegisterComponentForDesigner(object component);
+ DesignItem RegisterComponentForDesigner(object component, Type basetype=null);
/// Event raised whenever a component is registered
event EventHandler ComponentRegistered;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
index bb23a64926..a799c1f84e 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
@@ -21,6 +21,7 @@ using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
+using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners;
@@ -53,6 +54,10 @@ namespace ICSharpCode.WpfDesign
///
public interface IToolService
{
+ ///
+ /// Set custom HitTestFilterCallback for DesignPanel
+ ///
+ HitTestFilterCallback DesignPanelHitTestFilterCallback{ set; }
///
/// Gets the 'pointer' tool.
/// The pointer tool is the default tool for selecting and moving elements.
@@ -77,6 +82,10 @@ namespace ICSharpCode.WpfDesign
public interface IDesignPanel : IInputElement
{
///
+ /// Set a custom filter callback so that any element can be filtered out
+ ///
+ HitTestFilterCallback CustomHitTestFilterBehavior { get; set; }
+ ///
/// Gets the design context used by the DesignPanel.
///
DesignContext Context { get; }
diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/InstalledPackageViewModel.cs b/src/AddIns/Misc/PackageManagement/Project/Src/InstalledPackageViewModel.cs
new file mode 100644
index 0000000000..d5280d8403
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Project/Src/InstalledPackageViewModel.cs
@@ -0,0 +1,79 @@
+// 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 GetProcessPackageActionsForSelectedProjects(
+ IList selectedProjects)
+ {
+ var actions = new List();
+ 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 projects)
+ {
+ return true;
+ }
+ }
+}
diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs b/src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs
new file mode 100644
index 0000000000..090881631b
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs
@@ -0,0 +1,89 @@
+// 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
+{
+ ///
+ /// 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.
+ ///
+ public class ProjectTemplatePackageRepositoryCache : IPackageRepositoryCache
+ {
+ IPackageRepositoryCache packageRepositoryCache;
+ RegisteredProjectTemplatePackageSources registeredPackageSources;
+
+ ///
+ /// Creates a new instance of the ProjectTemplatePackageRepositoryCache.
+ ///
+ /// The main package repository cache used
+ /// with the Add Package Reference dialog.
+ public ProjectTemplatePackageRepositoryCache(
+ IPackageRepositoryCache packageRepositoryCache,
+ RegisteredProjectTemplatePackageSources registeredPackageSources)
+ {
+ this.packageRepositoryCache = packageRepositoryCache;
+ this.registeredPackageSources = registeredPackageSources;
+ }
+
+ public IRecentPackageRepository RecentPackageRepository {
+ get { throw new NotImplementedException(); }
+ }
+
+ public IPackageRepository CreateAggregateRepository()
+ {
+ IEnumerable repositories = GetRegisteredPackageRepositories();
+ return CreateAggregateRepository(repositories);
+ }
+
+ IEnumerable GetRegisteredPackageRepositories()
+ {
+ foreach (PackageSource packageSource in GetEnabledPackageSources()) {
+ yield return CreateRepository(packageSource.Source);
+ }
+ }
+
+ public IEnumerable GetEnabledPackageSources()
+ {
+ return registeredPackageSources.PackageSources.GetEnabledPackageSources();
+ }
+
+ public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IRecentPackageRepository CreateRecentPackageRepository(IList recentPackages, IPackageRepository aggregateRepository)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IPackageRepository CreateAggregateRepository(IEnumerable repositories)
+ {
+ return packageRepositoryCache.CreateAggregateRepository(repositories);
+ }
+
+ public IPackageRepository CreateRepository(string packageSource)
+ {
+ return packageRepositoryCache.CreateRepository(packageSource);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSources.cs b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSources.cs
new file mode 100644
index 0000000000..7b83b2b504
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSources.cs
@@ -0,0 +1,64 @@
+// 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; }
+ }
+ }
+}
diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSourcesView.xaml b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSourcesView.xaml
new file mode 100644
index 0000000000..3eb3e25f53
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSourcesView.xaml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/CodeGeneratorTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/CodeGeneratorTests.cs
new file mode 100644
index 0000000000..a6c0bb0b92
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Test/Src/CodeGeneratorTests.cs
@@ -0,0 +1,88 @@
+// 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());
+// 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);
+// }
+// }
+//}
diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/ProjectTemplatePackageRepositoryCacheTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/ProjectTemplatePackageRepositoryCacheTests.cs
new file mode 100644
index 0000000000..73ab8df4c6
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Test/Src/ProjectTemplatePackageRepositoryCacheTests.cs
@@ -0,0 +1,120 @@
+// 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 repositories = fakeMainCache.RepositoriesPassedToCreateAggregateRepository;
+ var expectedRepositories = new List();
+ 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 repositories = fakeMainCache.RepositoriesPassedToCreateAggregateRepository;
+ var expectedRepositories = new List();
+ expectedRepositories.Add(fakeRepository2);
+
+ Assert.AreEqual(expectedRepositories, repositories);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/RegisteredProjectTemplatePackageSourcesTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/RegisteredProjectTemplatePackageSourcesTests.cs
new file mode 100644
index 0000000000..de37d01190
--- /dev/null
+++ b/src/AddIns/Misc/PackageManagement/Test/Src/RegisteredProjectTemplatePackageSourcesTests.cs
@@ -0,0 +1,103 @@
+// 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 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();
+ 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();
+ 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();
+ CreateRegisteredPackageSources(packageSources, propertyService);
+
+ IEnumerable actualPackageSources =
+ registeredPackageSources.PackageSources;
+
+ string directory = fakeSettingsFactory.DirectoryPassedToCreateSettings;
+ string expectedDirectory = @"c:\Users\test\AppData\ICSharpCode\SharpDevelop4.1\templates";
+
+ Assert.AreEqual(expectedDirectory, directory);
+ }
+ }
+}