Click here to Skip to main content
15,905,912 members
Home / Discussions / C#
   

C#

 
AnswerRe: Help required in Threading.. Pin
Henry Minute1-Jun-10 0:57
Henry Minute1-Jun-10 0:57 
GeneralRe: Help required in Threading.. Pin
Luc Pattyn1-Jun-10 2:51
sitebuilderLuc Pattyn1-Jun-10 2:51 
GeneralRe: Help required in Threading.. Pin
Henry Minute1-Jun-10 3:09
Henry Minute1-Jun-10 3:09 
GeneralRe: Help required in Threading.. Pin
harold aptroot1-Jun-10 3:24
harold aptroot1-Jun-10 3:24 
GeneralRe: Help required in Threading.. Pin
Luc Pattyn1-Jun-10 3:51
sitebuilderLuc Pattyn1-Jun-10 3:51 
Questionremote debugging? Pin
swjam31-May-10 20:01
swjam31-May-10 20:01 
AnswerRe: remote debugging? Pin
Abhinav S31-May-10 20:49
Abhinav S31-May-10 20:49 
QuestionC# 2.0 Windows Service - Memory Leak? [modified] Pin
SarahMcM31-May-10 18:08
SarahMcM31-May-10 18:08 
AnswerRe: C# 2.0 Windows Service - Memory Leak? Pin
Pete O'Hanlon31-May-10 21:42
mvePete O'Hanlon31-May-10 21:42 
GeneralRe: C# 2.0 Windows Service - Memory Leak? Pin
SarahMcM1-Jun-10 12:22
SarahMcM1-Jun-10 12:22 
AnswerRe: C# 2.0 Windows Service - Memory Leak? Pin
#realJSOP1-Jun-10 0:06
professional#realJSOP1-Jun-10 0:06 
GeneralRe: C# 2.0 Windows Service - Memory Leak? Pin
SarahMcM1-Jun-10 12:21
SarahMcM1-Jun-10 12:21 
AnswerRe: C# 2.0 Windows Service - Memory Leak? Pin
PIEBALDconsult1-Jun-10 4:03
mvePIEBALDconsult1-Jun-10 4:03 
GeneralRe: C# 2.0 Windows Service - Memory Leak? Pin
SarahMcM1-Jun-10 12:13
SarahMcM1-Jun-10 12:13 
AnswerRe: C# 2.0 Windows Service - Memory Leak? Pin
SarahMcM1-Jun-10 15:19
SarahMcM1-Jun-10 15:19 
Questionhow about erasing trace of Rectangle? [modified] Pin
sonic74731-May-10 17:59
sonic74731-May-10 17:59 
AnswerRe: how about erasing trace of Rectangle? Pin
Stanciu Vlad31-May-10 21:53
Stanciu Vlad31-May-10 21:53 
GeneralRe: how about erasing trace of Rectangle? Pin
sonic74731-May-10 23:51
sonic74731-May-10 23:51 
GeneralRe: how about erasing trace of Rectangle? Pin
Stanciu Vlad1-Jun-10 0:37
Stanciu Vlad1-Jun-10 0:37 
AnswerRe: how about erasing trace of Rectangle? Pin
Pete O'Hanlon1-Jun-10 1:02
mvePete O'Hanlon1-Jun-10 1:02 
GeneralRe: how about erasing trace of Rectangle? Pin
sonic7471-Jun-10 2:12
sonic7471-Jun-10 2:12 
GeneralRe: how about erasing trace of Rectangle? Pin
Pete O'Hanlon1-Jun-10 2:37
mvePete O'Hanlon1-Jun-10 2:37 
You see this line?
Graphics g = Graphics.FromHwnd(new System.Windows.Interop.WindowInteropHelper(this).Handle);
That says you're using GDI+. Here's a sample rectangle implementation that uses native WPF features instead:
private System.Windows.Shapes.Rectangle GetRectangle(double left, double top)
{
  System.Windows.Shapes.Rectangle myRect = new System.Windows.Shapes.Rectangle();
  myRect.Stroke = System.Windows.Media.Brushes.Black;
  myRect.Fill = System.Windows.Media.Brushes.SkyBlue;  
  myRect.Height = 0;
  myRect.Width = 0;
  // Add the rectangle to the canvas.
  canvas.Children.Add(myRect);
  canvas.SetLeft(myRect, left);
  canvas.SetTop(myRect, top);
  return myRect;
}

private System.Windows.Shapes.Rectangle myRec;
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
  flg = true;
  firstPoint = e.GetPosition(mainwin);
  myRec = GetRectangle(firstPoint.X, firstPoint.y);
}

private void mainwin_MouseMove(object sender, MouseEventArgs e)
{
  if (!flg) return;
  System.Windows.Point currentPoint = e.GetPosition(mainwin);
  double width = currentPoint.X - firstPoint.X;
  double height = currentPoint.Y - firstPoint.Y;

  if (width <= 0 || height <= 0) return;

  myRec.Width = width;
  myRec.Height = height;
}
Please note that I've just knocked this up in Notepad, so it might require a bit of tweaking.

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



QuestionUnhandled exception in the designer (OnPaint) Pin
AussieLew31-May-10 13:18
AussieLew31-May-10 13:18 
AnswerRe: Unhandled exception in the designer (OnPaint) Pin
Luc Pattyn31-May-10 13:30
sitebuilderLuc Pattyn31-May-10 13:30 
AnswerRe: Unhandled exception in the designer (OnPaint) Pin
Stanciu Vlad31-May-10 21:57
Stanciu Vlad31-May-10 21:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.