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,
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; }
Please do not hesitate to contact us if you need any additional assistance.
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.
Hello pnchung,
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); } }