Exemple #1
0
        private void LauncherForm_Load(object sender, EventArgs e)
        {
            //DB를 읽어서 셋팅 파일을 가져온다
            //기본 셋팅값은 Status.IconSize와 같이 가지고 온다
            TabControl tabControl = new TabControl();

            // tabControl.Dock = DockStyle.Fill;
            tabControl.Name = "tabControl";
            this.Controls.Add(tabControl);

            foreach (DataRow tab in DB.ExecuteReader("SELECT * FROM TABS WHERE Enable = 1 ORDER BY ID").Rows)
            {
                //tabpage 를 만들어 넣고
                TabPage tb = new TabPage();
                tb.Name = tab["Name"].ToString();
                tb.Text = tab["Name"].ToString();
                tb.UseVisualStyleBackColor = true;
                tabControl.Controls.Add(tb);

                //tabpage에 button을 만들어 넣는다.
                for (int i = 0; i < Status.HorizonCount; i++)      //가로 갯수
                {
                    for (int j = 0; j < Status.VerticalCount; j++) // 세로 갯수
                    {
                        string  btnID = string.Format("btn_{0}_{1}_{2}", tab["ID"], i, j);
                        mButton b     = new mButton();
                        b.Name     = btnID;
                        b.Size     = new Size(Status.IconSize, Status.IconSize);
                        b.Location = new Point(0 + (Status.IconSize - 1) * i, 0 + (Status.IconSize - 1) * j);
                        b.UseVisualStyleBackColor = true;
                        b.AllowDrop = true;
                        string btnPath = DB.ExecuteValue <string>(string.Format("SELECT Path FROM Buttons WHERE ID = '{0}'", btnID));
                        b.Title       = Path.GetFileName(btnPath);
                        b.Image       = IconManager.ToBitmap(btnPath);
                        b.Click      += new EventHandler(Button_Click);
                        b.LabelClick += new EventHandler(Button_Click);
                        b.MouseHover += new EventHandler(Button_MouseHover);
                        b.DragEnter  += new DragEventHandler(Button_DragEnter);
                        b.DragDrop   += new DragEventHandler(Button_DragDrop);

                        b.MouseDown += new MouseEventHandler(Button_MouseDown);
                        b.MouseUp   += new MouseEventHandler(Button_MouseUp);
                        b.MouseMove += new MouseEventHandler(Button_MouseMove);

                        b.ContextMenuStrip = this.contextMenuStrip;
                        tb.Controls.Add(b);
                    }
                }
            }
            int BorderWidth    = SystemInformation.FrameBorderSize.Width;
            int TitlebarHeight = SystemInformation.CaptionHeight;

            if (tabControl.TabPages.Count > 0)
            {
                tabControl.TabPages[0].ClientSize = new Size(Status.IconSize * Status.HorizonCount, Status.IconSize * Status.VerticalCount);
                tabControl.ClientSize             = new Size(Status.IconSize * Status.HorizonCount, Status.IconSize * Status.VerticalCount + TitlebarHeight);
                this.ClientSize = new Size(Status.IconSize * Status.HorizonCount, Status.IconSize * Status.VerticalCount + TitlebarHeight + statusStrip.Height);
            }

            //this.ClientSize = new Size(Status.IconSize * Status.HorizonCount + BorderWidth / 2, Status.IconSize * Status.VerticalCount + statusStrip.Height + TitlebarHeight - BorderWidth / 2);

            //스레드 타이머
            TimerCallback tc = new TimerCallback((o) =>
            {
                prevClick = string.Empty;
                this.Invoke(new MethodInvoker(delegate
                {
                    txtDatetime.Text = DateTime.Now.ToString("yyyy-MM-dd(ddd) tt hh:mm:ss");
                }));
            });

            listClearTimer = new System.Threading.Timer(tc, null, 0, 500);

            //마우스 후킹
            //MouseHook();
            KeyboardHook();
        }