تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
Introduction To Screen Capture
#2
السلام عليكم ورحمة الله و بركاته

في الجزء الأول تم إعطاء مستخدم البرنامج إمكانية تحريك المستطيل و تغيير أبعاده لكي يستطيع تحديد الجزء الذي يريد تصويره من علي سطح الشاشة

في هذه المشاركة سأوضح كيفية أخذ صورة واحدة فقط لجزء معين علي شاشة الكمبيوتر وحفظها في Debug Folder الخاص بالمشروع

ولتنفيذ ذلك نحتاج  الي تعديل الكود قليلا في الكلاس ClientGlyph حتي نتخلص من عمليات الرسم التي تحدث في هذا الكلاس

الكود الخاص بالكلاس ClientGlyph يجب أن يكون كالتالي:

كود :
Public Class ClientGlyph
   Implements IBeltGlyph

#Region " Field "

   Private isVisible As Boolean = True
   Private rect As Rectangle = New Rectangle(0, 0, 0, 0)

#End Region

#Region " Property "


   Public Property Bounds As Rectangle Implements IBeltGlyph.Bounds
       Get
           Return Me.rect
       End Get
       Set(value As Rectangle)
           Me.rect = value
       End Set
   End Property

   Public ReadOnly Property GlyphCursor As Cursor Implements IBeltGlyph.GlyphCursor
       Get
           Return Cursors.Arrow
       End Get
   End Property

   Public ReadOnly Property GlyphPosition As BeltGlyphHitPosition Implements IBeltGlyph.GlyphPosition
       Get
           Return BeltGlyphHitPosition.BeltClient
       End Get
   End Property

   Public Property Visible As Boolean Implements IBeltGlyph.Visible
       Get
           Return Me.isVisible
       End Get
       Set(value As Boolean)
           Me.isVisible = value
       End Set
   End Property

#End Region

#Region " Method "

   Public Function HitBeltGlyph(pt As Point) As Boolean Implements IBeltGlyph.HitBeltGlyph
       Return Me.isVisible AndAlso Me.Bounds.Contains(pt)
   End Function

   Public Sub PaintBeltGlyph(g As Graphics, glyphBackColor As Color, glyphBorderColor As Color, glyphGradientColor As Color) Implements IBeltGlyph.PaintBeltGlyph
       ' Do not paint anything to keep the clientglyph area clear during screen capture
   End Sub

#End Region

End Class


الأن و في الفورم GhostWindow لنكتب الكود الذي ياخذ صورة واحدة لجزء من سطح المكتب و ذلك عند الضغط علي الباتون Capture لذلك سنقوم بالتعديل قليلا علي في الكود التالي

بالتاكيد يمكنكم التعديل غلي كود حفظ الصورة لإعطاء مستخدم البرنامج امكانية حفظ الصورة في المكان الذي يريده

كود :
  Private Sub BeltCaptureButtonClick(sender As Object, e As EventArgs) Implements IBeltBehaviour.BeltCaptureButtonClick
       'Me.clientGlyph.Visible = False
       'Me.Invalidate(Me.clientGlyph.Bounds)
       System.Threading.Thread.Sleep(500)
       Dim g As Graphics = CType(Nothing, Graphics)
       Try
           Dim captured As Bitmap = New Bitmap(Me.clientGlyph.Bounds.Width, Me.clientGlyph.Bounds.Height)
           g = Graphics.FromImage(captured)
           g.CopyFromScreen(Me.clientGlyph.Bounds.X, Me.clientGlyph.Bounds.Y, 0, 0, captured.Size)
           Dim fileName As String = ".\captured .jpeg"
           captured.Save(fileName)
       Catch ex As Exception
       Finally
           g.Dispose()
       End Try
   End Sub
الرد }}}
تم الشكر بواسطة: ربيع , asemshahen5 , wael75


الردود في هذا الموضوع
Introduction To Screen Capture - بواسطة silverlight - 22-09-15, 02:21 PM
RE: Introduction To Screen Capture - بواسطة silverlight - 03-10-15, 01:23 PM
RE: Introduction To Screen Capture - بواسطة silverlight - 09-10-15, 05:22 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  SoftWare Screen Resolution silverlight 5 3,988 20-06-18, 10:14 PM
آخر رد: HASAN6.0
  Detect Display Screen DPI silverlight 2 3,260 11-06-16, 12:07 PM
آخر رد: Sajad
  Capture Mouse Position within Control Coordinates silverlight 0 2,357 11-12-15, 10:30 PM
آخر رد: silverlight
  معلومة ::: How to resize Windows form to fit Windows screen ::: RaggiTech 0 2,284 06-10-12, 09:53 PM
آخر رد: RaggiTech
  درس- كيفية عمل شاشة البدء splash Screen RaggiTech 0 4,773 05-10-12, 10:36 AM
آخر رد: RaggiTech
  مثال Screen Server RaggiTech 0 2,361 05-10-12, 01:13 AM
آخر رد: RaggiTech
  إعمل Splash Screen في دقيقة! RaggiTech 0 2,406 02-10-12, 01:01 AM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم