Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

An Introduction to the Silverlight samples in the All-In-One Framework

, 12 Dec 2009
This article introduces several Silverlight samples in the All-In-One Framework.
SilverlightIntroduction_src.zip
CSSL3LocalMessage
Properties
CSSL3MediaElement
CSSL3MediaElement
Properties
CSSL3MediaElement.Web
App_Data
ClientBin
CSSL3MediaElement.xap
Properties
ReadMe.mht
CSSL3PixelShader
cyclewatery.ps
Humpback Whale.jpg
Properties
CSSL3WriteableBitmap
Heart Empty.png
Properties
VBSL3Animation
My Project
VBSL3DeepZoom
VBSL3DeepZoom
images
home_hover.png
home_pressed.png
home_rest.png
My Project
Service References
DeepZoomServiceReference
configuration.svcinfo
configuration91.svcinfo
GenerateDeepZoomService.disco
GenerateDeepZoomService.wsdl
Reference.svcmap
ServiceReferences.ClientConfig
VBSL3DeepZoom.Web
App_Code
App_Data
Bin
DeepZoomTools.DLL
DeepZoomTools.DLL.refresh
ClientBin
GeneratedImages
GenerateDeepZoomService.svc
SourceImages
atom.png
background.jpg
cell.png
dna.png
Molecular.png
neutron.png
seed.png
wrap in bamboo.png
VBSL3HTMLBridge
VBSL3HTMLBridge
My Project
VBSL3HTMLBridge.Web
App_Data
ClientBin
VBSL3HTMLBridge.xap
My Project
Application.myapp
MyExtensions
Settings.settings
VBSL3Input
My Project
VBSL3LocalMessage
My Project
VBSL3MediaElement
ReadMe.mht
VBSL3MediaElement
My Project
VBSL3MediaElement.Web
App_Data
ClientBin
VBSL3MediaElement.xap
My Project
Application.myapp
MyExtensions
Settings.settings
VBSL3PixelShader
cyclewatery.ps
Humpback Whale.jpg
My Project
CSSL3Animation
Properties
CSSL3DeepZoom
CSSL3DeepZoom
images
home_hover.png
home_pressed.png
home_rest.png
Properties
Service References
DeepZoomServiceReference
configuration.svcinfo
configuration91.svcinfo
GenerateDeepZoomService.disco
GenerateDeepZoomService.wsdl
GenerateDeepZoomService1.wsdl
Reference.svcmap
ServiceReferences.ClientConfig
CSSL3DeepZoom.Web
App_Code
Bin
DeepZoomTools.DLL
DeepZoomTools.DLL.refresh
ClientBin
GeneratedImages
GenerateDeepZoomService.svc
SourceImages
atom.png
background.jpg
cell.png
dna.png
Molecular.png
neutron.png
seed.png
wrap in bamboo.png
ReadMe.mht
CSSL3HTMLBridge
CSSL3HTMLBridge
Properties
CSSL3HTMLBridge.Web
App_Data
ClientBin
CSSL3HTMLBridge.xap
Properties
CSSL3Input
Properties
Imports System.Windows.Browser

