예제 #1
0
파일: Form1.cs 프로젝트: Vorafas/paint
        private void размерХолстаToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CanvasSize cs = new CanvasSize();

            cs.CanvasWidth  = ((Canvas)ActiveMdiChild).CanvasWidth;
            cs.CanvasHeight = ((Canvas)ActiveMdiChild).CanvasHeight;
            if (cs.ShowDialog() == DialogResult.OK)
            {
                ((Canvas)ActiveMdiChild).CanvasWidth  = cs.CanvasWidth;
                ((Canvas)ActiveMdiChild).CanvasHeight = cs.CanvasHeight;
            }
        }
예제 #2
0
        private void ChangeSizeButton_Click(object sender, EventArgs e)
        {
            CanvasSize form = new CanvasSize(ActiveMdiChild.Size.Width, ActiveMdiChild.Size.Height);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ActiveMdiChild.Size = new Size(form.SizeWidth, form.SizeHeight);
                (ActiveMdiChild.Controls[0] as PictureBox).Size = new Size(form.SizeWidth, form.SizeHeight);
                Bitmap image = new Bitmap(form.SizeWidth, form.SizeHeight);
                using (var graphics = Graphics.FromImage(image))
                {
                    graphics.Clear(Color.White);
                    //graphics.DrawImage((ActiveMdiChild.Controls[0] as PictureBox).Image,
                    //    new Rectangle(new Point(0, 0), new Size((ActiveMdiChild.Controls[0] as PictureBox).Image.Width,
                    //    (ActiveMdiChild.Controls[0] as PictureBox).Image.Height)));
                }
                (ActiveMdiChild.Controls[0] as PictureBox).Image = image;
            }
        }
예제 #3
0
        }          //выход

        #endregion Файл
        #region  исунок
        private void размерХолстаToolStripMenuItem_Click(object sender, EventArgs e)     //размер холста
        {
            try
            {
                CanvasSize cs = new CanvasSize(ActiveMdiChild.Size.Width, ActiveMdiChild.Size.Height);
                if (cs.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ActiveMdiChild.Size = new Size(cs.SizeWidth, cs.SizeHeight);
                    (ActiveMdiChild.Controls[0] as PictureBox).Size = new Size(cs.SizeWidth, cs.SizeHeight);
                    Bitmap image = new Bitmap(cs.SizeWidth, cs.SizeHeight);
                    using (var graphics = Graphics.FromImage(image))
                    {
                        graphics.Clear(Color.White);
                        graphics.DrawImage((ActiveMdiChild.Controls[0] as PictureBox).Image, new Rectangle(new Point(0, 0), new Size((ActiveMdiChild.Controls[0] as PictureBox).Image.Width, (ActiveMdiChild.Controls[0] as PictureBox).Image.Height)));
                    }
                    (ActiveMdiChild.Controls[0] as PictureBox).Image = image;
                }
            }
            catch (Exception) { MessageBox.Show("Сначала создайте холст"); }
        }