Results 1 to 2 of 2

Thread: needs help to load images

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    5

    needs help to load images

    Hi everyone, could you pls be so kind and help me.
    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?

    Here is the code I was using


    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

    (Last function does not work, i don't get any errors but images are not displayed either.

    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

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    5

    Re: needs help to load images

    also added
    Imports System.Windows.Media.Imaging
    Imports System.Windows.Resources

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width