I have an UltraListView control, in which I display two columns (or subitems) which contain an UltraProgressBar. For the most part, it works fine, but I want to extend the functionality a bit, in two ways:
1) I want to change the colour (or background image), so it is obvious which is which at a glance. I'm using an app style, and changing the appearance has proven to be problematic. I can make the bar (in the progress bar) disappear, by using:progBar.FillAppearance.ImageBackgroundAlpha = Alpha.Transparent;but for the life of me I cant get a different color or image to appear there. Would I need to use a draw filter for this?
2) I also want to customise the text in the progress bar, so rather than saying something like "20%", it says "20% (5/25)". As the whole listview column shares the one progress bar control, applying the text to the progress bar changes the whole column.
If anyone could suggest an answer to either of my queries, I would be much appreciated.
Hi,
There are a lot of different factors at work here, so it's hard to answer your questions without a more concrete example to work with.
Can you post a small sample project demonstrating what you are doing and using the same isl you are using?
It might not be possible to do this while there is an isl applied. The isl will apply to all controls, so it may be overriding any settings on the UltraProgressBar control. Sometimes you can override the isl settings by applying an Appearance to an individual sub-object like a grid cell. But since you are working with an entire column and an editor here, I don't know if it can be done.
As for setting the text, this should be a simple matter of setting the Text property on the UltraProgressBar control you are using. There are replacement codes for the percentage as well as the current value, maximum value, etc.
Mike,
I have attached a sample app, which demonstrates both issues i have raised. There is a bit of text in the <summary> of Form1 which should give you a pointer to what I'm trying. The appstyle is there, although you may need to copy it to the bin directory.
I have tried that with the ultraprogressbar, but it seems with the UltraListView control, you cant assign a progress bar per row/item - you can only assign one for the whole column. Hence, they all end up with the same text.
Thanks
Shanon.
fweeee said:I am guessing I can get around this by checking more points if it doesnt find a match (top right, middle, etc). I'll see how I go with this.
Hm, you are right, I didn't think of that.
What I would do is get the Rect of the control element, and then do an intersection.
case DrawPhase.BeforeDrawImageBackground: ProgressBarFillUIElement progressBarFillUIElement = drawParams.Element as ProgressBarFillUIElement; if (progressBarFillUIElement == null) return false; ControlUIElementBase controlUIElementBase = progressBarFillUIElement.GetAncestor(typeof(ControlUIElementBase)) as ControlUIElementBase; if (controlUIElementBase == null) return false; Rectangle rect = progressBarFillUIElement.Rect; rect.Intersect(controlUIElementBase.Rect); if (rect.IsEmpty) return false; UltraListViewSubItem subItem = this.listView.SubItemFromPoint(rect.Location); // Change the appearance here based on subItem.Column.Key break;
Thanks. I have my way working (checking every point), but I might give your way a go too.
I am having problems changing the text to "X% (Y/Z)" though. If the percentage figure is non-zero, it works fine. But if the percentage figure is zero, it ignores the text I put in it, and just puts "0%".
In GetPhasesToFilter I'm using:
if (drawParams.Element.GetType() == typeof(ProgressFillTextUIElement)) return DrawPhase.BeforeDrawForeground;
And in DrawElement I am doing something like:
case DrawPhase.BeforeDrawForeground:
ProgressFillTextUIElement progressFilleTextUIElement = drawParams.Element as ProgressFillTextUIElement;
progressFilleTextUIElement.Text = "my text here"
(obviously leaving out some detail there).
Any idea why it would not work for zero? I can provide a full working sample if it maks your life easier.
Why are you changing the text in the DrawFilter instead of just using the replacement codes?
I can't see any reason why 0 should be any different from any other value if you are setting the Text property directly on the UIElement. Unless the control uses different elements for 0, which seems unlikely.
If you want to post a small sample demonstrating this, I'd be happy to take a look, but I still think you are going about this the hard way. :)
I cant use the replacement codes becuase the whole column of the UltraListView uses a single common UltraProgressBar.
The format I want is "X% (Y/Z)". Z will be different for each row, which to my knowledge will make it impossible, as there is no way of setting a different maxvalue for each row in the listview.
I'll put an updated sample app soon.
Thanks for your help.
I worked it out. I was populating the ProgressFillTextUIElement.Text property. This only shows over the progress bar graphic/bar. So it shows up fine for high percentages (like 80-100%), as the whole text is in front of the bar graphic. But for lower pecentages (0-20%), the text is to long to fit over the bar graphic, so not all of it will show.
I managed to get around this by also updating the TextUIElement.Text property.
Although my understanding of all the UIElements is sketchy at best, I think I'm now updating the text element that is on top of the progress bar graphic (ProgressFillTextUIElement), and the text element that is behing the progress bar graphic (TextUIElement)
Again, thanks for your help.