C#中的面板上绘制和滚动的结果 [英] c# drawing on the panel and scrolling the result

查看:169
本文介绍了C#中的面板上绘制和滚动的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个展示图,它太大,看一个面板上的问题。
我有哪些应该改变图上来看滚动条,但是当我要滚动的画面,形状移动在不同的位置,一切都得到粉碎。

I have problem with showing a diagram which is too big to see on one panel. I have to scrollbars which should change the point of view on the diagram, but when i want to scroll the picture, the shapes are moving on the different position, everything getting crushed.

它看起来像这样这里链接
当我告诉它,像这样这里链接当我尝试把眼光放在该图的底部

it looks like this here link when i show it,and like this here link when i try to look on the bottom of the graph

它看起来像应用程序每次绘制形状,当我滚动面板,当我走在画面底部的点上左上角仍是(0,0)不是(0,500)

it looks like application drawing the shapes every time when i scroll the panel, and when i go on the bottom of picture the point on the top left corner still is (0,0) not (0,500)

我的算法,这对面板和NR对象的ID阵列上提供的位置值,那么我有其中绘制它,让信息从字典中关于对象和他从阵列位置的循环。

I have algorithm, which giving value of location on the panel and nr id of object to the array, then i have the loop which drawing it, getting info from dictionary about the object and his position from array.

如何这个问题是可以解决的?
THX的任何意见的。

How this problem can be solved ? Thx for any advice's

编辑
我不想再画它,我要画一个大图,这样的事情(联系在注释),但我知道,用户可以进行例如50个对象(形状)和那种大图小面板上不能看到,所以我们必须有一个机会,滚动,看到grapf,左侧或本底一边他想要的。

Edited I dont want to draw it again i want to draw one big graph, something like this(link in the comment), but i know that user can make for example 50 objects(shapes) and that kind of big graph cant be seen on the small panel so we have to have a chance to scroll and see the bottom of grapf, left side or this side which he want.

我会尽量提供有关应用程序的更多详细信息。
当午餐呢,你看控制面板(Form1)上,在那里你添加事件/功能/ XOR /或每到这个选项对图自己的形状。
以便用户增加了对与文本例如事件,按下按钮添加它创建对象,并将其添加到集合中。他补充说能事件/功能,XOR /或他希望尽可能多的。

I'll try to give more details about application. When you lunch it, you see the control panel(form1), where you adding events/functions/xor/or every of this option have their own shape on the graph. So user adds for example event with text, pressing the button add which creates the object and adding it to the collection. He can adds events/functions,xor/or as many as he wants.

好吧,当他补充说一切他想要的东西,现在他想看看图形,所以他按下按钮生成图,现在,应用程序显示接下来windwow与面板和滚动条。您可以在链接窗口。
在第二种形式此行

Ok, when he adds everything what he wanted, and now he would like to see graph so he pressing the button "generate the diagram", now the application is showing the next windwow with panel and scrollbars. You can see the window in links. In the second form after this line

private void panel1_Paint(object sender, PaintEventArgs e){

我的算法是把坐标值表,然后forech循环是从字典服用(集合):

I have algorithm which is putting the coordinate values to table, then forech loop is taking from dictionary ( collection):


  • 文本应当被显示在图中的形状的中间,

  • 值确定的类型塑造面板上。

从数组循环取坐标值。

这是如何工作的,我也可以把一个代码在这里它需要的时候。

This how its work, I can also put a code in here when its needed.

推荐答案

标准的错误就是忘记了滚动位置,以抵消您的绘图。使用面板的AutoScrollPosition属性,如:

The standard mistake is forgetting to offset your drawing by the scroll position. Use the panel's AutoScrollPosition property, like this:

    void panel1_Paint(object sender, PaintEventArgs e) {
        e.Graphics.TranslateTransform(panel1.AutoScrollPosition.X, panel1.AutoScrollPosition.Y);
        e.Graphics.DrawLine(Pens.Black, 0, 0, 300, 2000);
    }



Panel控件是一般相当胡思乱想画画,它被设计成一个容器控件。您通常也希望它双缓冲并迫使重绘时正在调整它。设置DoubleBuffered和ResizeRedraw性能要求派生从小组自己的控制

这篇关于C#中的面板上绘制和滚动的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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