Example #1
0
        private void Pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            try
            {
                e.Graphics.DrawImage(c_ImgGen.createPng(fs, fs.Limages, new object[] { fs.getDrawnPoints(), null }), new Point(100, 10));
                c_returnGraphicSettings cg = new c_returnGraphicSettings();

                e.Graphics.SmoothingMode     = cg.getSM();
                e.Graphics.InterpolationMode = cg.getIM();
                e.Graphics.PixelOffsetMode   = cg.getPOM();
                pd_PrintDialog.Document      = pd;
            }
            catch
            {
            }
        }
Example #2
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            try
            {
                e.Graphics.DrawImage(c_ImgGen.createPng(f_EditorScreen, f_EditorScreen.Limages, new object[] { f_EditorScreen.getDrawnPoints(), null }), new Point(10, 10));
                c_returnGraphicSettings cg = new c_returnGraphicSettings();

                e.Graphics.SmoothingMode     = cg.getSM();
                e.Graphics.InterpolationMode = cg.getIM();
                e.Graphics.PixelOffsetMode   = cg.getPOM();
                printPreviewDialog1.Document = printDocument1;
            }
            catch
            {
            }
        }
Example #3
0
        public void createScaledImage()
        {
            var cr = new c_returnGraphicSettings();

            if (getWidth() > 20 && getHeight() > 20)
            {
                scaledImage = new Bitmap(getWidth(), getHeight());
                using (Graphics g = Graphics.FromImage(scaledImage))
                {
                    g.InterpolationMode = cr.getIM();
                    g.PixelOffsetMode   = cr.getPOM();
                    g.SmoothingMode     = cr.getSM();

                    g.DrawImage(image, new Rectangle(new Point(0, 0), scaledImage.Size), new Rectangle(new Point(0, 0), image.Size), GraphicsUnit.Pixel);
                }
            }
        }
Example #4
0
        private void Ck_KeyPressDetected(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.PrintScreen && Properties.Settings.Default.s_handlePrintScreen)
            {
                Size   sz = getScreenSize();
                Bitmap b  = new Bitmap(sz.Width, sz.Height);
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.InterpolationMode = cr.getIM();
                    g.SmoothingMode     = cr.getSM();
                    g.PixelOffsetMode   = cr.getPOM();

                    g.CopyFromScreen(new Point(0, 0), new Point(0, 0), b.Size);
                }

                if (f_EditorScreen == null || f_EditorScreen.IsDisposed)
                {
                    btn_Screen_Click(null, null);
                }

                try
                {
                    f_EditorScreen.addImage(b, new Point(0, 0), "");
                }
                catch { }

                //OnKeyDown(new KeyEventArgs(Keys.V | Keys.Control));
                if (f_EditorScreen != null && !f_EditorScreen.IsDisposed)
                {
                    f_EditorScreen.BringToFront();
                }

                try
                {
                    Clipboard.SetImage(b);
                }
                catch
                {
                }
            }
            else if (e.KeyCode == Keys.Control ||
                     e.KeyCode == Keys.LControlKey ||
                     e.KeyCode == Keys.RControlKey)
            {
                CTRLDOWN = true;
            }
            else if (e.KeyCode == Keys.Shift ||
                     e.KeyCode == Keys.LShiftKey ||
                     e.KeyCode == Keys.ShiftKey ||
                     e.KeyCode == Keys.RShiftKey)
            {
                SHIFTDOWN = true;
            }
            else if (Properties.Settings.Default.s_HandleShortcuts && e.KeyCode == Keys.F1 && CTRLDOWN && SHIFTDOWN)
            {
                brn_New_Click("Rect2", null);
            }
            else if (Properties.Settings.Default.s_HandleShortcuts && e.KeyCode == Keys.F1 && CTRLDOWN && !SHIFTDOWN)
            {
                brn_New_Click("Rect", null);
            }
            else if (Properties.Settings.Default.s_HandleShortcuts && e.KeyCode == Keys.F2 && CTRLDOWN && !SHIFTDOWN)
            {
                //brn_New_Click("Window", null);
            }
            else if (Properties.Settings.Default.s_HandleShortcuts && e.KeyCode == Keys.F3 && CTRLDOWN && !SHIFTDOWN)
            {
                brn_New_Click("Freehand", null);
            }
            else if (Properties.Settings.Default.s_HandleShortcuts && e.KeyCode == Keys.F4 && CTRLDOWN && !SHIFTDOWN)
            {
                //brn_New_Click("Lines", null);
            }
            else if (Properties.Settings.Default.s_HandleShortcuts && e.KeyCode == Keys.F5 && CTRLDOWN && !SHIFTDOWN)
            {
                brn_New_Click("Magic", null);
            }
        }
Example #5
0
        //DrawTBG => Draw with Transparent Background checkered pattern
        public static Bitmap createImage(System.Drawing.Rectangle rec, List <c_ImageHolder> cutouts, bool drawTBG)
        {
            int border = 0;

            if (Properties.Settings.Default.s_hasBorder)
            {
                border = Properties.Settings.Default.s_borderWidth;
            }

            Bitmap bm = null;

            try
            {
                bm = new Bitmap(rec.Width + (border * 2), rec.Height + (border * 2));

                using (Graphics g = Graphics.FromImage(bm))
                {
                    c_returnGraphicSettings cg = new c_returnGraphicSettings();

                    g.SmoothingMode     = cg.getSM();
                    g.InterpolationMode = cg.getIM();
                    g.PixelOffsetMode   = cg.getPOM();

                    //g.Clear(Color.Transparent);

                    if (Properties.Settings.Default.s_hasBgColor)
                    {
                        g.Clear(Properties.Settings.Default.s_bgColor);
                    }
                    else
                    {
                        g.Clear(Color.Transparent);
                    }

                    if (drawTBG)
                    {
                        int x = 0;
                        int y = 0;
                        while (y < bm.Height)
                        {
                            while (x < bm.Width)
                            {
                                g.DrawImageUnscaled(Properties.Resources.transparentBG, new Point(x, y));
                                x += Properties.Resources.transparentBG.Width;
                            }

                            y += Properties.Resources.transparentBG.Height;
                            x  = 0;
                        }
                    }

                    foreach (c_ImageHolder c in cutouts)
                    {
                        c_ImageHolder k = c;
                        g.DrawImage(k.Image, new System.Drawing.Rectangle(k.Left - rec.Left + border, k.Top - rec.Top + border, k.Width, k.Height), new System.Drawing.Rectangle(0, 0, k.Image.Width, k.Image.Height), GraphicsUnit.Pixel);
                    }

                    if (Properties.Settings.Default.s_hasBorder)
                    {
                        Brush b = new SolidBrush(Properties.Settings.Default.s_borderColor);

                        g.FillRectangle(b, new RectangleF(0, 0, bm.Width, border));
                        g.FillRectangle(b, new RectangleF(0, bm.Height - border, bm.Width, border));
                        g.FillRectangle(b, new RectangleF(0, 0, border, bm.Height));
                        g.FillRectangle(b, new RectangleF(bm.Width - border, 0, border, bm.Height));
                    }
                }
            }
            catch
            {
            }

            return(bm);
        }