Browse Source

Outline Node Name Service

pull/690/head
jkuehner 10 years ago
parent
commit
eccb641ab0
  1. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs
  2. 44
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeNameService.cs
  3. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs
  4. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  5. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs
  6. 28
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs
  7. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs

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

@ -154,10 +154,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -154,10 +154,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
get
{
if (string.IsNullOrEmpty(DesignItem.Name)) {
return DesignItem.ComponentType.Name;
}
return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")";
return DesignItem.Services.GetService<IOutlineNodeNameService>().GetOutlineNodeName(DesignItem);
}
}

44
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeNameService.cs

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
// 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;
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
/// <summary>
/// Description of OulineNodeNameService.
/// </summary>
public class OutlineNodeNameService : IOutlineNodeNameService
{
public OutlineNodeNameService()
{
}
#region IOutlineNodeNameService implementation
public string GetOutlineNodeName(DesignItem designItem)
{
if (string.IsNullOrEmpty(designItem.Name)) {
return designItem.ComponentType.Name;
}
return designItem.ComponentType.Name + " (" + designItem.Name + ")";
}
#endregion
}
}

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

@ -54,7 +54,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -54,7 +54,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
var node = dragTreeViewitem.DataContext as IOutlineNode;
return string.IsNullOrEmpty(Filter) || node.Name.ToLower().Contains(Filter.ToLower());
return string.IsNullOrEmpty(Filter) || node.DesignItem.Services.GetService<IOutlineNodeNameService>().GetOutlineNodeName(node.DesignItem).ToLower().Contains(Filter.ToLower());
}
protected override void SelectOnly(DragTreeViewItem item)

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

@ -135,6 +135,7 @@ @@ -135,6 +135,7 @@
</Compile>
<Compile Include="Extensions\WrapItemsContextMenuExtension.cs" />
<Compile Include="MarkupExtensions\DesignItemBinding.cs" />
<Compile Include="OutlineView\OutlineNodeNameService.cs" />
<Compile Include="OutlineView\OutlineNodeBase.cs" />
<Compile Include="Extensions\WrapItemContextMenuExtension.cs" />
<Compile Include="Extensions\WrapItemsContextMenu.xaml.cs">

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs

@ -21,6 +21,7 @@ using System.Collections.Generic; @@ -21,6 +21,7 @@ using System.Collections.Generic;
using System.Reflection;
using System.Xml;
using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Extensions;
using ICSharpCode.WpfDesign.Extensions;
@ -73,6 +74,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -73,6 +74,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
this.Services.AddService(typeof(IToolService), new DefaultToolService(this));
this.Services.AddService(typeof(UndoService), new UndoService());
this.Services.AddService(typeof(IErrorService), new DefaultErrorService(this));
this.Services.AddService(typeof(IOutlineNodeNameService), new OutlineNodeNameService());
this.Services.AddService(typeof(ViewService), new DefaultViewService(this));
this.Services.AddService(typeof(OptionService), new OptionService());

28
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs

@ -65,6 +65,34 @@ namespace ICSharpCode.WpfDesign @@ -65,6 +65,34 @@ namespace ICSharpCode.WpfDesign
}
}
/// <summary>
/// Adds a new service to the container or Replaces a existing one.
/// </summary>
/// <param name="serviceInterface">
/// The type of the service interface to use as a key for the service.
/// </param>
/// <param name="serviceInstance">
/// The service instance implementing that interface.
/// </param>
public void AddOrReplaceService(Type serviceInterface, object serviceInstance)
{
if (serviceInterface == null)
throw new ArgumentNullException("serviceInterface");
if (serviceInstance == null)
throw new ArgumentNullException("serviceInstance");
if (_services.ContainsKey(serviceInterface))
_services.Remove(serviceInterface);
_services.Add(serviceInterface, serviceInstance);
Delegate subscriber;
if (_waitingSubscribers.TryGetValue(serviceInterface, out subscriber)) {
_waitingSubscribers.Remove(serviceInterface);
subscriber.DynamicInvoke(serviceInstance);
}
}
/// <summary>
/// Gets the service object of the specified type.
/// Returns null when the service is not available.

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

@ -173,6 +173,19 @@ namespace ICSharpCode.WpfDesign @@ -173,6 +173,19 @@ namespace ICSharpCode.WpfDesign
}
#endregion
#region IOutlineNodeNameService
/// <summary>
/// Used to get a description for the Outline Node.
/// </summary>
public interface IOutlineNodeNameService
{
/// <summary>
/// Gets a the Name for display in the Ouline Node.
/// </summary>
string GetOutlineNodeName(DesignItem designItem);
}
#endregion
#region IErrorService
/// <summary>
/// Service for showing error UI.

Loading…
Cancel
Save