[CLOSED] changing already created sprite data from code behind

  1. #1

    [CLOSED] changing already created sprite data from code behind

    Hello

    I ask myself a question since a while. I have solved it, but want to know it there is a better solution.

    I my soft, I have to play with sprites to draw arrows (I make a "sort of" visio interface).

    To create my sprites, I do something like that:

                 Dim mySpriteArrow As Sprite = New Sprite 'path sprite
    
                   With mySpriteArrow 'define arrow
                        .SpriteID = "myArrow" + ds.Tables("arrows").Rows(i).Item("ArrowID").ToString 'ID (myArrow1, myArrow2, ..., myArown
                        .Type = SpriteType.Path
                        .Path = NewPath
                        .Stroke = "#3457B6"
                        .StrokeWidth = 2
                        '.Fill = "#34ADB6" 'in case inner arrow must be filled
                    End With
    
                    drwVMProcess.Add(mySpriteArrow) 'add sprites to drawer
                    mySpriteArrow.Show(True) 'show it
    All works fine. I have panels at start and en of arrow to simulate some process of course.

    But, when I move process, I will have to change the path.

    I use
               drwVMProcess.GetSprite(ArrowsToDealWith(i))
    where
    drwVMProcess
    is my DrawComponent and
    ArrowsToDealWith(i)
    my sprite name, but the only thing I'm able to do with that is to call the Remove method, and create a new sprites with modified path.

    It works, but the question is :

    is there a way to get all javascript sprite object and change only data needed to redraw it?
    Last edited by Daniil; Sep 04, 2013 at 12:00 PM. Reason: [CLOSED]
  2. #2
    Hi @feanor91,

    It is possible to change some sprite attributes without removing it.
    https://examples2.ext.net/#/Draw/Basic/Actions/

    Please clarify what exactly do you need to change in a sprite?
  3. #3
    Hi,

    i will check that.

    For now, I need to change path (and redraw it), position and size for sprite circles
  4. #4
    I am not sure what "path" do you mean regarding circles... Could you, please, elaborate?

    As for sizing and positioning, I think it is possible to do without removing a sprite.
  5. #5
    I mean nothing regarding circle. Ihave path sprite on a side and circle sprite on another, I have both type
  6. #6
    Thank you for clarifying.

    It appears to be possible to change a Path as well.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void ChangePath(object sender, DirectEventArgs e)
        {
            Draw1.GetSprite("Sprite1").SetAttributes(new SpriteAttributes 
                {
                    Path = "M200,200 h-50 a50,50 0 1,0 50,-50 z"
                }, 
                true);
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Viewport runat="server" Layout="FitLayout">
                <Items>
                    <ext:Panel runat="server" Layout="FitLayout">
                        <TopBar>
                            <ext:Toolbar runat="server">
                                <Items>
                                    <ext:Button runat="server" Text="Change Path" OnDirectClick="ChangePath" />
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <Items>
                            <ext:DrawComponent ID="Draw1" runat="server">
                                <Items>
                                    <ext:Sprite
                                        SpriteID="Sprite1"
                                        Type="Path"
                                        Path="M 100 100 L 300 100 L 200 300 z"
                                        Fill="green" />
                                </Items>
                            </ext:DrawComponent>
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:Viewport>
            
        </form>
    </body>
    </html>
  7. #7
    Works like a charm. Thank you

Similar Threads

  1. Replies: 5
    Last Post: Mar 21, 2013, 4:41 PM
  2. [CLOSED] Charts created in code behind
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 31, 2012, 5:35 PM
  3. Replies: 1
    Last Post: Apr 13, 2012, 1:52 PM
  4. Replies: 5
    Last Post: Feb 02, 2012, 8:45 AM
  5. [CLOSED] Changing Listener Handler from Code Behind
    By Immobilmente in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 16, 2009, 11:23 AM

Posting Permissions