Visual Programming Lecture 5 PDF
Document Details
Uploaded by BonnySiren5014
Ahmed Alnasheri
Tags
Summary
This lecture covers Visual Programming, specifically focusing on GUI (Graphical User Interface) elements, including ListBoxes and ListViews. It includes examples and explanations of programming concepts.
Full Transcript
ﻣﺘﺮﺟﻢ ﻣﻦ ﺍﻹﻧﺠﻠﻴﺰﻳﺔ ﺇﻟﻰ ﺍﻟﻌﺮﺑﻴﺔ www.onlinedoctranslator.com - ﺩﻛﺘﻮﺭﺃﺣﻤﺪ ﺍﻟﻨﺎﺷﺮﻱ ﻣﺤﺘﻮﻳﺎﺕ -ﺃﺣﺪﺍﺙ ﺍﻟﻤﺎﻭﺱ -ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ -ﻣﺜﺎﻝ ﻋﻠﻰ ﺃﺣﺪﺍﺙ ﺍﻟﻤﺎﻭﺱ -ﻣﺜﺎﻝ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ -ﺃﺣﺪﺍﺙ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ...
ﻣﺘﺮﺟﻢ ﻣﻦ ﺍﻹﻧﺠﻠﻴﺰﻳﺔ ﺇﻟﻰ ﺍﻟﻌﺮﺑﻴﺔ www.onlinedoctranslator.com - ﺩﻛﺘﻮﺭﺃﺣﻤﺪ ﺍﻟﻨﺎﺷﺮﻱ ﻣﺤﺘﻮﻳﺎﺕ -ﺃﺣﺪﺍﺙ ﺍﻟﻤﺎﻭﺱ -ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ -ﻣﺜﺎﻝ ﻋﻠﻰ ﺃﺣﺪﺍﺙ ﺍﻟﻤﺎﻭﺱ -ﻣﺜﺎﻝ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ -ﺃﺣﺪﺍﺙ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ -ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ -ﻣﺜﺎﻝ ﻋﻠﻰ ﺃﺣﺪﺍﺙ ﺍﻟﻤﺎﻭﺱ -ﻣﺜﺎﻝ ﻋﻠﻰ ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ 2 ﻋﺮﺽﺍﻟﻘﺎﺉﻤﺔ -ﻣﺸﺎﺑﻬﺔ ﻟـ ListBox -ﻛﻼ ﺍﻟﻘﺎﺉﻤﺘﻴﻦ ﺗﻌﺮﺿﺎﻥ ﺣﻴﺚ ﻳﻤﻜﻦ ﻟﻠﻤﺴﺘﺨﺪﻡ ﺗﺤﺪﻳﺪ ﻋﻨﺼﺮ ﻭﺍﺣﺪ ﺃﻭ ﺃﻛﺜﺮ -ﺍﻟﻔﺮﻕ ﺑﻴﻦ ﺍﻟﻔﺉﺘﻴﻦ ﻫﻮ ﺃﻥ ListViewﻳﻤﻜﻨﻪ ﺫﻟﻚ ﻋﺮﺽﺍﻟﺮﻣﻮﺯ ﺑﺠﻮﺍﺭ ﻋﻨﺎﺻﺮ ﺍﻟﻘﺎﺉﻤﺔ -ﻳﺘﻴﺢ ﻟﻚ ﺗﺤﺪﻳﺪ ﺍﻟﺼﻮﺭ ﺍﻟﻤﺴﺘﺨﺪﻣﺔ ﻛﺄﻳﻘﻮﻧﺎﺕ ﻟﻌﻨﺎﺻﺮ ListView -ﻟﻌﺮﺽ ﺍﻟﺼﻮﺭ ،ﺃﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭﺍﻟﻤﻜﻮﻥ ﻣﻄﻠﻮﺏ 3 ﻃﺮﻕﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ -ﻋﻨﺪ ﺇﺿﺎﻓﺔ ListViewﺇﻟﻰ ﺍﻟﻨﻤﻮﺫﺝ ﻷﻭﻝ ﻣﺮﺓ ،ﺳﻴﺒﺪﻭ ﻣﺜﻞ ﻣﺮﺑﻊ ﻗﺎﺉﻤﺔ. -ﻓﻲ ،ListViewsﻳﻤﻜﻨﻚ ﺇﺿﺎﻓﺔ ﻋﻨﺎﺻﺮ ﻣﻦ ﺍﻟﻘﺎﺉﻤﺔ ﺃﺩﻧﺎﻩ ،ﺃﻭ ﻣﻦ ﺧﺎﺻﻴﺔﺍﻟﻌﻨﺎﺻﺮ.ﻳﻤﻜﻨﻚ ﺃﻳﻀﺎً ﺇﺿﺎﻓﺔ ﺃﻋﻤﺪﺓ ﺗﻤﺜﻞ ﺍﻟﻌﻨﺎﺻﺮ ﺍﻟﻔﺮﻋﻴﺔ ﻓﻲﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ. 4 ﻃﺮﻕﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ -ﺇﺿﺎﻓﺔ ﻋﻨﺎﺻﺮ -ﻹﺿﺎﻓﺔ ﻋﻨﺎﺻﺮ ﻓﻲ ﻭﻗﺖ ﺍﻟﺘﺼﻤﻴﻢ،ﻣﺎ ﻳﻠﻲ ﺳﻮﻑﺗﻈﻬﺮ ﺍﻟﻨﺎﻓﺬﺓ. -ﻣﻼﺣﻈﺔ :ﻓﻲ ﻫﺬﻩ ﺍﻟﻨﺎﻓﺬﺓ ،ﺗﺘﻢ ﺇﺿﺎﻓﺔﻛﻞ ﻋﻨﺼﺮ ﻛﻜﺎﺉﻦ ﻟﻪ ﻭﺭﻗﺔﺧﺼﺎﺉﺺ ﺧﺎﺻﺔ ﺑﻪ. ﻳﻤﻜﻦﺗﻌﺪﻳﻞ ﺧﺼﺎﺉﺺ ﻣﺜﻞ"ﺍﻟﻨﺺ" ﻭ"ﺍﻟﻌﻼﻣﺔ" ﻭ" ﺍﻟﻤﺤﺪﺩ" ﻋﻠﻰ ﻣﺴﺘﻮﻯ ﺍﻟﻌﻨﺼﺮ. 5 ﻃﺮﻕﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ -ﻋﺮﺽ -ﻣﻨﻈﺮ:ﻫﻲ ﺧﺎﺻﻴﺔ ﺗﺤﺪﺩ ﻃﺮﻳﻘﺔ ﻋﺮﺽ ﺍﻟﻌﻨﺎﺻﺮ ﻓﻲ .ListView -ﺃﻳﻘﻮﻧﺔ ﻛﺒﻴﺮﺓ SmallIcon- -ﺗﻔﺎﺻﻴﻞ -ﻗﺎﺉﻤﺔ -ﺑﻼﻁ -ﺗﺸﺒﻪ ﻃﺮﻕ ﺍﻟﻌﺮﺽ ﻫﺬﻩ ﻃﺮﻕ ﻋﺮﺽ ﺍﻟﻌﻨﺎﺻﺮ ﺍﻟﻤﻮﺟﻮﺩﺓ ﻓﻲ ﺍﻟﻤﺠﻠﺪﺍﻟﻌﺎﺩﻱ ﺍﻟﻤﻔﺘﻮﺡ ﻓﻲ .Windows 6 ﻃﺮﻕﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ -ﻋﺮﺽ -ﺳﺘﺒﺪﻭ ﻃﺮﻕ ﺍﻟﻌﺮﺽ ﻫﺬﻩ ﻣﺨﺘﻠﻔﺔ ﻛﺜﻴﺮﺍً ﻋﻨﺪ ﺭﺑﻂ ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ ﺑﻌﺮﺽﺍﻟﻘﺎﺉﻤﺔ ،ﻭﺭﺑﻂ ﻛﻞ ﻋﻨﺼﺮ ﺑﺼﻮﺭﺓ ﻣﻌﻴﻨﺔ. 7 ﻗﺎﺉﻤﺔﺍﻟﺼﻮﺭ -ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ ﻫﻲ ﻣﻜﻮﻥ ﻳﻤﻜﻦ ﺇﺿﺎﻓﺘﻪ ﺇﻟﻰ ﻣﺸﺮﻭﻋﻚ ،ﺣﻴﺚ ﻳﻤﻜﻨﻚﺇﺿﺎﻓﺔ ﺻﻮﺭ ﻣﺨﺘﻠﻔﺔ ﻳﻤﻜﻦ ﺍﺳﺘﺨﺪﺍﻣﻬﺎ ﻛﺄﻳﻘﻮﻧﺎﺕ ﻣﻊ ﻋﻨﺎﺻﺮ ،ListViewﺃﻭ ﻋﻘﺪ ،TreeViewﺍﻟﺘﻲ ﺳﻴﺘﻢ ﻣﻨﺎﻗﺸﺘﻬﺎ ﻻﺣﻘﺎً ) ﺍﻟﻤﺤﺎﺿﺮﺓﺍﻟﻘﺎﺩﻣﺔ( -ﻋﻨﺪ ﺇﺿﺎﻓﺔ ﻗﺎﺉﻤﺔ ﺻﻮﺭ ،ﺗﻈﻬﺮ ﻓﻲ ﺍﻟﺪﺭﺝ ﺍﻟﻤﻮﺟﻮﺩ ﺃﺳﻔﻞ ﺍﻟﻨﻤﻮﺫﺝ. -ﻓﻲ ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ ،ﻳﻤﻜﻨﻚ ﺗﺤﺪﻳﺪﺣﺠﻢ ﺍﻟﺼﻮﺭ ﺍﻟﻤﻀﻤﻨﺔ ﻓﻲﺍﻟﻘﺎﺉﻤﺔ. ﻣﻦﺍﺧﺘﻴﺎﺭ ﺍﻟﺼﻮﺭ ،ﻳﻤﻜﻨﻚ ﺗﺤﺪﻳﺪ ﺍﻟﺼﻮﺭ ﺍﻟﺘﻲ ﺗﺮﻳﺪﻫﺎ. 8 ﻗﺎﺉﻤﺔﺍﻟﺼﻮﺭ -ﺳﻴﻜﻮﻥ ﻟﻜﻞ ﺻﻮﺭﺓ ﻓﻬﺮﺱ ﺧﺎﺹ ﺑﻬﺎ ،ﻧﻈﺮﺍً ﻷﻥ ﺍﻟﺼﻮﺭ ﻋﺒﺎﺭﺓ ﻋﻦ ﻣﺠﻤﻮﻋﺔ. 9 ﻋﺮﺽﺍﻟﻘﺎﺉﻤﺔ ﻣﻘﺎﺑﻞ.ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ -ﻟﺮﺑﻂ ImageListﺑـ ،ListView ﺍﺳﺘﺨﺪﻡﺍﻟﺨﺼﺎﺉﺺImageList" : "Smallﻭ"."Large ImageList -ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ ﺍﻟﺼﻐﻴﺮﺓ :ﻋﺮﺽ ﺍﻟﺼﻮﺭ ﺍﻟﻤﻮﺟﻮﺩﺓﻓﻴﻬﺎ ﺇﻟﻰ ﺟﺎﻧﺐ ﺍﻟﻌﻨﺎﺻﺮ ﻋﻨﺪﺍﺳﺘﺨﺪﺍﻡ ﺍﻟﻘﺎﺉﻤﺔ ﻭ ﻃﺮﻕﻋﺮﺽ ﺍﻷﻳﻘﻮﻧﺎﺕ ﺍﻟﺼﻐﻴﺮﺓ. -ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ ﺍﻟﻜﺒﻴﺮﺓ :ﺗﻌﺮﺽ ﺍﻟﺼﻮﺭ ﺍﻟﻤﻮﺟﻮﺩﺓﺑﻬﺎ ﺇﻟﻰ ﺟﺎﻧﺐ ﺍﻟﻌﻨﺎﺻﺮ ﻋﻨﺪﺍﺳﺘﺨﺪﺍﻡ ﺍﻟﺒﻼﻁ ﻭ ﻣﺸﺎﻫﺪﺍﺕﺃﻳﻘﻮﻧﺔ ﻛﺒﻴﺮﺓ. 10 ﻋﺮﺽﺍﻟﻘﺎﺉﻤﺔ ﻣﻘﺎﺑﻞ.ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ -ﺍﻟﺨﻄﻮﺓ ﺍﻷﺧﻴﺮﺓ ﺍﻟﺘﻲ ﻳﺘﻌﻴﻦ ﻋﻠﻴﻚ ﺍﻟﻘﻴﺎﻡ ﺑﻬﺎ ﻫﻲ ﺭﺑﻂ ﻛﻞ ﻋﻨﺼﺮ ﻓﻲ ListViewﺑﺼﻮﺭﺓ ﻣﻌﻴﻨﺔ ﻓﻲ ،ImageListﺑﺎﺳﺘﺨﺪﺍﻡ ﺧﺎﺻﻴﺔ .ImageIndex 11 ﻋﺮﺽﺍﻟﻘﺎﺉﻤﺔ ﻣﻘﺎﺑﻞ.ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ -ﻋﺮﺽ ListViewﺑﻌﺪ ﺭﺑﻄﻪ ﺑـ .ImageList 12 ﻋﺮﺽﺍﻟﻘﺎﺉﻤﺔ -ﺍﻟﺘﻔﺎﺻﻴﻞ -ﺍﻷﻋﻤﺪﺓ -ﻻﺳﺘﺨﺪﺍﻡ ﻃﺮﻳﻘﺔ ﻋﺮﺽ ﺍﻟﺘﻔﺎﺻﻴﻞ ﻓﻲ ،ListViewﻳﺘﻌﻴﻦ ﻋﻠﻴﻨﺎ ﺇﺿﺎﻓﺔﺃﻋﻤﺪﺓ ﺃﻭﻻً. 13 ﻋﺮﺽﺍﻟﻘﺎﺉﻤﺔ -ﺍﻟﻌﻨﺎﺻﺮ ﺍﻟﻔﺮﻋﻴﺔ -ﻟﻤﻞءﺍﻟﺘﻔﺎﺻﻴﻞ ،ﻳﺠﺐ ﻋﻠﻴﻚ ﻣﻞء ﺍﻟﻌﻨﺎﺻﺮ ﺍﻟﻔﺮﻋﻴﺔ ﻟﻜﻞ ﻋﻨﺼﺮ ﻓﻲ .ListView -ﺍﻧﺘﻘﻞﺇﻟﻰ ﺻﻔﺤﺔ ﺧﺼﺎﺉﺺ ﺍﻟﻌﻨﺼﺮ ،ﻭﻣﻦ ﻫﻨﺎﻙ ﺃﺿﻒ ﻋﻨﺎﺻﺮ ﻓﺮﻋﻴﺔ )ﻭﻫﻲ ﺃﻳﻀﺎً ﻣﺠﻤﻮﻋﺔ(. -ﻣﻼﺣﻈﺔ:ﺃﺿﻒ ﻋﻨﺎﺻﺮ ﻓﺮﻋﻴﺔ ﻟﻜﻞ ﻋﻨﺼﺮ ﺗﺴﺎﻭﻱ ﻋﺪﺩ ﺍﻷﻋﻤﺪﺓ ﻓﻲ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ ،ﻭﺇﻻ ﻓﻠﻦﻳﺘﻢ ﻋﺮﺿﻬﺎ. 14 ﺧﺼﺎﺉﺺﺃﺧﺮﻯ – ListView -ﺍﻟﺘﺤﺪﻳﺪ ﺍﻟﻤﺘﻌﺪﺩ:ﻳﺤﺪﺩ ﻣﺎ ﺇﺫﺍ ﻛﺎﻥ ﻳﻤﻜﻨﻚ ﺗﺤﺪﻳﺪ ﺃﻛﺜﺮ ﻣﻦ ﻋﻨﺼﺮ ﻭﺍﺣﺪﻓﻲ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ ﺃﻡ ﻻ )ﻣﻨﻄﻘﻲ ،ﺍﻓﺘﺮﺍﺿﻲ :ﺻﺤﻴﺢ(. -ﺍﻟﻌﻨﺎﺻﺮ ﺍﻟﻤﺨﺘﺎﺭﺓ:ﻣﺼﻔﻮﻓﺔ ﻣﻦ ﺍﻟﻌﻨﺎﺻﺮ ﺍﻟﻤﺤﺪﺩﺓ ﻓﻲ .ListView -ﻣﻠﺤﻮﻇﺔ :ﻻ ﻳﻮﺟﺪﺍﻟﻌﻨﺼﺮ ﺍﻟﻤﺤﺪﺩﺧﺎﺻﻴﺔ ،ListViewﻭﻟﻜﻦ ﻳﻤﻜﻨﻚ ﺍﻟﺤﺼﻮﻝﻋﻠﻰ ﺍﻟﻌﻨﺼﺮ ﺍﻟﻤﺤﺪﺩ ﺑﻄﺮﻳﻘﺔ ﻣﻌﻴﻨﺔ ﺳﻴﺘﻢ ﻣﻨﺎﻗﺸﺘﻬﺎ ﻻﺣﻘﺎً. listView1.Items.Count:-ﻋﺪﺩ ﺍﻟﻌﻨﺎﺻﺮ ﻓﻲ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ. 15 ﻋﺮﺽﺍﻟﻘﺎﺉﻤﺔ -ﺍﻷﺣﺪﺍﺙ -ﺗﻢ ﺗﻐﻴﻴﺮ ﺍﻟﻔﻬﺮﺱ)ﺍﻟﺤﺪﺙ ﺍﻻﻓﺘﺮﺍﺿﻲ( -ﺗﻢ ﺗﻐﻴﻴﺮ ﺍﻟﻌﻨﺼﺮ)ﻳﻤﻜﻦ ﺇﻧﺸﺎﺅﻫﺎ ﻣﻦ ﻧﺎﻓﺬﺓ ﺍﻷﺣﺪﺍﺙ( -ﻳﺤﺘﻮﻱ ﻫﺬﺍ ﺍﻟﺤﺪﺙ ﻋﻠﻰ ﻓﺉﺔ ﻭﺳﻴﻄﺔ ﺧﺎﺻﺔ -ﺍﻟﻤﻌﻠﻤﺔ :eﺗﺴﺘﺮﺩ ﺍﻟﺨﺼﺎﺉﺺ ﺍﻟﺘﺎﻟﻴﺔ: .ﺧﺎﺻﻴﺔﻣﻨﻄﻘﻴﺔ ،ﺗﺤﺪﺩ ﻣﺎ ﺇﺫﺍ ﻛﺎﻥ ﺍﻟﻌﻨﺼﺮ ﺍﻟﺤﺎﻟﻲ ﻣﺤﺪﺩﺍً ﺃﻡ ﻻ e.IsSelected: - . -ﺍﻟﺤﺼﻮﻝﻋﻠﻰ ﺍﻟﻌﻨﺼﺮ ﺍﻟﻤﺤﺪﺩ e.Item: .ﻳﺤﺼﻞﻋﻠﻰ ﻓﻬﺮﺱ ﺍﻟﻌﻨﺼﺮ ﺍﻟﻤﺤﺪﺩ e.ItemIndex: - 16 ﻋﺮﺽﺍﻟﻘﺎﺉﻤﺔ -ﺍﻷﺳﺎﻟﻴﺐ listView1.Items.Add )...(:-ﺗﺴﺘﺨﺪﻡ ﻹﺿﺎﻓﺔ ﻋﻨﺼﺮ ﺟﺪﻳﺪ ﺇﻟﻰ ﻋﺮﺽﺍﻟﻘﺎﺉﻤﺔ. :listView1.Items]0[.SubItems.Add)...(-ﻳﺴﺘﺨﺪﻡ ﻹﺿﺎﻓﺔ ﻋﻨﺼﺮﻓﺮﻋﻲ ﺇﻟﻰ ﺍﻟﻌﻨﺼﺮ ﺍﻷﻭﻝ ﻓﻲ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ. :e.Item.SubItems.Add)...(-ﻳﺴﺘﺨﺪﻡ ﻹﺿﺎﻓﺔ ﻋﻨﺼﺮ ﻓﺮﻋﻲ ﺇﻟﻰﺍﻟﻌﻨﺼﺮ ﺍﻟﻤﺤﺪﺩ. :listView1.Items.Clear)(-ﻣﺴﺢ ﻛﺎﻓﺔ ﺍﻟﻌﻨﺎﺻﺮ ﻭﺍﻟﻌﻨﺎﺻﺮ ﺍﻟﻔﺮﻋﻴﺔﻓﻲ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ. listView1.Clear )(:-ﻣﺴﺢ ﻛﺎﻓﺔ ﺍﻟﻤﻜﻮﻧﺎﺕ ﻓﻲ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ،ﺣﺘﻰ ﺍﻷﻋﻤﺪﺓ. 17 ﻣﺜﺎﻝﻋﻠﻰ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ 18 ﻣﺜﺎﻝﻋﻠﻰ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ //ﺍﻟﺸﻜﻞ ListViewTestForm.cs :14.31 1 //ﻋﺮﺽ ﺍﻟﺪﻻﺉﻞ ﻭﻣﺤﺘﻮﻳﺎﺗﻬﺎ ﻓﻲ .ListViewﺍﺳﺘﺨﺪﺍﻡ 2 ﻧﻈﺎﻡ؛ 3 ;System.Drawing ﺍﺳﺘﺨﺪﺍﻡ 4 ;System.Windows.Forms ﺍﺳﺘﺨﺪﺍﻡ 5 ;System.IO ﺍﺳﺘﺨﺪﺍﻡ 6 7 //ﻳﺤﺘﻮﻱ ﺍﻟﻨﻤﻮﺫﺝ ﻋﻠﻰ ListViewﺍﻟﺬﻱ ﻳﻌﺮﺽ ﺍﻟﻤﺠﻠﺪﺍﺕ ﻭﺍﻟﻤﻠﻔﺎﺕ ﺍﻟﻤﻮﺟﻮﺩﺓ ﻓﻲ ﺍﻟﺪﻟﻴﻞ 8 9 10ﺍﻟﻄﺒﻘﺔ ﺍﻟﺠﺰﺉﻴﺔ ﺍﻟﻌﺎﻣﺔﺍﻟﻨﻤﻮﺫﺝ 11 ListViewTestForm: } //ﺗﺨﺰﻳﻦ ﺍﻟﺪﻟﻴﻞ ﺍﻟﺤﺎﻟﻲ 12 ﺧﻴﻂ;()currentDirectory = Directory.GetCurrentDirectory 13 14 //ﺍﻟﻤﻨﺸﺊ ﺍﻻﻓﺘﺮﺍﺿﻲ 15 ﻋﺎﻡﻗﺎﺉﻤﺔ ﺍﻟﻌﺮﺽ} ()TestForm 16 17 ;()InitializeComponent 18 //ﺗﺼﻔﺢ ﺍﻟﺪﻟﻴﻞ ﺍﻟﺬﻱ ﻧﻘﺮ ﻋﻠﻴﻪ ﺍﻟﻤﺴﺘﺨﺪﻡ ﺃﻭ ﺍﺭﺗﻔﻊ ﺑﻤﻘﺪﺍﺭ ﻣﺴﺘﻮﻯ ﻭﺍﺣﺪ 21 ﺍﻟﻔﺮﺍﻍﺍﻟﺨﺎﺹ)browserListView_Clickﻫﺪﻑﺍﻟﻤﺮﺳﻞ} ( EventArgs e ، 22 23 //ﺗﺄﻛﺪ ﻣﻦ ﺗﺤﺪﻳﺪ ﺍﻟﻌﻨﺼﺮ 24 ﻟﻮ=! } (0) browserListView.SelectedItems.Count 25 26 //ﺇﺫﺍ ﺗﻢ ﺗﺤﺪﻳﺪ ﺍﻟﻌﻨﺼﺮ ﺍﻷﻭﻝ ،ﻓﺎﻧﺘﻘﻞ ﺇﻟﻰ ﻣﺴﺘﻮﻯ ﻭﺍﺣﺪ ﻟﻮ)ﺍﻟﻤﺘﺼﻔﺢ.ListView.Itemsﻣﺤﺪﺩ( } 27 28 29 //ﺇﻧﺸﺎء ﻛﺎﺉﻦ DirectoryInfoﻟﻠﺪﻟﻴﻞ ﺩﻟﻴﻞ ﻣﻌﻠﻮﻣﺎﺕ ﺍﻟﺪﻟﻴﻞ= Object 30 31 ﺟﺪﻳﺪﻣﻌﻠﻮﻣﺎﺕ ﺍﻟﺪﻟﻴﻞ )ﺍﻟﺪﻟﻴﻞ ﺍﻟﺤﺎﻟﻲ( ؛ 32 33 //ﺇﺫﺍ ﻛﺎﻥ ﺍﻟﺪﻟﻴﻞ ﻳﺤﺘﻮﻱ ﻋﻠﻰ ﺍﻷﺻﻞ ،ﻓﻘﻢ ﺑﺘﺤﻤﻴﻠﻪ ﻟﻮ=! ) DirectoryObject.Parentﺑﺎﻃﻞ( 34 35 (; { //LoadFilesInDirectory) DirectoryObject.Parent.FullNameﺍﻟﻨﻬﺎﻳﺔ ﺇﺫﺍ 36 37 19 ﻣﺜﺎﻝﻋﻠﻰ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ 38 //ﺍﻟﺪﻟﻴﻞ ﺃﻭ ﺍﻟﻤﻠﻒ ﺍﻟﻤﺤﺪﺩ ﺁﺧﺮ 39 40 } 41 //ﺍﻟﺪﻟﻴﻞ ﺃﻭ ﺍﻟﻤﻠﻒ ﺍﻟﻤﺨﺘﺎﺭ 42 ﺧﻴﻂﺍﻟﻤﺨﺘﺎﺭ = .browserListView.SelectedItemsﻧﺺ؛ 43 44 //ﺇﺫﺍ ﻛﺎﻥ ﺍﻟﻌﻨﺼﺮ ﺍﻟﻤﺤﺪﺩ ﻫﻮ ﺍﻟﺪﻟﻴﻞ ،ﻓﻘﻢ ﺑﺘﺤﻤﻴﻞ ﺍﻟﺪﻟﻴﻞ ﺍﻟﻤﺤﺪﺩ ﻟﻮ) ﺍﻟﺪﻟﻴﻞ ﻣﻮﺟﻮﺩ ) ﺍﻟﺪﻟﻴﻞ 45 ﺍﻟﺤﺎﻟﻲ +"\"@ +ﺗﻢ ﺍﻻﺧﺘﻴﺎﺭ ( ( } 46 47 //ﺇﺫﺍ ﻛﺎﻥ ﻣﻮﺟﻮﺩﺍً ﺣﺎﻟﻴﺎً ﻓﻲ ،\:Cﻓﻼ ﺣﺎﺟﺔ ﺇﻟﻰ '\'؛ ﻭﺇﻻ ﻓﺈﻧﻨﺎ ﻧﻔﻌﻞ ﻟﻮ)ﺍﻟﺪﻟﻴﻞ ﺍﻟﺤﺎﻟﻲ == 48 @"ﺝ("\: 49 ;( LoadFilesInDirectory)currentDirectory +chooseﺁﺧﺮ 50 51 ﺗﺤﻤﻴﻞﺍﻟﻤﻠﻔﺎﺕ ﻓﻲ ﺍﻟﺪﻟﻴﻞ ) 52 ﺍﻟﺪﻟﻴﻞﺍﻟﺤﺎﻟﻲ +"\"@ +ﺍﻟﻤﺨﺘﺎﺭ(؛ { //ﺍﻟﻨﻬﺎﻳﺔ ﺇﺫﺍ 53 54 { //ﻧﻬﺎﻳﺔ ﺁﺧﺮ 55 56 //ﺗﺤﺪﻳﺚ ﻋﺮﺽ ﺍﻟﺘﺴﻤﻴﺔ 57 { ; //DisplayLabel.Text = currentDirectoryﺍﻟﻨﻬﺎﻳﺔ 58 ﺇﺫﺍ 59 { //ﻃﺮﻳﻘﺔ ﺍﻟﻨﻬﺎﻳﺔ browserListView_Click 60 20 ﻣﺜﺎﻝﻋﻠﻰ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ 61 //ﻋﺮﺽ ﺍﻟﻤﻠﻔﺎﺕ/ﺍﻟﺪﻻﺉﻞ ﺍﻟﻔﺮﻋﻴﺔ ﻟﻠﺪﻟﻴﻞ ﺍﻟﺤﺎﻟﻲ 62 ﺍﻟﻔﺮﺍﻍﺍﻟﻌﺎﻡﺗﺤﻤﻴﻞ ﺍﻟﻤﻠﻔﺎﺕ ﻓﻲ ﺍﻟﺪﻟﻴﻞ )ﺧﻴﻂﻗﻴﻤﺔ ﺍﻟﺪﻟﻴﻞ ﺍﻟﺤﺎﻟﻲ ( } 63 64 //ﺗﺤﻤﻴﻞ ﻣﻌﻠﻮﻣﺎﺕ ﺍﻟﺪﻟﻴﻞ ﻭﻋﺮﺿﻪ ﻳﺤﺎﻭﻝ 65 66 } 67 //ﺍﻣﺴﺢ ListViewﻭﻗﻢ ﺑﺘﻌﻴﻴﻦ ﺍﻟﻌﻨﺼﺮ ﺍﻷﻭﻝ )(; browserListView.Items.Add 68 )"browserListView.Items.Clearﺍﻻﺭﺗﻘﺎء ﺑﻤﺴﺘﻮﻯ ﻭﺍﺣﺪ"(; 69 70 71 //ﺗﺤﺪﻳﺚ ﺍﻟﺪﻟﻴﻞ ﺍﻟﺤﺎﻟﻲ = newCurrentDirectoryﻣﻌﻠﻮﻣﺎﺕ ﺍﻟﺪﻟﻴﻞ 72 ;currentDirectory = currentDirectoryValue 73 74 ﺟﺪﻳﺪﻣﻌﻠﻮﻣﺎﺕ ﺍﻟﺪﻟﻴﻞ )ﺍﻟﺪﻟﻴﻞ ﺍﻟﺤﺎﻟﻲ( ؛ 75 76 //ﺿﻊ ﺍﻟﻤﻠﻔﺎﺕ ﻭﺍﻷﺩﻟﺔ ﻓﻲ ﺍﻟﻤﺼﻔﻮﻓﺎﺕ = [ DirectoryArray 77 ]DirectoryInfo 78 ;()(; FileInfo][ fileArray = newCurrentDirectory.GetFiles 79 )newCurrentDirectory.GetDirectories 80 81 //ﺃﺿﻒ ﺃﺳﻤﺎء ﺍﻟﺪﻟﻴﻞ ﺇﻟﻰ ListView 82 )com.foreachﻣﻌﻠﻮﻣﺎﺕ ﺍﻟﺪﻟﻴﻞ ﺩﻳﺮﻓﻲﻣﺼﻔﻮﻓﺔ ﺍﻟﺪﻟﻴﻞ ( } 83 84 //ﺇﺿﺎﻓﺔ ﺩﻟﻴﻞ ﺇﻟﻰ newDirectoryItem ListView 85 = ListViewItem 86 ﺩﻳﺮ.ﺍﻻﺳﻢ (; )browserListView.Items.Add 87 88 //ﺗﻌﻴﻴﻦ ﺻﻮﺭﺓ ﺍﻟﺪﻟﻴﻞ = //{ ;0newDirectoryItem.ImageIndexﻧﻬﺎﻳﺔ 89 foreach 90 21 ﻣﺜﺎﻝﻋﻠﻰ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ 91 //ﺃﺿﻒ ﺃﺳﻤﺎء ﺍﻟﻤﻠﻔﺎﺕ ﺇﻟﻰ )com.foreach ListViewﻣﻠﻒ 92 ﻣﻌﻠﻮﻣﺎﺕﺍﻟﻤﻠﻒﻓﻲﻣﺼﻔﻮﻓﺔ ﺍﻟﻤﻠﻔﺎﺕ ( } 93 94 //ﺇﺿﺎﻓﺔ ﻣﻠﻒ ﺇﻟﻰ = ListView 95 ListViewItem newFileItem 96 (; ﺍﺳﻢﺍﻟﻤﻠﻒ )browserListView.Items.Add 97 98 //ﺗﻌﻴﻴﻦ ﺻﻮﺭﺓ ﺍﻟﻤﻠﻒ = //{ ;1newFileItem.ImageIndex 99 ﻧﻬﺎﻳﺔ //{ foreachﻧﻬﺎﻳﺔ ﺍﻟﻤﺤﺎﻭﻟﺔ 100 101 102 //ﺗﻢ ﺍﻟﺮﻓﺾ 103 ﻳﻤﺴﻚ)ﺍﺳﺘﺜﻨﺎء ﻭﺻﻮﻝ ﻏﻴﺮ ﻣﺼﺮﺡ ﺑﻪ( } 104 105 ﺻﻨﺪﻭﻕﺍﻟﺮﺳﺎﺉﻞ.ﺇﻇﻬﺎﺭ)"ﺗﺤﺬﻳﺮ :ﺑﻌﺾ ﺍﻟﺤﻘﻮﻝ ﻗﺪ ﻻ ﺗﻜﻮﻥ ﻛﺬﻟﻚ"+ 106 "ﻣﺮﺉﻲ ﺑﺴﺒﺐ ﺇﻋﺪﺍﺩﺍﺕ ﺍﻷﺫﻭﻧﺎﺕ"" ,ﺍﻧﺘﺒﺎﻩ" {0,؛ 107 ( //، messageBoxIcon.Warningﻧﻬﺎﻳﺔ ﺍﻟﺼﻴﺪ 108 109 { //ﻃﺮﻳﻘﺔ ﺍﻟﻨﻬﺎﻳﺔ LoadFilesInDirectory 110 22 ﻣﺜﺎﻝﻋﻠﻰ ﻋﺮﺽ ﺍﻟﻘﺎﺉﻤﺔ 111 } ( EventArgs e ،)ﻫﺪﻑﺍﻟﻤﺮﺳﻞTestForm_Load ﺍﻟﺘﻌﺎﻣﻞ ﻣﻊ ﺣﺪﺙ ﺍﻟﺘﺤﻤﻴﻞ ﻋﻨﺪ ﻋﺮﺽ ﺍﻟﻨﻤﻮﺫﺝ ﻷﻭﻝ ﻣﺮﺓ ﺍﻟﻔﺮﺍﻍ ﺍﻟﺨﺎﺹﻟﻴﺴﺘﻔﻴﻮ// 112 113 114 ﺗﻌﻴﻴﻦ ﻗﺎﺉﻤﺔ ﺍﻟﺼﻮﺭ// 115 )Image.FromFile = ﺻﻮﺭﺓﻣﺠﻠﺪ ﺍﻟﺼﻮﺭﺓ 116 ;("bmp. @"\ﺻﻮﺭ\ﻣﺠﻠﺪ+ ﺍﻟﺪﻟﻴﻞﺍﻟﺤﺎﻟﻲ 117 118 )fileImage = Image.FromFileﺻﻮﺭﺓ 119 ;("bmp. @"\ﺻﻮﺭ\ﻣﻠﻒ+ ﺍﻟﺪﻟﻴﻞﺍﻟﺤﺎﻟﻲ 120 121 FolderImage (; fileFolder.Images.Add) 122 ;( ﺻﻮﺭﺓﺍﻟﻤﻠﻒ fileFolder.Images.Add) 123 124 = currentDirectory; { browserListView ﺗﺤﻤﻴﻞ ﺍﻟﺪﻟﻴﻞ ﺍﻟﺤﺎﻟﻲ ﺇﻟﻰ// 125 ﻃﺮﻳﻘﺔ ﺍﻟﻨﻬﺎﻳﺔ//LoadFilesInDirectory)currentDirectory(; DisplayLabel.Text 126 ListViewTestForm_Load 127 128 ListViewTestForm ﻧﻬﺎﻳﺔ ﺍﻟﻔﺼﻞ//{129 23 ﻣﺮﺍﻗﺒﺔﻫﻨﺪﺳﺔ ﺍﻟﺒﺮﻣﺠﻴﺎﺕ -ﻋﻨﺪ ﺗﺼﻤﻴﻢ ﺍﻟﺘﻄﺒﻴﻘﺎﺕ ﺍﻟﺘﻲ ﺗﻌﻤﻞ ﻟﻔﺘﺮﺍﺕ ﻃﻮﻳﻠﺔ ﻣﻦ ﺍﻟﻮﻗﺖ، ﻳﻤﻜﻨﻚﺍﺧﺘﻴﺎﺭ ﺗﺄﺧﻴﺮ ﺃﻭﻟﻲ ﻛﺒﻴﺮ ﻟﺘﺤﺴﻴﻦ ﺍﻷﺩﺍء ﺧﻼﻝ ﺑﻘﻴﺔ ﺍﻟﺒﺮﻧﺎﻣﺞ. ﻭﻣﻊﺫﻟﻚ ،ﻓﻲ ﺍﻟﺘﻄﺒﻴﻘﺎﺕ ﺍﻟﺘﻲ ﻳﺘﻢ ﺗﺸﻐﻴﻠﻬﺎ ﻟﻔﺘﺮﺍﺕ ﺯﻣﻨﻴﺔ ﻗﺼﻴﺮﺓ ﻓﻘﻂ،ﻏﺎﻟﺒﺎً ﻣﺎ ﻳﻔﻀﻞ ﺍﻟﻤﻄﻮﺭﻭﻥ ﺃﻭﻗﺎﺕ ﺍﻟﺘﺤﻤﻴﻞ ﺍﻷﻭﻟﻴﺔ ﺍﻟﺴﺮﻳﻌﺔ ﻭﺍﻟﺘﺄﺧﻴﺮﺍﺕﺍﻟﺒﺴﻴﻄﺔ ﺑﻌﺪ ﻛﻞ ﺇﺟﺮﺍء. 24 ﺃﺣﺪﺍﺙﺍﻟﻤﺎﻭﺱ -ﺃﺣﺪﺍﺙ ﺍﻟﻤﺎﻭﺱ :ﻫﻲ ﺗﻠﻚ ﺍﻷﺣﺪﺍﺙ ﺍﻟﻤﺮﺗﺒﻄﺔ ﺑﺈﺟﺮﺍءﺍﺕ ﺍﻟﻤﺎﻭﺱ.ﻭﻳﻤﻜﻦ ﺃﻥ ﺗﻜﻮﻥ ﻣﺮﺗﺒﻄﺔ ﺑﺎﻟﺸﻜﻞ ﻛﻜﻞ ،ﺃﻭ ﺑﺘﺤﻜﻢ ﻣﻌﻴﻦﻣﺴﺘﻤﺪ ﻣﻦ ﺍﻟﻄﺒﻘﺔ System.Windows.Forms.Control. -ﻓﺉﺔ MouseEventArgs -ﻳﺤﺘﻮﻱ ﻋﻠﻰ ﻣﻌﻠﻮﻣﺎﺕ ﻣﺘﻌﻠﻘﺔ ﺑﺤﺪﺙ ﺍﻟﻤﺎﻭﺱ -ﻳﺘﻢ ﺗﻤﺮﻳﺮ ﻣﻌﻠﻮﻣﺎﺕ ﺣﻮﻝ ﺍﻟﺤﺪﺙ ﺇﻟﻰ ﺃﺳﻠﻮﺏ ﻣﻌﺎﻟﺠﺔ ﺍﻷﺣﺪﺍﺙ ﻣﻦﺧﻼﻝ ﻛﺎﺉﻦ ﻣﻦ ﻫﺬﻩ ﺍﻟﻔﺉﺔ -ﺍﻟﻤﻔﻮﺽ ﺍﻟﻤﺴﺘﺨﺪﻡ ﻹﻧﺸﺎء ﻣﻌﺎﻟﺠﺎﺕ ﺃﺣﺪﺍﺙ ﺍﻟﻤﺎﻭﺱ ﻫﻮ MouseEventHandler 25 ﺃﺣﺪﺍﺙﺍﻟﻤﺎﻭﺱ -ﺗﺤﺮﻳﻚ ﺍﻟﻤﺎﻭﺱ:ﻳﺤﺪﺙ ﻋﻨﺪﻣﺎ ﻳﺘﺤﺮﻙ ﻣﺆﺷﺮ ﺍﻟﻤﺎﻭﺱ ﻓﻮﻕ ﻧﻤﻮﺫﺝ ﺃﻭ ﻋﻨﺼﺮ ﺗﺤﻜﻢ ﻣﻌﻴﻦ. -ﺍﻟﻨﻘﺮ ﺑﺎﻟﻤﺎﻭﺱ:ﻳﺤﺪﺙ ﻋﻨﺪﻣﺎ ﻳﻨﻘﺮ ﺍﻟﻤﺴﺘﺨﺪﻡ ﻋﻠﻰ ﺍﻟﻨﻤﻮﺫﺝ ﺃﻭ ﻋﻠﻰ ﻋﻨﺼﺮ ﺗﺤﻜﻢ ﻣﻌﻴﻦ ﺑﺰﺭﺍﻟﻔﺄﺭﺓ )ﺃﻱ ﻧﻘﺮﺓ ﻋﻠﻰ ﺍﻟﺰﺭ ﺳﺘﺘﺴﺒﺐ ﻓﻲ ﻫﺬﺍ ﺍﻟﺤﺪﺙ(. -ﺃﺩﺧﻞ ﺍﻟﻤﺎﻭﺱ:ﻳﺤﺪﺙ ﻋﻨﺪﻣﺎ ﻳﺪﺧﻞ ﻣﺆﺷﺮ ﺍﻟﻤﺎﻭﺱ ﻓﻲ ﺣﺪﻭﺩ ﻧﻤﻮﺫﺝ ﺃﻭ ﻋﻨﺼﺮ ﺗﺤﻜﻢ ﻣﻌﻴﻦ. -ﺗﺮﻙ ﺍﻟﻤﺎﻭﺱ:ﻳﺤﺪﺙ ﻋﻨﺪﻣﺎ ﻳﺘﺮﻙ ﻣﺆﺷﺮ ﺍﻟﻤﺎﻭﺱ ﻣﻨﻄﻘﺔ ﺍﻟﻨﻤﻮﺫﺝ ﺃﻭ ﻋﻨﺼﺮ ﺗﺤﻜﻢ ﻣﻌﻴﻦ. -ﻣﺎﻭﺱ ﺩﺍﻭﻥ:ﻳﺤﺪﺙ ﻋﻨﺪﻣﺎ ﻳﻀﻐﻂ ﺍﻟﻤﺴﺘﺨﺪﻡ ﻋﻠﻰ ﺯﺭ ﺍﻟﻤﺎﻭﺱ ،ﻭﻳﺴﺘﻤﺮ ﻓﻲ ﺍﻟﻀﻐﻂ). ﺃﻱﺯﺭ(. -ﺭﻓﻊ ﺍﻟﻤﺎﻭﺱ:ﻳﺤﺪﺙ ﻋﻨﺪﻣﺎ ﻳﻘﻮﻡ ﺍﻟﻤﺴﺘﺨﺪﻡ ﺑﺘﺤﺮﻳﺮ ﺯﺭ ﺍﻟﻤﺎﻭﺱ).ﺃﻱ ﺯﺭ(. -ﺗﻤﺮﻳﺮ ﺍﻟﻤﺎﻭﺱ:ﻳﺤﺪﺙ ﻋﻨﺪﻣﺎ ﻳﻤﺮﺭ ﻣﺆﺷﺮ ﺍﻟﻤﺎﻭﺱ ﻓﻮﻕ ﻧﻤﻮﺫﺝ ﺃﻭ ﻋﻨﺼﺮ ﺗﺤﻜﻢ ﻣﻌﻴﻦ. 26 ﻭﺳﻴﻄﺎﺕﺃﺣﺪﺍﺙ ﺍﻟﻤﺎﻭﺱ -ﻭﻓﻘﺎً ﻟﺤﺪﺙ ﺍﻟﻤﺎﻭﺱ ﺍﻟﺬﻱ ﺗﻢ ﺍﻟﺘﻌﺎﻣﻞ ﻣﻌﻪ ،ﻳﺘﻢ ﺍﺳﺘﺨﺪﺍﻡ ﻭﺳﻴﻄﺎﺕﺃﺣﺪﺍﺙ ﻣﻌﻴﻨﺔ. -ﺳﺘﻈﻬﺮ ﺇﺣﺪﻯ ﻓﺉﺘﻲ ﻭﺳﻴﻄﺎﺕ ﺍﻷﺣﺪﺍﺙ ﻓﻲ ﺭﺃﺱ ﻣﻌﺎﻟﺞ ﺃﺣﺪﺍﺙﺍﻟﻤﺎﻭﺱ. MouseEventArgs:-ﺳﻴﺘﻢ ﺍﺳﺘﺨﺪﺍﻡ ﻓﺉﺔ ﻭﺳﺎﺉﻂ ﺍﻟﺤﺪﺙ ﻫﺬﻩ ﻓﻲﺍﻷﺣﺪﺍﺙ ) MouseClickﻭ MouseMoveﻭ MouseDownﻭ ،(MouseUpﻭﺗﺤﺘﻮﻱ ﻋﻠﻰ ﺧﺼﺎﺉﺺ ﺧﺎﺻﺔ ﻟﻠﻤﺎﻭﺱ. -ﻭﺳﻴﻄﺎﺕ ﺍﻷﺣﺪﺍﺙ:ﻓﺉﺔ ﻭﺳﺎﺉﻂ ﺍﻟﺤﺪﺙ ﺍﻟﻌﺎﺩﻳﺔ ،ﻭﺍﻟﺘﻲ ﺗﺮﺗﺒﻂ ﻋﺎﺩﺓ ًﺑﺄﻱ ﻣﻌﺎﻟﺞ ﺣﺪﺙ.ﻻ ﻳﺤﺘﻮﻱ ﻋﻠﻰ ﺃﻱ ﺧﺼﺎﺉﺺ ﺧﺎﺻﺔ ﺑﺎﻟﻤﺎﻭﺱ. 27 MouseEventArgs -ﺳﺘﻈﻬﺮ ﻫﺬﻩ ﺍﻟﻔﺉﺔ ﻓﻲ ﺭﺃﺱ ﺃﺣﺪﺍﺙ ﺍﻟﻤﺎﻭﺱ MouseClick :ﻭ MouseMoveﻭ MouseDownﻭ MouseUp. -ﺍﻟﻮﺳﻴﻄﺔ " ،"eﻭﻫﻲ ﻣﻦ ﻓﺉﺔ ""MouseEventArgs ﺳﻴﺤﺘﻮﻱﻋﻠﻰ ﺧﺼﺎﺉﺺ ﺍﻟﻤﺎﻭﺱ ﺍﻟﺘﺎﻟﻴﺔ: 28 MouseEventArgs -ﺍﻟﻌﺎﺷﺮ:ﻣﻦ ﺍﻟﻨﻮﻉﻛﺜﺎﻓﺔ ﺍﻟﻌﻤﻠﻴﺎﺕ; ﻭﺗﻘﻮﻡ ﺑﺈﺭﺟﺎﻉ ﺇﺣﺪﺍﺛﻲ X ﻟﻤﺆﺷﺮﺍﻟﻤﺎﻭﺱ ﻓﻮﻕ ﻧﻤﻮﺫﺝ ﺃﻭ ﻋﻨﺼﺮ ﺗﺤﻜﻢ ﻣﻌﻴﻦ. -ﺹ:ﻣﻦ ﺍﻟﻨﻮﻉﻛﺜﺎﻓﺔ ﺍﻟﻌﻤﻠﻴﺎﺕ; ﻭﺗﻘﻮﻡ ﺑﺈﺭﺟﺎﻉ ﺍﻹﺣﺪﺍﺛﻲ Y ﻟﻤﺆﺷﺮﺍﻟﻤﺎﻭﺱ ﻓﻮﻕ ﻧﻤﻮﺫﺝ ﺃﻭ ﻋﻨﺼﺮ ﺗﺤﻜﻢ ﻣﻌﻴﻦ. -ﺯﺭ:ﻣﻦ ﺍﻟﻨﻮﻉﺃﺯﺭﺍﺭ ﺍﻟﻤﺎﻭﺱ; ﻭﻫﻮ ﺗﻌﺪﺍﺩ ﻳﺤﺘﻮﻱ ﻋﻠﻰ ﺍﻟﻘﻴﻢ ) ﻳﺴﺎﺭ،ﻳﻤﻴﻦ ،ﻭﻭﺳﻂ( ،ﻭﺍﻟﺘﻲ ﺗﺸﻴﺮ ﺇﻟﻰ ﺯﺭ ﺍﻟﻤﺎﻭﺱ ﺍﻟﺬﻱ ﺗﻢ ﺍﻟﻨﻘﺮﻋﻠﻴﻪ ﻭﺗﺴﺒﺐ ﻓﻲ ﺍﻟﺤﺪﺙ. 29 ﻣﺜﺎﻝﻟﺤﺪﺙ ﺍﻟﻤﺎﻭﺱ 30 MouseEventArgs 31 ﺃﺣﺪﺍﺙﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ -ﺃﺣﺪﺍﺙ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ:ﻫﻲ ﺍﻷﺣﺪﺍﺙ ﺍﻟﻤﺮﺗﺒﻄﺔ ﺑﻤﻔﺎﺗﻴﺢ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ.ﻋﻨﺪﻣﺎ ﻳﻀﻐﻂ ﺍﻟﻤﺴﺘﺨﺪﻡ ﻋﻠﻰ ﺃﻱ ﻣﻔﺘﺎﺡ ﻋﻠﻰ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ،ﺗﺤﺪﺙ ﻫﺬﻩ ﺍﻷﺣﺪﺍﺙ. 32 ﺃﺣﺪﺍﺙﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ -ﺍﻟﻀﻐﻂ ﻋﻠﻰ ﺍﻟﻤﻔﺎﺗﻴﺢ:ﻳﺤﺪﺙ ﻋﻨﺪﻣﺎ ﻳﻀﻐﻂ ﺍﻟﻤﺴﺘﺨﺪﻡ ﻋﻠﻰ ﻣﻔﺘﺎﺡ ﻣﻌﻴﻦﻓﻲ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ. -ﻣﻔﺘﺎﺡ ﻷﺳﻔﻞ:ﻳﺤﺪﺙ ﻋﻨﺪﻣﺎ ﻳﻀﻐﻂ ﺍﻟﻤﺴﺘﺨﺪﻡ ﻋﻠﻰ ﻣﻔﺘﺎﺡ ﻣﻌﻴﻦﻓﻲ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ ﻭﻳﺴﺘﻤﺮ ﻓﻲ ﺍﻟﻀﻐﻂ. -ﺭﻓﻊ ﺍﻟﻤﻔﺘﺎﺡ:ﻳﺤﺪﺙ ﻣﺒﺎﺷﺮﺓ ﻋﻨﺪﻣﺎ ﻳﻘﻮﻡ ﺍﻟﻤﺴﺘﺨﺪﻡ ﺑﺘﺤﺮﻳﺮ ﺍﻟﻤﻔﺘﺎﺡ ﺍﻟﻤﻮﺟﻮﺩ ﻓﻲﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ. 33 ﻭﺳﻴﻄﺎﺕﺃﺣﺪﺍﺙ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ -ﻭﻓﻘﺎً ﻟﺤﺪﺙ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ ﺍﻟﺬﻱ ﺗﻢ ﺍﻟﺘﻌﺎﻣﻞ ﻣﻌﻪ ،ﻳﺘﻢ ﺍﺳﺘﺨﺪﺍﻡﻭﺳﻴﻄﺎﺕ ﺃﺣﺪﺍﺙ ﻣﻌﻴﻨﺔ. -ﺳﺘﻈﻬﺮ ﺇﺣﺪﻯ ﻓﺉﺘﻲ ﻭﺳﻴﻄﺎﺕ ﺍﻷﺣﺪﺍﺙ ﻓﻲ ﺭﺃﺱ ﻣﻌﺎﻟﺞ ﺍﻷﺣﺪﺍﺙﻟﻠﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ. KeyPressEventArgs:-ﺳﻴﺘﻢ ﺍﺳﺘﺨﺪﺍﻡ ﻓﺉﺔ ﻭﺳﻴﻄﺎﺕ ﺍﻟﺤﺪﺙ ﻫﺬﻩﻓﻲ ﺣﺪﺙ ،KeyPressﻭﻫﻲ ﺗﺤﺘﻮﻱ ﻋﻠﻰ ﺧﺼﺎﺉﺺ ﺧﺎﺻﺔ ﻟﻠﻤﻔﺘﺎﺡ. KeyEventArgs:-ﺳﻴﺘﻢ ﺍﺳﺘﺨﺪﺍﻡ ﻓﺉﺔ ﻭﺳﻴﻄﺎﺕ ﺍﻟﺤﺪﺙ ﻫﺬﻩ ﻓﻲ ﺣﺪﺙ KeyDownﻭ ،KeyUpﻭﺗﺤﺘﻮﻱ ﻋﻠﻰ ﺧﺼﺎﺉﺺ ﺧﺎﺻﺔ ﻟﻠﻤﻔﺘﺎﺡ. 34 KeyPressEventArgs -ﺍﻟﺨﺎﺻﻴﺔ ﺍﻟﺮﺉﻴﺴﻴﺔ ﺍﻟﺘﻲ ﺗﻢ ﺍﺳﺘﺮﺩﺍﺩﻫﺎ ﺑﻮﺍﺳﻄﺔ ﻫﺬﻩ ﺍﻟﻔﺉﺔ ﻫﻲ.KeyChar: .-؛ ﻳﻘﻮﻡ ﺑﺎﺳﺘﺮﺩﺍﺩ ﺍﻟﺤﺮﻑ ﺍﻟﻔﻌﻠﻲ ﺍﻟﻤﻄﺒﻮﻉ ﺑﻮﺍﺳﻄﺔ ﺍﻟﻤﻔﺘﺎﺡ ﺍﻟﺬﻱ ﺗﻢ ﺍﻟﻀﻐﻂ ﻋﻠﻴﻪ).ﺍﻷﺣﺮﻑ ﺍﻟﻘﺎﺑﻠﺔﻟﻠﻄﺒﺎﻋﺔ ﻓﻘﻂ ،ﻟﻦ ﺗﻘﻮﻡ ﺍﻷﺣﺮﻑ ﻏﻴﺮ ﺍﻟﻘﺎﺑﻠﺔ ﻟﻠﻄﺒﺎﻋﺔ ﺑﺎﺳﺘﺮﺩﺍﺩ ﺍﻟﺒﻴﺎﻧﺎﺕ ﻓﻲ ﻫﺬﻩ ﺍﻟﺨﺎﺻﻴﺔ( charﻣﻦ ﺍﻟﻨﻮﻉ KeyChar: 35 KeyEventArgs -ﻣﻮﺟﻮﺩ ﻓﻲ ﻛﻞ ﻣﻦ ﻣﻌﺎﻟﺠﺎﺕ ﺍﻷﺣﺪﺍﺙ KeyDownﻭ.KeyUp -ﺍﻟﺨﺼﺎﺉﺺ ﺍﻟﻤﻮﺟﻮﺩﺓ ﻓﻲ ﻫﺬﻩ ﺍﻟﻔﺉﺔ: -ﺭﻣﺰ ﺍﻟﻤﻔﺘﺎﺡ:ﻣﻦ ﺍﻟﻨﻮﻉﻣﻔﺎﺗﻴﺢ; ﻭﻫﻮ ﺗﻌﺪﺍﺩ ﻳﺤﺘﻮﻱ ﻋﻠﻰ ﺟﻤﻴﻊ ﺍﻟﻤﻔﺎﺗﻴﺢ ﺍﻟﻤﻤﻜﻨﺔ ﻋﻠﻰﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ )ﺍﻟﻘﺎﺑﻠﺔ ﻟﻠﻄﺒﺎﻋﺔ ﻭﻏﻴﺮ ﺍﻟﻘﺎﺑﻠﺔ ﻟﻠﻄﺒﺎﻋﺔ(. -ﺍﻟﺒﻴﺎﻧﺎﺕ ﺍﻟﺮﺉﻴﺴﻴﺔ:ﻣﻦ ﺍﻟﻨﻮﻉﻣﻔﺎﺗﻴﺢ; ﻟﻜﻨﻪ ﻳﺨﺘﻠﻒ ﺃﻥ .KeyCodeﺳﻴﻌﻴﺪ KeyCode ﺁﺧﺮﻣﻔﺘﺎﺡ ﺗﻢ ﺍﻟﻀﻐﻂ ﻋﻠﻴﻪ ،ﺑﻴﻨﻤﺎ ﺳﻴﻌﻴﺪ KeyDataﺟﻤﻴﻊ ﺍﻟﻤﻔﺎﺗﻴﺢ ﺍﻟﺘﻲ ﺗﻢ ﺍﻟﻀﻐﻂ ﻋﻠﻴﻬﺎﻓﻲ ﻧﻔﺲ ﺍﻟﻮﻗﺖ. -ﻗﻴﻤﺔ ﺍﻟﻤﻔﺘﺎﺡ:ﻣﻦ ﺍﻟﻨﻮﻉﻛﺜﺎﻓﺔ ﺍﻟﻌﻤﻠﻴﺎﺕ; ﺗﻘﻮﻡ ﺑﺈﺭﺟﺎﻉ ﻗﻴﻤﺔ ﻋﺪﺩﻳﺔ ﺗﻤﺜﻞ ﺍﻟﻤﻔﺘﺎﺡ ﺍﻟﻤﻮﺟﻮﺩﻋﻠﻰ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ. -ﺍﻟﺒﺪﻳﻞ:ﻣﻦ ﺍﻟﻨﻮﻉ ﺑﻮﻝ؛ ﻳﺮُﺟﻊ ﺻﺤﻴﺤﺎً ﺇﺫﺍ ﺗﻢ ﺍﻟﻀﻐﻂ ﻋﻠﻰ ﻣﻔﺘﺎﺡ ،Altﻭﻳﺮُﺟﻊ ﺧﻄﺄ ﺇﺫﺍ ﻟﻢ ﻳﻜﻦ ﻛﺬﻟﻚ. -ﻳﺤﻮﻝ:ﻣﻦ ﺍﻟﻨﻮﻉ ﺑﻮﻝ؛ ﻳﺮُﺟﻊ ﻃﺒﻴﻌﻴﺎً ﺇﺫﺍ ﺗﻢ ﺍﻟﻀﻐﻂ ﻋﻠﻰ ﻣﻔﺘﺎﺡ ،Shiftﻭﻳﺮُﺟﻊ ﺧﻄﺄ ﺇﺫﺍ ﻟﻢ ﻳﻜﻦ ﻛﺬﻟﻚ. -ﻳﺘﺤﻜﻢ:ﻣﻦ ﺍﻟﻨﻮﻉ ﺑﻮﻝ؛ ﻳﺮُﺟﻊ ﺻﺤﻴﺤﺎً ﺇﺫﺍ ﺗﻢ ﺍﻟﻀﻐﻂ ﻋﻠﻰ ﻣﻔﺘﺎﺡ ،Ctrlﻭﻳﺮُﺟﻊ ﺧﻄﺄ ﺇﺫﺍ ﻟﻢ ﻳﻜﻦ ﻛﺬﻟﻚ. 36 ﻣﺜﺎﻝﻋﻠﻰ ﺣﺪﺙ ﻟﻮﺣﺔ ﺍﻟﻤﻔﺎﺗﻴﺢ 37 ﺍﻟﻮﺍﺟﺐﺍﻟﻤﻨﺰﻟﻲ 4 38 ﺍﻟﻮﺍﺟﺐﺍﻟﻤﻨﺰﻟﻲ 4 39 ﺍﻟﻨﻬﺎﻳﺔ 40