expandable GridView/Tile View (like charmap.exe) needed

Bloop

Newcomer
Joined
May 17, 2006
Messages
2
Hi Community

I am working on a communication logger for Serial comm. I have got 2 Channels (COM Ports) which are recieving data. The data structure is a 6 byte long dataset containing a Status-byte, a Character-byte and 4 Timestamp-bytes. I already created a storage class (inheriting CollectionBase and implementing the IList and IColletion interfaces) to access the single DataSets like an Array. Now I need to display this Data in a Windows Form.

I need a possibility to display Data from both channels in a Line e.g. chan A is uppercase and chan B is lowercase. When the line is full, go to the next line untill the screen is full.

I thought about a DataGrid but found no way to display 2 Channels in it without using two grid lines. Also I found it hard to calculate the needed space for 1 DataSet when resizing the Form.

What I also need is all other Information about the DataSet when I click on it.

Think about the Windows Charmap (System32\charmap.exe) just resizable and with upper or lowercased chars or a horizontal seperator in it.

How can I do such things?

Many Thanks

Blooop
 
You could simply write the control yourself, by dynamically creating the controls onto a control that you've written yourself. I've done something similar (ie adding controls dynamically) on a control that I've written.

I'll post some of the code when I get to work.


Paul.
 
Well I thought I have to Build one myself.

Ok, I'm starting to develop a control that:

-Can Display my DataBlocks ( one Datablock: 2 Rows with Chars, aprox. 15x15 pixels, and is also a Control)
-Can respond to a SizeChange by reordering the DataBlocks
-Can Scrool
-Is fast enough for "RealTime" Display

Basicly I'm going to rebuild "FlowLayoutPanel" cause it's much to slow.

If requested I will post my progress here.
Any help is welcome.
 
