Пример #1
0
        private Program()
        {
            SuspendLayout();

            // イベント
            PreviewKeyDown += Form_KeyDown;
            MouseDown      += Form_MouseDown;
            MouseMove      += Form_MouseMove;
            MouseUp        += Form_MouseUp;

            // Looks and Feel
            StartPosition   = FormStartPosition.Manual;
            FormBorderStyle = FormBorderStyle.None;
            BackColor       = Color.Black;
            Cursor          = Cursors.Cross;
            ShowInTaskbar   = false;
            ControlBox      = false;
            TopMost         = true;

            // コンテキストメニュー
            var contextMenu = new ContextMenuStrip();

            contextMenu.Items.Add(doUpload = new ToolStripMenuItem("アップロード (Shift)"));
            contextMenu.Items.Add(doSave   = new ToolStripMenuItem("ファイルに保存 (Ctrl)"));

            doUpload.Click += toggle;
            doSave.Click   += toggle;

            void toggle(object sender, EventArgs _)
            {
                ((ToolStripMenuItem)sender).Checked = !((ToolStripMenuItem)sender).Checked;
            }

            ContextMenuStrip = contextMenu;

            // 最大化
            Location = new Point(region.X, region.Y);
            Size     = region.Size;

            // 透明化
            var margins = new int[] { 0, 0, Width, Height };

            RenderUtil.DwmExtendFrameIntoClientArea(Handle, ref margins);

            // レンダリング最適化
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            ResumeLayout(false);
        }