C# 在winform画面上点击某个区域造成按钮按下效果(2)

pxControl.Location = new Point(0,0);
        pxControl.Size = new Size(1024,768);
        SetBackGroudImg();
        this.Controls.Add(pxControl);
        dc = pxControl.CreateGraphics();
        pxControl.MouseDoubleClick +=new MouseEventHandler(this.Main_MouseDoubleClick);
        pxControl.MouseDown+=new MouseEventHandler(this.pxControl_MouseDown);
        pxControl.MouseUp += new MouseEventHandler(this.pxControl_MouseUp);
        pxControl.MouseMove += new MouseEventHandler(this.pxControl_MouseMove);
        pxControl.MouseClick += new MouseEventHandler(this.pxControl_MouseClick);

}

/// <summary>
    ///按下4个按钮时的状态变化
    /// </summary>
    /// <param></param>
    /// <param></param>
    private void pxControl_MouseDown(object sender,MouseEventArgs e)
    {
        if (gpRealTime.IsVisible(e.Location))
        {
           using(Image imgTemp = Image.FromFile(strWineRealStatusDownPath))
           {
                dc.DrawImage(imgTemp, BtnLocation[0, 0], BtnLocation[0, 1], BtnSize.Width,BtnSize.Height);
                FlageMouseDownRealTime = true;
           }
        }
        if (gpWinePos.IsVisible(e.Location))
        {
            using (Image imgTemp = Image.FromFile(strWinePosQueryDownPath))
            {
                dc.DrawImage(imgTemp, BtnLocation[1, 0], BtnLocation[1, 1], BtnSize.Width, BtnSize.Height);
                FlageMouseDownWinePos = true;
            }
        }
        if (gpCupIntrol.IsVisible(e.Location))
        {
            using (Image imgTemp = Image.FromFile(strWineCupIntroDownPath))
            {
                dc.DrawImage(imgTemp, BtnLocation[2, 0], BtnLocation[2, 1], BtnSize.Width, BtnSize.Height);
                FlageMouseDownCupIntrol = true;
            }
        }
        if (gpNetPurchase.IsVisible(e.Location))
        {
            using (Image imgTemp = Image.FromFile(strWinePurchaseDownPath))
            {
                dc.DrawImage(imgTemp, BtnLocation[3, 0], BtnLocation[3, 1], BtnSize.Width, BtnSize.Height);
                FlageMouseDownNetPurchase = true;
            }
        }
    }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyjwwy.html