LabelPlus.PicView.PicView_Label_MouseClick C# (CSharp) Method

PicView_Label_MouseClick() public method

public PicView_Label_MouseClick ( object sender, MouseEventArgs e ) : void
sender object
e MouseEventArgs
return void
        void PicView_Label_MouseClick(object sender, MouseEventArgs e)
        {
            if (image == null) return;
            if (alreadyDraged == true) return;

            int index = getLabelIndex(e.X, e.Y);
            float x_percent = (startP.X * zoom + e.X) / image.Width;
            float y_percent = (startP.Y * zoom + e.Y) / image.Height;
            if (x_percent > 1.0f || y_percent > 1.0f) return;   //忽略超出边界的点击

            //var referRect = getLabelRectangle(0, 0); //参考矩形
            //x_percent = (startP.X * zoom + e.X - referRect.Width / 2) / image.Width;
            //y_percent = (startP.Y * zoom + e.Y - referRect.Height / 2) / image.Height;
            //重新计算,为了契合鼠标点击的目标

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                //左键
                if (LabelUserAction != null)
                    LabelUserAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent, LabelUserActionEventArgs.ActionType.leftClick));

                ////添加
                //var referRect = getLabelRectangle(0, 0); //参考矩形
                //x_percent = (startP.X * zoom + e.X - referRect.Width / 2) / image.Width;
                //y_percent = (startP.Y * zoom + e.Y - referRect.Height / 2) / image.Height;
                ////重新计算,为了契合鼠标点击的目标
                //if(LabelUserAddAction!=null)
                //    LabelUserAddAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent));
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //右键
                if (LabelUserAction != null)
                    LabelUserAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent, LabelUserActionEventArgs.ActionType.rightClick));

                ////删除
                //if (index == -1) return;
                //if(LabelUserDelAction!=null)
                //    LabelUserDelAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent));
            }
            //else if (!ctrlBepush && e.Button == System.Windows.Forms.MouseButtons.Left)
            //{
            //    //点击事件
            //    if (index == -1) return;
            //    if (LabelUserClickAction != null)
            //        LabelUserClickAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent));
            //}
            //else if (!ctrlBepush && e.Button == System.Windows.Forms.MouseButtons.Right)
            //{
            //    //检阅模式

            //}
        }