面板对象在DrawToBitmap之后排序 [英] Panel Objects order after DrawToBitmap

查看:162
本文介绍了面板对象在DrawToBitmap之后排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,需要将它放在前面,然后发回给面板中的对象。




当我选择按钮对象,然后单击发送回来,我会看到在图标框按钮前面!并带来前台发回功能工作倒置!当你想通过drawgraphic函数将面板转换为位图对象时!

  if(SelectedControl!= null)
{
SelectedControl.SendToBack();
SelectedControl.Invalidate();
}

这是发送回每个对象的代码, / p>

  if(SelectedControl!= null)
{
SelectedControl.BringToFront();
SelectedControl.Invalidate();
}

这是PaintToBitmap函数:

  private static ImageBitToBitmap(Control pnl)
{
var bmp = new Bitmap(pnl.Width,pnl.Height);
pnl.DrawToBitmap(bmp,new Rectangle(0,0,bmp.Width,bmp.Height));

return bmp;

$ / code>

有什么不对?

为什么看起来这些函数倒转了?



Update 调用 DrawToBitmap ,并且只在生成的位图中。 ((TaW))

解决方案

检查此图: img src =https://i.stack.imgur.com/J38Oa.jpgalt =selected object>



你可以看到哪个对象被选中消息框。



在点击发回按钮并从面板创建位图后看到此图片!




I have a problem with bring to front and send to back for objects in a a panel.

when i select button object and click to send to back, i will see on picturebox button bring to front! and bring to front and send to back function work inverted! when you want convert panel to bitmap object by drawgraphic function!

        if (SelectedControl != null)
        {
            SelectedControl.SendToBack();
            SelectedControl.Invalidate();
        }

that's code for send to back each object and this for bring to front:

        if (SelectedControl != null)
        {
            SelectedControl.BringToFront();
            SelectedControl.Invalidate();
        }

and this is PaintToBitmap function:

    private static Image PanelToBitmap(Control pnl)
    {
        var bmp = new Bitmap(pnl.Width, pnl.Height);
        pnl.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));

        return bmp;
    }

what's wrong?

why seem those functions to work inverted?

Update The inversion only happens after calling DrawToBitmap and only in the resulting Bitmap. ((TaW))

解决方案

Check this picture:

You can see which object was selected in the message box.

See this picture after having clicked the "send to back" button and creating a bitmap from panel!

这篇关于面板对象在DrawToBitmap之后排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