ImageCellType

Posted by: silkkeng-fp on 8 September 2017, 2:05 pm EST

  • Posted 8 September 2017, 2:05 pm EST

    Hi

    I am not sure if there is a best way to implement this, but I generally have an idea.

    I would like an image celltype which has row/column span. The image is a snapshot of a panel which contains report.

    When I resize the column it should redraw the image to make it fit to the size instead of stretch or scale.

    To achieve this, i create a CustomCelltype which implement ImageCellType:


    Imports System.Reflection.MethodBase
    Imports FarPoint.Win.Spread
    Imports System.Drawing

    Public Class ReportCellType
        Inherits FarPoint.Win.Spread.CellType.ImageCellType

        Private mPanel As ReportPanel = Nothing
        Private mPanelImage As Bitmap = Nothing

        Public Sub New(ByVal panel As ReportPanel )
            mPanel = panel
            mPanel.Visible = True
        End Sub

        Public Overrides Sub PaintCell(ByVal g As System.Drawing.Graphics, ByVal r As System.Drawing.Rectangle, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal isSelected As Boolean, ByVal isLocked As Boolean, ByVal zoomFactor As Single)
            Dim nr As System.Drawing.Rectangle = r
            If mPanelImage Is Nothing OrElse r.Size <> mPanel.Size Then
                mPanel.Size = r.Size
                mPanel.Reset()
                mPanel.Render(value) 'This will draw the image and etc to the panel
                mPanel.Visible = True

                mPanelImage = New Bitmap(r.Size.Width, r.Size.Height, Imaging.PixelFormat.Format64bppPArgb)

                nr = New Rectangle(New Point(0, 0), r.Size)
                mPanel.DrawToBitmap(mPanelImage, nr)
               
                g.FillRectangle(New SolidBrush(appearance.BackColor), nr)
            End If
            MyBase.PaintCell(g, nr, appearance, mPanelImage, isSelected, isLocked, zoomFactor)
        End Sub


    End Class

     

    In my Spread, I set the the value of the Cell

    mSpread.Cell(row,col)= valueObject

    mSpread.Cell(row,col) = New ReportCellType(panel)

    The value object is neither a picture or an image. It is an object which is required for Panel to work out what to draw.

     

    Is this the right way to achieve when Column get resize the image get redraw? or if there is any other better way?

    The reason I am asking this is because even it achieve the result I wanted, but, it also showing something weird when I do print preview.

    There is a white cell which looks like a focus stuff located at the corner. I also checked during PaintCell, the image doesn't have white cell. So, I am wondering where this WhiteCell coming from.

    See image. My report is blue color.

    The white cell come up when I do print preview. Then, if I close print preview, scroll down the row, and mouse move near that white cell, the white cell suddenly disappear.

    After the white cell disappear, it won't happen again until I do a print preview. 

    I was wondering if anyone also having the same problem?

     

    Regards,
    David

     

     

     

     


    2009/10/test.gif
  • Replied 8 September 2017, 2:05 pm EST

    David,

    I am not sure what ReportPanel is and how to reference it in a project? Also the behavior as mentioned by you, could be also caused by the PrintPreview control. We don't have any built in preview control and use the MS PrintPreview control. As far as sizing issue in Spread, you may try using the GetPreferredColumnWidth and GetPreferredRowHeight to allow the automatic size adjusting as per image in Paint Cell override(but I think, it is already working for you).

    Thanks

  • Replied 8 September 2017, 2:05 pm EST

    David,


    I am not able to reproduce this issue. As I scroll down in the Spread, the red image draws correctly in the Spread. One thing I did notice, you are using an old release of Spread for Windows Forms. I would suggest going to our website to get the latest release.

  • Replied 8 September 2017, 2:05 pm EST

    Thanks Suresh.

    I would thought that is related to how I setup the cell type as I did not assign the image to the cell value.

    I might try to replicate into a small project and send it to you as it is also happening when I first load up spread without print preview.

    Updated.

    Now, I have replicate the project.

    To see my issue:

    1. Run the project

    2. Scroll down by using the scroll bar.

    3. On the spot, you will see there is a grey cell at the top left corner.


     

     


    2009/10/SpreadTest7.zip
  • Replied 8 September 2017, 2:05 pm EST

    Hello,

    Thanks for the sample project. I tried running it and the top most left corner cell color remains same at different scroll position. I tested the issue with Spread 4.0.2010.2005. I am attaching screen shot of the behavior(with different scrollbar position) I am seeing at my side, let us know your further observations.

    Thanks


    2009/10/ImageCellType.JPG
  • Replied 8 September 2017, 2:05 pm EST

    David,


     


    I have tried this way of scrolling as well however could not re-create the issue at my end.


    I would suggest you to please update Spread to the latest version and let us know if it resolves the issue or not.


     


    Regards,


    Amit

  • Replied 8 September 2017, 2:05 pm EST

    Hi Suresh,

    Your print screen is looking at wrong position.

    The position you should be looking at is where the Red Panel located, around row 50.

    That's where you see the problem.

    To see the issue:

    1. Run project.

    2. Press on the scroll bar to scroll down to around position 50.slowly don't rush

    3. On the top left corner of the red panel (don't look at the top most left corner), you can see there is a grey cell on top of the panel.

    Note : this is happen on startup only.

     

     

    Regards,
    David

  • Replied 8 September 2017, 2:05 pm EST

    Hi Scotts,

    I'll try on new spread see if I can reproduce the issue.

    With old spread, you can't use mouse scroll, you need to move your mouse hold down the scroll button, move it down to where the red panel is and release your left mouse click and you can see the white cell straightaway.

     

    Regards,
    david

     

  • Replied 8 September 2017, 2:05 pm EST

    It seems that the issue can be replicated for the first time only. I could not replicate it when I tried to run the sample again.I have forwarded this to the concerned team and will update you accordingly.

     

    Thanks,

     

  • Replied 8 September 2017, 2:05 pm EST

    Hello,


     


    Does this mean that the issue has been resolved or do you require further assistance/clarifications?

  • Replied 8 September 2017, 2:05 pm EST

    Hi,

    We have upgraded to latest spread and it is still replicable using the same project.

    I have sent the link to download the movies to fpsupport@fpoint.com


    Thanks

    David

     

     

  • Replied 8 September 2017, 2:05 pm EST

    Hi,

    Thanks for clarify. That's definitely an error 69...

    David

     

  • Replied 8 September 2017, 2:05 pm EST

    Hi David,

    I think you are passing the wrong rectangle (nr instead of r) to the base class PaintCell.  Change the code to this and it works as expected:

            MyBase.PaintCell(g, r, appearance, mPanelImage, isSelected, isLocked, zoomFactor)

  • Replied 8 September 2017, 2:05 pm EST

    Hello,

    I have downloaded the  movie and able to replicate the issue with the sample that you sent earlier.I have set  FpSpread1.AllowCellOverflow = False and it seems to fix the problem.

    Thanks,

     

     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels