Respondido Outlook To-Do bar, How-to

  • sexta-feira, 13 de abril de 2012 19:24
     
     

    I have looked around the internets  for the last couple of days now for anything I can get on this, but to no avail.  I am trying to create an application that has an interface similar to the To-Do bar in Outlook, specifically the upcoming events that show below the calendar.

    I've tried a couple of different approaches but cannot achieve the same results.  Does anyone know of a way to duplicate this?

    I am not using my program as an add in to outlook, I just want a similar look for my program.


    • Editado ThanklessPentium sexta-feira, 13 de abril de 2012 19:25 Forgot to add something.
    •  

Todas as Respostas

  • sexta-feira, 13 de abril de 2012 20:23
    Moderador
     
     

    It seems like this could be reproduced pretty easily with a MonthCalendar and Buttons... what part is giving you problems?  If Button controls don't give you the right "look" you could always create a simple custom control instead.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • sexta-feira, 13 de abril de 2012 21:21
     
      Contém Código

    I figured buttons would be the way to go and tried to use buttons, but I just can't seem to wrap my mind around formatting the text; i.e. making some text bold while other text is regular, inserting new lines into the buttons text, etc.

    I'm using the GData Calendar API to interface with my application, and I have code which programmatically creates the buttons and places them into a Flow Layout Panel.  I'm just not sure how to make it look like the Outlook equivalent.  The code block that does this is below:

    For Each gFeedEntry As Google.GData.Calendar.EventEntry In gCalFeed.Entries
                Dim item As New Button
                With item
                    .Text = gFeedEntry.Title.Text
                    .Width = flpAppointments.Width - 2
                    .Height = 50
                    .TextAlign = ContentAlignment.TopLeft
                End With
                flpAppointments.Controls.Add(item)
            Next

  • domingo, 15 de abril de 2012 16:16
    Moderador
     
     Respondido Contém Código

    You could customize a button to make your own control with the custom text formatting.

    Something like the following might work for you (though you may want to further customize the text rendering):

    Public Class CalendarEventButton
        Inherits Button
    
        Private _Caption As String
        Public Property Caption As String
            Get
                Return _Caption
            End Get
            Set(value As String)
                _Caption = value
                Invalidate()
            End Set
        End Property
    
        Private _Description As String
        Public Property Description As String
            Get
                Return _Description
            End Get
            Set(value As String)
                _Description = value
                Invalidate()
            End Set
        End Property
    
        Private _BoldFont As Font
        Public Overrides Property Font As System.Drawing.Font
            Get
                Return MyBase.Font
            End Get
            Set(value As System.Drawing.Font)
                _BoldFont = New Font(value, FontStyle.Bold)
                MyBase.Font = value
            End Set
        End Property
    
        Private _TextBrush As Brush
        Public Overrides Property ForeColor As System.Drawing.Color
            Get
                Return MyBase.ForeColor
            End Get
            Set(value As System.Drawing.Color)
                _TextBrush = New SolidBrush(value)
                MyBase.ForeColor = value
            End Set
        End Property
    
        Public Overrides Property Text As String
            Get
                Return String.Empty
            End Get
            Set(value As String)
                MyBase.Text = value
            End Set
        End Property
    
        Public Sub New()
            Size = New Size(124, 38)
            Text = String.Empty
            _BoldFont = New Font(Font, FontStyle.Bold)
            _Caption = "New Event"
            _Description = "(no event information)"
            _TextBrush = New SolidBrush(ForeColor)
        End Sub
    
        Protected Overrides Sub OnPaint(pevent As System.Windows.Forms.PaintEventArgs)
            MyBase.OnPaint(pevent)
            pevent.Graphics.DrawString(_Caption, _BoldFont, _TextBrush, New Point(4, 2))
            pevent.Graphics.DrawString(_Description, Font, _TextBrush, New Point(4, 2 + Font.Height * 1.25))
        End Sub
    End Class
    

    You would use this CalendarEventButton instead of regular Buttons, setting the Caption and Description and ignoring the Text property.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • segunda-feira, 16 de abril de 2012 13:36
     
     
    Nice!  Thanks so much, this is what I was looking for!