Ejemplo n.º 1
0
 /// <summary>
 /// Flips to the component that was added to this layout with the
 /// specified <code>name</code>, using <code>addLayoutComponent</code>.
 /// If no such component exists, then nothing happens. </summary>
 /// <param name="parent">   the parent container in which to do the layout </param>
 /// <param name="name">     the component name </param>
 /// <seealso cref=       java.awt.CardLayout#addLayoutComponent(java.awt.Component, java.lang.Object) </seealso>
 public virtual void Show(Container parent, String name)
 {
     lock (parent.TreeLock)
     {
         CheckLayout(parent);
         Component next        = null;
         int       ncomponents = Vector.Count;
         for (int i = 0; i < ncomponents; i++)
         {
             Card card = (Card)Vector[i];
             if (card.Name.Equals(name))
             {
                 next        = card.Comp;
                 CurrentCard = i;
                 break;
             }
         }
         if ((next != null) && !next.Visible)
         {
             ncomponents = parent.ComponentCount;
             for (int i = 0; i < ncomponents; i++)
             {
                 Component comp = parent.GetComponent(i);
                 if (comp.Visible)
                 {
                     comp.Visible = false;
                     break;
                 }
             }
             next.Visible = true;
             parent.Validate();
         }
     }
 }
Ejemplo n.º 2
0
 internal virtual void ShowDefaultComponent(Container parent)
 {
     if (parent.ComponentCount > 0)
     {
         CurrentCard = 0;
         parent.GetComponent(0).Visible = true;
         parent.Validate();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Flips to the previous card of the specified container. If the
 /// currently visible card is the first one, this method flips to the
 /// last card in the layout. </summary>
 /// <param name="parent">   the parent container in which to do the layout </param>
 /// <seealso cref=       java.awt.CardLayout#next </seealso>
 public virtual void Previous(Container parent)
 {
     lock (parent.TreeLock)
     {
         CheckLayout(parent);
         int ncomponents = parent.ComponentCount;
         for (int i = 0; i < ncomponents; i++)
         {
             Component comp = parent.GetComponent(i);
             if (comp.Visible)
             {
                 comp.Visible = false;
                 CurrentCard  = ((i > 0) ? i - 1 : ncomponents - 1);
                 comp         = parent.GetComponent(CurrentCard);
                 comp.Visible = true;
                 parent.Validate();
                 return;
             }
         }
         ShowDefaultComponent(parent);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Flips to the last card of the container. </summary>
 /// <param name="parent">   the parent container in which to do the layout </param>
 /// <seealso cref=       java.awt.CardLayout#first </seealso>
 public virtual void Last(Container parent)
 {
     lock (parent.TreeLock)
     {
         CheckLayout(parent);
         int ncomponents = parent.ComponentCount;
         for (int i = 0; i < ncomponents; i++)
         {
             Component comp = parent.GetComponent(i);
             if (comp.Visible)
             {
                 comp.Visible = false;
                 break;
             }
         }
         if (ncomponents > 0)
         {
             CurrentCard = ncomponents - 1;
             parent.GetComponent(CurrentCard).Visible = true;
             parent.Validate();
         }
     }
 }