Public Class MouseWheelHelper
	' Events
	Public Event Moved As EventHandler(Of MouseWheelEventArgs)

	' Methods
	Public Sub New(ByVal element As FrameworkElement)
		If (MouseWheelHelper.workerInstance Is Nothing) Then
			MouseWheelHelper.workerInstance = New Worker
		End If
		AddHandler MouseWheelHelper.workerInstance.Moved, New EventHandler(Of MouseWheelEventArgs)(AddressOf Me.HandleMouseWheel)
		AddHandler element.MouseEnter, New MouseEventHandler(AddressOf Me.HandleMouseEnter)
		AddHandler element.MouseLeave, New MouseEventHandler(AddressOf Me.HandleMouseLeave)
		AddHandler element.MouseMove, New MouseEventHandler(AddressOf Me.HandleMouseMove)
	End Sub

	Private Sub HandleMouseEnter(ByVal sender As Object, ByVal e As EventArgs)
		Me.isMouseOver = True
	End Sub

	Private Sub HandleMouseLeave(ByVal sender As Object, ByVal e As EventArgs)
		Me.isMouseOver = False
	End Sub

	Private Sub HandleMouseMove(ByVal sender As Object, ByVal e As EventArgs)
		Me.isMouseOver = True
	End Sub

	Private Sub HandleMouseWheel(ByVal sender As Object, ByVal args As MouseWheelEventArgs)
		If Me.isMouseOver Then
			RaiseEvent Moved(Me, args)
		End If
	End Sub


	' Fields
	Private isMouseOver As Boolean = False
	Private Shared workerInstance As Worker

	' Nested Types
	Private Class Worker
		' Events
		Public Event Moved As EventHandler(Of MouseWheelEventArgs)

		' Methods
		Public Sub New()
			If HtmlPage.IsEnabled Then
				HtmlPage.Window.AttachEvent("DOMMouseScroll", New EventHandler(Of HtmlEventArgs)(AddressOf Me.HandleMouseWheel))
				HtmlPage.Window.AttachEvent("onmousewheel", New EventHandler(Of HtmlEventArgs)(AddressOf Me.HandleMouseWheel))
				HtmlPage.Document.AttachEvent("onmousewheel", New EventHandler(Of HtmlEventArgs)(AddressOf Me.HandleMouseWheel))
			End If
		End Sub

		Private Sub HandleMouseWheel(ByVal sender As Object, ByVal args As HtmlEventArgs)
			Dim delta As Double = 0
			Dim eventObject As ScriptObject = args.EventObject
			If (Not eventObject.GetProperty("wheelDelta") Is Nothing) Then
				delta = (CDbl(eventObject.GetProperty("wheelDelta")) / 120)
				If (Not HtmlPage.Window.GetProperty("opera") Is Nothing) Then
					delta = -delta
				End If
			ElseIf (Not eventObject.GetProperty("detail") Is Nothing) Then
				delta = (-CDbl(eventObject.GetProperty("detail")) / 3)
				If (HtmlPage.BrowserInformation.UserAgent.IndexOf("Macintosh") <> -1) Then
					delta = (delta * 3)
				End If
			End If
			If (delta <> 0) Then
				Dim e As New MouseWheelEventArgs(delta)
				RaiseEvent Moved(Me, e)
				If e.Handled Then
					args.PreventDefault()
				End If
			End If
		End Sub

	End Class
End Class

Public Class MouseWheelEventArgs
	Inherits EventArgs
	' Methods
	Public Sub New(ByVal delta As Double)
		Me.deltaField = delta
	End Sub


	' Properties
	Public ReadOnly Property Delta() As Double
		Get
			Return Me.deltaField
		End Get
	End Property

	Public Property Handled() As Boolean
		Get
			Return Me.handledField
		End Get
		Set(ByVal value As Boolean)
			Me.handledField = value
		End Set
	End Property


	' Fields
	Private deltaField As Double
	Private handledField As Boolean = False
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Microsoft All-In-One Code Framework delineates the framework and skeleton of Microsoft development techniques through typical sample codes in three popular programming languages (Visual C#, VB.NET, Visual C++). Each sample is elaborately selected, composed, and documented to demonstrate one frequently-asked, tested or used coding scenario based on our support experience in MSDN newsgroups and forums. If you are a software developer, you can fill the skeleton with blood, muscle and soul. If you are a software tester or a support engineer like us, you may extend the sample codes a little to fit your specific test scenario or refer your customer to this project if the customer's question coincides with what we collected.
http://cfx.codeplex.com/

| Advertise | Privacy | Mobile
Web03 | 2.8.140921.1 | Last Updated 12 Dec 2009
Article Copyright 2009 by All-In-One Code Framework
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid