I have 2 more questions:
1. if I embed a ButtonUIElement inside a TimeSlotUIElement like the code in above post (http://forums.infragistics.com/forums/t/47504.aspx), everything seem to be OK. But when I embed a TextUIElement, the Text of its property not show and also the click event not fire, the code is:
public void AfterCreateChildElements(UIElement parent) { if (parent is Infragistics.Win.UltraWinSchedule.TimelineView.TimeSlotUIElement) { TextUIElement txtUI = new TextUIElement(parent, "Whatever you want to write"); txtUI.Rect = parent.Rect; txtUI.Text = "OK"; txtUI.ElementClick += OnEmbeddedButtonClicked; parent.ChildElements.Add(txtUI); } } /// </summary> protected virtual void OnEmbeddedButtonClicked(object sender, UIElementEventArgs e) { MessageBox.Show("A Clicked on Lable "); } 2. I set a startday and endday of a WinMonthViewSingle control to 1 month, but when running application, its also show days of next month with disabled.My question is how to hide (invisible) these disabled items from the control.Thank you very much.
Hello pnchung,
I was able to reproduce your scenarios, so:
To the first question:
Actually, when you add a TextUIElement in this way, the text of the txtUI(in your case) is shown. However, the color is the same as the color of the element your txtUI resides in, so this might be the reason for the text not to be actually visible, but the text is still there. You could try changing some appearances like in my code sample which is a possible approach for dealing with this behavior:
ultraTimeLineView1.Appearance.ForeColor = Color.Black;
As to the second question:
You could remove the disabled items using creation filter.
Another possible approach might be setting the DayAppearance.BackColorDisabled and DayAppearance.ForeColorDisabled to the background color of your control(white by default). If you choose the second approach these days will still be shown in run-time, but they will not be visible, because of there appearance settings.
Please do not hesitate to contact us if you need any additional assistance.
Thank you for your help.
For the 2nd question, could you please show me the code snipet to remove the disabled items using creation filter.
Thank again!
Hello,
Thank you for contacting us again.
What the ElementClick EventHandler does is to fire the 'OnEmbeddedButtonClicked' on clicking the button Element. Since your element is a TextUIElement this event would not be fired as expected.
What you could do is to use a ButtonUIElement.
public void AfterCreateChildElements(UIElement parent) { if (parent is Infragistics.Win.UltraWinSchedule.TimelineView.TimeSlotUIElement) { ButtonUIElement buttonUI = new ButtonUIElement(parent); buttonUI.Rect = new Rectangle(parent.Rect.X, parent.Rect.Y, 50, 20); buttonUI.Text = "OK"; buttonUI.ElementClick += OnEmbeddedButtonClicked; parent.ChildElements.Add(buttonUI); } } protected virtual void OnEmbeddedButtonClicked(object sender, UIElementEventArgs e) { MessageBox.Show("Clicked on a button!"); } public bool BeforeCreateChildElements(UIElement parent) { return false; }
Thank you for your reply.And I have one more problem.As your recommend, I successful add a TextUIElement to TimeSlotUIElement and show it's Text.My Question is how to fire a click event on this TextUIElement like code in the first post. Many thanks.
I think that in this case you could use a draw filter as a possible approach to achieve the desired look.
With the following code I was able to get the look you need:
class DrawFilter : IUIElementDrawFilter { Pen borderPen = new Pen(new SolidBrush(Color.Black), 3); public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { if (drawPhase.Equals(Infragistics.Win.DrawPhase.BeforeDrawBorders) && drawParams.Element is ActivityAreaUIElement) { return true; } if (drawPhase.Equals(Infragistics.Win.DrawPhase.AfterDrawBorders) && drawParams.Element is TimeSlotUIElement) { Point sp = new Point(drawParams.Element.Rect.Left, drawParams.Element.Rect.Top+drawParams.Element.Rect.Height); Point ep = new Point(drawParams.Element.Rect.Left + drawParams.Element.Rect.Width, drawParams.Element.Rect.Top+drawParams.Element.Rect.Height); drawParams.Graphics.DrawLine(borderPen, sp, ep); } return false; } public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is ActivityAreaUIElement) return Infragistics.Win.DrawPhase.BeforeDrawBorders; else { if (drawParams.Element is TimeSlotUIElement) return DrawPhase.AfterDrawBorders; else return Infragistics.Win.DrawPhase.None; } } }
You could 'tune' the code as you want to achieve the best look and feel for your application.
Please do not hesitate to contact me if you need any additional assistance.
Thank you, Boris.
As your recommended, I use this code to hide the disabled area of the TimelIneView, but I don't know why the horizontal line still visible. How can I remove it.
public void AfterCreateChildElements(UIElement parent)
{
if (parent is Infragistics.Win.UltraWinSchedule.TimelineView.TimeSlotUIElement && !parent.Enabled) { parent.Rect = new Rectangle(parent.Rect.X, parent.Rect.Y, 0, 0); } } And this is the picture of it http://113.160.224.51/qlcv/TimelineView2.png http://113.160.224.51/qlcv/TimelineView.png
if (parent is Infragistics.Win.UltraWinSchedule.TimelineView.TimeSlotUIElement && !parent.Enabled) {
parent.Rect = new Rectangle(parent.Rect.X, parent.Rect.Y, 0, 0);
} }
And this is the picture of it
http://113.160.224.51/qlcv/TimelineView2.png
http://113.160.224.51/qlcv/TimelineView.png
Something similar to what you are looking for could be achieved using the following code sample:
public void AfterCreateChildElements(UIElement parent){ if (parent is DayUIElement && !parent.Enabled) { parent.Rect = new Rectangle(parent.Rect.X, parent.Rect.Y, 0, 0); } }
if (parent is DayUIElement && !parent.Enabled) { parent.Rect = new Rectangle(parent.Rect.X, parent.Rect.Y, 0, 0); } }