Guest User

Untitled

a guest
Feb 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.33 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Collections.Specialized;
  5. using System.Text;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Drawing.Design;
  9. using System.Drawing.Drawing2D;
  10.  
  11. using Server;
  12. using Server.Gumps;
  13. using Server.Network;
  14. using Server.Commands;
  15. using Server.Mobiles;
  16.  
  17. namespace Server.AutoPVP
  18. {
  19.     public abstract class AutoPVP_UITemplateList<T> : SuperGumpList<T>
  20.     {
  21.         public const int ErrorHue = 0x22, TextHue = 0x55;
  22.         public const string HtmlFontColor = @"<BASEFONT COLOR=#8CEFD6>";
  23.  
  24.         private string _TitleLeft;
  25.         public string TitleLeft { get { return _TitleLeft; } set { _TitleLeft = value; } }
  26.  
  27.         private string _TitleRight;
  28.         public string TitleRight { get { return _TitleRight; } set { _TitleRight = value; } }
  29.  
  30.         private string _Notification;
  31.         public string Notification { get { return _Notification; } set { _Notification = value; } }
  32.  
  33.         private bool _Minimized;
  34.         public bool Minimized { get { return _Minimized; } set { _Minimized = value; } }
  35.  
  36.         private T _Selected;
  37.         public T Selected { get { return _Selected; } set { _Selected = value; } }
  38.  
  39.         public AutoPVP_UITemplateList(Gump parent, PlayerMobile user, SuperGump_Args args)
  40.             : base(new Point(100, 100), parent, user, args)
  41.         {
  42.             AddBackground(0, 0, 600, 50, 9270);
  43.             AddImageTiled(295, 10, 15, 30, 9275);
  44.  
  45.             AddLabel(20, 15, TextHue, _TitleLeft);
  46.             AddLabel(320, 15, TextHue, _TitleRight);
  47.  
  48.             if (!_Minimized)
  49.             { AddButton(295, 15, 250, 251, ToggleMinimize); }
  50.             else
  51.             {
  52.                 AddButton(295, 15, 252, 253, ToggleMinimize);
  53.                 return;
  54.             }
  55.  
  56.             AddBackground(0, 50, 600, 350, 9270);
  57.  
  58.             AddImageTiled(10, 90, 300, 5, 9277);
  59.             AddImageTiled(10, 120, 300, 5, 9277);
  60.             AddImageTiled(10, 150, 300, 5, 9277);
  61.             AddImageTiled(10, 180, 300, 5, 9277);
  62.             AddImageTiled(10, 210, 300, 5, 9277);
  63.             AddImageTiled(10, 240, 580, 5, 9277);
  64.             AddImageTiled(10, 270, 580, 5, 9277);
  65.             AddImageTiled(10, 300, 580, 5, 9277);
  66.             AddImageTiled(10, 330, 580, 5, 9277);
  67.             AddImageTiled(10, 360, 580, 5, 9277);
  68.             AddImageTiled(100, 60, 5, 330, 9275);
  69.             AddImageTiled(295, 60, 15, 330, 9275);
  70.             AddImageTiled(360, 240, 5, 150, 9275);
  71.  
  72.             AddLabel(20, 65, TextHue, AutoPVP_System.GetMessage(User, 539));
  73.             AddLabel(115, 65, TextHue, AutoPVP_System.GetMessage(User, 551));
  74.  
  75.             ForEach();
  76.  
  77.             if (Page > 0)
  78.             { AddButton(295, 60, 250, 251, ScrollUp); }
  79.             else
  80.             { AddImage(295, 60, 251); }
  81.  
  82.             int minSize = 28, maxSize = 280;
  83.             int size = maxSize / PageCount;
  84.  
  85.             if (size < minSize)
  86.             { size = minSize; }
  87.  
  88.             if (size > maxSize)
  89.             { size = maxSize; }
  90.  
  91.             int yPos = 85 + ((maxSize / PageCount) * (Page + 1)) - size;
  92.  
  93.             AddImageTiled(299, yPos, 5, size, 10742);
  94.  
  95.             if (Page + 1 < PageCount)
  96.             { AddButton(295, 367, 252, 253, ScrollDown); }
  97.             else
  98.             { AddImage(295, 367, 253); }
  99.  
  100.             AddBackground(0, 400, 600, 50, 9270);
  101.             AddLabelCropped(20, 415, 560, 20, TextHue, _Notification);
  102.  
  103.             _Notification = String.Empty;
  104.         }
  105.  
  106.         private void ToggleMinimize(GumpButton entry)
  107.         {
  108.             _Minimized = !_Minimized;
  109.             Refresh();
  110.         }
  111.  
  112.         private void ScrollUp(GumpButton entry)
  113.         { PreviousPage(); }
  114.  
  115.         private void ScrollDown(GumpButton entry)
  116.         { NextPage(); }
  117.  
  118.         public override SuperGump_Args InvalidateArgs(SuperGump_Args args)
  119.         {
  120.             if (args["title_left"] == null || !(args["title_left"] is string))
  121.             { args["title_left"] = _TitleLeft; }
  122.             else
  123.             { _TitleLeft = args.Get<string>("title_left"); }
  124.  
  125.             if (args["title_right"] == null || !(args["title_right"] is string))
  126.             { args["title_right"] = _TitleRight; }
  127.             else
  128.             { _TitleRight = args.Get<string>("title_right"); }
  129.  
  130.             if (args["notification"] == null || !(args["notification"] is string))
  131.             { args["notification"] = _Notification; }
  132.             else
  133.             { _Notification = args.Get<string>("notification"); }
  134.  
  135.             if (args["minimized"] == null || !(args["minimized"] is bool))
  136.             { args["minimized"] = _Minimized; }
  137.             else
  138.             { _Minimized = args.Get<bool>("minimized"); }
  139.  
  140.             if (args["selected"] == null || !(args["selected"] is T))
  141.             { args["selected"] = _Selected; }
  142.             else
  143.             { _Selected = args.Get<T>("selected"); }
  144.  
  145.             return base.InvalidateArgs(args);
  146.         }
  147.  
  148.         public override SuperGump Refresh(bool openIfClosed)
  149.         {
  150.             Args["title_left"] = _TitleLeft;
  151.             Args["title_right"] = _TitleRight;
  152.             Args["notification"] = _Notification;
  153.             Args["minimized"] = _Minimized;
  154.             Args["selected"] = _Selected;
  155.  
  156.             return base.Refresh(openIfClosed);
  157.         }
  158.     }
  159. }
Add Comment
Please, Sign In to add comment