-
Random Text 3
یکشنبه 6 تیرماه سال 1389 13:45
private long GenerateId3() { byte[] buffer = Guid.NewGuid().ToByteArray(); return BitConverter.ToInt64(buffer, 0); }
-
Random Text 2
یکشنبه 6 تیرماه سال 1389 13:45
private string GenerateId2() { long i = 1; foreach (byte b in Guid.NewGuid().ToByteArray()) { i *= ((int)b + 1); } return string.Format("{0:x}", i - DateTime.Now.Ticks); }
-
Random Text
یکشنبه 6 تیرماه سال 1389 13:44
private string GenerateId1() { return Guid.NewGuid().ToString(); }
-
Radar
یکشنبه 6 تیرماه سال 1389 13:44
using System.Drawing.Drawing2D; int i = 0; private void timer1_Tick(object sender, EventArgs e) { i += 2; Rectangle r = new Rectangle(0, 0, pictureBox1.Width - 1, pictureBox1.Height - 1); Bitmap b = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(b); g.SmoothingMode =...
-
Program In Startup
یکشنبه 6 تیرماه سال 1389 13:43
private void AddStartUpKey(string _name, string _path) { RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true); key.SetValue(_name, _path); } private void RemoveStartUpKey(string _name) { RegistryKey key =...
-
Play Sound And Video
یکشنبه 6 تیرماه سال 1389 13:42
using System.Runtime.InteropServices; string CommandString; OpenFileDialog file = new OpenFileDialog(); [DllImport("winmm.dll")] private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback); private void button1_Click(object sender,...
-
Picture In TextBox
یکشنبه 6 تیرماه سال 1389 13:42
private void Form1_Load(object sender, EventArgs e) { PictureBox pic = new PictureBox(); //pic.Image = Image.FromFile("FilePath"); pic.Image = SystemIcons.Information.ToBitmap();; textBox1.Controls.Add(pic); }
-
Persial Calender
یکشنبه 6 تیرماه سال 1389 13:41
using System.Globalization; public string Miladi2Shamsi(DateTime _date) { PersianCalendar pc = new PersianCalendar(); StringBuilder sb = new StringBuilder(); sb.Append(pc.GetYear(_date).ToString("0000")); sb.Append("/"); sb.Append(pc.GetMonth(_date).ToString("00"));...
-
Painting Chart
یکشنبه 6 تیرماه سال 1389 13:40
private void numericUpDown1_ValueChanged(object sender, EventArgs e) { int a, b, c, d = 0; a = int.Parse(numericUpDown1.Value.ToString()); b = a * 3600; c = b / 1000; d = 50; SolidBrush sb = new SolidBrush(Color.Black); Bitmap bit = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(bit); g.SmoothingMode =...
-
Make Bitmap On Startup 2
یکشنبه 6 تیرماه سال 1389 13:39
using System.Drawing; void New_file(PictureBox pb) { bmp_image = newBitmap(pb.Width, pb.Height); g = Graphics.FromImage(bmp_image); g.FillRectangle(Brushes.White, newRectangle(0, 0, bmp_image.Width, bmp_image.Height)); pb.Image = bmp_image; }
-
Make Bitmap On Startup
یکشنبه 6 تیرماه سال 1389 13:38
private Image CreateBitmap() { System.Drawing.Bitmap flag = new System.Drawing.Bitmap(10, 10); for (int x = 0; x < flag.Height; ++x) for (int y = 0; y < flag.Width; ++y) flag.SetPixel(x, y, Color.White); for (int x = 0; x < flag.Height; ++x) flag.SetPixel(x, x, Color.Red); return flag; } private void...
-
ListView View Change
یکشنبه 6 تیرماه سال 1389 13:38
private void button2_Click(object sender, EventArgs e) { int n = (int) listView1.View; if (n == 4) n = -1; listView1.View = (View)Enum.ToObject(typeof(View), ++n); }
-
Gray Scale 2
یکشنبه 6 تیرماه سال 1389 13:37
using System.Drawing.Imaging; public static Bitmap MakeGrayscale(Bitmap original) { //create a blank bitmap the same size as original Bitmap newBitmap = new Bitmap(original.Width, original.Height); //get a graphics object from the new image Graphics g = Graphics.FromImage(newBitmap); //create the grayscale ColorMatrix...
-
Gray Scale
یکشنبه 6 تیرماه سال 1389 13:37
using System.Drawing.Imaging; public Image GrayScaleImage(Graphics graph, Image img, int left, int top) { ColorMatrix colorMix = new ColorMatrix(); colorMix.Matrix00 = 1 / 3f; colorMix.Matrix01 = 1 / 3f; colorMix.Matrix02 = 1 / 3f; colorMix.Matrix10 = 1 / 3f; colorMix.Matrix11 = 1 / 3f; colorMix.Matrix12 = 1 / 3f;...
-
Graphic Up
یکشنبه 6 تیرماه سال 1389 13:36
private void Form1_Paint(object sender, PaintEventArgs e) { // حالت معمولی e.Graphics.DrawEllipse(new Pen(Color.Red, 10), 30, 30, 50, 50); // SmoothingMode.AntiAlias روانسازی به کمک e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.DrawEllipse(new Pen(Color.Blue, 10), 30, 100, 50,...
-
Get All Windows Handle
یکشنبه 6 تیرماه سال 1389 13:35
using System.Runtime.InteropServices; // The signature for the callback method. public delegate bool CallBack(IntPtr hwnd, int lParam); [DllImport("user32.dll")] public static extern int EnumWindows(CallBack callback, int param); [DllImport("user32.dll")] public static extern int...
-
Form Shadow
یکشنبه 6 تیرماه سال 1389 13:35
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private const int CS_DROPSHADOW = 0x00020000; protected override CreateParams CreateParams { get { CreateParams p = base.CreateParams; p.ClassStyle |= CS_DROPSHADOW; return p; } } }
-
Form Opacity
یکشنبه 6 تیرماه سال 1389 13:35
private void button1_Click(object sender, EventArgs e) { this.Opacity = 1; for (int i = 0; i < 100; i++) { this.Opacity -= 0.01; Application.DoEvents(); } }
-
Follower
یکشنبه 6 تیرماه سال 1389 13:34
bool b = false; private void Form1_MouseDown(object sender, MouseEventArgs e) { b = true; a.Clear(); } private void Form1_MouseUp(object sender, MouseEventArgs e) { b = false; } ArrayList a = new ArrayList(); Point[] p = new Point[50]; private void Form1_MouseMove(object sender, MouseEventArgs e) { if (b == true) {...
-
Filled Squere
یکشنبه 6 تیرماه سال 1389 13:33
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; // Create pen. Pen blackPen = new Pen(Color.Black, 3); // Create points that define polygon. Point point1 = new Point(30, 50); Point point2 = new Point(100, 25); Point point3 = new Point(200, 5); Point point4 = new Point(250, 50);...
-
Encrypt String
یکشنبه 6 تیرماه سال 1389 13:33
using System.Security.Cryptography; private string encryptString(string strToEncrypt) { UTF8Encoding ue = new UTF8Encoding(); byte[] bytes = ue.GetBytes(strToEncrypt); MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] hashBytes = md5.ComputeHash(bytes); // Bytes to string return...
-
Drawing Line
یکشنبه 6 تیرماه سال 1389 13:32
int x1, y1 = 0; bool c = false; private void Form1_MouseDown(object sender, MouseEventArgs e) { x1 = e.X; y1 = e.Y; c = true; al.Add(new Point(e.X, e.Y)); } System.Collections.ArrayList al = new System.Collections.ArrayList(); private void Form1_MouseMove(object sender, MouseEventArgs e) { if (c == true) {...
-
Drawing Chart 2
یکشنبه 6 تیرماه سال 1389 13:31
private void numericUpDown1_ValueChanged(object sender, EventArgs e) { int a, b, c, d = 0; a = int.Parse(numericUpDown1.Value.ToString()); b = a * 3600; c = b / 1000; d = 50; System.Drawing.Drawing2D.LinearGradientBrush b1 = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(50, 20, 190, 170),...
-
Denabled Close Button
یکشنبه 6 تیرماه سال 1389 13:30
using System.Runtime.InteropServices; private const int SC_CLOSE = 0xF060; private const int MF_GRAYED = 0x1; [DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [DllImport("user32.dll")] private static extern int EnableMenuItem(IntPtr hMenu, int...
-
Circle Form
یکشنبه 6 تیرماه سال 1389 13:27
private void Form1_Load(object sender, EventArgs e) { this.Height = 350; this.Width = 350; //Creating circle path System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(0, 0, 300, 300); //Creating the region from the circle path this.Region = new Region(path);...
-
Analog Clock
یکشنبه 6 تیرماه سال 1389 13:26
private void Form1_Load(object sender, EventArgs e) { Bitmap b = new Bitmap(pictureBox1.Width,pictureBox1.Height); Graphics g = Graphics.FromImage(b); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; for (int i = 1; i <=4; i++) { float f1 = (float)Math.Sin(Math.PI / 2 * i) * b.Width / 2 + b.Width...
-
3D Box
یکشنبه 6 تیرماه سال 1389 13:25
private void Form1_Load(object sender, EventArgs e) { SolidBrush sb = new SolidBrush(Color.Black); Bitmap bi = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(bi); Rectangle r = new Rectangle(20, 20, 150, 130); sb.Color = Color.Red; g.FillRectangle(sb, r); g.SmoothingMode =...
-
3D Borders With GDI+
یکشنبه 6 تیرماه سال 1389 13:22
private void DrawBorder3D(Graphics g, ref Rectangle rc, Border3DStyle borderStyle) { ControlPaint.DrawBorder3D(g, rc, borderStyle); g.DrawString(borderStyle.ToString(), Font, Brushes.Black, rc.Width + 5, rc.Y + (rc.Height - Font.Height) / 2); rc.Offset(0, rc.Height + 5); } private void Form1_Paint(object sender,...