Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collection is removed from memory after a while
Message
De
15/11/2013 15:42:27
 
 
À
15/11/2013 14:05:50
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01588067
Message ID:
01588109
Vues:
32
Here is what I have so far.

This is the class definition:
' ImageData class
Public Class ImageData
    Private cExtension As String = ""
    Private nHeight As Integer = 0
    Private nWidth As Integer = 0

    Friend Property Extension() As String
        Get
            Return cExtension
        End Get
        Private Set(tcValue As String)
            cExtension = tcValue
        End Set
    End Property

    Friend Property Height() As Integer
        Get
            Return nHeight
        End Get
        Private Set(tnValue As Integer)
            nHeight = tnValue
        End Set
    End Property

    Friend Property Width() As Integer
        Get
            Return nWidth
        End Get
        Private Set(tnValue As Integer)
            nWidth = tnValue
        End Set
    End Property

    Friend Sub New(tnWidth As Integer, tnHeight As Integer, tcExtension As String)
        Width = tnWidth
        Height = tnHeight
        Extension = tcExtension
    End Sub

End Class
This is the initialization of the images in memory:
        Dim loImageData As New Dictionary(Of String, ImageData)

        ' If this is the Web site
        If oApp.nApplicationMode = 3 Then

            ' If we have some images in memory
            If oApp.oAdmin.oRow("Image").length > 0 Then

                ' Load the application into the string builder
                loStringBuilderFile.LoadString(oApp.oAdmin.oRow("Image"))

                ' For each image
                For lnCounter = 1 To loStringBuilderFile.nLine

                    ' Get the line
                    If Not loStringBuilderFile.MLine(lnCounter) Then
                        Return False
                    End If

                    lcImage = loStringBuilderFile.cLine

                    ' If the file exists
                    If oApp.FileExist(oApp.cGraphicFat + lcImage) Then

                        ' Get the image details making it OK to reender the HTML without flickering
                        loImage = New System.Drawing.Bitmap(oApp.cGraphicFat + lcImage)
                        lnWidth = loImage.Width
                        lnHeight = loImage.Height

                        ' Initializaiton
                        lcName = Trim(lcImage)
                        lnLocation = oApp.At(".", lcName)
                        lcExtension = ""

                        ' If we have found it
                        If lnLocation > 0 Then

                            ' If this is not the last character
                            If lnLocation < lcName.Length Then
                                lcExtension = Mid(lcName, lnLocation + 1)
                            End If

                        End If

                        loImageData.Add(lcImage, New ImageData(lnWidth, lnHeight, lcExtension))
                    Else
                        AddError(oApp.cGraphicFat + lcImage + " does not exist.")
                    End If

                Next

            End If

        End If
The tricky part is to access later on in the application, whereas needed, the method to return some info from it. So far, I have something like this:
    ' Return True or False if an image is loaded in memory
    ' expC1 Name
    Public Function IsImageInMemory(ByVal tcName As String) As Boolean
        Dim lcName As String = ""
        Dim llFound As Boolean = False
        Dim loImageData As New Dictionary(Of String, ImageData)
        Dim loImageData2 As ImageData = Nothing

        ' Initialization
        lcName = UCase(Trim(tcName))

        ' If the image is found in the dictionary
        If loImageData.TryGetValue(lcName, loImageData2) Then
            llFound = True

            ' Initialization
            nWidth = loImageData2.Width
            nHeight = loImageData2.Height

        End If

        Return llFound
    End Function
But, this of course wouldn't work. The goal is to instantiate a reference to the ImageData class, which is already initialized, and query it to get the data. The remaining changes are in here and they are probably small to do.

Anyone has an idea on what it is?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform