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. 40
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs
  6. 19
      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. 222
      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. 22
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs
  16. 11
      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. 11
      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. 188
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
  26. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
  27. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
  28. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs
  29. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs
  30. 35
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
  31. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
  32. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
  33. 79
      src/AddIns/Misc/PackageManagement/Project/Src/InstalledPackageViewModel.cs
  34. 89
      src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs
  35. 64
      src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSources.cs
  36. 26
      src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSourcesView.xaml
  37. 88
      src/AddIns/Misc/PackageManagement/Test/Src/CodeGeneratorTests.cs
  38. 120
      src/AddIns/Misc/PackageManagement/Test/Src/ProjectTemplatePackageRepositoryCacheTests.cs
  39. 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 @@ @@ -54,7 +54,6 @@
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Design" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">

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

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

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

@ -26,25 +26,25 @@ using System.Windows.Controls; @@ -26,25 +26,25 @@ using System.Windows.Controls;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Display height of the element.
/// </summary>
public class HeightDisplay : Control
{
static HeightDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
}
}
/// <summary>
/// Display height of the element.
/// </summary>
class HeightDisplay : Control
{
static HeightDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
}
}
/// <summary>
/// Display width of the element.
/// </summary>
public class WidthDisplay : Control
{
static WidthDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
}
}
/// <summary>
/// Display width of the element.
/// </summary>
class WidthDisplay : Control
{
static WidthDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
}
}
}

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

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

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

@ -31,19 +31,6 @@ namespace ICSharpCode.WpfDesign.Designer @@ -31,19 +31,6 @@ 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);

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

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

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

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

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

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

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

