header-img
Info :
728x90

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 screan_detect
{
    public partial class Form1 : Form
    {
        Form2 frm2 = new Form2();
        Form3 frm3 = new Form3();
        
        public Form1()
        {
            InitializeComponent();

            this.Load += FormLoad_Event;
        }

        // Form Load Event Handler
        private void FormLoad_Event(object sender, EventArgs e)
        {
            ScreenDetect();
        }

        // ๋‹ค์ค‘ mornitor ๊ฐ์ง€
        private void ScreenDetect()
        {
            Screen[] sc = Screen.AllScreens;

            if (sc.Length > 1)
            {
                for (int i = 0; i < sc.Length; i++)
                {
                    Screen screen = (sc[i].WorkingArea.Contains(this.Location)) ? sc[i+1] : sc[i];

                    if (i == 1)
                    {
                        frm2.Show();
                        frm2.Location = screen.Bounds.Location;
                        frm2.WindowState = FormWindowState.Maximized;
                    }
                    else if (i == 2)
                    {
                        frm3.Show();
                        frm3.Location = screen.Bounds.Location;
                        frm3.WindowState = FormWindowState.Maximized;
                    }

                    Console.WriteLine((i + 1) + "๋ฒˆ์งธ ๋ชจ๋‹ˆํ„ฐ=========================================================");

                    Console.WriteLine("์žฅ์น˜์ด๋ฆ„ : " + sc[i].DeviceName);
                    Console.WriteLine("์ฃผ๋ชจ๋‹ˆํ„ฐ ์—ฌ๋ถ€ : " + sc[i].Primary.ToString());
                    Console.WriteLine("X ์ขŒํ‘œ : " + sc[i].WorkingArea.X);
                    Console.WriteLine("Y ์ขŒํ‘œ : " + sc[i].WorkingArea.Y);
                    Console.WriteLine("Width : " + sc[i].WorkingArea.Width);
                    Console.WriteLine("Height : " + sc[i].WorkingArea.Height);

                    Console.WriteLine("==================================================================\n");
                }
            }
        }
    }
}

๋ชจ๋‹ˆํ„ฐ ๊ฐฏ์ˆ˜ ์ธ์‹ ํ›„.. ํผ ๊ฐฏ์ˆ˜ ์ž๋™์œผ๋กœ ๋Š˜์ด๋Š” ๊ฒƒ๋„ ํ•„์š”ํ• ๋“ฏ..

์•„์ง ๋ฏธ์™„์ด์–ด์š”.. 

728x90
๋”๋ณด๊ธฐ
FRONTEND/C#