C# SqlClient execute a stored procedure and return

  [code language=”cpp”]   using System.Data.SqlClient; namespace ImagingApp { public partial class frmDatabase : Form { public frmDatabase() { InitializeComponent(); } private void frmDatabase_Load(object sender, EventArgs e) { string connStr; connStr = "Data Source=ServerName;Initial Catalog=AdventureWorks2014;Persist Security Info=True;User ID=sa;Password=YourSecret"; SqlConnection db = new Read More

C# Draw with mouse

private Graphics m_objGraphics; Pen p = new Pen(Color.Black); private void frmPainting_Load(object sender, EventArgs e) { m_objGraphics = this.CreateGraphics(); } private void frmPainting_MouseMove(object sender, MouseEventArgs e) { Rectangle rectEllipse = new Rectangle(); if (e.Button != MouseButtons.Left) return; rectEllipse.X = e.X – 1; rectEllipse.Y Read More

C# DrawString to Graphics

private void buttonDrawText_Click(object sender, EventArgs e) { // Create string to draw. String drawString = “My Drawing Text”; // Create font and brush. Font drawFont = new Font(“Arial”, 16); SolidBrush drawBrush = new SolidBrush(Color.Blue); // Create point for upper-left corner of drawing. Read More

C# LinearGradientBrush

Learn from http://www.functionx.com/vcsharp2003/gdi/gradientbrushes.htm   private void buttonGradientMode_Click(object sender, EventArgs e) { ////Get Image //Bitmap bmp = (Bitmap)myPictureBox.Image; //LinearGradientBrush lgb = new LinearGradientBrush(new Point(20, 20), // new Point(450, 20), // Color.DarkGreen, // Color.LightBlue); ////Draw //using (var graphics = Graphics.FromImage(bmp)) //{ // graphics.FillRectangle(lgb, 20, Read More

C# Draw Linear Gradient

private void buttonGradientMode_Click(object sender, EventArgs e) { ////Get Image //Bitmap bmp = (Bitmap)myPictureBox.Image; //LinearGradientBrush lgb = new LinearGradientBrush(new Point(20, 20), // new Point(450, 20), // Color.DarkGreen, // Color.LightBlue); ////Draw //using (var graphics = Graphics.FromImage(bmp)) //{ // graphics.FillRectangle(lgb, 20, 20, 430, 180); //} Read More

C# Draw Circle to Image

private void buttonCircle_Click(object sender, EventArgs e) { //Get Image Bitmap bmp = (Bitmap)myPictureBox.Image; //Define Pen and Color Pen myPen = new Pen(Color.Orange, 5); SolidBrush myBrush = new SolidBrush(Color.LightGray); //Center Position int x = 100; int y = 100; //Draw using (var graphics Read More

C# Listen Clipboard Change

Learn from Monitor clipboard in C#   using System.Runtime.InteropServices; [DllImport(“User32.dll”, CharSet = CharSet.Auto)] public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer); [DllImport(“User32.dll”, CharSet = CharSet.Auto)] public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);   private const int WM_DRAWCLIPBOARD = 0x0308; // WM_DRAWCLIPBOARD message private Read More