I have a scenario where task could be various states.
For example there are 100 Task. On 70 task have been 'Processed'. Out of 70 task 'Processed', 30 task are 'Pending approval', 20 task have been 'Approved' and 20 task have been 'Rejected'.
In terms of progress, percent completed is 70 i.e. task 'Processed'. This 70 is further divided into part value of 30 / 20 / 20. I want to represent them with different colors.
Is it possible to do with UltraProgressBar ? What are my options with DrawFilter ? Any other control that might be useful in this context ?
Well, there are a couple of ways you could handle this. If you want to use a single DrawFilter for both the grid and the standalone ProgressBar controls, then you will have to get the value of the cell/progressbar in a generic way.
You could do that by calling GetAncestor on the Fill
If the grid cell is using a different type of object for it's value, then the UIElement you are drawing on and passing in a type of EmbeddableUIElementBase. That will give you the embeddable element and you can use the GetValue method on it to get the value of whatever object that element is in - the cell or the control.
Of course, if your grid is using a custom class as it's value and the control is not, you probably will want to use a different DrawFilter for each, anyway.
So the thing to do in the case of the grid is simply call GetContext on the UIElement and pass in a type of UltraGridCell and then once you have the cellm you can get it's Value.
Hi,
I had tried setting Editor for the column to ProgressBar and use the DrawFilter. However since the column data is of type 'TaskProgress' it throws an exception. Am I missing something?
I found one bug in the DrawFilter for the UltraProgressBar. The rectangle passed as parameter to DrawElement is the complete control rectangle rather than based on progress value (%). I confirmed that by using UIElementViewer. I wrote custom logic to calculate the width base on progress value. After this change the drawing of multiple rectangle based on part value works.
public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams){// If the element being drawn is a ProgressFillTextUIElement // we're interested in drawing its borders only.if (drawParams.Element is ProgressFillTextUIElement) return DrawPhase.BeforeDrawBackColor;return DrawPhase.None;}
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams){// This will only be called for the BeforeDrawBackColor phase of a // ProgressFillTextUIElement based on the flags returned from // GetPhasesToFilter. Rectangle elementRect = drawParams.Element.Rect; //Custom logic to compute the actual drawing areaint totalWidth = (int)(elementRect.Width * (taskProgress.Selected / (float)100));}
// ProgressFillTextUIElement based on the flags returned from // GetPhasesToFilter. Rectangle elementRect = drawParams.Element.Rect;
//Custom logic to compute the actual drawing areaint totalWidth = (int)(elementRect.Width * (taskProgress.Selected / (float)100));}
I ran your sample, but I'm not sure what "weird behavior" you are referring to.
If you've already written a DrawFilter to handle the drawing of the standalone ProgressBar, then you could apply the same DrawFilter to the grid and you would not have to use the ControlContainerEditor. That seems like it would be a lot simpler implementation. The grid cell will contain essentially the same UIElements in the ProgressBar cell as the standalone control does.
I reviewed this API and thats not my scenario. The work completed in 70% but this 70 is composed of (30 Accepted, 20 Rejected, 20 Pending). I have written a DrawFilter for this (project attached to this post). This works well as standalone control on Form.
But now the problem is different. In the grid data source the part data is represented as object with three properties (similar to Grades class in ControlContainerElement example). Ans I set ControlContainerEditor with UltraProgressBar derived class (so I can indirecrtly bind the Value Property). There is strange behaviour here, the ProgressFillTextUIElement drawing rectangle seems to cover the complete cell.
//Selected = 30, Rejected = 10, Sucesseded = 2 ControlBasedPartValueDrawFilter:Infragistics.Win.UltraWinProgressBar.ProgressFillTextUIElement elementRect:{X=2,Y=2,Width=120,Height=12} selectedRect:{X=50,Y=2,Width=72,Height=12} sucessededRect:{X=10,Y=2,Width=40,Height=12} rejecetedRect:{X=2,Y=2,Width=8,Height=12} //Selected = 80, Rejected = 10, Sucesseded = 15 ControlBasedPartValueDrawFilter:Infragistics.Win.UltraWinProgressBar.ProgressFillTextUIElement elementRect:{X=2,Y=2,Width=120,Height=12} selectedRect:{X=39,Y=2,Width=83,Height=12} sucessededRect:{X=17,Y=2,Width=22,Height=12} rejecetedRect:{X=2,Y=2,Width=15,Height=12}
//Selected = 30, Rejected = 10, Sucesseded = 2
ControlBasedPartValueDrawFilter:Infragistics.Win.UltraWinProgressBar.ProgressFillTextUIElement
elementRect:{X=2,Y=2,Width=120,Height=12}
selectedRect:{X=50,Y=2,Width=72,Height=12}
sucessededRect:{X=10,Y=2,Width=40,Height=12}
rejecetedRect:{X=2,Y=2,Width=8,Height=12}
//Selected = 80, Rejected = 10, Sucesseded = 15
selectedRect:{X=39,Y=2,Width=83,Height=12}
sucessededRect:{X=17,Y=2,Width=22,Height=12}
rejecetedRect:{X=2,Y=2,Width=15,Height=12}
I'm not entirely sure that I understand what you are asking, but it sounds like you want to change the colors on the ProgressBar in stages depending on the current value.
This is a pretty common scenario. For example, the first 30% of the progress bar could be red, the next 20 after that could be yellow, and then the next 20% could be red.
If that's what you want, the way to do it is to use the PercentSettings collection. This collection allows you to add certain threshholds with different appearances.