Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Print_My_Screen
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void PrintScreen()
- {
- Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- Graphics graphics = Graphics.FromImage(printscreen as Image);
- graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);
- string subPath = @"C:PrintMyScreen";
- bool exists = System.IO.Directory.Exists(subPath);
- if (!exists)
- System.IO.Directory.CreateDirectory(subPath);
- printscreen.Save(@"C:PrintMyScreenprintscreen.png", ImageFormat.Png);
- printIt();
- MessageBox.Show("Your screen has been printed successfully","",MessageBoxButtons.OK,MessageBoxIcon.Information);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- PrintScreen();
- }
- private void printIt()
- {
- PrintDocument pd = new PrintDocument();
- // pd.PrintPage += PrintPage;
- pd.PrintPage += (sender, args) =>
- {
- System.Drawing.Image img = System.Drawing.Image.FromFile(@"C:PrintMyScreenprintscreen.png");
- img.RotateFlip(RotateFlipType.Rotate90FlipXY);
- args.Graphics.DrawImage(img, args.MarginBounds);
- };
- pd.Print();
- }
- private void PrintPage(object o, PrintPageEventArgs e)
- {
- System.Drawing.Image img = System.Drawing.Image.FromFile(@"C:PrintMyScreenprintscreen.png");
- Point loc = new Point(100, 100);
- e.Graphics.DrawImage(img, loc);
- img.Dispose();
- }
- protected override void WndProc(ref Message m)
- {
- switch (m.Msg)
- {
- case 0x84:
- base.WndProc(ref m);
- if ((int)m.Result == 0x1)
- m.Result = (IntPtr)0x2;
- return;
- }
- base.WndProc(ref m);
- }
- private void moveApp()
- {
- }
- public void Repeater(Button btn, int interval)
- {
- var timer = new Timer { Interval = interval };
- timer.Tick += (sender, e) => moveApp();
- btn.MouseDown += (sender, e) => timer.Start();
- btn.MouseUp += (sender, e) => timer.Stop();
- btn.Disposed += (sender, e) =>
- {
- timer.Stop();
- timer.Dispose();
- };
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement