كود :
[SIZE=2][color=#0000ff]Private[/color][/SIZE][SIZE=2][color=#0000ff]Sub[/color][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][color=#0000ff]ByVal[/color][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][color=#0000ff]ByVal[/color][/SIZE][SIZE=2] e [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][color=#0000ff]Handles[/color][/SIZE][SIZE=2][color=#0000ff]MyBase[/color][/SIZE][SIZE=2].Load[/SIZE]
[SIZE=2]Timer1.Start()[/SIZE]
[SIZE=2]'لكى نبدأ تشغيل التايمر مع بدء البرنامج[/SIZE]
[SIZE=2][color=#0000ff]End[/color][/SIZE][SIZE=2][color=#0000ff]Sub[/color][/SIZE]
-----------
كود :
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] perfFreeMemory [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2][color=#0000ff]New[/color][/SIZE][SIZE=2] PerformanceCounter([/SIZE][SIZE=2][color=#800000]"Memory"[/color][/SIZE][SIZE=2], _[/SIZE]
[SIZE=2][color=#800000]"Available MBytes"[/color][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]'عرف متغير كعداد للذاكرة المتوفرة[/SIZE]
[SIZE=2]Label1.Text = perfFreeMemory.NextValue [/SIZE]
[SIZE=2][color=#008000]'---------------------نجعل نص اليبل يساوى القيمة التالية للمتغير[/color][/SIZE]
[SIZE=2][color=#008000]'---------------------نضيف المتغيرات الأتية[/color][/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] graph [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2] System.Drawing.Graphics'متغير من النوع جرافيك لرسم العداد[/SIZE]
[SIZE=2]graph = [/SIZE][SIZE=2][color=#0000ff]Me[/color][/SIZE][SIZE=2].CreateGraphics'هذا لكى نتمكن من الرسم على الفورم[/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] brush [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2] System.Drawing.SolidBrush'متغير من النوع سوليد براش(نوع من اربع انواع متوفرة من الفرش)[/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] rect [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2] Rectangle'مستطيل لنضع الدائرة فى حدوده[/SIZE]
[SIZE=2]brush = [/SIZE][SIZE=2][color=#0000ff]New[/color][/SIZE][SIZE=2] System.Drawing.SolidBrush(Color.Green)'نحدد لون اساسى للفرشاة[/SIZE]
[SIZE=2][color=#008000]'--------------------------------------[/color][/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] Angles [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2][color=#0000ff]New[/color][/SIZE][SIZE=2] ArrayList'ارى ليست لنضع بها زاوية القطاع الذى يحدد الذاكرة[/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] ang [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2][color=#0000ff]Single[/color][/SIZE]
[SIZE=2]Angles.Capacity = 2'لن نحتاج اكثر من هذا هنا[/SIZE]
[SIZE=2]Angles.Add(0)'ساشرح الفكرة لاحقا ان شاء الله[/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] late [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2][color=#0000ff]Integer'متغيرلحساب الذاكرة المتبقية[/color][/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] latetotal [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2][color=#0000ff]Integer'لحساب اجمالى الذاكرة المتوفرة[/color][/SIZE]
[SIZE=2]late = perfFreeMemory.NextValue[/SIZE]
[SIZE=2]latetotal = [/SIZE][SIZE=2][color=#0000ff]My[/color][/SIZE][SIZE=2].Computer.Info.TotalPhysicalMemory \ 1000000'نقسم على 1000000 لكى نجعلها بالميجا بدلا من البايت[/SIZE]
[SIZE=2]ang = (late * 360 \ latetotal)'اذا كان اجمالى زوايا الدائرة يساوى 360 فنحن نجعل اجمالى الذاكرة = 360 و بالمقص نعرف الزاوية المطلوبة للذاكرة المتوفرة[/SIZE]
[SIZE=2]Angles.Add(ang)'نضيف الزاوية الجديدة الى المصفوفة[/SIZE]
[SIZE=2][color=#008000]'-------------------------------------------------------------------------------------------[/color][/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] colors() [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2] Color = {Color.Aquamarine, Color.Red, Color.Chocolate, Color.Bisque, Color.Blue, Color.Chartreuse, Color.DarkCyan, Color.Coral, Color.Cornsilk, Color.Firebrick, Color.OliveDrab, Color.LawnGreen, Color.SandyBrown, Color.MidnightBlue}'لن نحتاج الى كل هذه الألوان و السبب انى اخذت الكود كوبى من برنامج اخر و لكن ان اردنا انصنع باى شارت فسنحتاج الى كل هذه الأوان و اكثر[/SIZE]
[SIZE=2]rect = [/SIZE][SIZE=2][color=#0000ff]New[/color][/SIZE][SIZE=2] Rectangle(11, 9, 75, 75)'المستطيل او المربع اولا احداثيات المربع ثم الطول و العرض[/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] angle [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2][color=#0000ff]Integer[/color][/SIZE]
[SIZE=2][color=#008000]'-----------------------------------------------------------------------------------------[/color][/SIZE]
[SIZE=2][color=#0000ff]For[/color][/SIZE][SIZE=2] angle = 1 [/SIZE][SIZE=2][color=#0000ff]To[/color][/SIZE][SIZE=2] Angles.Count - 1' هذا اللوب لا تظهر فائدته الا اذا زدنا من عدد الزوايا و عدد القطاعات بالدائرة حيث تطرح كل زاوية من التى قبلها لنعرف زاوية القطاع الحالى و يكون هذا مفيدا فى الرسم البيانى[/SIZE]
[SIZE=2][color=#0000ff]Dim[/color][/SIZE][SIZE=2] clr [/SIZE][SIZE=2][color=#0000ff]As[/color][/SIZE][SIZE=2][color=#0000ff]Integer[/color][/SIZE]
[SIZE=2]clr = clr + 1[/SIZE]
[SIZE=2][color=#0000ff]If[/color][/SIZE][SIZE=2] clr > colors.GetUpperBound(0) - 1 [/SIZE][SIZE=2][color=#0000ff]Then[/color][/SIZE]
[SIZE=2]clr = 0[/SIZE]
[SIZE=2][color=#0000ff]End[/color][/SIZE][SIZE=2][color=#0000ff]If[/color][/SIZE]
[SIZE=2]brush.Color = colors(clr)[/SIZE]
[SIZE=2]graph.DrawPie(System.Drawing.Pens.Blue, rect, Angles(angle - 1), Angles(angle) - Angles(angle - 1))'ده علشان نرسم الحدود الخارجية للقطاعات اولا نحدد القلم و لونه ثم المربع الخارجى او الحدود الخارجية للدائرة ثم زاوية القطاع[/SIZE]
[SIZE=2]graph.FillPie(brush, rect, Angles(angle - 1), Angles(angle) - Angles(angle - 1))'هنا لملئ لون القطاع الفرشاة ثم الحدود ثم الزاوية[/SIZE]
[SIZE=2][color=#0000ff]Next[/color][/SIZE]
[SIZE=2][color=#008000]'------------------------------------------------------------------------------------------[/color][/SIZE]
[SIZE=2]graph.DrawEllipse(Pens.Blue, rect)'هنا لرسم الحدود الخارجية للدائرة القلم ثم الحدود الخارجية[/SIZE]
[SIZE=2]graph.DrawEllipse(Pens.Blue, rect)[/SIZE]
و ان شاء الله استكمل الشرح مع شرح عمل الرسم البيانى