[CLOSED] drawcomponent adding sprite in stead of replacing

  1. #1

    [CLOSED] drawcomponent adding sprite in stead of replacing

    Hi,

    I am facing a very strange performance:

    In a web site I'm using a drawcomponent that is filled with an image. The image is replaced when the users clicks at a button or by a selection event in a gridpanel. The image is constructed on the fly using a handler (ashx).

    In one situation (after a selection event in a gridpanel) the sprite (type image) in the drawcomponent is not replaced. That is: it is not replaced when running the website under IIS on a live server. When running it in Visual Studio it works ok (image is replaced).
    This is very curious. Do you have any idea what might go wrong.

    Code for replacing the sprite:
                Dim cNewId As String = drawMap.ClientID + "_" + "spritebgrnd"
                Dim spritebkgrnd As Sprite = drawMap.GetSprite(cNewId)
                spritebkgrnd.Src = cNewText
                Dim attrs As SpriteAttributes = New SpriteAttributes
                attrs.Src = cNewText
                attrs.Type = SpriteType.Image
                attrs.Height = CInt(Session("iMapHeight"))
                attrs.Width = CInt(Session("iMapWidth"))
                spritebkgrnd.SetAttributes(attrs, True)
                spritebkgrnd.Redraw()
    When I check the result (F12 in IE9) the following is the result. Notice that App.drawMap_spritebgrnd appears twice in the list.

    <div class="x-surface x-surface-default" id="drawMap" style="width: 1560px; height: 951px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px;">
        <svg id="ext-gen1246" style="width: 1560px; height: 951px;" width="1560" height="951" xmlns="http://www.w3.org/2000/svg" version="1.1">
            <defs/>
            <rect id="ext-gen1247" opacity="0" fill="#000" stroke="none" width="100%" height="100%"/>
            <image id="App.drawMap_spritebgrnd" transform="matrix(1 0 0 1 0 0)" preserveAspectRatio="none meet" x="0" y="0" width="1560" height="951" href="MapHandler.ashx?test=2014061024091051177448" zIndex="0" src="MapHandler.ashx?test=2014061024091051177448" hidden="false"/>
            <image id="App.drawMap_spritebgrnd" transform="matrix(1 0 0 1 0 0)" preserveAspectRatio="none meet" x="0" y="0" width="1560" height="951" href="MapHandler.ashx?test=2014061024021406900889" zIndex="0" src="MapHandler.ashx?test=2014061024021406900889" hidden="false"/>
    To reconstruct the problem I made a small example with just png files as sprites, but of course: there everything works fine.
    Do you have any suggestion where to search. I looked at a delay in de selection event, but without any result.

    Thanks,
    Hans Wapenaar
    Last edited by Daniil; Jun 12, 2014 at 11:04 AM. Reason: [CLOSED]
  2. #2
    Hi Hans,

    I have no idea why it might happen.

    There should be a way to reproduce that locally...

    When running it in Visual Studio it works ok (image is replaced).
    There is a Visual Studio Development server used by default. Please try with IIS Express.

    Right click the project =>
    Properties =>
    Web =>
    "Use Local IIS Web server" =>
    Tick the "Use IIS Express" =>
    Launch the application


    Is it reproducible with IIS Exress?
  3. #3
    Hi Daniil,

    I found out that when running the application in Visual Studio there appear also two images. But there the sequence is so that the newest is on top and shown.
    I tried something else: removing the image and adding it again. Also that does not work.

                If (drawMap.GetSprite(cNewId) IsNot Nothing) Then
                    Dim flexspritetoberemoved As Sprite = New Sprite
                    flexspritetoberemoved.SpriteID = cNewId
                    drawMap.Remove(flexspritetoberemoved, True)
                End If
    But when I add:

                drawMap.Update()
    Then the old image is removed.

    So it seems that this update of the drawcomponent is required in one part of the application. With this knowledge I can make a workaround.
    But it remains strange that in most cases the update is not required and in this particular case it is.

    Thanks,

    Hans Wapenaar
  4. #4
    Hard to say what is going on there.

    If can provide a test case to reproduce, I would be happy to investigate.
  5. #5
    Hi Daniil,

    Solved the problem.
    Took some time to trace all steps in the process that generates the images.
    Found that in my code in one pageload amongst others two methods were called, one adding a sprite (image) to the drawcomponent and an other updating the sprite in the drawcomponent. Apperently it seems to be possible to have two sprites with the same ID.
    I made sure that the method which added the sprite is only called when sprite doesnot exist.

    All works well now (without the need to update the drawcomponent).



    Thanks,
    Hans Wapenaar
  6. #6
    It is nice that you were able to find a solution.

    Yes, we don't check Sprites' ids on unique. At this point it is up to a developer. Maybe, we will revise it some day.

Similar Threads

  1. Replies: 2
    Last Post: Mar 03, 2014, 5:41 AM
  2. [CLOSED] DrawComponent in UserControl
    By HansWapenaar in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 12, 2013, 4:28 PM
  3. [CLOSED] replacing topBar (toolbar) of Panel
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 15, 2013, 4:28 PM
  4. Save DrawComponent Sprites as PNG
    By Sean in forum 2.x Help
    Replies: 6
    Last Post: Feb 07, 2013, 4:13 PM
  5. Replies: 7
    Last Post: Dec 13, 2011, 2:39 PM

Posting Permissions