@ -34,45 +34,138 @@ using ICSharpCode.WpfDesign.XamlDom; @@ -34,45 +34,138 @@ using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
public interface IOutlineNode
public class OutlineNode : INotifyPropertyChanged
{
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<IOutlineNode> nodes, IOutlineNode after, bool copy);
void Insert(IEnumerable<IOutlineNode> nodes, IOutlineNode after, bool copy);
ObservableCollection<IOutlineNode> Children{ get; }
}
//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;
}
public class OutlineNode: OutlineNodeBase
{
//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();
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);
}
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;
if (!outlineNodes.TryGetValue(designItem, out node)) {
node = new OutlineNode(designItem);
outlineNodes[designItem] = node;
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<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)
@ -80,7 +173,19 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -80,7 +173,19 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
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();
@ -88,7 +193,8 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -88,7 +193,8 @@ 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 });
}
@ -102,12 +208,16 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -102,12 +208,16 @@ 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 });
}
@ -116,5 +226,57 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -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 @@ @@ -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 @@ -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 IOutlineNode).CanInsert(_customOutlineNodes,
after == null ? null : after.DataContext as IOutlineNode, copy);
return (target.DataContext as OutlineNode).CanInsert(_customOutlineNodes,
after == null ? null : after.DataContext as OutlineNode, copy);
}
protected override void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
{
UpdateCustomNodes(items);
(target.DataContext as IOutlineNode).Insert(_customOutlineNodes,
after == null ? null : after.DataContext as IOutlineNode, copy);
(target.DataContext as OutlineNode).Insert(_customOutlineNodes,
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
private List<IOutlineNode> _customOutlineNodes;
private List<OutlineNode> _customOutlineNodes;
void UpdateCustomNodes(IEnumerable<DragTreeViewItem> items)
{
_customOutlineNodes = new List<IOutlineNode>();
_customOutlineNodes = new List<OutlineNode>();
foreach (var item in items)
_customOutlineNodes.Add(item.DataContext as IOutlineNode);
_customOutlineNodes.Add(item.DataContext as OutlineNode);
}
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());
}
@ -60,7 +60,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -60,7 +60,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
base.SelectOnly(item);
var node = item.DataContext as IOutlineNode;
var node = item.DataContext as OutlineNode;
var surface = node.DesignItem.View.TryFindParent<DesignSurface>();
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 @@ -64,7 +64,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
if(control!=null){
TypeMappings.TryGetValue(control.GetType(), out _type);
if (_type != null) {
IOutlineNode node = OutlineNode.Create(item);
OutlineNode node = OutlineNode.Create(item);
Outline.Root = node;
PropertyGridView.PropertyGrid.SelectedItems = item.Services.Selection.SelectedItems;
}

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

@ -35,19 +35,7 @@ using System.Windows; @@ -35,19 +35,7 @@ using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
public interface IPropertyGrid
{
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 class PropertyGrid : INotifyPropertyChanged
{
public PropertyGrid()
{
@ -67,13 +55,9 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid @@ -67,13 +55,9 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
Dictionary<MemberDescriptor, PropertyNode> nodeFromDescriptor = new Dictionary<MemberDescriptor, PropertyNode>();
public Dictionary<MemberDescriptor, PropertyNode> 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
@ -229,15 +213,13 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid @@ -229,15 +213,13 @@ 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);
}
}

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

@ -42,16 +42,13 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid @@ -42,16 +42,13 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
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;
}
private Thumb thumb;
public override void OnApplyTemplate()
{
@ -64,7 +61,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid @@ -64,7 +61,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
static PropertyContextMenu propertyContextMenu = new PropertyContextMenu();
public IPropertyGrid PropertyGrid { get; private set; }
public PropertyGrid PropertyGrid { get; private set; }
public static readonly DependencyProperty FirstColumnWidthProperty =
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; @@ -20,7 +20,6 @@ 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;
@ -152,31 +151,15 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -152,31 +151,15 @@ 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, componentType);
DesignItem item = context.Services.Component.RegisterComponentForDesigner(newInstance);
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)
{
return AddItemWithCustomSize(container, createdItem, position, ModelTools.GetDefaultSize(createdItem));
}
internal static bool AddItemWithCustomSize(DesignItem container, DesignItem createdItem, Point position, Size size)
{
var size = ModelTools.GetDefaultSize(createdItem);
PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents(
container,
new DesignItem[] { createdItem },

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

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

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

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

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

@ -21,7 +21,7 @@ using System.Collections.Generic; @@ -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,18 +68,15 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -68,18 +68,15 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
return site;
}
public DesignItem RegisterComponentForDesigner(object component, Type basetype = null)
public DesignItem RegisterComponentForDesigner(object component)
{
if (component == null) {
component = new NullExtension();
} else if (component is Type) {
component = new TypeExtension((Type)component);
}
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);
XamlDesignItem item = new XamlDesignItem(_context.Document.CreateObject(component), _context);
_sites.Add(component, item);
if (ComponentRegistered != null) {
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 @@ -668,52 +668,31 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
}
[Test]
public void AddNativeTypeAsResource(object component, string expectedXamlValue)
public void AddStringAsResource()
{
DesignItem textBlock = CreateCanvasContext("<TextBlock/>");
DesignItem canvas = textBlock.Parent;
DesignItemProperty canvasResources = canvas.Properties.GetProperty("Resources");
DesignItem componentItem = canvas.Services.Component.RegisterComponentForDesigner(component);
componentItem.Key = "res1";
DesignItem str = canvas.Services.Component.RegisterComponentForDesigner("stringresource 1");
str.Key = "str1";
Assert.IsTrue(canvasResources.IsCollection);
canvasResources.CollectionElements.Add(componentItem);
DesignItemProperty prop = textBlock.Properties[TextBlock.TagProperty];
prop.SetValue(new StaticResourceExtension());
prop.Value.Properties["ResourceKey"].SetValue("res1");
canvasResources.CollectionElements.Add(str);
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" +
" <Controls0:" + typeName + " x:Key=\"res1\">" + expectedXamlValue + "</Controls0:" + typeName + ">\n" +
" <Controls0:String x:Key=\"str1\">stringresource 1</Controls0:String>\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\"");
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

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

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

188
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj

@ -1,94 +1,94 @@ @@ -1,94 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.WpfDesign.XamlDom</RootNamespace>
<AssemblyName>ICSharpCode.WpfDesign.XamlDom</AssemblyName>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Globalization#CA1303;-Microsoft.Performance#CA1800</CodeAnalysisRules>
<OutputPath>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\</OutputPath>
<DocumentationFile>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml</DocumentationFile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SourceAnalysisOverrideSettingsFile>C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="PresentationCore">
<Private>False</Private>
</Reference>
<Reference Include="PresentationFramework">
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CollectionElementsCollection.cs" />
<Compile Include="CollectionSupport.cs" />
<Compile Include="DesignTimeProperties.cs" />
<Compile Include="IXamlErrorSink.cs" />
<Compile Include="MarkupCompatibilityProperties.cs" />
<Compile Include="MarkupExtensionParser.cs" />
<Compile Include="MarkupExtensionPrinter.cs" />
<Compile Include="NameScopeHelper.cs" />
<Compile Include="PositionXmlDocument.cs" />
<Compile Include="XamlConstants.cs" />
<Compile Include="XamlDocument.cs" />
<Compile Include="XamlLoadException.cs" />
<Compile Include="XamlObject.cs" />
<Compile Include="XamlObjectServiceProvider.cs" />
<Compile Include="XamlParser.cs" />
<Compile Include="XamlParserSettings.cs" />
<Compile Include="XamlProperty.cs" />
<Compile Include="XamlPropertyInfo.cs" />
<Compile Include="XamlPropertyValue.cs" />
<Compile Include="XamlStaticTools.cs" />
<Compile Include="XamlTextValue.cs" />
<Compile Include="XamlTypeFinder.cs" />
<Compile Include="XamlTypeResolverProvider.cs" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.WpfDesign.XamlDom</RootNamespace>
<AssemblyName>ICSharpCode.WpfDesign.XamlDom</AssemblyName>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Globalization#CA1303;-Microsoft.Performance#CA1800</CodeAnalysisRules>
<OutputPath>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\</OutputPath>
<DocumentationFile>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml</DocumentationFile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SourceAnalysisOverrideSettingsFile>C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="PresentationCore">
<Private>False</Private>
</Reference>
<Reference Include="PresentationFramework">
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CollectionElementsCollection.cs" />
<Compile Include="CollectionSupport.cs" />
<Compile Include="DesignTimeProperties.cs" />
<Compile Include="IXamlErrorSink.cs" />
<Compile Include="MarkupCompatibilityProperties.cs" />
<Compile Include="MarkupExtensionParser.cs" />
<Compile Include="MarkupExtensionPrinter.cs" />
<Compile Include="NameScopeHelper.cs" />
<Compile Include="PositionXmlDocument.cs" />
<Compile Include="XamlConstants.cs" />
<Compile Include="XamlDocument.cs" />
<Compile Include="XamlLoadException.cs" />
<Compile Include="XamlObject.cs" />
<Compile Include="XamlObjectServiceProvider.cs" />
<Compile Include="XamlParser.cs" />
<Compile Include="XamlParserSettings.cs" />
<Compile Include="XamlProperty.cs" />
<Compile Include="XamlPropertyInfo.cs" />
<Compile Include="XamlPropertyValue.cs" />
<Compile Include="XamlStaticTools.cs" />
<Compile Include="XamlTextValue.cs" />
<Compile Include="XamlTypeFinder.cs" />
<Compile Include="XamlTypeResolverProvider.cs" />
</ItemGroup>
</Project>

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

@ -158,14 +158,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -158,14 +158,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// <summary>
/// Create an XamlObject from the instance.
/// </summary>
public XamlObject CreateObject(object instance, object baseobject=null)
public XamlObject CreateObject(object instance)
{
object obj = instance;
if (baseobject != null && instance.GetType() != baseobject.GetType())
obj = baseobject;
XamlObject xamlobj = (XamlObject)CreatePropertyValue(obj, null);
xamlobj.Instance = instance;
return xamlobj;
return (XamlObject)CreatePropertyValue(instance, null);
}
/// <summary>
@ -198,7 +193,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -198,7 +193,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
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);
} 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
@ -219,6 +214,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -219,6 +214,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
}
} else if (instance is string) {
xml.InnerText = (string)instance;
}
return new XamlObject(this, xml, elementType, instance);
@ -277,10 +274,5 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -277,10 +274,5 @@ namespace ICSharpCode.WpfDesign.XamlDom
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 @@ -287,7 +287,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// </summary>
public object Instance {
get { return instance; }
internal set { instance = value; }
}
/// <summary>

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

