[CLOSED] Updating window size during DirectEvent

  1. #1

    [CLOSED] Updating window size during DirectEvent

    After the next button is clicked, how can I make the window resize to fit the contents (keeping it centered)?

    <script runat="server">
    
        Protected Sub CheckButtons()
            Dim index = WizardPanel.ActiveIndex
            NextButton.Disabled = index = (WizardPanel.Items.Count - 1)
            PrevButton.Disabled = index = 0
        End Sub
    
        Protected Sub NextButton_Click(ByVal sender As Object, ByVal e As DirectEventArgs)
            Dim index = CInt(e.ExtraParams("index")) + 1
            If index < WizardPanel.Items.Count Then
                WizardPanel.ActiveIndex = index
            End If
            CheckButtons()
        End Sub
    
        Protected Sub PrevButton_Click(ByVal sender As Object, ByVal e As DirectEventArgs)
            Dim index = CInt(e.ExtraParams("index")) - 1
            If index >= 0 Then
                WizardPanel.ActiveIndex = index
            End If
            CheckButtons()
        End Sub
        
    </script>
    
    <ext:Window ID="ActionWindow" runat="server" Layout="fit">
        <Items>
            <ext:Panel runat="server" Layout="fit" Border="false">
                <Items>
                    <ext:Panel ID="WizardPanel" runat="server" Padding="15" Layout="card" ActiveIndex="0" Border="false">
                        <Items>
                            <ext:Panel ID="SummaryPanel" runat="server" Border="false" Header="false">
                                <Items>
                                    <ext:Label ID="Label1" runat="server" Text="Test" />
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="ParametersPanel" runat="server" Border="false" Header="false">
                                <Items>
                                    <ext:Button runat="server" Text="TEST" Width="500" Height="500" />
                                </Items>
                            </ext:Panel>
                        </Items>
                        <Buttons>
                            <ext:Button ID="PrevButton" runat="server" Text="Previous" Disabled="true" Icon="PreviousGreen">
                                <DirectEvents>
                                    <Click OnEvent="PrevButton_Click">
                                        <ExtraParams>
                                            <ext:Parameter Name="index" Value="#{WizardPanel}.items.indexOf(#{WizardPanel}.layout.activeItem)" Mode="Raw" />
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:Button ID="NextButton" runat="server" Text="Next" Icon="NextGreen">
                                <DirectEvents>
                                    <Click OnEvent="NextButton_Click">
                                        <ExtraParams>
                                            <ext:Parameter Name="index" Value="#{WizardPanel}.items.indexOf(#{WizardPanel}.layout.activeItem)" Mode="Raw" />
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Buttons>
                    </ext:Panel>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Window>
    Last edited by Daniil; Sep 15, 2010 at 7:23 PM. Reason: [CLOSED]
  2. #2
    Hello!

    Unfortunately the Window class doesn't support auto-resizing depending on its content.
    It needs to set the Height and Width properties manually.

    The SetSize and Center methods would be helpful to achieve this behavior.

    Example
    ActionWindow.SetSize(500, 500)
    ActionWindow.Center()
  3. #3
    Does calling .DoLayout() on the Window resize it correctly?

    You would still need to call .Center() as well.

    Hope this helps.
    Geoffrey McGill
    Founder
  4. #4
    Quote Originally Posted by geoffrey.mcgill View Post
    Does calling .DoLayout() on the Window resize it correctly?

    You would still need to call .Center() as well.

    Hope this helps.
    It doesn't.
  5. #5
    Looks like .SetSize() is the answer.

    Here's a full sample.

    Example

    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void CheckButtons()
        {
            var index = this.Window1.ActiveIndex;
    
            this.Button1.Disabled = (index == 0);
            this.Button2.Disabled = (index == this.Window1.Items.Count - 1);
    
            this.Window1.SetSize(this.Panel1.Width, this.Panel1.Height);
            this.Window1.Center();
        }
        
        public void Button1_Click(object sender, DirectEventArgs e)
        {
            this.Window1.ActiveIndex = int.Parse(e.ExtraParams["index"]) - 1;
            this.CheckButtons();
        }
    
        public void Button2_Click(object sender, DirectEventArgs e)
        {
            this.Window1.ActiveIndex = int.Parse(e.ExtraParams["index"]) + 1;
            this.CheckButtons();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
    <form runat="server">
        <ext:ResourceManager runat="server" />
        
        <ext:Window 
            ID="Window1" 
            runat="server"
            Title="Example"
            Height="215"
            Width="350"
            Layout="card" 
            ActiveIndex="0">
            <Items>
                <ext:Container runat="server">
                    <Items>
                        <ext:Label runat="server" Text="Test" />
                    </Items>
                </ext:Container>
                <ext:Panel ID="Panel1" runat="server" Title="Child" Border="false" Width="500" Height="500" />
            </Items>
            <Buttons>
                <ext:Button ID="Button1" runat="server" Text="Previous" Disabled="true" Icon="PreviousGreen">
                    <DirectEvents>
                        <Click OnEvent="Button1_Click">
                            <ExtraParams>
                                <ext:Parameter 
                                    Name="index" 
                                    Value="#{Window1}.items.indexOf(#{Window1}.layout.activeItem)" 
                                    Mode="Raw" 
                                    />
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="Button2" runat="server" Text="Next" Icon="NextGreen">
                    <DirectEvents>
                        <Click OnEvent="Button2_Click">
                            <ExtraParams>
                                <ext:Parameter 
                                    Name="index" 
                                    Value="#{Window1}.items.indexOf(#{Window1}.layout.activeItem)" 
                                    Mode="Raw" 
                                    />
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
        </ext:Window>
    </form>
    </body>
    </html>
    Geoffrey McGill
    Founder

Similar Threads

  1. Replies: 2
    Last Post: Jul 26, 2012, 2:12 AM
  2. [CLOSED] Updating UI in a Dynamic Control DirectEvent
    By mmemioglu in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 06, 2012, 10:02 AM
  3. [CLOSED] Updating window content
    By borja_cic in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 15, 2011, 6:04 PM
  4. Replies: 0
    Last Post: Feb 22, 2010, 12:24 PM
  5. Replies: 0
    Last Post: Dec 10, 2009, 6:54 PM

Posting Permissions