هذه مجموعة من الأكواد للغة السي شارب وهي لعمل حركات جميلة على الشاشة
تحريك الشاشة بشكل مائي :
كود:
كود:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Runtime.InteropServices; namespace RgheedScreenWater { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.ComponentModel.IContainer components; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // myImage = Rgheed.DesktopImage(); } /// /// 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(); this.timer1 = new System.Windows.Forms.Timer(this.components); // // timer1 // this.timer1.Interval = 50; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(350, 190); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "Form1"; this.Text = "Form1"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Click += new System.EventHandler(this.Form1_Click); this.Load += new System.EventHandler(this.Form1_Load); this.Closed += new System.EventHandler(this.Form1_Closed); } #endregion private System.Windows.Forms.Timer timer1; private Image myImage; private Random rnd = new Random(); private const int mySize = 60; private IntPtr myHDC; /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Click(object sender,System.EventArgs e) { this.Close(); } private void Form1_Load(object sender, System.EventArgs e) { myHDC = Rgheed.GetWindowDC(this.Handle); this.CreateGraphics().DrawImage(myImage,0,0); timer1.Enabled=true; } private void Form1_Closed(object sender, System.EventArgs e) { myImage.Dispose(); Rgheed.ReleaseDC(this.Handle,myHDC); Rgheed.DeleteObject(Rgheed.memHDC); Rgheed.DeleteObject(Rgheed.memBtm); } private void timer1_Tick(object sender, System.EventArgs e) { Rgheed.BitBlt(myHDC,0,0,Rgheed.ScreenWidth,Rgheed. ScreenHeight,Rgheed.memHDC,0,0,13369376); for (int x=0; x تحريك الشاشة بشكل متاسارع:
كود:
كود:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Runtime.InteropServices; namespace RgheedFunScreen { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.ComponentModel.IContainer components; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // myImage = Rgheed.DesktopImage(); } /// /// 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(); this.timer1 = new System.Windows.Forms.Timer(this.components); // // timer1 // this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(350, 190); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "Form1"; this.Text = "Form1"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Click += new System.EventHandler(this.Form1_Click); this.Load += new System.EventHandler(this.Form1_Load); } #endregion private System.Windows.Forms.Timer timer1; private Image myImage; private int xPos = 0,xInc = 0; private Graphics Grp; /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Click(object sender,System.EventArgs e) { this.Close(); } private void Form1_Load(object sender, System.EventArgs e) { Grp = this.CreateGraphics(); timer1.Enabled=true; } private void timer1_Tick(object sender, System.EventArgs e) { xInc++; xPos = (xPos + xInc) % Rgheed.ScreenWidth; Grp.DrawImage(myImage,new Rectangle(xPos,0,Rgheed.ScreenWidth-xPos,Rgheed.ScreenHeight),new Rectangle(0,0,Rgheed.ScreenWidth-xPos,Rgheed.ScreenHeight),GraphicsUnit.Pixel); Grp.DrawImage(myImage,new Rectangle(0,0,xPos,Rgheed.ScreenHeight),new Rectangle(Rgheed.ScreenWidth-xPos,0,xPos,Rgheed.ScreenHeight),GraphicsUnit.Pixe l); } } class Rgheed { [DllImport("user32.dll")] private static extern IntPtr GetDesktopWindow (); [DllImport("user32.dll")] private static extern IntPtr GetWindowDC (IntPtr hwnd); [DllImport("user32.dll")] private static extern int ReleaseDC (IntPtr hwnd, IntPtr hdc); [DllImport("gdi32.dll")] private static extern IntPtr CreateCompatibleDC (IntPtr hdc); [DllImport("gdi32.dll")] private static extern IntPtr CreateCompatibleBitmap (IntPtr hdc, int nWidth, int nHeight); [DllImport("gdi32.dll")] private static extern IntPtr SelectObject (IntPtr hdc, IntPtr hObject); [DllImport("gdi32.dll")] private static extern int DeleteObject (IntPtr hObject); [DllImport("gdi32.dll")] private static extern int BitBlt (IntPtr hDestDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop); [DllImport("user32.dll")] private static extern IntPtr GetDC (IntPtr hwnd); public static int ScreenHeight = Screen.PrimaryScreen.Bounds.Height; public static int ScreenWidth = Screen.PrimaryScreen.Bounds.Width; public static Image DesktopImage() { IntPtr dskHDC,dskWnd,memHDC,memBtm,tmpBtm; dskWnd = Rgheed.GetDesktopWindow(); dskHDC = Rgheed.GetDC(dskWnd); memHDC = Rgheed.CreateCompatibleDC(dskHDC); memBtm = Rgheed.CreateCompatibleBitmap(dskHDC,Rgheed.Screen Width,Rgheed.ScreenHeight); tmpBtm = Rgheed.SelectObject(memHDC,memBtm); Rgheed.BitBlt(memHDC,0,0,Rgheed.ScreenWidth,Rgheed .ScreenHeight,dskHDC,0,0,13369376); Image btm = Image.FromHbitmap(memBtm); Rgheed.DeleteObject(Rgheed.SelectObject(memHDC,tmp Btm)); Rgheed.DeleteObject(memHDC); Rgheed.ReleaseDC(dskWnd,dskHDC); return btm; } } }
إضافة فقاعات على سطح المكتب:
كود:
كود:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Drawing2D; using System.Runtime.InteropServices; namespace RgheedScreenBubbles { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Timer timer1; private System.ComponentModel.IContainer components; private Graphics grp; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.BackgroundImage = desktop(); } /// /// 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(); this.timer1 = new System.Windows.Forms.Timer(this.components); // // timer1 // this.timer1.Enabled = true; this.timer1.Interval = 500; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // frmMain // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.Color.White; this.ClientSize = new System.Drawing.Size(432, 256); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "frmMain"; this.Text = "Form1"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.Form1_Load); this.Click += new System.EventHandler(this.Form1_Click); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { Application.Run(new Form1()); } private void timer1_Tick(object sender, System.EventArgs e) { drawBall(); } private void drawBall() { Random rnd = new Random(); GraphicsPath gp = new GraphicsPath(); Color myColor = Color.FromArgb(rnd.Next(250),rnd.Next(250), rnd.Next(250)); int x = rnd.Next(this.Width), y = rnd.Next(this.Height); int radius = rnd.Next(10,100), diameter = radius + radius; gp.StartFigure(); gp.AddEllipse(x-radius,y-radius,diameter,diameter); gp.CloseFigure(); PathGradientBrush pgb = new PathGradientBrush(gp); pgb.CenterColor = Color.FromArgb(150,Color.White); pgb.CenterPoint = new Point(x,y); pgb.SurroundColors =new Color[] { Color.FromArgb(150,myColor) }; grp.SmoothingMode = SmoothingMode.AntiAlias; http://grp.Clear(this.BackColor); grp.FillPath(pgb,gp); grp.DrawPath(new Pen(Color.FromArgb(120,Color.Black)),gp); } private Bitmap desktop() { IntPtr dskWnd,dskDC,memBtm,memDC,tmpBtm; int wdt = Screen.PrimaryScreen.Bounds.Width; int hgt = Screen.PrimaryScreen.Bounds.Height; dskWnd = api.GetDesktopWindow(); dskDC = api.GetDC(dskWnd); memDC = api.CreateCompatibleDC(dskDC); memBtm = api.CreateCompatibleBitmap(dskDC,wdt,hgt); tmpBtm = api.SelectObject(memDC,memBtm); api.BitBlt(memDC,0,0,wdt,hgt,dskDC,0,0,api.SRCCOPY ); Bitmap btm = Image.FromHbitmap(memBtm); api.SelectObject(memDC,tmpBtm); api.DeleteObject(memBtm); api.DeleteDC(memDC); api.ReleaseDC(dskWnd,dskDC); GC.Collect(); return btm; } private void Form1_Click(object sender, System.EventArgs e) { this.Close(); } private void Form1_Load(object sender, System.EventArgs e) { grp = this.CreateGraphics(); } } public class api { public const int SRCCOPY = 13369376; [DllImport("user32.dll")] public static extern IntPtr GetDesktopWindow(); [DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hwnd); [DllImport("user32.dll")] public static extern int ReleaseDC(IntPtr hwnd,IntPtr hdc); [DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc,int nWidth,int nHeight); [DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleDC(IntPtr hdc); [DllImport("gdi32.dll")] public static extern IntPtr SelectObject(IntPtr hdc,IntPtr hObject); [DllImport("gdi32.dll")] public static extern int DeleteDC(IntPtr hdc); [DllImport("gdi32.dll")] public static extern int DeleteObject(IntPtr hObject); [DllImport("gdi32.dll")] public static extern int BitBlt(IntPtr hDestDC,int x,int y,int nWidth,int nHeight,IntPtr hSrcDC,int xSrc,int ySrc,int dwRop); } }
أتمنى أن تنال هذه المجموعة من الأكواد إعجابكم
تحريك الشاشة بشكل مائي :
كود:
كود:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Runtime.InteropServices; namespace RgheedScreenWater { ///
كود:
كود:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Runtime.InteropServices; namespace RgheedFunScreen { ///
إضافة فقاعات على سطح المكتب:
كود:
كود:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Drawing2D; using System.Runtime.InteropServices; namespace RgheedScreenBubbles { ///
أتمنى أن تنال هذه المجموعة من الأكواد إعجابكم
الثلاثاء مارس 13, 2012 3:39 pm من طرف Admin
» An Introduction to VBA in Excel
السبت مارس 10, 2012 1:03 pm من طرف Admin
» المهرجان الخيرى الثالث لجمعية مصريين
الخميس مارس 08, 2012 1:47 pm من طرف Admin
» هندسة الشبكات
الأربعاء مارس 07, 2012 7:59 pm من طرف Admin
» ﺎﻬﺗﺎﻘﻴﺒﻄﺗﻭ ﺔﻴﻜﻠﺳﻼﻟﺍ ﺕﺎﻜﺒﺸﻟﺍ
الأربعاء مارس 07, 2012 7:14 pm من طرف Admin
» تعلم الـ JavaScript ( أساسيات كتابة الكود )
الأحد فبراير 12, 2012 3:10 pm من طرف Admin
» مكتبة الأكواد والحلول البرمجية , سوف نخصص هذا الجزء لوضع اي كود يسهل الوصول إلى عملية معينة , كما تستطيع شرح اي خاصية يمكن ان تستخدم للقيام بوظيفة معينة .
الأربعاء فبراير 08, 2012 2:38 pm من طرف Admin
» مجموعة أكواد للغة السي شارب c#
الأربعاء فبراير 08, 2012 2:28 pm من طرف Admin
» شرح عمل تصويت بتقنية AJAX.pdf
الإثنين فبراير 06, 2012 9:17 pm من طرف Admin