Ejemplo n.º 1
0
        private void menuOpenPic_Click(object sender, EventArgs e)
        {
            if (dia_loadPic.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Image imgNeu = Image.FromFile(dia_loadPic.FileName);
                    int widthNeu = 0;
                    int heightNeu = 0;

                    if (imgNeu.Width > picBox_bild.Width)
                    {
                        widthNeu = picBox_bild.Width;
                    }
                    else
                    {
                        widthNeu = imgNeu.Width;
                    }
                    if (imgNeu.Height > picBox_bild.Height)
                    {
                        heightNeu = picBox_bild.Height;
                    }
                    else
                    {
                        heightNeu = imgNeu.Height;
                    }

                    DrawnImg neu = new DrawnImg(imgNeu, 0, 0, widthNeu, heightNeu);
                    drawn.Add(neu);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Datei kann nicht geladen werden", "Ladefehler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Ejemplo n.º 2
0
        private void btn_einfügen_Click(object sender, EventArgs e)
        {
            if (mode == editMode.LINE)
            {
                paintPen = new Pen(Brushes.Black);
                paintPen.Width = paintPenWidth;
                paintPen.Color = saveColor;
                DrawnLine act = new DrawnLine(paintPen, editX, editY, (editX + editWidth), (editY + editHeight));
                menurueckgaengig.Enabled = true;

                drawn.Add(act);
            }
            else if (mode == editMode.RECT)
            {
                paintPen = new Pen(Brushes.Black);
                paintPen.Width = paintPenWidth;
                paintPen.Color = saveColor;
                DrawnRect act = new DrawnRect(paintPen, editX, editY, editWidth, editHeight);
                menurueckgaengig.Enabled = true;

                drawn.Add(act);
            }
            else if (mode == editMode.TEXT)
            {
                TextFormatFlags tf = TextFormatFlags.Left | TextFormatFlags.Top | TextFormatFlags.WordBreak;
                DrawnText act = new DrawnText(editString, editFont, new Rectangle(editX, editY, editWidth, editHeight), saveColor, tf);
                menurueckgaengig.Enabled = true;

                drawn.Add(act);
            }
            else if (mode == editMode.PIC)
            {
                if (editImage != null)
                {
                    menurueckgaengig.Enabled = true;
                    DrawnImg act = new DrawnImg(editImage, editX, editY, editWidth + 1, editHeight + 1);
                    drawn.Add(act);
                }
            }
            else if (mode == editMode.CUT)
            {
                Bitmap bmp = new Bitmap(picBox_bild.Width, picBox_bild.Height);

                mode = editMode.CUT_EINFUEGEN;

                picBox_bild.DrawToBitmap(bmp, new Rectangle(0, 0, picBox_bild.Width, picBox_bild.Height));

                mode = editMode.CUT;

                menurueckgaengig.Enabled = true;
                DrawnImg act = new DrawnImg(bmp, 0, 0, picBox_bild.Width, picBox_bild.Height);
                drawn.Add(act);
            }

            else if (mode == editMode.AREA)
            {
                Brush brushAct = new SolidBrush(saveColor);
                DrawnArea act = new DrawnArea(brushAct, editX, editY, editWidth + 1, editHeight + 1);
                menurueckgaengig.Enabled = true;

                drawn.Add(act);
            }
        }