-
Feb 18th, 2011, 06:50 PM
#1
Thread Starter
New Member
load images
Hi everyone,
i got application which allows users to choose images from their own locations in computer and application has button add. when they click it the picture is displayed and starts to rotate as in carousel. i would like to add some images that would be preloaded. would it be possible to use this application for that?d (VB.Net was used to build initial application). Thank you.
-
Feb 18th, 2011, 06:52 PM
#2
Thread Starter
New Member
Re: load images
forgot to mention. Silverlight 4 was used for building application.
-
Feb 19th, 2011, 03:30 PM
#3
Re: load images
If you have the source it's no problem
-
Feb 22nd, 2011, 12:03 PM
#4
Thread Starter
New Member
Re: load images
Here is the code I was using
Code:
Partial Public Class Carousel
Inherits UserControl
Private Rotation As New Storyboard
Private Images As New List(Of ImageSource)
Private Items As New List(Of CarouselItem)
Private Position As Point
Private Radius As Point = New Point With {.X = 150, .Y = -40}
Private Speed As Double = 0.0125
Private Perspective As Double = 200
Private Distance As Double
Private Sub Populate(ByRef Canvas As Canvas)
Canvas.Children.Clear()
For Each image In Images
Dim index As Integer
Dim item As New CarouselItem
item.Image.Source = image
item.Angle = index * ((Math.PI * 2) / Images.Count)
Position.X = Math.Cos(item.Angle) * Radius.X
Position.Y = Math.Sin(item.Angle) * Radius.Y
Canvas.SetLeft(item, Position.X)
Canvas.SetTop(item, Position.Y)
Distance = 1 / (1 - (Position.Y / Perspective))
item.ItemScale.ScaleY = Distance
item.ItemScale.ScaleX = item.ItemScale.ScaleY
item.Opacity = item.ItemScale.ScaleX
Items.Add(item)
Canvas.Children.Add(item)
index += 1
Next
End Sub
Private Sub Rotate()
For Each item As CarouselItem In Items
item.Angle -= Speed
Position.X = Math.Cos(item.Angle) * Radius.X
Position.Y = Math.Sin(item.Angle) * Radius.Y
Canvas.SetLeft(item, Position.X)
Canvas.SetTop(item, Position.Y)
If Radius.Y >= 0 Then
Distance = 1 * (1 - (Position.Y / Perspective))
Canvas.SetZIndex(item, CInt(Position.Y))
Else
Distance = 1 / (1 - (Position.Y / Perspective))
Canvas.SetZIndex(item, CInt(Position.Y))
End If
item.ItemScale.ScaleY = Distance
item.ItemScale.ScaleX = item.ItemScale.ScaleY
item.Opacity = item.ItemScale.ScaleX
Next
Rotation.Begin()
End Sub
Public Sub Add(ByVal Source As ImageSource)
Images.Add(Source)
Populate(Display)
End Sub
Public Sub RemoveLast()
If Images.Count > 0 Then
Images.RemoveAt(Images.Count - 1)
Populate(Display)
End If
End Sub
Public Sub Clear()
Images.Clear()
Populate(Display)
End Sub
Public Sub New()
InitializeComponent()
Canvas.SetLeft(Display, Container.Width / 2 - Display.Width / 2)
Canvas.SetTop(Display, Container.Height / 2 - Display.Height / 2)
AddHandler Rotation.Completed, AddressOf Rotate
Rotation.Begin()
End Sub
Private Function ImageMedium() As Object
ImageMedium.Source = New System.Windows.Media.Imaging.BitmapImage(New Uri("/images/image1.png", UriKind.Absolute))
End Function
End Class
If somebody could help me with it I would be very appreciated. I need my images to be loaded from the images folder. Thank you
Last edited by gep13; Mar 10th, 2011 at 07:54 AM.
Reason: Added Code Tags
-
Mar 7th, 2011, 02:33 PM
#5
Re: load images
Initialize your Images List with the images you want to start with and call Populate in the constructor.
-
Mar 10th, 2011, 07:53 AM
#6
Re: load images
pikosan,
When you are posting code into the forum, can you please remember to surround it in [code][/code] or [HIGHLIGHT=vb][/highlight] tags? It makes it a lot easier to read.
I have edited your posted to do this.
Thanks
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|