Search Results

Search found 12 results on 1 pages for 'qwertie'.

Page 1/1 | 1 

  • Labeling algorithm for points

    - by Qwertie
    I need an algorithm to place horizontal text labels for multiple series of points on the screen (basically I need to show timestamps and other information for a history of moving objects on a map; in general there are multiple data points per object). The text labels should appear close to their points--above, below, or on the right side--but should not overlap other points or text labels. Does anyone know an algorithm/heuristic for this?

    Read the article

  • What might cause this ExecutionEngineException?

    - by Qwertie
    I am trying to use Reflection.Emit to generate a wrapper class in a dynamic assembly. Automatic wrapper generation is part of a new open-source library I'm writing called "GoInterfaces". The wrapper class implements IEnumerable<string> and wraps List<string>. In C# terms, all it does is this: class List1_7931B0B4_79328AA0 : IEnumerable<string> { private readonly List<string> _obj; public List1_7931B0B4_79328AA0(List<string> obj) { this._obj = obj; } IEnumerator IEnumerable.GetEnumerator() { return this._obj.GetEnumerator(); } public sealed IEnumerator<string> GetEnumerator() { return this._obj.GetEnumerator(); } } However, when I try to call the GetEnumerator() method on my wrapper class, I get ExecutionEngineException. So I saved my dynamic assembly to a DLL and used ildasm on it. Is there anything wrong with the following code? .class public auto ansi sealed List`1_7931B0B4_79328AA0 extends [mscorlib]System.Object implements [mscorlib]System.Collections.Generic.IEnumerable`1<string>, [Loyc.Runtime]Loyc.Runtime.IGoInterfaceWrapper { .field private initonly class [mscorlib]System.Collections.Generic.List`1<string> _obj .method public hidebysig virtual final instance class [mscorlib]System.Collections.Generic.IEnumerator`1<string> GetEnumerator() cil managed { // Code size 12 (0xc) .maxstack 1 IL_0000: ldarg.0 IL_0001: ldfld class [mscorlib]System.Collections.Generic.List`1<string> List`1_7931B0B4_79328AA0::_obj IL_0006: call instance valuetype [mscorlib]System.Collections.Generic.List`1/Enumerator<!0> class [mscorlib]System.Collections.Generic.List`1<string>::GetEnumerator() IL_000b: ret } // end of method List`1_7931B0B4_79328AA0::GetEnumerator .method public hidebysig virtual final instance class [mscorlib]System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() cil managed { .override [mscorlib]System.Collections.IEnumerable::GetEnumerator // Code size 12 (0xc) .maxstack 1 IL_0000: ldarg.0 IL_0001: ldfld class [mscorlib]System.Collections.Generic.List`1<string> List`1_7931B0B4_79328AA0::_obj IL_0006: call instance valuetype [mscorlib]System.Collections.Generic.List`1/Enumerator<!0> class [mscorlib]System.Collections.Generic.List`1<string>::GetEnumerator() IL_000b: ret } // end of method List`1_7931B0B4_79328AA0::System.Collections.IEnumerable.GetEnumerator ... I have a test suite that wraps all sorts of different things, including interfaces derived from other interfaces, and multiple interface methods with identical signatures. It's only when I try to wrap IEnumerable<T> that this problem occurs. I'd be happy to send the source code (2 *.cs files, no dependencies) if anyone would like.

    Read the article

  • Why won't my program terminate?

    - by Qwertie
    I have a .NET Compact Framework app that can runs on three windows machines (Desktop windows and two WinCE machines) and on the WinCE devices, the process never terminates on exit, even if I call Application.Exit(). Besides .NET, it uses one COM component (which does everything on the UI thread). If I break into the debugger after exitting, Visual Studio shows only one thread and a completely blank call stack. What could possibly cause this? Update: My process is terminating on the desktop but not the WinCE machines. I tried to force the process to terminate with the following code, but it doesn't work: [DllImport("coredll.dll")] static extern int TerminateProcess(IntPtr hProcess, uint uExitCode); static public void ExitProcess() { if (Platform.IsWindowsCE) TerminateProcess(new IntPtr(-1), 0); Application.Exit(); } There are also supposed to be ExitProcess() and GetCurrentProcess() APIs like the following, but if I try to call them, I get EntryPointNotFoundException. Therefore I am using TerminateProcess(-1, 0) because the documentation for the desktop version of GetCurrentProcess claims that it simply returns -1. [DllImport("coredll.dll")] static extern int ExitProcess(IntPtr hProcess); [DllImport("coredll.dll")] static extern IntPtr GetCurrentProcess(); Even if I do this: static public void ExitProcess() { if (Platform.IsWindowsCE) TerminateProcess(new IntPtr(-1), 0); Application.Exit(); throw new Exception("Trying to force quit."); } A fatal error dialog appears with a helpful "Quit" button, but pushing the button still does not cause the process to terminate on either machine!

    Read the article

  • Reflection.Emit: How to convert MethodBuilder to RuntimeMethodInfo reliably?

    - by Qwertie
    After generating a type dynamically and calling TypeBuilder.CreateType, I want to create a delegate that points to a method in the new type. But if I use code like loadedType = typeBuilder.CreateType(); myDelegate = (MyDelegate)Delegate.CreateDelegate( typeof(MyDelegate), methodBuilder); Reusing the methodBuilder as a methodInfo, I get the exception "MethodInfo must be a RuntimeMethodInfo". Now normally I can re-acquire the MethodInfo with MethodInfo mi = loadedType.GetMethod(methodBuilder.Name); myDelegate = (MyDelegate)Delegate.CreateDelegate(typeof(MyDelegate), mi); But my class may contain several overloaded methods with the same name. How do I make sure I get the right one? Do methods have some persistent identifier I could look up in loadedType?

    Read the article

  • How to use reflection to get a default constructor?

    - by Qwertie
    I am writing a library that generates derived classes of abstract classes dynamically at runtime. The constructor of the derived class needs a MethodInfo of the base class constructor so that it can invoke it. However, for some reason Type.GetConstructor() returns null. For example: abstract class Test { public abstract void F(); } public static void Main(string[] args) { ConstructorInfo constructor = typeof(Test).GetConstructor( BindingFlags.NonPublic | BindingFlags.Public, null, System.Type.EmptyTypes, null); // returns null! } Note that GetConstructor returns null even if I explicitly declare a constructor in Test, and even if Test is not abstract.

    Read the article

  • Why doesn't this data binding work?

    - by Qwertie
    I have a ViewModel class that contains a list of points, and I am trying to bind it to a Polyline. The Polyline picks up the initial list of points, but does not notice when additional points are added even though I implement INotifyPropertyChanged. What's wrong? <StackPanel> <Button Click="Button_Click">Add!</Button> <Polyline x:Name="_line" Points="{Binding Pts}" Stroke="Black" StrokeThickness="5"/> </StackPanel> C# side: // code-behind _line.DataContext = new ViewModel(); private void Button_Click(object sender, RoutedEventArgs e) { // The problem is here: NOTHING HAPPENS ON-SCREEN! ((ViewModel)_line.DataContext).AddPoint(); } // ViewModel class public class ViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public PointCollection Pts { get; set; } public ViewModel() { Pts = new PointCollection(); Pts.Add(new Point(1, 1)); Pts.Add(new Point(11, 11)); } public void AddPoint() { Pts.Add(new Point(25, 13)); if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Pts")); } }

    Read the article

  • WPF: How to refresh a window while debugging?

    - by Qwertie
    I am debugging an algorithm that is being represented by a set of ViewModels. In order to debug this algorithm I would like to redraw the View while stepping through part of the algorithm. Is this possible? (I would prefer to just repaint, not do what they call "DoEvents" to process all events.)

    Read the article

  • WPF: Binding to ListBoxItem.IsSelected doesn't work for off-screen items

    - by Qwertie
    In my program I have a set of view-model objects to represent items in a ListBox (multi-select is allowed). The viewmodel has an IsSelected property that I would like to bind to the ListBox so that selection state is managed in the viewmodel rather than in the listbox itself. However, apparently the ListBox doesn't maintain bindings for most of the off-screen items, so in general the IsSelected property is not synchronized correctly. Here is some code that demonstrates the problem. First XAML: <StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock>Number of selected items: </TextBlock> <TextBlock Text="{Binding NumItemsSelected}"/> </StackPanel> <ListBox ItemsSource="{Binding Items}" Height="200" SelectionMode="Extended"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected}"/> </Style> </ListBox.ItemContainerStyle> </ListBox> <Button Name="TestSelectAll" Click="TestSelectAll_Click">Select all</Button> </StackPanel> C# Select All handler: private void TestSelectAll_Click(object sender, RoutedEventArgs e) { foreach (var item in _dataContext.Items) item.IsSelected = true; } C# viewmodel: public class TestItem : NPCHelper { TestDataContext _c; string _text; public TestItem(TestDataContext c, string text) { _c = c; _text = text; } public override string ToString() { return _text; } bool _isSelected; public bool IsSelected { get { return _isSelected; } set { _isSelected = value; FirePropertyChanged("IsSelected"); _c.FirePropertyChanged("NumItemsSelected"); } } } public class TestDataContext : NPCHelper { public TestDataContext() { for (int i = 0; i < 200; i++) _items.Add(new TestItem(this, i.ToString())); } ObservableCollection<TestItem> _items = new ObservableCollection<TestItem>(); public ObservableCollection<TestItem> Items { get { return _items; } } public int NumItemsSelected { get { return _items.Where(it => it.IsSelected).Count(); } } } public class NPCHelper : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public void FirePropertyChanged(string prop) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(prop)); } } Two separate problems can be observed. If you click the first item and then press Shift+End, all 200 items should be selected; however, the heading reports that only 21 items are selected. If you click "Select all" then all items are indeed selected. If you then click an item in the ListBox you would expect the other 199 items to be deselected, but this does not happen. Instead, only the items that are on the screen (and a few others) are deselected. All 199 items will not be deselected unless you first scroll through the list from beginning to end (and even then, oddly enough, it doesn't work if you perform scrolling with the little scroll box). My questions are: Can someone explain precisely why this occurs? Can I avoid or work around the problem?

    Read the article

  • Reflection: How to get the underlying type of a by-ref type

    - by Qwertie
    I was surprised to learn that "ref" and "out" parameters are not marked by a special attribute, despite the existence of ParameterInfo.IsOut, ParameterInfo.IsIn (both of which are always false as far as I can see), ParameterAttributes.In and ParameterAttributes.Out. Instead, "ref" parameters are actually represented by a special kind of "Type" object and "out" parameters are just ref parameters with an additional attribute (what kind of attribute I don't yet know). Anyway, to make a by-ref argument you call Type.MakeByRefType(), but my question is, if you already have a by-ref type, how do you get back to the original Type? Hint: it's not UnderlyingSystemType: Type t = typeof(int); Console.WriteLine(t.MakeByRefType().UnderlyingSystemType==t); // FALSE

    Read the article

  • Delegates with explicit "this" pointer?

    - by Qwertie
    Is it possible to adapt a method like this function "F" class C { public void F(int i); } to a delegate like Action<C,int>? I have this vague recollection that Microsoft was working on supporting this kind of adaptation. But maybe I misremembered!

    Read the article

1