diff --git a/data/templates/packages/Modernizr.2.5.3.nupkg b/data/templates/packages/Modernizr.2.5.3.nupkg deleted file mode 100644 index 98ade6d191..0000000000 Binary files a/data/templates/packages/Modernizr.2.5.3.nupkg and /dev/null differ diff --git a/data/templates/packages/jQuery.1.7.2.nupkg b/data/templates/packages/jQuery.1.7.2.nupkg deleted file mode 100644 index 033bae95d0..0000000000 Binary files a/data/templates/packages/jQuery.1.7.2.nupkg and /dev/null differ diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj b/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj index 366aa3a811..1b41ab422d 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj @@ -54,7 +54,6 @@ - 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 7e2dae8f41..911f7d12bb 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)); - public PlacementAlignment Alignment; + internal 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 e3fa8bc88f..8f660b84db 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. - /// - public class HeightDisplay : Control - { - static HeightDisplay() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay))); - } - } + /// + /// Display height of the element. + /// + class HeightDisplay : Control + { + static HeightDisplay() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay))); + } + } - /// - /// Display width of the element. - /// - public class WidthDisplay : Control - { - static WidthDisplay() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay))); - } - } + /// + /// Display width of the element. + /// + 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 dbfb56eb09..0a5ba978a3 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,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 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 #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 82e9b5476f..efc39f6ee1 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs @@ -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); 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 c9fdb029a2..2ca8308f66 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))] - public class QuickOperationMenuExtension : PrimarySelectionAdornerProvider + 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 caa0eb4cf5..1eec1629ae 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))] - public class SizeDisplayExtension : PrimarySelectionAdornerProvider + 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 43f5702af4..da541a9cf3 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,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); } } 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 261d1b47e5..844ebd0d03 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs @@ -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 nodes, IOutlineNode after, bool copy); - void Insert(IEnumerable nodes, IOutlineNode after, bool copy); - ObservableCollection 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 outlineNodes = new Dictionary(); + static Dictionary outlineNodes = new Dictionary(); - 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(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 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 + ")"; } - return node; } void Selection_SelectionChanged(object sender, DesignItemCollectionEventArgs e) @@ -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 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 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 } } } + + 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 deleted file mode 100644 index 648b4097ec..0000000000 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs +++ /dev/null @@ -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 -{ - /// - /// 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 30d9a974b5..ffbd1347aa 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 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 _customOutlineNodes; + private List _customOutlineNodes; void UpdateCustomNodes(IEnumerable items) { - _customOutlineNodes = new List(); + _customOutlineNodes = new List(); 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 { base.SelectOnly(item); - var node = item.DataContext as IOutlineNode; + var node = item.DataContext as OutlineNode; 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 e592e37cf2..420cc02c4e 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) { - IOutlineNode node = OutlineNode.Create(item); + OutlineNode 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 872a0cc49c..14de050360 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs @@ -35,19 +35,7 @@ using System.Windows; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid { - 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 class PropertyGrid : INotifyPropertyChanged { public PropertyGrid() { @@ -67,13 +55,9 @@ 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 @@ -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); } } 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 d0435c13e8..b80aeb5582 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs @@ -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 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), 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 adb0dc04c9..c066d06222 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs @@ -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 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 }, 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 1837bc404d..63a450f196 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,11 +37,6 @@ 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 ebbffae7ed..8f016aaea9 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj @@ -91,7 +91,6 @@ - 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 ba5dac471e..81fa1cddd3 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,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)); 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 b3867622d5..44d4611df9 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs @@ -668,52 +668,31 @@ namespace ICSharpCode.WpfDesign.Tests.Designer } [Test] - public void AddNativeTypeAsResource(object component, string expectedXamlValue) + public void AddStringAsResource() { DesignItem textBlock = CreateCanvasContext(""); 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 = "\n" + - " " + expectedXamlValue + "\n" + + " stringresource 1\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 7a0a7cdcb3..fd1e76ea4e 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 IOutlineNode _outline; + private OutlineNode _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 d91fcb011c..542b353bb0 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 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 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() 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 849687a48b..9d3c37d7c5 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 IOutlineNode _outline; + private OutlineNode _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 2f185ebfeb..01ba32c1cd 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 b324fd1bc7..7a23eabac7 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs @@ -158,14 +158,9 @@ namespace ICSharpCode.WpfDesign.XamlDom /// /// Create an XamlObject from the instance. /// - 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); } /// @@ -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 } } } + } else if (instance is string) { + xml.InnerText = (string)instance; } return new XamlObject(this, xml, elementType, instance); @@ -277,10 +274,5 @@ 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 1adaeaaf39..e8275a34e4 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs @@ -287,7 +287,6 @@ 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 a01b335e9c..1e8589676b 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs @@ -48,18 +48,7 @@ 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 b413596204..73174617fc 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionForAttribute.cs @@ -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 { Type _designedItemType; Type _overrideExtension; - List _overrideExtensions = new List(); /// /// Gets the type of the item that is designed using this extension. @@ -38,18 +36,6 @@ 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. /// @@ -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); } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs index 35234862ea..21046f321e 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs @@ -64,19 +64,13 @@ namespace ICSharpCode.WpfDesign.Extensions { internal readonly Type ExtensionType; internal readonly ExtensionServer Server; - internal readonly List OverriddenExtensionTypes = new List(); + 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 overriddenExtensionTypes) - { - this.ExtensionType = extensionType; - this.Server = server; - this.OverriddenExtensionTypes= overriddenExtensionTypes; + this.OverriddenExtensionType = overriddenExtensionType; } } @@ -93,18 +87,23 @@ namespace ICSharpCode.WpfDesign.Extensions List GetExtensionEntries(Type extendedItemType) { - 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)); + 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; + }); + } result.Add(entry); } } - return result; } @@ -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)); } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs index 082c32632f..2f95f1b266 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, Type basetype=null); + DesignItem RegisterComponentForDesigner(object component); /// 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 a799c1f84e..bb23a64926 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs @@ -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 /// 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. @@ -82,10 +77,6 @@ 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 deleted file mode 100644 index d5280d8403..0000000000 --- a/src/AddIns/Misc/PackageManagement/Project/Src/InstalledPackageViewModel.cs +++ /dev/null @@ -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 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 deleted file mode 100644 index 090881631b..0000000000 --- a/src/AddIns/Misc/PackageManagement/Project/Src/ProjectTemplatePackageRepositoryCache.cs +++ /dev/null @@ -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 -{ - /// - /// 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 deleted file mode 100644 index 7b83b2b504..0000000000 --- a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSources.cs +++ /dev/null @@ -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; } - } - } -} diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSourcesView.xaml b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSourcesView.xaml deleted file mode 100644 index 3eb3e25f53..0000000000 --- a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredProjectTemplatePackageSourcesView.xaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - \ 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 deleted file mode 100644 index a6c0bb0b92..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/CodeGeneratorTests.cs +++ /dev/null @@ -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()); -// 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 deleted file mode 100644 index 73ab8df4c6..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/ProjectTemplatePackageRepositoryCacheTests.cs +++ /dev/null @@ -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 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 deleted file mode 100644 index de37d01190..0000000000 --- a/src/AddIns/Misc/PackageManagement/Test/Src/RegisteredProjectTemplatePackageSourcesTests.cs +++ /dev/null @@ -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 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); - } - } -}