Beispiel #1
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            try
            {
                e.Graphics.DrawImage(c_ImgGen.createPng(fs, fs.Limages, new object[] { fs.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
            {
            }
        }
        public Bitmap getImage()
        {
            Bitmap __bmp = new Bitmap(Width, Height);

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

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

                Rectangle r = this.Bounds;
                r.Y = panel1.Height;

                Rectangle rr = new Rectangle(0, 0, r.Width, r.Height);

                g.DrawImage(img, rr);
            }

            return(__bmp);
        }
Beispiel #3
0
        /*
         * public static Bitmap createImage(System.Drawing.Rectangle rec, Dictionary<int, uc_CutoutHolder> cutouts)
         * {
         *      return createImage(rec, cutouts, false);
         * }
         */
        /*
         * public static Bitmap createImage(System.Drawing.Rectangle rec, Dictionary<int, uc_CutoutHolder> 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 (KeyValuePair<int, uc_CutoutHolder> kvp in cutouts)
         *                      {
         *                              uc_CutoutHolder k = kvp.Value;
         *                              g.DrawImage(k.BMP, 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.BMP.Width, k.BMP.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;
         * }
         */


        /*
         * public static Bitmap createPng(f_Screen fs, Dictionary<int, uc_CutoutHolder> cutouts, Object[] drawings) { return createPng(fs, cutouts, drawings, false); }
         */
        /*
         * public static Bitmap createPng(f_Screen fs, Dictionary<int, uc_CutoutHolder> cutouts, Object[] drawings, bool drawTBG)
         * {
         *      if (fs != null)
         *      {
         *              fillDict(fs,out cutouts);
         *
         *              int left = int.MaxValue;
         *              int top = int.MaxValue;
         *
         *              int right = 0;
         *              int bottom = 0;
         *
         *              foreach (var v in cutouts)
         *              {
         *                      var k = v.Value;
         *                      if (k.Left < left) { left = k.Left; }
         *                      if (k.Top < top) { top = k.Top; }
         *                      if (k.Right > right) { right = k.Right; }
         *                      if (k.Bottom > bottom) { bottom = k.Bottom; }
         *              }
         *
         *              int height = bottom - top;
         *              int width = right - left;
         *
         *              var picrec = new System.Drawing.Rectangle(left, top, width, height);
         *
         *              Bitmap _b = createImage(picrec, cutouts, drawTBG);
         *
         *              //TODO: Redo this. drawnpoints instead of lines
         *              //TODO: New object type instead of Bitmaps
         *              if (drawings != null && drawings.Length == 2)
         *              {
         *                      List<c_DrawnPoints> lines = drawings[0] as List<c_DrawnPoints>;
         *                      //List<Bitmap> shapes = drawings[1] as List<Bitmap>;
         *
         *                      if(lines.Count > 0)
         *
         *                      try
         *                      {
         *                              using (Graphics g = Graphics.FromImage(_b))
         *                              {
         *
         *                                      for (int i = 0; i < lines.Count - 2; i++)
         *                                      {
         *                                              c_DrawnPoints l = lines[i];
         *                                              c_DrawnPoints l2 = lines[i + 1];
         *
         *                                              Point p1 = new Point(l.X, l.Y);
         *                                              Point p2 = new Point(l2.X, l2.Y);
         *
         *                                              g.DrawLine(Pens.Black, p1, p2);
         *                                      }
         *
         *                              }
         *                      }
         *                      catch
         *                      {
         *
         *                      }
         *
         *              }
         *
         *              return _b;
         *      }
         *      else { return null; }
         * }
         * /* -- */


        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);
        }
Beispiel #4
0
        private void Ck_KeyPressDetected(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.PrintScreen)
            {
                Bitmap b = new Bitmap(getScreenSize().Width, getScreenSize().Height);
                using (Graphics g = Graphics.FromImage(b))
                {
                    c_returnGraphicSettings cr = new c_returnGraphicSettings();
                    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 (fs == null || fs.IsDisposed)
                {
                    btn_Screen_Click(null, null);
                }

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

                //OnKeyDown(new KeyEventArgs(Keys.V | Keys.Control));
                if (fs != null && !fs.IsDisposed)
                {
                    fs.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.F1 && CTRLDOWN)
            {
                brn_New_Click("Rect", null);
            }
            else if (e.KeyCode == Keys.F2 && CTRLDOWN)
            {
                brn_New_Click("Window", null);
            }
            else if (e.KeyCode == Keys.F3 && CTRLDOWN)
            {
                brn_New_Click("Freehand", null);
            }
            else if (e.KeyCode == Keys.F4 && CTRLDOWN)
            {
                brn_New_Click("Lines", null);
            }
            else if (e.KeyCode == Keys.F5 && CTRLDOWN)
            {
                brn_New_Click("Magic", null);
            }
        }