Repaint problem

Hello,

I dont know if it is a bug or a bad usage, but I have a repaint problem.
I still use my 4 scrollable views on the same document. I'm creating a selection rectangle (inherited GoRectangle), drawing a partially rectangle from left to right on a given height.
Before to draw the rect, I make a clear on the layer containing the selection objects.
It is working perfectly until I scroll a litlle bit in the view. When selecting successively, the old resct are not erase. As soon as I provocate an invalidate (moving scroll bar), all is redrawn correctly.
Is the Clear from a layer forwarding an invalidate to all views ?
In my sample below, I've tried to force the invalidate, but no success.
Any hint ?
Thanks
Bye
Didier
*****************************************************
private void rowGridHeaderItemSelected(IGridHeaderItem item, int ix) {
// Erase all selections
(m_CntDoc as GridContentDocument).Layers.Find(GridContentDocument.K_LAYER_SELECTION).Clear();
(m_CntDoc as GridContentDocument).InvalidateViews();
// Add selection to document
SelectionItem selItem = new SelectionItem(ESelectionItemKind.Row, ix);
(m_CntDoc as GridContentDocument).Layers.Find(GridContentDocument.K_LAYER_SELECTION).Add(selItem);
}

Did you override GoObject.Paint? If so, do you ever draw beyond the Bounds of the object? If so, did you also override GoObject.ExpandPaintBounds so that each GoView can know whether the object needs to be repainted upon a part of the view being invalidated?

You shouldn't need to call GoDocument.InvalidateViews just because you add/remove/modify any GoObject.
Minor comment: you don't need to cast "m_CntDoc as GridContentDocument", since the Layers property and the InvalidateViews method are defined on GoDocument. And even if you did need to do that cast for getting access to other members, you should just do it once, instead of at each usage.

Hello,

- No, I've not overrided the Paint method
- No, I'm drawing in the bounds of the object
- Only overrided the ComputeBounds method.
It seems that removing the objects from layers with a clear doesn't repaint when view is scrolled. If you want I can try to manually remove the selected object with a 'real' remove.
So far I'm not drawing out of the bounds, I do not have to override GoObject.ExpandPaintBounds ?
Thanks for your hint about casting. Is that time consuming ?
Bye
Didier

Ah, overriding ComputeBounds could also cause the problem that there is painting beyond the (alternately computed) Bounds.
In particular, you really shouldn’t be overriding GoRectangle.ComputeBounds, since anything that’s a “rectangle” should have the Bounds that GoRectangle currently has.

Hello,

Thanks for your answers.
I TEST THAT IN ANOTHER program using simply a GoRectangle, and the Layer.Clear() works perfectly.
So the question is : how to set bounds from other internal variables and document variables ? I thought that computBounds is fine, but its seems to give problems.
Below my code.
Thanks
Didier
**************************************************
protected override RectangleF ComputeBounds() {
RectangleF l_ComputedBounds = new RectangleF(0, 0, 0, 0);
if (Document as GridContentDocument != null) {
SizeF l_GridSize = (Document as GridContentDocument).GridCellSize;
if (m_SelItemKind == ESelectionItemKind.Column) {
l_ComputedBounds = new RectangleF(m_Ix * l_GridSize.Width, 0.0F,
l_GridSize.Width, Document.Size.Height);
}
else if (m_SelItemKind == ESelectionItemKind.Row) {
l_ComputedBounds = new RectangleF(0.0F, m_Ix * l_GridSize.Height,
Document.Size.Width, l_GridSize.Height);
}
}
return (l_ComputedBounds);
}

Don’t override ComputeBounds unless you are defining a completely new class with interesting geometry.
When you change the GoGrid.CellSize, then you can set the Bounds of all of the GoObjects you need, including any GoRectangles.

ok, will try and will advise.

Thanks

Removed override of ComputeBounds, it works perfectly.

Thanks
Bye