ReSharper and GUI-Testing

by Michael R. Albertin 1. June 2009 10:59

If you try to run a test like the following from NUnit, you will find that it does not work.
You get an InvalidOperationException telling you that “The calling thread must be STA, because many UI components require this”.

http://www.hedgate.net/articles/2007/01/08/instantiating-a-wpf-control-from-an-nunit-test/

System.InvalidOperationException: Beim aufrufenden Thread muss es sich um einen STA-Thread handeln, da dies für viele Komponenten der Benutzeroberfläche erforderlich ist.

Changing the Selected Item's Backcolor in a ListBox

by Michael R. Albertin 28. February 2009 17:50

Changing the Selected Item's Backcolor in a ListBox

if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
     e = new DrawItemEventArgs(e.Graphics, e.Font, e.Bounds, e.Index, 
     e.State ^ DrawItemState.Selected, e.ForeColor, Color.Red);

http://www.codeguru.com/csharp/csharp/cs_controls/custom/article.php/c13423/#more

Custom Properties on Control

by Michael R. Albertin 28. February 2009 17:46

Custom Properties on a Control with Serialization and Reset:

public class MyLabel : Label
    {
        public MyLabel()
        {


        }


        private static readonly string txtExtendedDefaultValue = "Extended Text Property";
        private string txtExtended = txtExtendedDefaultValue;
        public string TxtExtended
        {
            get { return txtExtended; }
            set { txtExtended = value; }
        }


        void ResetTxtExtended()
        {
            txtExtended = txtExtendedDefaultValue;
        }


        bool ShouldSerializeTxtExtended()
        {
            return txtExtended != txtExtendedDefaultValue;
        }


        private string txtSimple = "Simple Text Property";
        [DefaultValue("Simple Text Property")]
        public string TxtSimple
        {
            get { return txtSimple; }
            set { txtSimple = value; }
        }
    }

Extending the ComboBox with C#

by Michael R. Albertin 28. February 2009 17:40

With the use of the SetWindowLong API, you are aligning each object as you want. Add these methods' associated properties.

http://www.codeguru.com/csharp/csharp/cs_controls/custom/article.php/c15261__6/

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 Syntax Error