示例#1
0
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            var relativePoint1 = pictureBox1.PointToClient(Cursor.Position);

            if (MoveText)
            {
                foreach (var el in tab)
                {
                    if (el.cheked)
                    {
                        stroka strochka = new stroka();
                        strochka.text        = el.text;
                        strochka.sizeTxt     = el.sizeTxt;
                        strochka.cor         = el.cor;
                        strochka.cheked      = el.cheked;
                        strochka.alignusha   = el.alignusha;
                        strochka.FontSizeAdd = el.FontSizeAdd;
                        strochka.cor.X       = relativePoint1.X + relat.X;
                        strochka.cor.Y       = relativePoint1.Y + relat.Y;
                        tab.Remove(el);
                        tab.Add(strochka);

                        pictureBox1.Invalidate();
                        break;
                    }
                }
            }
        }
示例#2
0
 private void pictureBox1_DoubleClick(object sender, EventArgs e)
 {
     using (Form3 dlg3 = new Form3())
     {
         var relativePoint1 = pictureBox1.PointToClient(Cursor.Position);
         foreach (var el in tab)
         {
             if (relativePoint1.X - (pictureBox1.Width / 2 - (shirina + SpShir / 2)) <= (el.cor.X + (int)el.sizeTxt.Width / 2) &&
                 relativePoint1.X - (pictureBox1.Width / 2 - (shirina + SpShir / 2)) >= (el.cor.X - (int)el.sizeTxt.Width / 2) &&
                 relativePoint1.Y - (pictureBox1.Height / 2 - wysota / 2) <= (el.cor.Y + (int)el.sizeTxt.Height / 2) &&
                 relativePoint1.Y - (pictureBox1.Height / 2 - wysota / 2) >= (el.cor.Y - (int)el.sizeTxt.Height / 2))
             {
                 stroka   strochka = new stroka();
                 Graphics gr       = pictureBox1.CreateGraphics();
                 SizeF    si       = new SizeF();
                 dlg3.SetText(el.text);
                 dlg3.SetFont(el.FontSizeAdd);
                 dlg3.SetAlign(el.alignusha);
                 if (dlg3.ShowDialog() == DialogResult.OK)
                 {
                     strochka.alignusha   = dlg3.align;
                     strochka.text        = dlg3.ADDtxt;
                     strochka.FontSizeAdd = dlg3.FSize;
                     si = gr.MeasureString(strochka.text, new Font("Arial", strochka.FontSizeAdd));
                     strochka.sizeTxt = si;
                     strochka.cor     = el.cor;
                     tab.Remove(el);
                     tab.Add(strochka);
                     pictureBox1.Invalidate();
                 }
                 break;
             }
         }
     }
 }
示例#3
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            var relativePoint1 = pictureBox1.PointToClient(Cursor.Position);

            switch (e.Button)
            {
            case MouseButtons.Right:
            {
                foreach (var el in tab)
                {
                    if (el.cheked == true)
                    {
                        stroka strochka = new stroka();
                        strochka.text        = el.text;
                        strochka.sizeTxt     = el.sizeTxt;
                        strochka.cor         = el.cor;
                        strochka.cheked      = false;
                        strochka.alignusha   = el.alignusha;
                        strochka.FontSizeAdd = el.FontSizeAdd;
                        tab.Remove(el);
                        tab.Add(strochka);
                        pictureBox1.Invalidate();
                        break;
                    }
                }

                foreach (var el in tab)
                {
                    if (relativePoint1.X - (pictureBox1.Width / 2 - (shirina + SpShir / 2)) <= (el.cor.X + (int)el.sizeTxt.Width / 2) &&
                        relativePoint1.X - (pictureBox1.Width / 2 - (shirina + SpShir / 2)) >= (el.cor.X - (int)el.sizeTxt.Width / 2) &&
                        relativePoint1.Y - (pictureBox1.Height / 2 - wysota / 2) <= (el.cor.Y + (int)el.sizeTxt.Height / 2) &&
                        relativePoint1.Y - (pictureBox1.Height / 2 - wysota / 2) >= (el.cor.Y - (int)el.sizeTxt.Height / 2))
                    {
                        stroka strochkap = new stroka();
                        strochkap.text        = el.text;
                        strochkap.sizeTxt     = el.sizeTxt;
                        strochkap.cor         = el.cor;
                        strochkap.cheked      = true;
                        strochkap.alignusha   = el.alignusha;
                        strochkap.FontSizeAdd = el.FontSizeAdd;
                        tab.Remove(el);
                        tab.Add(strochkap);
                        pictureBox1.Invalidate();
                        break;
                    }
                }
                break;
            }

            case MouseButtons.Middle:
            {
                MoveText = false;
                break;
            }
            }
        }
