Ejemplo n.º 1
0
        private void Mouse_Click(object sender, MouseEventArgs e)
        {
            ;

            if (wybranyItem == Item.pipeta) //nie da się pobrać koloru bezpośrednio, dlatego trzeba zrobić screena
            {                               // robi zrzut ekranu (prostokątna bitmapa będąca kopią przestrzeni rysowania)
                Bitmap    bmp  = new Bitmap(PB.Width, PB.Height);
                Graphics  g    = Graphics.FromImage(bmp);
                Rectangle rect = PB.RectangleToScreen(PB.ClientRectangle);
                g.CopyFromScreen(rect.Location, Point.Empty, PB.Size);
                g.Dispose();

                maluj_kolor             = bmp.GetPixel(e.X, e.Y);
                wybrany_kolor.BackColor = maluj_kolor;
            }
            if (wybranyItem == Item.tekst)
            {
                Bitmap imgbmp = copy.Clone() as Bitmap;

                Graphics tk = Graphics.FromImage(imgbmp);

                int xx = e.X;
                int yy = e.Y;


                tk.DrawString(textBox1.Text, new Font(toolStripComboBox1.Text, Convert.ToInt32(toolStripTextBox1.Text), FontStyle.Regular), new SolidBrush(maluj_kolor), new PointF(e.X - Convert.ToInt32(toolStripTextBox1.Text), e.Y - Convert.ToInt32(toolStripTextBox1.Text)));
                tk.Dispose();
                PB.Image = imgbmp;
            }
        }