using System; using System.IO; using System.Drawing; using System.Drawing.Imaging; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using ScreenShotDemo; using System.Threading; namespace blurbsnews { /// /// Summary description for Form1. /// Form 1 is the fronen, sucka /// public class Form1 : System.Windows.Forms.Form { private System.ComponentModel.IContainer components; private System.Windows.Forms.MenuItem menuItem5; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.NotifyIcon notifyIcon1; private System.Windows.Forms.Timer moveDownTimer; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.ContextMenu contextMenu1; private System.Windows.Forms.Timer moveUpTimer; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem1; private ScreenCapture screencap; private System.Drawing.Imaging.ImageFormat format; private Screen screen = Screen.PrimaryScreen; //private bool toggle; private int maxAppHeight; private double opChangeVal; private int moveIncrement; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); format = ImageFormat.Png; } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.moveUpTimer = new System.Windows.Forms.Timer(this.components); this.contextMenu1 = new System.Windows.Forms.ContextMenu(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.moveDownTimer = new System.Windows.Forms.Timer(this.components); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.menuItem4 = new System.Windows.Forms.MenuItem(); this.menuItem5 = new System.Windows.Forms.MenuItem(); this.SuspendLayout(); // // menuItem1 // this.menuItem1.Index = 0; this.menuItem1.Text = "Close"; this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click); // // menuItem2 // this.menuItem2.Index = 1; this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem4, this.menuItem5}); this.menuItem2.Text = "Format"; this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click); // // menuItem3 // this.menuItem3.Index = 2; this.menuItem3.Text = "About"; this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click); // // moveUpTimer // this.moveUpTimer.Interval = 10; this.moveUpTimer.Tick += new System.EventHandler(this.moveUpTimer_Tick); // // contextMenu1 // this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1, this.menuItem2, this.menuItem3}); // // pictureBox1 // this.pictureBox1.Location = new System.Drawing.Point(16, 16); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(208, 152); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; // // moveDownTimer // this.moveDownTimer.Interval = 10; this.moveDownTimer.Tick += new System.EventHandler(this.moveDownTimer_Tick); // // notifyIcon1 // this.notifyIcon1.ContextMenu = this.contextMenu1; this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); this.notifyIcon1.Text = "Captivate 0.0.1"; this.notifyIcon1.Visible = true; this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); // // menuItem4 // this.menuItem4.Index = 0; this.menuItem4.Text = "JPG"; this.menuItem4.Click += new System.EventHandler(this.MenuItem4Click); // // menuItem5 // this.menuItem5.Index = 1; this.menuItem5.Text = "PNG"; this.menuItem5.Click += new System.EventHandler(this.MenuItem5Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.SystemColors.InactiveCaption; this.ClientSize = new System.Drawing.Size(240, 184); this.ControlBox = false; this.Controls.Add(this.pictureBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Form1"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Screen Capture"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { this.Close(); } private void button1_Click_1(object sender, System.EventArgs e) { moveDownTimer.Enabled = true; } private void Form1_Load(object sender, System.EventArgs e) { maxAppHeight = 160; moveIncrement = 2; opChangeVal = (double)moveIncrement / (double)maxAppHeight; this.Left = screen.WorkingArea.Width - this.Width; //this.Top = screen.WorkingArea.Height - this.Height; //makes app come up maximized in tray this.Top = screen.WorkingArea.Height; UpdateSelectedFormat(); } /// /// The context menu lets you select an image format to save to; this makes sure its' set right /// private void UpdateSelectedFormat() { if (this.format == ImageFormat.Jpeg) { this.menuItem4.Checked = true; this.menuItem5.Checked = false; } if (this.format == ImageFormat.Png) { this.menuItem4.Checked = false; this.menuItem5.Checked = true; } } private void moveDownTimer_Tick(object sender, System.EventArgs e) { if (this.Top < screen.WorkingArea.Height) { this.Top = this.Top + this.moveIncrement; //this.Height = this.Height - this.moveIncrement; /* if (toggle) { if (this.Opacity > 0.05) { this.Opacity = this.Opacity - (opChangeVal * 2); } toggle = false; } else { toggle = true; } */ } else { moveDownTimer.Enabled = false; } } private void moveUpTimer_Tick(object sender, System.EventArgs e) { if (this.Top > (screen.WorkingArea.Height - this.maxAppHeight)) { //this.Height = this.Height + this.moveIncrement; this.Top = this.Top - this.moveIncrement; /* if (toggle) { if (this.Opacity < 1) { this.Opacity = this.Opacity + opChangeVal*2; } toggle=false; } else { toggle=true; } */ } else { System.Threading.Thread.Sleep(2000); moveUpTimer.Enabled = false; moveDownTimer.Enabled = true; } } private void menuItem1_Click(object sender, System.EventArgs e) { this.Close(); } /// /// Image format button /// /// /// private void menuItem2_Click(object sender, System.EventArgs e) { //this.BringToFront(); //moveUpTimer.Enabled = true; } /// /// About Menu /// /// /// private void menuItem3_Click(object sender, System.EventArgs e) { FormAbout a = new FormAbout(); a.Show(); //this.moveDownTimer.Enabled = true; } private void panel1_Paint(object sender, PaintEventArgs e) { } public bool ThumbCallback() { return false; } private void notifyIcon1_DoubleClick(object sender, EventArgs e) { Mutex m = new Mutex( ); m.WaitOne( ); screencap = new ScreenCapture( ); string desktop = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string cap = "screenshot"; if( format == ImageFormat.Jpeg ) cap = cap + ".jpg"; if (format == ImageFormat.Png) cap = cap + ".png"; screencap.CaptureScreenToFile(desktop + Path.DirectorySeparatorChar + cap, format); //System.Threading.Thread.Sleep(1000); Image i = System.Drawing.Image.FromFile(desktop + Path.DirectorySeparatorChar + cap); Image.GetThumbnailImageAbort callback = new Image.GetThumbnailImageAbort(ThumbCallback); int height = this.pictureBox1.Height; int width = this.pictureBox1.Width; this.pictureBox1.Image = i.GetThumbnailImage(width, height, callback, IntPtr.Zero); this.pictureBox1.Visible = true; m.Close( ); moveUpTimer.Enabled = true; } private void pictureBox1_Click(object sender, EventArgs e) { } void MenuItem4Click(object sender, System.EventArgs e) { this.format = ImageFormat.Jpeg; UpdateSelectedFormat(); } void MenuItem5Click(object sender, System.EventArgs e) { this.format = ImageFormat.Png; UpdateSelectedFormat(); } } }