Monthly Archives: September 2011

Get Cursor Position on Wpf

    [DllImport(“user32.dll”)]     [return: MarshalAs(UnmanagedType.Bool)]     static extern bool GetCursorPos(out POINT lpPoint);     [StructLayout(LayoutKind.Sequential)]     public struct POINT {       public int X;       public int Y;       public POINT(int x, int y) {         this.X = x;         this.Y = y;       }     }     POINT p;       if(GetCursorPos(out p) && myEllipse … Continue reading

Posted in Snippets, Wpf | Leave a comment

Ctrl key press condition in WPF MouseLeftButtonDown event-handler

private void ellipse1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { //some code } }

Posted in Snippets, Wpf | Leave a comment

how to change Ellipse fill Color at runtime

ellipse1.Fill = new SolidColorBrush(Color.FromRgb(1,1,1));

Posted in Snippets, Wpf | Leave a comment