示例#4
0
        private void OpenFileItem_Click(object sender, EventArgs e)
        {
            Stream         plik;
            OpenFileDialog dlg4 = new OpenFileDialog();

            dlg4.Filter = "txt files (*.txt)|*.txt";
            if (dlg4.ShowDialog() == DialogResult.OK)
            {
                if ((plik = dlg4.OpenFile()) != null)
                {
                    using (StreamReader chtec = new StreamReader(plik, System.Text.Encoding.Default))
                    {
                        shirina        = int.Parse(chtec.ReadLine());
                        wysota         = int.Parse(chtec.ReadLine());
                        SpShir         = int.Parse(chtec.ReadLine());
                        TitleBox.Text  = chtec.ReadLine().Replace("{}", "\n");
                        AuthorBox.Text = chtec.ReadLine();

                        cvetik  = Color.FromArgb(int.Parse(chtec.ReadLine()), int.Parse(chtec.ReadLine()), int.Parse(chtec.ReadLine()));
                        cvetTxt = Color.FromArgb(int.Parse(chtec.ReadLine()), int.Parse(chtec.ReadLine()), int.Parse(chtec.ReadLine()));
                        string chl;
                        tab = new List <stroka>();
                        while ((chl = chtec.ReadLine()) != null)
                        {
                            string[] mnogochlen = chl.Split("{}");
                            stroka   strochka   = new stroka();
                            strochka.text           = mnogochlen[0];
                            strochka.FontSizeAdd    = int.Parse(mnogochlen[1]);
                            strochka.cor.X          = int.Parse(mnogochlen[2]);
                            strochka.cor.Y          = int.Parse(mnogochlen[3]);
                            strochka.alignusha      = int.Parse(mnogochlen[4]);
                            strochka.sizeTxt.Width  = int.Parse(mnogochlen[5]);
                            strochka.sizeTxt.Height = int.Parse(mnogochlen[6]);
                            tab.Add(strochka);
                        }
                    }
                    plik.Close();
                }
            }
            pictureBox1.Invalidate();
        }
示例#5
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     if (pictureBox1.Cursor == Cursors.Cross)
     {
         Font     f        = new Font("Arial", FontSize);
         Graphics gr       = pictureBox1.CreateGraphics();
         Point    pon      = new Point();
         stroka   strochka = new stroka();
         pon                  = pictureBox1.PointToClient(Cursor.Position);
         strochka.cor.X       = pon.X - (pictureBox1.Width / 2 - (shirina + SpShir / 2));
         strochka.cor.Y       = pon.Y - (pictureBox1.Height / 2 - wysota / 2);
         strochka.text        = addText;
         strochka.FontSizeAdd = FontSize;
         SizeF txtSize = gr.MeasureString(strochka.text, f);
         strochka.sizeTxt.Width  = txtSize.Width;
         strochka.sizeTxt.Height = txtSize.Height;
         strochka.alignusha      = aligg;
         tab.Add(strochka);
         pictureBox1.Cursor = Cursors.Default;
         pictureBox1.Invalidate();
         gr.Dispose();
         f.Dispose();
     }
 }