Browse Source

Sort items in Go To dialog. Move GetBitmapExtension to core.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0wpf@3375 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
70b488e4a6
  1. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/GetBitmapExtension.cs
  2. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj
  3. 56
      src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs
  4. 30
      src/Main/ICSharpCode.Core.Presentation/GetBitmapExtension.cs
  5. 1
      src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj
  6. 1
      src/Main/ICSharpCode.Core.Presentation/Menu/CoreMenuItem.cs

21
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/GetBitmapExtension.cs

@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
using System;
using System.Windows.Markup;
using ICSharpCode.Core.Presentation;
namespace ICSharpCode.WpfDesign.AddIn
{
class GetBitmapExtension : MarkupExtension
{
public GetBitmapExtension(string key)
{
this.key = key;
}
protected string key;
public override object ProvideValue(IServiceProvider sp)
{
return PresentationResourceService.GetBitmapSource(key);
}
}
}

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj

@ -59,7 +59,6 @@ @@ -59,7 +59,6 @@
<Compile Include="Src\AbstractEventHandlerService.cs" />
<Compile Include="Src\CSharpEventHandlerService.cs" />
<Compile Include="Src\FileUriContext.cs" />
<Compile Include="Src\GetBitmapExtension.cs" />
<Compile Include="Src\IdeChooseClassService.cs" />
<Compile Include="Src\MyTypeFinder.cs" />
<Compile Include="Src\ObjectEditor.xaml.cs">

56
src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs

@ -1,21 +1,21 @@ @@ -1,21 +1,21 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core.Presentation;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
@ -42,14 +42,35 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -42,14 +42,35 @@ namespace ICSharpCode.SharpDevelop.Gui
public GotoDialog()
{
InitializeComponent();
// listView.SmallImageList = ClassBrowserIconService.ImageList;
// listView.ItemActivate += OKButtonClick;
// listView.Sorting = SortOrder.Ascending;
// listView.HideSelection = false;
// FormLocationHelper.Apply(this, "ICSharpCode.SharpDevelop.Gui.GotoDialog.Bounds", true);
textBox.Focus();
}
class MyListBoxItem : ListBoxItem, IComparable<MyListBoxItem>
{
public readonly string Text;
public MyListBoxItem(string text, int imageIndex)
{
this.Text = text;
this.Content = new StackPanel {
Orientation = Orientation.Horizontal,
Children = {
PresentationResourceService.GetImage(ClassBrowserIconService.ResourceNames[imageIndex]),
new TextBlock {
Text = text,
Margin = new Thickness(4, 0, 0, 0)
}
}
};
}
public int CompareTo(MyListBoxItem other)
{
return Text.CompareTo(other.Text);
}
}
void textBoxPreviewKeyDown(object sender, KeyEventArgs e)
{
if (listBox.SelectedItem == null)
@ -113,12 +134,14 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -113,12 +134,14 @@ namespace ICSharpCode.SharpDevelop.Gui
Dictionary<string, object> visibleEntries = new Dictionary<string, object>();
int bestMatchType;
double bestPriority;
List<MyListBoxItem> newItems = new List<MyListBoxItem>();
ListBoxItem bestItem;
void textBoxTextChanged(object sender, TextChangedEventArgs e)
{
string text = textBox.Text.Trim();
listBox.Items.Clear();
newItems.Clear();
visibleEntries.Clear();
bestItem = null;
if (text.Length == 0) {
@ -173,6 +196,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -173,6 +196,9 @@ namespace ICSharpCode.SharpDevelop.Gui
AddSourceFiles(text, 0);
ShowCtrlSpaceCompletion(text);
}
newItems.Sort();
foreach (MyListBoxItem item in newItems)
listBox.Items.Add(item);
if (bestItem != null) {
bestItem.IsSelected = true;
listBox.ScrollIntoView(bestItem);
@ -318,17 +344,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -318,17 +344,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (visibleEntries.ContainsKey(text))
return;
visibleEntries.Add(text, null);
ListBoxItem item = new ListBoxItem();
item.Content = new StackPanel {
Orientation = Orientation.Horizontal,
Children = {
PresentationResourceService.GetImage(ClassBrowserIconService.ResourceNames[imageIndex]),
new TextBlock {
Text = text,
Margin = new Thickness(4, 0, 0, 0)
}
}
};
MyListBoxItem item = new MyListBoxItem(text, imageIndex);
item.MouseDoubleClick += okButtonClick;
item.Tag = tag;
if (bestItem == null
@ -340,7 +356,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -340,7 +356,7 @@ namespace ICSharpCode.SharpDevelop.Gui
bestPriority = priority;
bestMatchType = matchType;
}
listBox.Items.Add(item);
newItems.Add(item);
}
void AddItem(IClass c, int matchType)

30
src/Main/ICSharpCode.Core.Presentation/GetBitmapExtension.cs

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Markup;
namespace ICSharpCode.Core.Presentation
{
/// <summary>
/// Markup extension that gets a BitmapSource object for a ResourceService bitmap.
/// </summary>
public class GetBitmapExtension : MarkupExtension
{
public GetBitmapExtension(string key)
{
this.key = key;
}
protected string key;
public override object ProvideValue(IServiceProvider sp)
{
return PresentationResourceService.GetBitmapSource(key);
}
}
}

1
src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj

@ -60,6 +60,7 @@ @@ -60,6 +60,7 @@
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="ConditionalSeparator.cs" />
<Compile Include="GetBitmapExtension.cs" />
<Compile Include="IStatusUpdate.cs" />
<Compile Include="LocalizeExtension.cs" />
<Compile Include="Menu\IMenuItemBuilder.cs" />

1
src/Main/ICSharpCode.Core.Presentation/Menu/CoreMenuItem.cs

@ -9,6 +9,7 @@ using System; @@ -9,6 +9,7 @@ using System;
using System.Collections;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace ICSharpCode.Core.Presentation
{

Loading…
Cancel
Save