鼠标事件

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace PopupProject
{
    public partial class Form1 : Form
    {
        private ToolStripContainer toolStripContainer1;
        private ToolStrip toolStrip1;


        private Panel panel1;
        private Label label1;
        private Label label2;


        private Label label3;


        private Label label4;
        private Label label5;
        private Label label6;
        private Label label7;
        private Label label8;
        private Label label9;
        private Button clearButton;


        private System.Drawing.Drawing2D.GraphicsPath mousePath;
        private GroupBox groupBox1;


        private int fontSize = 20;


        public Form1()
        {


            mousePath = new System.Drawing.Drawing2D.GraphicsPath();
            panel1 = new Panel();
            clearButton = new Button();


            label1 = new Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.label7 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.label9 = new System.Windows.Forms.Label();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            //InitializeComponent();


            //mouse events label


            label1.Location = new Point(23, 503);
            label1.Size = new Size(392, 23);


            //doubleClickSize label
            label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(24, 48);
            this.label2.Size = new System.Drawing.Size(35, 13);
            // DoubleClickTime Label
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(24, 72);
            this.label3.Size = new System.Drawing.Size(35, 13);
            // MousePresent Label
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(24, 96);
            this.label4.Size = new System.Drawing.Size(35, 13);
            // MouseButtons Label
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(24, 120);
            this.label5.Size = new System.Drawing.Size(35, 13);
            // MouseButtonsSwapped Label
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(320, 48);
            this.label6.Size = new System.Drawing.Size(35, 13);
            // MouseWheelPresent Label
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(320, 72);
            this.label7.Size = new System.Drawing.Size(35, 13);
            // MouseWheelScrollLines Label
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(320, 96);
            this.label8.Size = new System.Drawing.Size(35, 13);
            // NativeMouseWheelSupport Label
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(320, 120);
            this.label9.Size = new System.Drawing.Size(35, 13);


            //Mouse Panel


            this.panel1.Anchor = ((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right);


            this.panel1.BackColor = SystemColors.ControlDarkDark;
            this.panel1.Location = new Point(16, 260);
            panel1.Size = new Size(663, 320);


            panel1.MouseUp += new MouseEventHandler(panel1_MouseUp);
            panel1.Paint += new PaintEventHandler(panel1_Paint);
            panel1.MouseEnter += new EventHandler(panel1_MouseEnter);
            panel1.MouseHover += new EventHandler(panel1_MouseHover);
            panel1.MouseMove += new MouseEventHandler(panel1_MouseMove);
            panel1.MouseLeave += new EventHandler(panel1_MouseLeave);
            panel1.MouseDown += new MouseEventHandler(panel1_MouseDown);
            panel1.MouseWheel += new MouseEventHandler(panel1_MouseWheel);


            //Clear button


            clearButton.Anchor = AnchorStyles.Top | AnchorStyles.Left;
            clearButton.Location = new Point(592, 503);
            clearButton.TabIndex = 1;
            clearButton.Text = "Clear";
            clearButton.Click += new EventHandler(this.clearButton_Click);


            // GroupBox
            this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right);
            this.groupBox1.Location = new System.Drawing.Point(16, 24);
            this.groupBox1.Size = new System.Drawing.Size(664, 128);
            this.groupBox1.Text = "System.Windows.Forms.SystemInformation";


            //Set up how the form should be displayed and add the controls to the form.


            ClientSize = new Size(696, 534);


            this.Controls.AddRange(new Control[] {
                                        this.label9,this.label8,this.label7,this.label6,
                                        this.label5,this.label4,this.label3,this.label2,
                                        this.clearButton,this.panel1,this.label1,this.groupBox1


            });


            this.Text = "Mouse Event Example";


            // Displays information about the system mouse.
            label2.Text = "SystemInformation.DoubleClickSize: " + SystemInformation.DoubleClickSize.ToString();
            label3.Text = "SystemInformation.DoubleClickTime: " + SystemInformation.DoubleClickTime.ToString();
            label4.Text = "SystemInformation.MousePresent: " + SystemInformation.MousePresent.ToString();
            label5.Text = "SystemInformation.MouseButtons: " + SystemInformation.MouseButtons.ToString();
            label6.Text = "SystemInformation.MouseButtonsSwapped: " + SystemInformation.MouseButtonsSwapped.ToString();
            label7.Text = "SystemInformation.MouseWheelPresent: " + SystemInformation.MouseWheelPresent.ToString();
            label8.Text = "SystemInformation.MouseWheelScrollLines: " + SystemInformation.MouseWheelScrollLines.ToString();
            label9.Text = "SystemInformation.NativeMouseWheelSupport: " + SystemInformation.NativeMouseWheelSupport.ToString();






        }


        private void panel1_MouseDown(object sender,MouseEventArgs e)
        {
            //Update the mouse path with the mouse information
            Point mouseDownLocation = new Point(e.X, e.Y);


            string eventString = null;
            switch(e.Button)
            {
                case MouseButtons.Left:
                    eventString = "L";
                    break;
                case MouseButtons.Right:
                    eventString = "R";
                    break;
                case MouseButtons.Middle:
                    eventString = "M";
                    break;


                case MouseButtons.XButton1:
                    eventString = "X2";
                    break;
                case MouseButtons.XButton2:
                    eventString = "X2";
                    break;
                case MouseButtons.None:
                default:
                    break;


                    
            }
            if(eventString!=null)
            {
                mousePath.AddString(eventString, FontFamily.GenericSerif, (int)FontStyle.Bold, fontSize, mouseDownLocation, StringFormat.GenericDefault);


            }
            else
            {
                mousePath.AddLine(mouseDownLocation, mouseDownLocation);


            }


            panel1.Focus();
            panel1.Invalidate();
        }


        private void panel1_MouseEnter(object sender, EventArgs e)
        {
            label1.Text = sender.GetType().ToString() + ": MouseEnter";
        }


        private void panel1_MouseHover(object sender, System.EventArgs e)
        {
            // Update the mouse event label to indicate the MouseHover event occurred.
            label1.Text = sender.GetType().ToString() + ": MouseHover";
        }


        private void panel1_MouseLeave(object sender, System.EventArgs e)
        {
            // Update the mouse event label to indicate the MouseLeave event occurred.
            label1.Text = sender.GetType().ToString() + ": MouseLeave";
        }


        private void panel1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            int mouseX = e.X;
            int mouseY = e.Y;


            mousePath.AddLine(mouseX, mouseY, mouseX, mouseY);
        }


        private void panel1_MouseWheel(object sender ,MouseEventArgs e)
        {
            //Update the drawing based upon the mouse wheel scrolling.


            int numberOfTextLineToMove = e.Delta * SystemInformation.MouseWheelScrollLines / 120;
            int numberOfPixelsToMove = numberOfTextLineToMove * fontSize;


            if(numberOfPixelsToMove!=0)
            {
                System.Drawing.Drawing2D.Matrix translateMatrix = new System.Drawing.Drawing2D.Matrix();
                translateMatrix.Translate(0, numberOfPixelsToMove);
                mousePath.Transform(translateMatrix);
            }
            panel1.Invalidate();
        }


        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            Point mouseUpLocation = new Point(e.X, e.Y);


            int numberOfClicks = e.Clicks;


            mousePath.AddString("   " + numberOfClicks.ToString(), FontFamily.GenericSerif, (int)FontStyle.Bold, fontSize, mouseUpLocation, StringFormat.GenericDefault);


            panel1.Invalidate();
        }


        private void panel1_Paint(object sender,PaintEventArgs e)
        {
            e.Graphics.DrawPath(Pens.DarkRed, mousePath);
        }


        private void clearButton_Click(object sender, System.EventArgs e)
        {
            // Clear the Panel display.


            mousePath.Dispose();
            mousePath = new System.Drawing.Drawing2D.GraphicsPath();






            panel1.Invalidate();






        }
    }
}
深度学习是机器学习的一个子领域,它基于人工神经网络的研究,特别是利用多层次的神经网络来进行学习和模式识别。深度学习模型能够学习数据的高层次特征,这些特征对于图像和语音识别、自然语言处理、医学图像分析等应用至关重要。以下是深度学习的一些关键概念和组成部分: 1. **神经网络(Neural Networks)**:深度学习的基础是人工神经网络,它是由多个层组成的网络结构,包括输入层、隐藏层和输出层。每个层由多个神经元组成,神经元之间通过权重连接。 2. **前馈神经网络(Feedforward Neural Networks)**:这是最常见的神经网络类型,信息从输入层流向隐藏层,最终到达输出层。 3. **卷积神经网络(Convolutional Neural Networks, CNNs)**:这种网络特别适合处理具有网格结构的数据,如图像。它们使用卷积层来提取图像的特征。 4. **循环神经网络(Recurrent Neural Networks, RNNs)**:这种网络能够处理序列数据,如时间序列或自然语言,因为它们具有记忆功能,能够捕捉数据中的时间依赖性。 5. **长短期记忆网络(Long Short-Term Memory, LSTM)**:LSTM 是一种特殊的 RNN,它能够学习长期依赖关系,非常适合复杂的序列预测任务。 6. **生成对抗网络(Generative Adversarial Networks, GANs)**:由两个网络组成,一个生成器和一个判别器,它们相互竞争,生成器生成数据,判别器评估数据的真实性。 7. **深度学习框架**:如 TensorFlow、Keras、PyTorch 等,这些框架提供了构建、训练和部署深度学习模型的工具和库。 8. **激活函数(Activation Functions)**:如 ReLU、Sigmoid、Tanh 等,它们在神经网络中用于添加非线性,使得网络能够学习复杂的函数。 9. **损失函数(Loss Functions)**:用于评估模型的预测与真实值之间的差异,常见的损失函数包括均方误差(MSE)、交叉熵(Cross-Entropy)等。 10. **优化算法(Optimization Algorithms)**:如梯度下降(Gradient Descent)、随机梯度下降(SGD)、Adam 等,用于更新网络权重,以最小化损失函数。 11. **正则化(Regularization)**:技术如 Dropout、L1/L2 正则化等,用于防止模型过拟合。 12. **迁移学习(Transfer Learning)**:利用在一个任务上训练好的模型来提高另一个相关任务的性能。 深度学习在许多领域都取得了显著的成就,但它也面临着一些挑战,如对大量数据的依赖、模型的解释性差、计算资源消耗大等。研究人员正在不断探索新的方法来解决这些问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值