Created
February 17, 2011 20:37
-
-
Save vquaiato/832626 to your computer and use it in GitHub Desktop.
Very simples canvas dashboard in WPF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class MainWindow : Window | |
{ | |
private Line line = null; | |
private Brush oldBrush; | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
} | |
void onDragDelta(object sender, DragDeltaEventArgs e) | |
{ | |
line = new Line { Stroke = Brushes.Black, StrokeThickness = 1 }; | |
var element = sender as Thumb; | |
line.X1 = Canvas.GetLeft(element); | |
line.X2 = line.X1 + e.HorizontalChange; | |
Canvas.SetLeft(element, Canvas.GetLeft(element) + | |
e.HorizontalChange); | |
line.Y1 = Canvas.GetTop(element) + 15; | |
line.Y2 = line.Y1 + e.VerticalChange; | |
Canvas.SetTop(element, Canvas.GetTop(element) + | |
e.VerticalChange); | |
this.myCanvasStretch.Children.Add(line); | |
} | |
void onDragStarted(object sender, DragStartedEventArgs e) | |
{ | |
var element = sender as Thumb; | |
oldBrush = element.Background; | |
element.Background = Brushes.DarkGray; | |
} | |
void onDragCompleted(object sender, DragCompletedEventArgs e) | |
{ | |
line = null; | |
var element = sender as Thumb; | |
element.Background = oldBrush; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment