⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 points.cs

📁 一个Wince的小程序
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace SettingInterface
{
    class Points    //程序中用到的点列表的封装,包含了点列表应用的功能
    {
        const int X = 4;
        const int Y = 6;
        private int index = -1;
        point[] pointList = new point[X * Y];
        public Points()
        {
        }
        public point[] PointList
        {
            get { return pointList; }
            set { pointList = value; index = 0; }
        }
        public point Point
        {
            get { return this.pointList[index]; }
            set { pointList[index] = value; }
        }
        public Points(point[] PL)   //初始化点列表
        {
            this.pointList = PL;
            for (int i = 0; i < PL.Length; i++)
            {
                this.pointList[i].Num = i;
            }
            index = 0;
        }
        public void SetPoint(int X, int Y, int num)
        {
            for (int i = 0; i < X * Y; i++)
            {
                if (this.pointList[index].Num == num)
                {
                    this.pointList[index].X = X;
                    this.pointList[index].Y = Y;
                }
            }
            
        }
        public void SetPoint(Point p, int num)
        {
           for (int i = 0; i < X * Y; i++)
            {
                if (this.pointList[index].Num == num)
                {
                    this.pointList[index].X = p.X;
                    this.pointList[index].Y = p.Y;
                }
            }
        }
        public bool First()
        {
            if (pointList.Length > 0)
            {
                index = 0;
                return true;
            }
            index = 0;
            return false;
        }
        public bool Next() //移到下一个点
        {
            if (index < X * Y - 1)
            {
                index++;
                return true;
            }
            return false;
        }
        public void AddPoint(Point p)
        {
            if (this.pointList.Length < X * Y - 1)
            {
                this.pointList[pointList.Length].X = p.X;
                this.pointList[pointList.Length].Y = p.Y;
                this.pointList[pointList.Length].Num = pointList.Length;
            }
        }
        public void AddPoint(int X, int Y)
        {
            if (this.pointList.Length < X * Y - 1)
            {
                this.pointList[pointList.Length].X = X;
                this.pointList[pointList.Length].Y = Y;
                this.pointList[pointList.Length].Num = pointList.Length;
            }
        }
        public Image PrintPoint(Image img)  //把传进来的点打印到传进来的图上
        {
            Graphics gr = Graphics.FromImage(img);
            int x, y;
            for (int i = 0; i < this.pointList.Length; i++)
            {
                x = this.pointList[i].X;
                y = this.pointList[i].Y;
                gr.DrawLine(Pens.Red, x - 5, y, x + 5, y);
                gr.DrawLine(Pens.Red, x, y - 5, x, y + 5);
            }
            return img;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -