• 大小: 44KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-18
  • 语言: 其他
  • 标签: 网格  坐标  

资源简介

可添加图片,绘制网格,鼠标画图,并点击鼠标或得点的坐标,以便计算点与点之间的距离。

资源截图

代码片段和文件信息

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 菜单
{
    public partial class Form1 : Form
    {
        public bool shouldPaint;
        public Point startpt;
        public Point endpt;
        public Graphics g;
        public Pen Mypen;
        private Image curImage;
        private string curFileName = null;
        private Rectangle curRect;
        private Size originalSize = new Size(00);
        private double curZoom = 1.0;

        public Form1()
        {
            InitializeComponent();
            bit = new Bitmap(10 10);
            Graphics g = Graphics.FromImage(bit);
            g.Clear(this.BackColor);
            g.DrawRectangle(Pens.Blue new Rectangle(0 0 10 10));
            g.Dispose();
            textureBrush = new TextureBrush(bit);//使用TextureBrush可以有效减少窗体拉伸时的闪烁
        }

        TextureBrush textureBrush;
        Bitmap bit;
        int x = 0;
        int y = 0;
        bool showRec = false;

        private void Form1_Load(object sender EventArgs e)
        {
            g = this.CreateGraphics();
            Mypen = new Pen(Color.Blue 3);

        }



        private void ExitMenu_Click(object sender EventArgs e)
        {
            this.Close();
        }

        private void openFileToolStripMenuItem_Click(object sender EventArgs e)
        {
            OpenFileDialog opnDlg = new OpenFileDialog();
            opnDlg.Filter = “All Image files|*.jpg;“;
            opnDlg.title = “ImageViewer:Open Image File“;
            opnDlg.ShowHelp = true;
            if (opnDlg.ShowDialog() == DialogResult.OK)
            {
                curFileName = opnDlg.FileName;
                try
                {
                    curImage = Image.FromFile(curFileName);

                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message);
                }
                this.AutoScroll = true;
                this.AutoScrollMinSize = new Size
                ((int)(curImage.Width)
                (int)(curImage.Height));
                this.Invalidate();
            }
           // Invalidate();
            curRect = new Rectangle(0 0 curImage.Width curImage.Height);
            originalSize.Width = curImage.Width;
            originalSize.Height = curImage.Height;
        }

        private void Form1_Paint(object sender PaintEventArgs e)
        {
            e.Graphics.FillRectangle(textureBrush this.ClientRectangle);
            if (showRec)
            {
                e.Graphics.DrawRectangle(Pens.Red new Rectangle(x * 10 y * 10 10 10));
                Console.WriteLine(“xxx1“);
        
            }

            Graphics g = e.Graphics;
           // Image curImage = Image.FromFile(curFileName);
 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      13824  2010-05-20 18:39  菜单\菜单\bin\Debug\菜单.exe

     文件      30208  2010-05-20 18:39  菜单\菜单\bin\Debug\菜单.pdb

     文件      14328  2010-05-20 18:39  菜单\菜单\bin\Debug\菜单.vshost.exe

     文件        490  2007-07-21 01:33  菜单\菜单\bin\Debug\菜单.vshost.exe.manifest

     文件       6096  2010-05-20 18:39  菜单\菜单\Form1.cs

     文件       9403  2010-05-20 18:39  菜单\菜单\Form1.Designer.cs

     文件       6012  2010-05-20 18:39  菜单\菜单\Form1.resx

     文件       1021  2010-05-20 18:44  菜单\菜单\obj\Debug\菜单.csproj.FileListAbsolute.txt

     文件        847  2010-05-20 18:39  菜单\菜单\obj\Debug\菜单.csproj.GenerateResource.Cache

     文件      13824  2010-05-20 18:39  菜单\菜单\obj\Debug\菜单.exe

     文件        180  2010-05-20 18:39  菜单\菜单\obj\Debug\菜单.Form1.resources

     文件      30208  2010-05-20 18:39  菜单\菜单\obj\Debug\菜单.pdb

     文件        180  2010-05-20 11:35  菜单\菜单\obj\Debug\菜单.Properties.Resources.resources

     文件        487  2010-05-18 19:39  菜单\菜单\Program.cs

     文件       1354  2010-05-18 19:39  菜单\菜单\Properties\AssemblyInfo.cs

     文件       2862  2010-05-18 19:39  菜单\菜单\Properties\Resources.Designer.cs

     文件       5612  2010-05-18 19:39  菜单\菜单\Properties\Resources.resx

     文件       1091  2010-05-18 19:39  菜单\菜单\Properties\Settings.Designer.cs

     文件        249  2010-05-18 19:39  菜单\菜单\Properties\Settings.settings

     文件       3758  2010-05-20 11:35  菜单\菜单\菜单.csproj

     文件        908  2010-05-18 19:39  菜单\菜单.sln

    ..A..H.     17408  2010-05-20 18:44  菜单\菜单.suo

     目录          0  2010-05-18 19:39  菜单\菜单\obj\Debug\TempPE

     目录          0  2010-05-18 20:14  菜单\菜单\bin\Debug

     目录          0  2010-05-20 18:39  菜单\菜单\obj\Debug

     目录          0  2010-05-18 19:39  菜单\菜单\bin

     目录          0  2010-05-18 19:39  菜单\菜单\obj

     目录          0  2010-05-18 19:39  菜单\菜单\Properties

     目录          0  2010-05-20 18:39  菜单\菜单

     目录          0  2010-05-18 19:39  菜单

............此处省略3个文件信息

评论

共有 条评论