本文介绍了背景屏面设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在gdi +中创建瓷砖网格背景,我可以在其中绘制形状或在其上做其他事情.这将是我的应用程序的表面设计并使用滚动功能?由于我是 GDI + 的新手,所以请提供一些指导原则

我已经创建了此功能,现在我想将此设计设置为背景屏幕

How to create tiles grid background in gdi+ where i can draw shapes or do other stuff on it..it would be my application ''s surface design and and use scrolling feature ??????? As I am new to GDI+ so kindly gives some guideline

i have have created this function now i want to set this design as background screen

private void DrawCaroBoard(Graphics graphics, int row, int col, int width)
        {
            //Draw background
            var linearBrush = new LinearGradientBrush(new Rectangle(_startPoint.X, _startPoint.Y, col * width, row * width), Color.Turquoise,
                Color.White, LinearGradientMode.BackwardDiagonal);
            graphics.FillRectangle(linearBrush, _startPoint.X, _startPoint.Y, col * width, row * width);

            //Draw rows
            for (var i = 0; i <= row; i++)
            {
                graphics.DrawLine(new Pen(Brushes.DarkTurquoise, 2), _startPoint.X, _startPoint.Y + i * width, _startPoint.X + col * width, _startPoint.Y + i * width);
            }

            //Draw columns
            for (var j = 0; j <= col; j++)
            {
                graphics.DrawLine(new Pen(Brushes.DarkTurquoise, 2), _startPoint.X + j * width, _startPoint.Y, _startPoint.X + j * width, _startPoint.Y + row * width);
            }
        }


现在如何在我的表单中使用它的背景功能????


now how to use this function in my form to its background ???

推荐答案

protected void OnPaint(PaintEventArgs e) {
   int row = // ???
   int column = // ???
   int width = // I have no idea how you calculate those, but this is something 
               // depending on the state of the form -- you should know better
   DrawCaroBoard(e.Graphics, row, column, width);
}


请参阅 http://msdn.microsoft.com/en-us/library/3e40ahaz.aspx [ ^ ].

现在,滚动.请注意,类System.Windows.Forms.Form是从类System.Windows.Forms.ScrollableControl派生的,因此已经为您创建了滚动.由于Panel也继承了此类的属性和行为,因此可以以相同的方式滚动其内容.请参阅:
http://msdn.microsoft.com/en-us/library/system. windows.forms.scrollablecontrol.aspx [ ^ ].

这个想法是使用AutoScrollAutoScrollMinSize.当实际大小小于或等于自动"时,垂直或水平出现,相应的滚动条(或同时出现),帮助滚动控件的内容以显示假定为最小大小的整个内容. br/>

—SA


Please see http://msdn.microsoft.com/en-us/library/3e40ahaz.aspx[^].

Now, scrolling. Pay attention that the class System.Windows.Forms.Form is derived from the class System.Windows.Forms.ScrollableControl, so scrolling is already created for you. As Panel also inherits the properties and behavior of this class, you can scroll its content the same way. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollablecontrol.aspx[^].

The idea is to use AutoScroll and AutoScrollMinSize. When the actual size becomes less then "auto", vertically or horizontally, the appropriate scroll bar appears (or both), helping to scroll the control''s content to show the whole content which is assumed to be of the minimal size.

—SA


这篇关于背景屏面设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 13:49