Click here to Skip to main content
15,886,799 members
Articles / Web Development

Silverlight web comic

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
7 Feb 2012CPOL3 min read 18.3K   305   5  
Its a silverlight page to create a simple comic with photos and text-ballons
  • comic.zip
    • comic
      • comic.sln
      • comic.suo
      • comic.Web
      • comic
        • App.xaml
        • App.xaml.vb
        • Bin
          • Debug
            • AppManifest.xaml
            • ar
              • System.ComponentModel.DataAnnotations.resources.dll
            • bg
              • System.ComponentModel.DataAnnotations.resources.dll
            • ca
              • System.ComponentModel.DataAnnotations.resources.dll
            • comic.dll
            • comic.pdb
            • comic.xap
            • comic.xml
            • comicTestPage.html
            • cs
              • System.ComponentModel.DataAnnotations.resources.dll
            • da
              • System.ComponentModel.DataAnnotations.resources.dll
            • de
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
            • el
              • System.ComponentModel.DataAnnotations.resources.dll
            • es
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
            • et
              • System.ComponentModel.DataAnnotations.resources.dll
            • eu
              • System.ComponentModel.DataAnnotations.resources.dll
            • fi
              • System.ComponentModel.DataAnnotations.resources.dll
            • fr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
            • he
              • System.ComponentModel.DataAnnotations.resources.dll
            • hr
              • System.ComponentModel.DataAnnotations.resources.dll
            • hu
              • System.ComponentModel.DataAnnotations.resources.dll
            • id
              • System.ComponentModel.DataAnnotations.resources.dll
            • Images
              • nube_derecha.png
              • nube_derecha1.png
              • nube_izquierda.png
              • nube_izquierda1.png
              • nuebe1.jpg
              • nuebe1.jpg.png
              • ovalo_derecha1.png
              • ovalo_izquierda1.png
              • rectangulo_derecha1.png
              • rectangulo_izquierdo1.png
              • rectangulo1.png
            • it
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
            • ja
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
            • ko
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
            • lt
              • System.ComponentModel.DataAnnotations.resources.dll
            • lv
              • System.ComponentModel.DataAnnotations.resources.dll
            • ms
              • System.ComponentModel.DataAnnotations.resources.dll
            • nl
              • System.ComponentModel.DataAnnotations.resources.dll
            • no
              • System.ComponentModel.DataAnnotations.resources.dll
            • pl
              • System.ComponentModel.DataAnnotations.resources.dll
            • pt
              • System.ComponentModel.DataAnnotations.resources.dll
            • pt-BR
              • System.ComponentModel.DataAnnotations.resources.dll
            • ro
              • System.ComponentModel.DataAnnotations.resources.dll
            • ru
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
            • sk
              • System.ComponentModel.DataAnnotations.resources.dll
            • sl
              • System.ComponentModel.DataAnnotations.resources.dll
            • sr-Cyrl-CS
              • System.ComponentModel.DataAnnotations.resources.dll
            • sr-Latn-CS
              • System.ComponentModel.DataAnnotations.resources.dll
            • sv
              • System.ComponentModel.DataAnnotations.resources.dll
            • System.ComponentModel.DataAnnotations.dll
            • System.ComponentModel.DataAnnotations.xml
            • System.ServiceModel.DomainServices.Client.dll
            • System.ServiceModel.DomainServices.Client.Web.dll
            • System.ServiceModel.DomainServices.Client.Web.xml
            • System.ServiceModel.DomainServices.Client.xml
            • System.ServiceModel.Web.Extensions.dll
            • System.ServiceModel.Web.Extensions.xml
            • th
              • System.ComponentModel.DataAnnotations.resources.dll
            • tr
              • System.ComponentModel.DataAnnotations.resources.dll
            • uk
              • System.ComponentModel.DataAnnotations.resources.dll
            • vi
              • System.ComponentModel.DataAnnotations.resources.dll
            • zh-Hans
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
            • zh-Hant
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.ServiceModel.Web.Extensions.resources.dll
        • clases
        • comic.sln
        • comic.suo
        • comic.vbproj
        • comic.vbproj.user
        • comic.Web
        • comic
          • App.xaml
          • App.xaml.vb
          • Bin
            • Debug
              • AppManifest.xaml
              • ar
                • System.ComponentModel.DataAnnotations.resources.dll
              • bg
                • System.ComponentModel.DataAnnotations.resources.dll
              • ca
                • System.ComponentModel.DataAnnotations.resources.dll
              • comic.dll
              • comic.pdb
              • comic.xap
              • comic.xml
              • comicTestPage.html
              • cs
                • System.ComponentModel.DataAnnotations.resources.dll
              • da
                • System.ComponentModel.DataAnnotations.resources.dll
              • de
                • System.ComponentModel.DataAnnotations.resources.dll
                • System.ServiceModel.DomainServices.Client.resources.dll
                • System.ServiceModel.DomainServices.Client.Web.resources.dll
                • System.ServiceModel.Web.Extensions.resources.dll
              • el
                • System.ComponentModel.DataAnnotations.resources.dll
              • es
                • System.ComponentModel.DataAnnotations.resources.dll
                • System.ServiceModel.DomainServices.Client.resources.dll
                • System.ServiceModel.DomainServices.Client.Web.resources.dll
                • System.ServiceModel.Web.Extensions.resources.dll
              • et
                • System.ComponentModel.DataAnnotations.resources.dll
              • eu
                • System.ComponentModel.DataAnnotations.resources.dll
              • fi
                • System.ComponentModel.DataAnnotations.resources.dll
              • fr
                • System.ComponentModel.DataAnnotations.resources.dll
                • System.ServiceModel.DomainServices.Client.resources.dll
                • System.ServiceModel.DomainServices.Client.Web.resources.dll
                • System.ServiceModel.Web.Extensions.resources.dll
              • he
                • System.ComponentModel.DataAnnotations.resources.dll
              • hr
                • System.ComponentModel.DataAnnotations.resources.dll
              • hu
                • System.ComponentModel.DataAnnotations.resources.dll
              • id
                • System.ComponentModel.DataAnnotations.resources.dll
              • Images
                • box.png
                • left_box.png
                • left_cloud.png
                • left_oval.png
                • nuebe1.jpg
                • rght_oval.png
                • right_box.png
                • right_cloud.png
              • it
                • System.ComponentModel.DataAnnotations.resources.dll
                • System.ServiceModel.DomainServices.Client.resources.dll
                • System.ServiceModel.DomainServices.Client.Web.resources.dll
                • System.ServiceModel.Web.Extensions.resources.dll
              • ja
                • System.ComponentModel.DataAnnotations.resources.dll
                • System.ServiceModel.DomainServices.Client.resources.dll
                • System.ServiceModel.DomainServices.Client.Web.resources.dll
                • System.ServiceModel.Web.Extensions.resources.dll
              • ko
                • System.ComponentModel.DataAnnotations.resources.dll
                • System.ServiceModel.DomainServices.Client.resources.dll
                • System.ServiceModel.DomainServices.Client.Web.resources.dll
                • System.ServiceModel.Web.Extensions.resources.dll
              • lt
                • System.ComponentModel.DataAnnotations.resources.dll
              • lv
                • System.ComponentModel.DataAnnotations.resources.dll
              • ms
                • System.ComponentModel.DataAnnotations.resources.dll
              • nl
                • System.ComponentModel.DataAnnotations.resources.dll
              • no
                • System.ComponentModel.DataAnnotations.resources.dll
              • pl
                • System.ComponentModel.DataAnnotations.resources.dll
              • pt
                • System.ComponentModel.DataAnnotations.resources.dll
              • pt-BR
                • System.ComponentModel.DataAnnotations.resources.dll
              • ro
                • System.ComponentModel.DataAnnotations.resources.dll
              • ru
                • System.ComponentModel.DataAnnotations.resources.dll
                • System.ServiceModel.DomainServices.Client.resources.dll
                • System.ServiceModel.DomainServices.Client.Web.resources.dll
                • System.ServiceModel.Web.Extensions.resources.dll
              • sk
                • System.ComponentModel.DataAnnotations.resources.dll
              • sl
                • System.ComponentModel.DataAnnotations.resources.dll
              • sr-Cyrl-CS
                • System.ComponentModel.DataAnnotations.resources.dll
              • sr-Latn-CS
                • System.ComponentModel.DataAnnotations.resources.dll
              • sv
                • System.ComponentModel.DataAnnotations.resources.dll
              • System.ComponentModel.DataAnnotations.dll
              • System.ComponentModel.DataAnnotations.xml
              • System.ServiceModel.DomainServices.Client.dll
              • System.ServiceModel.DomainServices.Client.Web.dll
              • System.ServiceModel.DomainServices.Client.Web.xml
              • System.ServiceModel.DomainServices.Client.xml
              • System.ServiceModel.Web.Extensions.dll
              • System.ServiceModel.Web.Extensions.xml
              • th
                • System.ComponentModel.DataAnnotations.resources.dll
              • tr
                • System.ComponentModel.DataAnnotations.resources.dll
              • uk
                • System.ComponentModel.DataAnnotations.resources.dll
              • vi
                • System.ComponentModel.DataAnnotations.resources.dll
              • zh-Hans
                • System.ComponentModel.DataAnnotations.resources.dll
                • System.ServiceModel.DomainServices.Client.resources.dll
                • System.ServiceModel.DomainServices.Client.Web.resources.dll
                • System.ServiceModel.Web.Extensions.resources.dll
              • zh-Hant
                • System.ComponentModel.DataAnnotations.resources.dll
                • System.ServiceModel.DomainServices.Client.resources.dll
                • System.ServiceModel.DomainServices.Client.Web.resources.dll
                • System.ServiceModel.Web.Extensions.resources.dll
          • clases
          • comic.vbproj
          • comic.vbproj.user
          • Generated_Code
          • Images
            • box.png
            • left_box.png
            • left_cloud.png
            • left_oval.png
            • nuebe1.jpg
            • rght_oval.png
            • right_box.png
            • right_cloud.png
            • Thumbs.db
          • MainPage.xaml
          • MainPage.xaml.vb
          • My Project
          • obj
        • Generated_Code
        • Images
          • nube_derecha.png
          • nube_derecha1.png
          • nube_izquierda.png
          • nube_izquierda1.png
          • nuebe1.jpg
          • nuebe1.jpg.png
          • ovalo_derecha1.png
          • ovalo_izquierda1.png
          • rectangulo_derecha1.png
          • rectangulo_izquierdo1.png
          • rectangulo1.png
          • Thumbs.db
        • MainPage.xaml
        • MainPage.xaml.vb
        • My Project
        • obj
