www.pudn.com > wpfwin7.rar > MainWindow.xaml.cs, change:2012-05-10,size:2162b


using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 
 
namespace MyWindow 
{ 
    /// <summary> 
    /// Interaction logic for MainWindow.xaml 
    /// </summary> 
    public partial class MainWindow : Window 
    { 
        public MainWindow() 
        { 
            InitializeComponent(); 
        } 
 
        private bool canMove = false; 
         
 
        private void image1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
        {//时钟插件 按下左键 
            (sender as FrameworkElement).CaptureMouse(); 
            canMove = true; 
        } 
 
        private void image1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) 
        {//时钟插件 左键抬起 
            (sender as FrameworkElement).ReleaseMouseCapture(); 
            canMove = false; 
        } 
 
        private void image1_MouseLeave(object sender, MouseEventArgs e) 
        {//时钟插件 鼠标离开 
            (sender as FrameworkElement).ReleaseMouseCapture(); 
            canMove = false; 
        } 
 
        private void image1_MouseMove(object sender, MouseEventArgs e) 
        {////时钟插件 拖动 
             
            if (canMove) 
            { 
                Point p = e.GetPosition(canvas1); 
                Canvas.SetLeft(spClock, p.X); 
                Canvas.SetTop(spClock, p.Y-20-20); 
            } 
        } 
 
        private void Label_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
        {//关闭时钟插件 
            spClock.Visibility = System.Windows.Visibility.Collapsed; 
        } 
 
        private void image2_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
        {//点击我的电脑 以及任务栏中我的电脑 
            MyComputer mc=new MyComputer(); 
            mc.Topmost = true; 
            mc.Show(); 
        } 
    } 
}