context: using System;
  using System.Collections;
  using Server.Items;
  using Server.Mobiles;
  using Server.Network;
  
  /*
  ** Changelog
  **
  ** 3/25/04
  ** added party status information
  ** 3/23/04
  ** changed bottom border location in the quest status gump for 3dclient compatibility
  */
  namespace Server.Gumps
  {
      public class XmlConfirmDeleteGump : Gump
      {
          readonly Item m_Item;
          readonly Mobile m_From;
          public XmlConfirmDeleteGump(Mobile from, Item item)
              : base(0, 0)
          {
              this.m_Item = item;
              this.m_From = from;
  
              this.Closable = false;
              this.Dragable = true;
              this.AddPage(0);
              this.AddBackground(10, 180, 200, 130, 5054);
  
              if (item is XmlQuestBook)
              {
                  this.AddLabel(20, 185, 33, String.Format("Delete this questbook?"));
                  this.AddLabel(20, 205, 33, String.Format("{0} quest(s) will be lost.", item.TotalItems));
                  this.AddLabel(20, 225, 53, item.Name);
              }
              else if (item is IXmlQuest)
              {
                  this.AddLabel(20, 205, 33, String.Format("Delete this quest?"));
                  this.AddLabel(20, 225, 53, item.Name);
              }
              else
              {
                  this.AddLabel(20, 225, 33, String.Format("Delete this item?"));
              }
              this.AddRadio(35, 255, 9721, 9724, false, 1); // accept/yes radio
              this.AddRadio(135, 255, 9721, 9724, true, 2); // decline/no radio
              this.AddHtmlLocalized(72, 255, 200, 30, 1049016, 0x7fff, false, false); // Yes
              this.AddHtmlLocalized(172, 255, 200, 30, 1049017, 0x7fff, false, false); // No
              this.AddButton(80, 289, 2130, 2129, 3, GumpButtonType.Reply, 0); // Okay button
          }
  
          public override void OnResponse(NetState state, RelayInfo info)
          {
              if (info == null || state == null || state.Mobile == null)
                  return;
              
              int radiostate = -1;
              if (info.Switches.Length > 0)
              {
                  radiostate = info.Switches[0];
              }
              switch(info.ButtonID)
              {
                  default:
                      {
                          if (radiostate == 1 && this.m_Item != null)
                          { // accept
                              if (this.m_Item is IXmlQuest)
                              {
                                  ((IXmlQuest)this.m_Item).Invalidate();
                              }
                              else if (this.m_Item is XmlQuestBook)
                              {
                                  ((XmlQuestBook)this.m_Item).Invalidate();
                              }
                              else
                              {
                                  this.m_Item.Delete();
                              }
                          }
                          else if (this.m_From != null && this.m_Item != null && !this.m_Item.Deleted)
                          {
                              this.m_From.AddToBackpack(this.m_Item);
                          }
                          break;
                      }
              }
          }
      }
  
      public class XmlSimpleGump : Gump
      {
          private readonly int m_gumptype;
          private readonly object m_invoker;
          private readonly BaseXmlSpawner.KeywordTag m_keywordtag;
          private readonly XmlGumpCallback m_gumpcallback;
          private readonly ArrayList gumpSelections = new ArrayList();
          public XmlSimpleGump(object invoker, string gumptext, string gumptitle, int gumptype, BaseXmlSpawner.KeywordTag tag, Mobile from)
              : this(invoker, gumptext, gumptitle, gumptype, tag, from, null)
          {
          }
  
          public XmlSimpleGump(object invoker, string gumptext, string gumptitle, int gumptype, BaseXmlSpawner.KeywordTag tag, Mobile from, XmlGumpCallback gumpcallback)
              : base(0, 0)
          {
              string maintext = gumptext;
              int nselections = 0;
              int height = 400;
              int width = 369;
  
              this.Closable = false;
              this.Dragable = true;
              this.m_gumptype = gumptype;
  
              this.m_invoker = invoker;
              this.m_keywordtag = tag;
              this.m_gumpcallback = gumpcallback;
  
              this.AddPage(0);
  
              // for the multiple selection gump, parse the gumptext for selections and responses
              if (gumptype == 4)
              {
                  maintext = this.ParseGumpText(gumptext);
                  nselections = this.gumpSelections.Count;
                  height = height + nselections * 40;
              }
              if (gumptype == 5)
              {
                  maintext = this.ParseGumpText(gumptext);
                  nselections = this.gumpSelections.Count;
                  // the maintext in this case is a width,height specifier so parse it
                  try
                  {
                      string[] args = maintext.Split(',');
                      width = int.Parse(args[0].Trim());
                      height = int.Parse(args[1].Trim());
                  }
                  catch
                  {
                  }
              }
  
              this.AddImageTiled(54, 33, width, height, 2624);
              this.AddAlphaRegion(54, 33, width, height);
  
              this.AddImageTiled(width + 47, 39, 44, height - 11, 203);
  
              this.AddImageTiled(58, 39, 29, height - 10, 10460); // left hand border
              this.AddImageTiled(width + 43, 37, 31, height - 11, 10460); // right hand border
  
              this.AddImageTiled(40, 38, 17, height - 9, 9263); // leftmost border
  
              //AddImageTiled( 94, 25, width - 27, 15, 10304 );  // top border
              this.AddImageTiled(40, 25, width + 48, 15, 10304);  // top border
              this.AddImageTiled(40, height + 27, width + 46, 16, 10304); // bottom border
  
              if (gumptype != 5)
              {
                  this.AddImage(width + 61, 9, 10441); // dragon borders
                  this.AddImage(6, 25, 10421);
                  this.AddImage(34, 12, 10420);
                  this.AddImage(-10, height - 86, 10402);
                  this.AddImage(56, 150, 10411);
  
                  this.AddImage(136, 84, 96); // divider
                  this.AddImage(width + 3, 57, 1417); // quest icons
                  this.AddImage(width + 12, 66, 5576);
  
                  this.AddButton(width - 31, height - 8, 2130, 2129, 3, GumpButtonType.Reply, 0); // Okay button
              }
              else
              {
                  this.AddButton(width + 70, 25, 0x138b, 0x138b, 0, GumpButtonType.Reply, 0); // closegump button
              }
  
              if (gumptitle != null && gumptitle.Length > 0 && gumptype != 5)
              { // display the title if it is there
                  this.AddImage(156, 126, 2103); // bullet
                  this.LocalAddHtml(gumptitle, 174, 121, 200, 40, 0x00FF42, false, false);
              }
  
              if (gumptype == 0)
              { // simple message gump
                  this.LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true);
              }
              else if (gumptype == 1)
              { // Yes/no type gump
                  this.AddRadio(101, height - 45, 9721, 9724, true, 1); // accept/yes radio
                  this.AddRadio(101, height - 11, 9721, 9724, false, 2); // decline/no radio
                  this.AddHtmlLocalized(137, height - 41, 200, 30, 1049016, 0x7fff, false, false); // Yes
                  this.AddHtmlLocalized(137, height - 7, 200, 30, 1049017, 0x7fff, false, false); // No
  
                  this.LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true);
              }
              else if (gumptype == 2)
              { // reply type gump
                  this.AddImageTiled(134, height - 7, 159, 23, 0x52);
                  this.AddImageTiled(135, height - 6, 157, 21, 0xBBC);
                  this.AddHtmlLocalized(105, height - 7, 200, 30, 3002006, 0x7fff, false, false); // Say:
                  this.AddTextEntry(135, height - 7, 150, 21, 0, 99, null);
  
                  this.LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true);
              }
              else if (gumptype == 3)
              { // Quest type gump
  
gt:                 this.AddImage(97, 49, 9005); // quest ribbon