WPF Thumb

来源:互联网 发布:win32 串口编程 编辑:程序博客网 时间:2024/05/21 05:43
//---------------------------------------------------------------------------------//double canvas1Width,canvas1Height,thumb1Width,thumb1Height;public MainWindow(){ this.InitializeComponent(); //记忆canvas1初始尺寸 canvas1Width=this.canvas.Width; canvas1Height=this.canvas.Height; //记忆thumb初始尺寸 thumb1Width=this.canvas.Width; thumb1Height=this.canvas.Height;}//鼠标拖动开始private void thumb1_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e){ this.thumb1.Background=Brushes.Red;}//拖动结束private void thumb1_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e){ this.thumb1.Background=Brushes.Blue;}//拖动private void thumb1_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e){ double eW=this.canvas1.Width+e.HorizontalChange; double eH=this.canvas1.Height+e.HorizontalChange; if(eW>0.5*thumb1Width&&eH>0.5*thumb1Height&&eH<=canvas1Height) { this.canvas1.Width=eW; this.canvas1.Height=eH; this.grid1.Width=this.canvas1.Width; this.grid1.Height=this.canvas1.Height; }}
0 0