My appologies, Bloop - I forgot to post some code! This is what I'm using presently to draw a control that is something similar to a tree control. It's not fast, but I'm busy trying to debug the graphical version which should be much quicker! Don't know if it'll be any use to you, but...
Visual Basic:
    'Draws the tree from scratch, we'll use recursion to draw this tree - it'll be a lot easier than stacking...
    Private Sub DrawTree()
        'Quick check to see everything's in place...
        If _OccurenceTypes Is Nothing Or groupEvent Is Nothing Or groupAction Is Nothing Or groupCausality Is Nothing Then
            Throw New InvalidOperationException("Occurence Codes not set.")
        End If
        'Dimensions...
        Dim currOcc As Occurence
        'Clear the controls from the controls collection...
        Controls.Clear()
        SuspendLayout()
        nodeLine = 0
        stackTop = 0
        'Loop through the StartOfDay within the base of the tree and call a build routine to build the tree...
        DrawNode(_StartOfDay)
        'stackLevels(0) = currOcc
        'DrawNode(stackLevels(0))
        'Next currOcc
        ResumeLayout()
        'Debugging...
        If _Debug Then MessageBox.Show("Controls.Count: " & Controls.Count.ToString)
    End Sub
    'Draws the start of the node...
    Private Sub DrawNode(ByVal pOccurence As Occurence)
        'Check to see if the node has been deleted first (no need to check anyfurther up the tree)...
        If Not pOccurence.Deleted Then
            'Build the strings...
            Dim startString As String = "Start: " & pOccurence.Started.ToString("HH:mm") & " - " & pOccurence.Title
            Dim descString As String = pOccurence.Description
            Dim endString As String = "Ended: " & pOccurence.Ended.ToString("HH:mm")
            Dim occClass As Integer = CType(pOccurence.Class.OptionValue, ehLabelType)
            'Set-up the values for icons that will be drawn on the control...
            Dim occHiLite As Integer = Math.Abs(CType(_Value Is pOccurence, Integer)) * hiliteStart
            Dim occIsOpen As Integer = CType(pOccurence.Ended = Util.defaultDate, Integer)
            Dim iconTop As Integer = occClass * iconGap + bracket.Top + occHiLite - 1
            Dim iconBot As Integer = occClass * iconGap + bracket.Bottom + occHiLite + occIsOpen - 1
            Dim iconLeft As Integer = stackTop * tileX
            Dim textLeft As Integer = (stackTop + 2) * tileX
            Dim tempGraphic As PictureBox
            Dim tempLabel As Label
            'Determine how much stack space we have, and whether we need to increase it...
            stackLevels(stackTop) = pOccurence
            If stackTop > stackLevels.GetUpperBound(0) Then
                ReDim Preserve stackLevels(stackLevels.GetUpperBound(0) * 2)
            End If
            'Draw the start of the node...
            DrawLevels(stackTop - 1)
            AddHandler NewGraphic(iconTop, iconLeft, nodeLine * tileY, pOccurence).Click, AddressOf SelectNode
            AddHandler NewLabel(startString, textLeft, nodeLine * tileY, pOccurence).Click, AddressOf SelectNode
            AddHandler NewGraphic(iconStart, iconLeft + tileX, nodeLine * tileY, pOccurence).Click, AddressOf SelectNode
            nodeLine += 1
            'Draw the next detail into the tree...
            If CType(pOccurence.Class.OptionValue, Integer) <> ehClassType.typeCausality Then
                'Draw the bracket levels and description text...
                DrawLevels(stackTop)
                AddHandler NewLabel(pOccurence.Description, textLeft, nodeLine * tileY, pOccurence).Click, AddressOf SelectNode
                nodeLine += 1
                'Now draw any internal StartOfDay...
                If pOccurence.Count > 0 Then
                    Dim currOcc As Occurence
                    stackTop += 1
                    For Each currOcc In pOccurence
                        DrawNode(currOcc)
                    Next
                    stackTop -= 1
                End If
                'Close the node...
                DrawLevels(stackTop - 1)
                tempGraphic = NewGraphic(iconEnd, (stackTop + 1) * tileX, nodeLine * tileY, pOccurence)
                If pOccurence.Ended = Util.defaultDate Then
                    endString = "[ Open - Click stop to end ]"
                    AddHandler NewLabel(endString, textLeft, nodeLine * tileY, pOccurence).Click, AddressOf CloseClass
                Else
                    AddHandler NewLabel(endString, textLeft, nodeLine * tileY, pOccurence).Click, AddressOf SelectNode
                End If
                AddHandler NewGraphic(iconBot, stackTop * tileX, nodeLine * tileY, pOccurence).Click, AddressOf SelectNode
                AddHandler tempGraphic.Click, AddressOf SelectNode
                nodeLine += 1
                If _Debug Then Debug.WriteLine("Controls.Count: " & Controls.Count)
            End If
        End If
    End Sub
    'Draws the stack levels...
    Private Sub DrawLevels(ByVal pBottom As Integer)
        'Dimensions...
        Dim loopCounter As Integer
        Dim occHiLite As Integer
        Dim iconMid As Integer
        'Loop through the stack and add each level bar to the screen...
        For loopCounter = 0 To pBottom
            occHiLite = Math.Abs(CType(_Value Is stackLevels(loopCounter), Integer)) * hiliteStart
            iconMid = CType(stackLevels(loopCounter).Class.OptionValue, Integer) * iconGap + bracket.Middle + occHiLite - 1
            AddHandler NewGraphic(iconMid, loopCounter * tileX, nodeLine * tileY, stackLevels(loopCounter)).Click, AddressOf SelectNode
        Next
    End Sub
    'Adds a new graphic to the form at the specified location...
    Private Function NewGraphic(ByVal pType As Integer, ByVal pLocX As Integer, ByVal pLocY As Integer, ByVal pTarget As Occurence) As PictureBox
        'Define and build the object...
        Dim addObject As New PictureBox
        Dim iType As Integer = pType
        If pType >= hiliteStart Then iType -= hiliteStart
        addObject.Name = "ehPic_" & iType & "_" & Me.Controls.Count()
        addObject.Image = iconList.Images(pType)
        addObject.Top = pLocY
        addObject.Left = pLocX
        addObject.Width = tileX
        addObject.Height = tileY
        addObject.Tag = pTarget
        addObject.Cursor = Cursors.Hand
        'Add it to the controls collection and increment the object counter...
        If _Debug Then
            Debug.WriteLine(addObject.Name & ": " & addObject.Left & ", " & addObject.Top)
        End If
        Me.Controls.Add(addObject)
        Return addObject
    End Function
    'Adds a new graphic to the form at the specified location...
    Private Function NewLabel(ByVal pText As String, ByVal pLocX As Integer, ByVal pLocY As Integer, ByVal pTarget As Occurence) As Label
        'Define and build the object...
        Dim addObject As New Label
        addObject.Name = "ehLab" & Me.Controls.Count()
        addObject.Left = pLocX
        addObject.Top = pLocY
        addObject.AutoSize = True
        addObject.Tag = pTarget
        addObject.Text = pText
        addObject.Cursor = Cursors.Hand
        'Check to see if the current node is selected...
        If pTarget Is _Value Then
            addObject.BackColor = hiliteColor
        Else
            addObject.BackColor = Color.Transparent
        End If
        'Check to see if the current node has been changed...
        If pTarget.IsDirty Then
            addObject.Font = New Font(addObject.Font, FontStyle.Bold)
        End If
        'Set the font colour according to the class properties...
        Select Case pTarget.Class.Name
            Case groupEvent.Name
                addObject.ForeColor = eventColor
            Case groupAction.Name
                addObject.ForeColor = actionColor
            Case groupCausality.Name
                addObject.ForeColor = causeColor
        End Select
        'Add it to the controls collection and increment the object counter...
        If _Debug Then Debug.WriteLine(addObject.Name & ": " & addObject.Left & ", " & addObject.Top)
        Me.Controls.Add(addObject)
        Return addObject
    End Function
Regards,
Paul.
 
Back
Top