Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4326 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
8 changed files with 191 additions and 22 deletions
@ -0,0 +1,54 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
using System; |
||||||
|
using System.Windows.Controls; |
||||||
|
|
||||||
|
namespace Debugger.AddIn.Visualizers.GridVisualizer |
||||||
|
{ |
||||||
|
|
||||||
|
public class LazyListView<T> |
||||||
|
{ |
||||||
|
private ListView listView; |
||||||
|
|
||||||
|
public LazyListView(ListView wrappedListView) |
||||||
|
{ |
||||||
|
if (wrappedListView == null) |
||||||
|
throw new ArgumentNullException("wrappedListView"); |
||||||
|
|
||||||
|
this.listView = wrappedListView; |
||||||
|
this.listView.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(handleListViewScroll)); |
||||||
|
} |
||||||
|
|
||||||
|
private VirtualizingIEnumerable<T> itemsSource; |
||||||
|
|
||||||
|
public VirtualizingIEnumerable<T> ItemsSource |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return itemsSource; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
this.itemsSource = value; |
||||||
|
this.itemsSource.RequestNextItems(14); |
||||||
|
this.listView.ItemsSource = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void handleListViewScroll(object sender, ScrollChangedEventArgs e) |
||||||
|
{ |
||||||
|
if (e.VerticalChange > 0) |
||||||
|
{ |
||||||
|
// scrolled to bottom
|
||||||
|
if (e.VerticalOffset == this.itemsSource.Count - e.ViewportHeight) |
||||||
|
{ |
||||||
|
this.itemsSource.RequestNextItems(1); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Collections.ObjectModel; |
||||||
|
|
||||||
|
namespace Debugger.AddIn.Visualizers.GridVisualizer |
||||||
|
{ |
||||||
|
|
||||||
|
public class VirtualizingIEnumerable<T> : ObservableCollection<T> |
||||||
|
{ |
||||||
|
private IEnumerator<T> originalSourceEnumerator; |
||||||
|
|
||||||
|
public VirtualizingIEnumerable(IEnumerable<T> originalSource) |
||||||
|
{ |
||||||
|
if (originalSource == null) |
||||||
|
throw new ArgumentNullException("originalSource"); |
||||||
|
|
||||||
|
this.originalSourceEnumerator = originalSource.GetEnumerator(); |
||||||
|
} |
||||||
|
|
||||||
|
public void RequestNextItems(int count) |
||||||
|
{ |
||||||
|
for (int i = 0; i < count; i++) |
||||||
|
{ |
||||||
|
if (!originalSourceEnumerator.MoveNext()) break; |
||||||
|
this.Add(originalSourceEnumerator.Current); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,63 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
using System; |
||||||
|
using System.Collections; |
||||||
|
using Debugger.MetaData; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace Debugger.AddIn.Visualizers.Utils |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Helper for obtaining information about DebugType.
|
||||||
|
/// </summary>
|
||||||
|
public static class TypeResolverExtension |
||||||
|
{ |
||||||
|
public static bool ResolveIListImplementation(this DebugType type, out DebugType iListType, out DebugType itemType) |
||||||
|
{ |
||||||
|
if (type == null) |
||||||
|
throw new ArgumentNullException("type"); |
||||||
|
|
||||||
|
iListType = null; |
||||||
|
itemType = null; |
||||||
|
// alternative: search val.Type.Interfaces for IList<T>, from it, get T
|
||||||
|
// works when MyClass : IList<int> - MyClass is not generic, yet can be displayed
|
||||||
|
iListType = type.GetInterface(typeof(IList).FullName); |
||||||
|
if (iListType != null) |
||||||
|
{ |
||||||
|
List<DebugType> genericArguments = type.GenericArguments; |
||||||
|
if (genericArguments.Count == 1) |
||||||
|
{ |
||||||
|
itemType = genericArguments[0]; |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
public static bool ResolveIEnumerableImplementation(this DebugType type, out DebugType iEnumerableType, out DebugType itemType) |
||||||
|
{ |
||||||
|
if (type == null) |
||||||
|
throw new ArgumentNullException("type"); |
||||||
|
|
||||||
|
iEnumerableType = null; |
||||||
|
itemType = null; |
||||||
|
// alternative: search val.Type.Interfaces for IList<T>, from it, get T
|
||||||
|
// works when MyClass : IEnumerable<int> - MyClass is not generic, yet can be displayed
|
||||||
|
iEnumerableType = type.GetInterface(typeof(IEnumerable).FullName); |
||||||
|
if (iEnumerableType != null) |
||||||
|
{ |
||||||
|
List<DebugType> genericArguments = type.GenericArguments; |
||||||
|
if (genericArguments.Count == 1) |
||||||
|
{ |
||||||
|
itemType = genericArguments[0]; |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue