Exemplo n.º 1
0
        public TransparentForm()
        {
            InitializeComponent();
            //setting
            this.ShowInTaskbar = false;

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            this.BackColor       = Color.DarkMagenta;
            this.TransparencyKey = this.BackColor;
            this.TopMost         = true;
            this.Opacity         = 0.5;

            screenLeft   = SystemInformation.VirtualScreen.Left;
            screenTop    = SystemInformation.VirtualScreen.Top;
            screenWidth  = SystemInformation.VirtualScreen.Width;
            screenHeight = SystemInformation.VirtualScreen.Height;

            this.Size = new Size(screenWidth, screenHeight);
            //end of setting
            this.Paint += Form2_Paint;

            pointStart = null;
            //time lable
            timeL.BackColor = Color.LightBlue;
            timeL.Hide();

            //capture panel
            capturePanel = new MyCapturePanel(this)
            {
            };
            capturePanel.BackColor       = Color.Green;
            capturePanel.Visible         = false;
            capturePanel.btnStartCapture = btnStartCapture;

            //start capture button
            btnStartCapture           = new Button();
            btnStartCapture.BackColor = Color.DeepPink;
            btnStartCapture.Click    += B_ClickAsync;
            btnStartCapture.Visible   = false;
            btnStartCapture.Text      = "OK";

            Controls.Add(capturePanel);
            Controls.Add(btnStartCapture);

            action = Action.OK;
        }
Exemplo n.º 2
0
        private void Form2_Paint(object sender, PaintEventArgs e)
        {
            g = e.Graphics;

            Point pointA = new Point();
            Point pointB = new Point();

            //
            DrawAPlus(pointCurrent, g);
            //

            if (isMouseDrag)
            {
                //drawing start point
                if (pointStart != null && !pointCurrent.Equals((Point)pointStart))
                {
                    var _ptStart = (Point)pointStart;
                    DrawAPlus(_ptStart, g);

                    using (Brush brush = new SolidBrush(this.BackColor))
                    {
                        var varStart = new Point();
                        var varEnd   = new Point();
                        if (_ptStart.Y > pointCurrent.Y)
                        {
                            varStart = pointCurrent;
                            varEnd   = _ptStart;
                        }
                        else
                        {
                            varStart = _ptStart;
                            varEnd   = pointCurrent;
                        }
                        if (varStart.X > varEnd.X)
                        {
                            //swapping
                            int i = varStart.X;
                            varStart.X = varEnd.X;
                            varEnd.X   = i;
                        }

                        if (!capturePanel.IsDisposed)
                        {
                            capturePanel.Visible = false;
                            capturePanel.Dispose();
                        }
                        capturePanel = new MyCapturePanel(this)
                        {
                            Location        = varStart,
                            Size            = new Size(Math.Abs(varEnd.X - varStart.X), Math.Abs(varEnd.Y - varStart.Y)),
                            BackColor       = Color.DarkMagenta,
                            btnStartCapture = btnStartCapture
                        };
                        if (!Controls.Contains(capturePanel))
                        {
                            Controls.Add(capturePanel);
                        }

                        capturePanel.Visible = true;


                        //using (Button b = new Button())
                        //{
                        //    Button b = new Button()
                        //    {
                        //        Location = new Point(0, 0),
                        //    };
                        //    if (!capturePanel.Controls.Contains(b))
                        //    {
                        //        capturePanel.Controls.Add(b);
                        //        b.Show();
                        //    }
                        //    b.Click += B_ClickAsync;
                        //}



                        //g.FillRectangle(brush,
                        //    new Rectangle(varStart.X, varStart.Y,
                        //        Math.Abs(varEnd.X - varStart.X), Math.Abs(varEnd.Y - varStart.Y)));
                    }
                }
            }
        }