header-img
Info :
728x90

null

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#