I know that the BarColor property of the appointment object does not exist in the WeekView or the MonthViewSingle. I have added a creation filter to the week and month views to try to simulate the BarColor that exists in the day view I also am adding a couple of buttons to the appointment as well. This code is working, however I seem to be running into some sort of screen refresh problem. Once I change a view from week to month, my buttons appear properly, but my colored rectangle disappears. If I move the mouse around, the colors magically appear.
I know this is a refresh problem, but I have put refreshes all over my code to no avail. What's curious is that the buttons display properly all the time. It's just the colored rectangle that disappears. Of course, I'd love to see the BarColor property built directly into the Week and Month views, but until then I am happy with this work-around. Here is my code that adds the colored rectangle. I've also attached a screen cap.
Private Sub AddBarColorUIElement(ByRef objUIElement As UIElement, ByRef objAppointment As Appointment, ByVal objWeekView As UltraWeekView, ByVal objColor As Color)
'this sub adds a UIElement to the CreationFilter...
If Not IsNothing(objColor) Then
'create an instance of E2WeekViewUIElement to place a button in the appointment...
Dim objNewWeekViewUIElement As New E2WeekViewUIElementobjUIElement.Parent)
objNewWeekViewUIElement.Appointment = objAppointment
objNewWeekViewUIElement.WeekView = objWeekView
'IMPORTANT! position the custom UIElement using its Rect property...
objNewWeekViewUIElement.Rect = New Rectangle(objUIElement.RectInsideBorders.X, objUIElement.RectInsideBorders.Y, intBarColorWidth, objUIElement.RectInsideBorders.Height)
'fill the rectangle with the barcolor of the appointment...
Dim gr As Graphics = objWeekView.CreateGraphics
Dim SolidBrush As New SolidBrush(objColor)
gr.FillRectangle(SolidBrush, objNewWeekViewUIElement.Rect)
End If
'add the custom UIElement to its parent's ChildElements collection...
objUIElement.Parent.ChildElements.Add(objNewWeekViewUIElement)
End Sub
The Infragistcs.Win.DrawUtility class exposes a 'DrawBorders' method, which should support the rounded border styles; if it doesn't, use the 'DrawRounded1Border' method. You can also do this yourself, using the Graphics.DrawArc/DrawLine methods.
rehemann said:I found it, Brian, on the Graphics property of the drawParams parameter.
Sorry, I must have been unclear about this. What I meant was, in your E2WeekViewUIElement class implementation, which derives from the Infragistics.Win.UIElement class, you should override the DrawBackColor method, so that this overridden implementation is used whenever the control draws itself.
One last detail: How do I emulate the rounded border on the top and bottom? I have seen some posts that talk about BorderSides, but can't seem to find any sample code that shows how to do it. Is that the best approach?
I found it, Brian, on the Graphics property of the drawParams parameter. Thanks for your help!
Brian:
I found the DrawBackColor method, but didn't find a FillRectangle method in it or on the DrawParams parameter. Can you steer me toward where I might find the FillRectangle method?