@ -48,18 +48,7 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -48,18 +48,7 @@ namespace ICSharpCode.WpfDesign.Extensions
/// <summary>
/// Creates an instance of the specified type, passing the specified arguments to its constructor.
/// </summary>
/// <param name="type"></param>
/// <param name="arguments"></param>
/// <returns></returns>
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 uiElement = instance as UIElement;

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

@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
namespace ICSharpCode.WpfDesign.Extensions
{
@ -29,7 +28,6 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -29,7 +28,6 @@ namespace ICSharpCode.WpfDesign.Extensions
{
Type _designedItemType;
Type _overrideExtension;
List<Type> _overrideExtensions = new List<Type>();
/// <summary>
/// Gets the type of the item that is designed using this extension.
@ -38,18 +36,6 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -38,18 +36,6 @@ namespace ICSharpCode.WpfDesign.Extensions
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>
/// Gets/Sets the type of another extension that this extension is overriding.
/// </summary>
@ -61,8 +47,6 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -61,8 +47,6 @@ 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);
}
}
}

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

@ -64,19 +64,13 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -64,19 +64,13 @@ namespace ICSharpCode.WpfDesign.Extensions
{
internal readonly Type ExtensionType;
internal readonly ExtensionServer Server;
internal readonly List<Type> OverriddenExtensionTypes = new List<Type>();
internal readonly Type OverriddenExtensionType;
public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType)
{
this.ExtensionType = extensionType;
this.Server = server;
this.OverriddenExtensionTypes.Add(overriddenExtensionType);
}
public ExtensionEntry(Type extensionType, ExtensionServer server, List<Type> overriddenExtensionTypes)
{
this.ExtensionType = extensionType;
this.Server = server;
this.OverriddenExtensionTypes= overriddenExtensionTypes;
this.OverriddenExtensionType = overriddenExtensionType;
}
}
@ -93,18 +87,23 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -93,18 +87,23 @@ namespace ICSharpCode.WpfDesign.Extensions
List<ExtensionEntry> GetExtensionEntries(Type extendedItemType)
{
List<ExtensionEntry> result = new List<ExtensionEntry>();
List<Type> overriddenExtensions = new List<Type>();
IEnumerable<ExtensionEntry> 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));
List<ExtensionEntry> result;
if (extendedItemType.BaseType != null)
result = GetExtensionEntries(extendedItemType.BaseType);
else
result = new List<ExtensionEntry>();
List<ExtensionEntry> 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;
});
}
result.Add(entry);
}
}
return result;
}
@ -185,7 +184,7 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -185,7 +184,7 @@ namespace ICSharpCode.WpfDesign.Extensions
foreach (ExtensionForAttribute designerFor in extensionForAttributes) {
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 @@ -122,7 +122,7 @@ namespace ICSharpCode.WpfDesign
DesignItem GetDesignItem(object component);
/// <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>
event EventHandler<DesignItemEventArgs> ComponentRegistered;

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

@ -21,7 +21,6 @@ using System.Collections.Generic; @@ -21,7 +21,6 @@ using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners;
@ -54,10 +53,6 @@ namespace ICSharpCode.WpfDesign @@ -54,10 +53,6 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public interface IToolService
{
/// <summary>
/// Set custom HitTestFilterCallback for DesignPanel
/// </summary>
HitTestFilterCallback DesignPanelHitTestFilterCallback{ set; }
/// <summary>
/// Gets the 'pointer' tool.
/// The pointer tool is the default tool for selecting and moving elements.
@ -82,10 +77,6 @@ namespace ICSharpCode.WpfDesign @@ -82,10 +77,6 @@ namespace ICSharpCode.WpfDesign
public interface IDesignPanel : IInputElement
{
/// <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.
/// </summary>
DesignContext Context { get; }

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

@ -1,79 +0,0 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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