如何在Form的所有方面绘制C#?

时间:2019-04-01 10:09:14

标签: c# c#-4.0 draw

我不能不依赖于属性(普通,混合,最小化)来绘制此代码

因此,当我在所有窗体上不仅在边框法线上放置“属性法线”时,我该如何画画,您可以在下面找到我修改过的图片以解释我想要的。我做了很多尝试来解决此问题,但找不到解决方法

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DrawC
{
    public partial class Form1: Form
    {
        Graphics g;
        int x = -1;
        int y = -1;
        bool movieng = false;
        Pen pen;
        public Form1()
        {
            InitializeComponent();
            g = this.CreateGraphics();
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None ;
            pen =new Pen (Color .Black ,5);
            pen.StartCap = System.Drawing.Drawing2D.LineCap.Round   ;
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            PictureBox p = (PictureBox)sender;
            pen.Color = p.BackColor;
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            movieng = true;
            x = e.X;
            y = e.Y;
        }

        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            movieng = false;
            x = -1;
            y = -1;
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (movieng && x != -1 && y != -1)
            {
                g.DrawLine(pen, new Point(x, y), e.Location);
                x = e.X;
                y = e.Y;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Bounds = Screen.PrimaryScreen.Bounds;
            this.TopMost = true;
            Application.EnableVisualStyles();
        } 
    }
}    

我需要修复此代码以绘制不带有惯性属性(正常,混合,最小化)的图形。

这是我当前输出的屏幕截图: enter image description here

0 个答案:

没有答案