中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

C#實現(xiàn)點擊窗體任意位置拖動

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用

基本思路很簡單:

先得到鼠標(biāo)點擊的位置并記錄,鼠標(biāo)移動時得到移動后的位置計算出差值,然后平移。

代碼:

    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 DragWindowTest  
    {  
        /// <summary>  
        /// MainWindow.xaml 的交互邏輯  
        /// </summary>  
        public partial class MainWindow : Window  
        {  
            public MainWindow()  
            {  
                InitializeComponent();  
            }  
            private static bool IsDrag = false;  
            private double enterX;  
            private double enterY;  
            private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)  
            {  
                IsDrag = true;  
                enterX = e.GetPosition(this).X;  
                enterY = e.GetPosition(this).Y;  
            }  
      
            private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)  
            {  
                IsDrag = false;  
                enterX = 0;  
                enterY = 0;  
            }  
            private void Window_MouseMove(object sender, MouseEventArgs e)  
            {  
                if (IsDrag)  
                {  
                    this.Left += e.GetPosition(this).X - enterX;  
                    this.Top += e.GetPosition(this).Y - enterY;  
                }  
            }  
       
        }  
    }  

標(biāo)簽: 代碼

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:利用MySQL備份工具mydumper備份代碼

下一篇:通過JAVA NIO實現(xiàn)Socket服務(wù)器與客戶端功能