Imports System.IO
Imports System.Windows.Printing
Imports System.Windows.Media.Imaging

Public Class cFigure
    Public tb As New TextBlock
    Public type As MainPage.eFigure
    Public iNumber As Integer
    Public iChildren As Integer
    Public bAux As Boolean
    Public iPosition As Point
    Public newImage As New Image()
    ''' <summary>
    ''' Set the ballon and the text and the mouse events
    ''' </summary>
    ''' <param name="sText">Text for the ballon</param>
    ''' <param name="pPosition">Coordinates (x,y) for the location of the ballon</param>
    ''' <param name="typeFigure">The Type of figure</param>
    ''' <param name="iActualBallon">The number of the ballon in the list of ballons</param>
    ''' <remarks></remarks>
    Public Sub SetImage(ByVal sText As String, ByVal pPosition As Point, ByVal typeFigure As MainPage.eFigure, ByVal iActualBallon As Integer)
        Dim sFigure As String = ""
        'Set the text to the combobox
        tb.Text = "  " + sText
        'Save the color of the text
        tb.Foreground = New SolidColorBrush(Colors.Black)
        'Set options to center the text and automatic wordwrap
        tb.TextAlignment = System.Windows.TextAlignment.Center
        tb.TextWrapping = TextWrapping.Wrap
        type = typeFigure
        iNumber = iActualBallon
        'Set the image of the ballon
        Select Case type
            Case MainPage.eFigure.leftCloud
                sFigure = "Images/left_cloud.png"
            Case MainPage.eFigure.rightCloud
                sFigure = "Images/right_cloud.png"
            Case MainPage.eFigure.rightOval
                sFigure = "Images/rght_oval.png"
            Case MainPage.eFigure.leftOval
                sFigure = "Images/left_oval.png"
            Case MainPage.eFigure.rightBox
                sFigure = "Images/right_box.png"
            Case MainPage.eFigure.leftBox
                sFigure = "Images/left_box.png"
            Case MainPage.eFigure.Box
                sFigure = "Images/box.png"
        End Select
        'The uri of the image of the ballon
        Dim uriImage As New Uri(sFigure, UriKind.Relative)
        'Get the stream of the image of the ballon
        Dim oImageStream As Stream = Application.GetResourceStream(uriImage).Stream
        'Create a new Image for the ballon
        Dim oImage As New BitmapImage()
        'Set the image of the ballon
        oImage.SetSource(oImageStream)
        'Set the size proportional to the text only for the ballons.    
        newImage.Width = tb.ActualWidth + 50
        newImage.Height = tb.ActualHeight
        'If the figure is different of the box add a space for center the text
        If type <> MainPage.eFigure.Box Then
            newImage.Height += 30
            tb.SetValue(Canvas.TopProperty, pPosition.Y + 8)
        Else
            newImage.Height += 10
            tb.SetValue(Canvas.TopProperty, pPosition.Y + 5)
        End If
        tb.SetValue(Canvas.LeftProperty, pPosition.X + 18)
        newImage.SetValue(Canvas.LeftProperty, pPosition.X)
        newImage.SetValue(Canvas.TopProperty, pPosition.Y)
        iPosition.Y = tb.GetValue(Canvas.TopProperty)
        iPosition.X = tb.GetValue(Canvas.TopProperty)
        'Set the ballon with text
        newImage.Source = oImage
        newImage.Stretch = Stretch.Fill
        'Set the events for the ballon
        AddHandler newImage.MouseLeftButtonDown, AddressOf Image_Mouse_Button_Down
        AddHandler newImage.MouseMove, AddressOf Image_Mouse_Button_Move
        AddHandler newImage.MouseLeftButtonUp, AddressOf Image_Mouse_Button_Up
    End Sub
    ''' <summary>
    ''' Set the position of the ballon
    ''' </summary>
    ''' <param name="pPosition">Coordinates (x,y) for the location of the ballon</param>
    ''' <remarks></remarks>
    Public Sub SetPosition(ByVal pPosition As Point)
        newImage.SetValue(Canvas.TopProperty, pPosition.Y)
        newImage.SetValue(Canvas.LeftProperty, pPosition.X)
        If type <> MainPage.eFigure.Box Then
            tb.SetValue(Canvas.TopProperty, pPosition.Y + 8)
        Else
            tb.SetValue(Canvas.TopProperty, pPosition.Y + 5)
        End If
        tb.SetValue(Canvas.LeftProperty, pPosition.X + 18)
        iPosition.Y = tb.GetValue(Canvas.TopProperty)
        iPosition.X = tb.GetValue(Canvas.LeftProperty)
    End Sub
    Private Sub Image_Mouse_Button_Down(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
        bAux = True
        MainPage.iActualCloud = iNumber
    End Sub
    Private Sub Image_Mouse_Button_Move(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseEventArgs)

    End Sub
    Private Sub Image_Mouse_Button_Up(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
        bAux = False
    End Sub
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 Code Project Open License (CPOL)


Written By
Software Developer armheSistemas
Mexico Mexico
I'm a software developer. I like to develop web pages and desktop systems. I'm learning unity, xamarin, swift, android, security, UX

Comments and Discussions