zoukankan      html  css  js  c++  java
  • C#画图超出屏幕的部分无法显示的解决方法

    C#画图超出屏幕的部分无法显示,通过AutoScrollMinSize属性及相关方法解决问题。

    可以实现

     到

     的转变。

    代码如下:

    using System.Drawing;
    using System.Windows.Forms;
    
    namespace drawing_test
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                this.AutoScrollMinSize = new Size(250, 350);//解决问题需添加
            }
    
            private Point rectangleTopLeft = new Point(0, 0);
            private Size rectangleSize = new Size(200, 200);
            private Point ellipseTopLeft = new Point(50, 200);
            private Size ellipseSize = new Size(200, 150);
            private Pen bluePen = new Pen(Color.Blue, 3);
            private Pen redPen = new Pen(Color.Red, 2);
    
            private void OnPaint(object sender, PaintEventArgs e)
            {
                Graphics dc = e.Graphics;
                Size scrollOffset = new Size(this.AutoScrollPosition);//解决问题需添加
    
                Rectangle rectangleArea = new Rectangle(rectangleTopLeft + scrollOffset, rectangleSize);//解决问题需修改
                Rectangle ellipseArea = new Rectangle(ellipseTopLeft + scrollOffset, ellipseSize);//解决问题需修改
    
                dc.DrawRectangle(bluePen, rectangleArea);
                dc.DrawEllipse(redPen, ellipseArea);
            }
        }
    }
  • 相关阅读:
    Spring配置文件的命名空间URI
    Hibernate @Embeddable注释
    HIbernate实体类注解配置
    Hibernate关系映射之many-to-many
    Hibernate中cascade属性的区别
    Hibernate注解配置与XML配置区别
    JPA关系映射之one-to-one
    Mysql修改id自增值
    JPA关系映射之one-to-many和many-to-one
    swift
  • 原文地址:https://www.cnblogs.com/ming-4/p/12290732.html
Copyright © 2011-2022 走看看