FrmScreenPoint.cs 2.2 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TSA_V
{
    public partial class FrmScreenPoint : Form
    { 
        public  FrmScreenPoint()
        {
            InitializeComponent();
        }
        public int ScreenIndex = 1;
        private void FrmScreenPoint_Load(object sender, EventArgs e)
        {
            this.Text = "显示测试_" + ScreenIndex;
            Screen[] sc = Screen.AllScreens;

            this.StartPosition = FormStartPosition.Manual;
            if (sc.Count() > ScreenIndex)
            {
                Screen screen = sc[ScreenIndex];
                this.Location = new Point(screen.Bounds.Left, screen.Bounds.Top);
                this.WindowState = FormWindowState.Normal;
                this.WindowState = FormWindowState.Maximized;

                //string text ="名称:"+ screen.DeviceName+"\r\n";
                //text += "X:" + screen.Bounds.X + "\r\n";
                //text += "Y:" + screen.Bounds.Y+ "\r\n";
                //text += "Width:" + screen.Bounds.Width+ "\r\n";
                //text += "Heigh:" + screen.Bounds.Height+ "\r\n";
                //text += "是否主显示器:"+screen.Primary.ToString() + "\r\n"; 
                //lblInfo.Text = text;

            }
            else
            {
                this.Visible = false;
            }
        }


        public void DrawPoint(int x,int y,int size=20)
        {  
            Graphics g = panel1.CreateGraphics();
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);//画刷

            //int x = index % 20 * 60;
            //int y = index / 20 * 60; 

            g.FillEllipse(myBrush, new Rectangle(x, y, size, size));//画实心椭圆          
            g.Dispose(); 
        } 
        public  void ClearPoint( )
        { 
            Graphics g = this.panel1.CreateGraphics();
            g.Clear(Color.White); 
            g.Dispose();//释放资源
            this.TransparencyKey = this.panel1.BackColor;
        }
    }
}