Advertisement
Guest User

Untitled

a guest
May 10th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 79.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.IO;
  9.  
  10. namespace Pizza
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         #region Variable
  15.         public MapEngine miestas;
  16.         private int scrsize;
  17.         #endregion
  18.  
  19.         #region Initialization
  20.         public Form1()
  21.         {
  22.             InitializeComponent();
  23.  
  24.             Cursor myCursor = new Cursor(@"images/other/cursor.cur");
  25.             this.Cursor = myCursor;
  26.         }
  27.         #endregion
  28.  
  29.         #region Load
  30.         public void create()
  31.         {
  32.             Scr scr = new Scr();
  33.             scrsize = scr.Get();
  34.  
  35.             miestas = new MapEngine("images/images.txt", "maps/pica.txt", true, this);
  36.             miestas.Generate(new Point(50, 50), new Point(0, 0), scrsize, false);
  37.  
  38.             Gui gui = new Gui(this);
  39.  
  40.             MiniMap minimap = new MiniMap(new Point(50, Screen.PrimaryScreen.Bounds.Height - 150), new Size(miestas.matricasize * 5, miestas.matricasize * 5), this);
  41.  
  42.             Navigator navigator = new Navigator(this, miestas, new Point((50 * scrsize) + 52, 51), minimap);
  43.  
  44.             Attributs attributs = new Attributs(100, this);
  45.  
  46.             Messenger msg = new Messenger();
  47.             msg.ShowMessage("Hello!", "Game is loaded.", false);
  48.         }
  49.         #endregion
  50.  
  51.         #region test
  52.         private void Form1_Load(object sender, EventArgs e)
  53.         {
  54.             this.Size = Screen.PrimaryScreen.Bounds.Size;
  55.             this.Location = new Point(0, 0);
  56.  
  57.             /*Functions fc = new Functions();
  58.             SuperRw rw = new SuperRw();
  59.             string path = "info/users/Profas.txt";
  60.             rw.Write(fc.ChangeWord(1, 2, rw.Read(path), "only", ':'), path);*/
  61.         }
  62.  
  63.         private void Form1_Shown(object sender, EventArgs e)
  64.         {
  65.             MMeniu mmeniu = new MMeniu(this);
  66.             mmeniu.ShowMeniu();
  67.         }
  68.         #endregion
  69.     }
  70.  
  71.     class Skipper
  72.     {
  73.         #region Skipper
  74.         public Skipper() { }
  75.         ~Skipper() { }
  76.         #endregion
  77.  
  78.         #region Get
  79.         public string Get(string info, int step)
  80.         {
  81.             int skip = 0;
  82.             int instep = 1;
  83.             string buf = "";
  84.             int row = 0;
  85.  
  86.             if (step > 1)
  87.             {
  88.                 for (int i = 0; i < info.Length; i++)
  89.                 {
  90.                     if ((info[i] != '\n') && (info[i] != '\r'))
  91.                     {
  92.                         if (++skip == 3)
  93.                         {
  94.                             skip = 0;
  95.                             if (++instep == step)
  96.                             {
  97.                                 Scr scr = new Scr();
  98.  
  99.                                 row = (instep / scr.Get());
  100.  
  101.                                 if (instep % ((scr.Get()*row)+1) == 0)
  102.                                     i += 2;
  103.  
  104.                                 for (int j = 0; j < 3; j++)
  105.                                     buf += info[++i];
  106.                                 break;
  107.                             }
  108.                         }
  109.                     }
  110.                 }
  111.             }
  112.             else
  113.                 for (int i = 0; i < 3; i++)
  114.                     buf += info[i];
  115.  
  116.             return buf;
  117.         }
  118.         #endregion
  119.  
  120.         #region Set
  121.         public string Set(string data, string info, int step)
  122.         {
  123.             int skip = 0;
  124.             int instep = 1;
  125.             string buf = "";
  126.  
  127.             if (step > 1)
  128.             {
  129.                 for (int i = 0; i < info.Length; i++)
  130.                 {
  131.                     buf += info[i];
  132.  
  133.                     if ((info[i] != '\n') && (info[i] != '\r'))
  134.                     {
  135.                         if (++skip == 3)
  136.                         {
  137.                             skip = 0;
  138.                             if (++instep == step)
  139.                             {
  140.                                 if (instep == LineCount(info) + 2)
  141.                                 {
  142.                                     buf += "\r\n";
  143.                                     i += 2;
  144.                                 }
  145.  
  146.                                 buf += data;
  147.                                 i += 3;
  148.                             }
  149.                         }
  150.                     }
  151.                 }
  152.             }
  153.             else
  154.             {
  155.                 buf += data;
  156.                 for (int i = 3; i < info.Length; i++)
  157.                     buf += info[i];
  158.             }
  159.  
  160.             return buf;
  161.         }
  162.         #endregion
  163.  
  164.         #region LineCount
  165.         private int LineCount(string text)
  166.         {
  167.             int line = 0;
  168.  
  169.             for (int i = 0; i < text.Length; i++)
  170.                 if (text[i] == '\n')
  171.                     ++line;
  172.  
  173.             return line;
  174.         }
  175.         #endregion
  176.     }
  177.  
  178.     class Scr
  179.     {
  180.         #region Scr
  181.         public Scr() { }
  182.         ~Scr() { }
  183.         #endregion
  184.  
  185.         #region Get
  186.         public int Get()
  187.         {
  188.             System.Drawing.Size size = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size;
  189.  
  190.             if ((size.Width == 1280) && (size.Height == 1024))
  191.                 return 15;
  192.             else
  193.                 if ((size.Width == 1280) && (size.Height == 800))
  194.                     return 12;
  195.                 else if ((size.Width == 1440) && (size.Height == 900))
  196.                     return 14;
  197.                 else if ((size.Width == 1024) && (size.Height == 768))
  198.                     return 11;
  199.                 else if ((size.Width == 1280) && ((size.Height == 768) || (size.Height == 720)))
  200.                     return 11;
  201.                 else if ((size.Width == 800) && (size.Height == 600))
  202.                     return 8;
  203.                 else if ((size.Width == 1152) && (size.Height == 864))
  204.                     return 13;
  205.                 else
  206.                     return 10;
  207.         }
  208.         #endregion
  209.     }
  210.  
  211.     class Ranking
  212.     {
  213.         #region Variables
  214.         //public
  215.         public string[] Array = new string[0];
  216.  
  217.         //private
  218.         private int ElementCounter = 0;
  219.  
  220.         #endregion
  221.  
  222.         #region Ranking
  223.         public Ranking() { }
  224.         ~Ranking() { }
  225.         #endregion
  226.  
  227.         #region AddToArray
  228.         private void AddToArray(string Data)
  229.         {
  230.             string Element = "";
  231.             int Counter = 0;
  232.  
  233.             for (int i = 0; i < Data.Length; i++)
  234.                 if (Data[i] == '\n')
  235.                     ElementCounter++;
  236.  
  237.             Array = new string[ElementCounter];
  238.  
  239.             for (int i = 0; i < Data.Length; i++)
  240.             {
  241.                 if ((Data[i] != '\n') && (Data[i] != '\r'))
  242.                 {
  243.                     if (Data[i] != ':')
  244.                         Element += Data[i];
  245.                     else
  246.                         Element += ' ';
  247.                 }
  248.                 else
  249.                 {
  250.                     Array[Counter] = Element;
  251.                     Counter++;
  252.                     i++;
  253.                     Element = "";
  254.                 }
  255.             }
  256.         }
  257.         #endregion
  258.  
  259.         #region SortArray
  260.         private void SortArray()
  261.         {
  262.             string x;
  263.             for (int limit = Array.Length - 1; limit > 0; limit--)
  264.             {
  265.                 for (int i = 0; i < limit; i++)
  266.                 {
  267.                     if (GetScore(Array[i]) < GetScore(Array[i + 1]))
  268.                     {
  269.                         x = Array[i];
  270.                         Array[i] = Array[i + 1];
  271.                         Array[i + 1] = x;
  272.                     }
  273.                 }
  274.             }
  275.         }
  276.  
  277.         private int GetScore(string Element)
  278.         {
  279.             string Score = "";
  280.  
  281.             for (int i = 0; i < Element.Length; i++)
  282.             {
  283.                 if (Element[i] == ' ')
  284.                 {
  285.                     i++;
  286.                     while (i != Element.Length)
  287.                         Score += Element[i++];
  288.  
  289.                     break;
  290.                 }
  291.             }
  292.  
  293.             return int.Parse(Score);
  294.         }
  295.         #endregion
  296.  
  297.         #region ShowRanking
  298.         public string ShowRanking(string Data, int top, bool All)
  299.         {
  300.             string Ranking = "";
  301.  
  302.             AddToArray(Data);
  303.             SortArray();
  304.  
  305.             if (All == true)
  306.                 top = Array.Length;
  307.  
  308.             for (int i = 0; i < top; i++)
  309.                 Ranking += (i + 1).ToString() + ": " + Array[i] + ".\r\n";
  310.  
  311.             return Ranking;
  312.         }
  313.         #endregion
  314.     }
  315.  
  316.     static class Program
  317.     {
  318.         #region Main
  319.         [STAThread]
  320.         static void Main()
  321.         {
  322.             Application.EnableVisualStyles();
  323.             Application.SetCompatibleTextRenderingDefault(false);
  324.             Application.Run(new Form1());
  325.         }
  326.         #endregion
  327.     }
  328.  
  329.     class Objector
  330.     {
  331.         #region Objector
  332.         public Objector() { }
  333.         ~Objector() { }
  334.         #endregion
  335.  
  336.         #region PictureBox
  337.         public PictureBox OPictureBox(Point location, Image image)
  338.         {
  339.             try
  340.             {
  341.                 PictureBox img = new PictureBox();
  342.                 img.Image = image;
  343.                 img.Location = location;
  344.                 img.Size = img.Image.Size;
  345.  
  346.                 return img;
  347.             }
  348.             catch { return null; }
  349.         }
  350.         #endregion
  351.  
  352.         #region Form
  353.         public Form OForm(Point location, Size size, bool border)
  354.         {
  355.             try
  356.             {
  357.                 Form form = new Form();
  358.  
  359.                 if (border != true)
  360.                     form.FormBorderStyle = FormBorderStyle.None;
  361.  
  362.                 form.Size = size;
  363.                 form.StartPosition = FormStartPosition.Manual;
  364.                 form.Location = location;
  365.  
  366.                 return form;
  367.             }
  368.             catch { return null; }
  369.         }
  370.         #endregion
  371.  
  372.         #region Label
  373.         public Label OLabel(Point location, Color backcolor, string text)
  374.         {
  375.             try
  376.             {
  377.                 Label label = new Label();
  378.                 label.Text = text;
  379.                 label.Location = location;
  380.                 label.BackColor = backcolor;
  381.  
  382.                 return label;
  383.             }
  384.             catch { return null; }
  385.         }
  386.         #endregion
  387.  
  388.         #region Textbox
  389.         public TextBox OTextBox(Point location, int width, BorderStyle borderstyle)
  390.         {
  391.             try
  392.             {
  393.                 TextBox textbox = new TextBox();
  394.                 textbox.Width = width;
  395.                 textbox.Location = location;
  396.                 textbox.BorderStyle = borderstyle;
  397.  
  398.                 return textbox;
  399.             }
  400.             catch { return null; }
  401.         }
  402.         #endregion
  403.  
  404.         #region GroupBox
  405.         public GroupBox OGroupBox(Point location, Size size, string text)
  406.         {
  407.             try
  408.             {
  409.                 GroupBox groupbox = new GroupBox();
  410.                 groupbox.Location = location;
  411.                 groupbox.Size = size;
  412.                 groupbox.Text = text;
  413.  
  414.                 return groupbox;
  415.             }
  416.             catch { return null; }
  417.         }
  418.         #endregion
  419.  
  420.         #region Panel
  421.         public Panel OPanel(Point location, Size size, Color color)
  422.         {
  423.             try
  424.             {
  425.                 Panel panel = new Panel();
  426.                 panel.Location = location;
  427.                 panel.Size = size;
  428.                 panel.BackColor = color;
  429.  
  430.                 return panel;
  431.             }
  432.             catch { return null; }
  433.         }
  434.         #endregion
  435.  
  436.         #region ListBox
  437.         public ListBox OListBox(Point location, Size size, Color color)
  438.         {
  439.             try
  440.             {
  441.                 ListBox listbox = new ListBox();
  442.                 listbox.Location = location;
  443.                 listbox.Size = size;
  444.                 listbox.BackColor = color;
  445.  
  446.                 return listbox;
  447.             }
  448.             catch { return null; }
  449.         }
  450.         #endregion
  451.     }
  452.  
  453.     class SuperRw
  454.     {
  455.         #region SuperRw
  456.         public SuperRw() { }
  457.         ~SuperRw() { }
  458.         #endregion
  459.  
  460.         #region Read
  461.         public string Read(string file)
  462.         {
  463.             FileStream rfile = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Read);
  464.             StreamReader read = new StreamReader(rfile);
  465.             string info = read.ReadToEnd();
  466.             read.Close();
  467.             rfile.Close();
  468.  
  469.             return info;
  470.         }
  471.         #endregion
  472.  
  473.         #region Write
  474.         public void Write(string info, string file)
  475.         {
  476.             FileStream wfile = new FileStream(@file, FileMode.Create, FileAccess.Write);
  477.             StreamWriter write = new StreamWriter(wfile);
  478.             write.Write(info);
  479.             write.Close();
  480.             wfile.Close();
  481.         }
  482.         #endregion
  483.  
  484.         #region FLineRead
  485.         public string FLineRead(string file, int line)
  486.         {
  487.             string info = Read(file);
  488.             string buf = "";
  489.             int ln = 0;
  490.  
  491.             for (int i = 0; i < info.Length; i++)
  492.             {
  493.                 if (info[i] == '\n')
  494.                     ln++;
  495.  
  496.                 if (line == ln)
  497.                 {
  498.                     if (line != 0)
  499.                         ++i;
  500.  
  501.                     while ((i != info.Length) && (info[i] != '\n'))
  502.                         if (info[i++] != '\r')
  503.                             buf += info[i - 1];
  504.  
  505.                     break;
  506.                 }
  507.             }
  508.  
  509.             return buf;
  510.         }
  511.         #endregion
  512.     }
  513.  
  514.     class Navigator
  515.     {
  516.         #region Variable
  517.         private Functions fc = new Functions();
  518.         private MapEngine map;
  519.         private MiniMap mmap;
  520.         private Point location;
  521.         private Label label;
  522.         private int left;
  523.         private int top;
  524.         private int size;
  525.         private int step;
  526.         #endregion
  527.  
  528.         #region Navigator
  529.         public Navigator(Form form, MapEngine Emap, Point start, MiniMap minimap)
  530.         {
  531.             step = 3;
  532.             map = Emap;
  533.             mmap = minimap;
  534.             left = 0;
  535.             top = 0;
  536.             size = map.mapsize;
  537.             location = start;
  538.  
  539.             Objector obj = new Objector();
  540.  
  541.             PictureBox img = obj.OPictureBox(start, Image.FromFile(@"images/other/navigator.bmp"));
  542.             img.Click += new EventHandler(img_Click);
  543.  
  544.             label = obj.OLabel(new Point(img.Left + 2, img.Top + 163), Color.FromArgb(33, 53, 139), "Step Size: 1");
  545.             label.Width = 85;
  546.             label.Font = new Font("Tahoma", 11);
  547.             label.Text = "Step Size: " + step.ToString();
  548.             label.ForeColor = Color.LightGray;
  549.  
  550.             Label title = obj.OLabel(new Point(start.X + 5, start.Y + 5), Color.FromArgb(13, 31, 107), "Map Navigator");
  551.             title.Size = new Size(150, 20);
  552.             title.ForeColor = Color.White;
  553.             title.Font = new Font("Tahoma", 12);
  554.  
  555.             form.Controls.Add(title);
  556.             form.Controls.Add(img);
  557.             form.Controls.Add(label);
  558.             label.BringToFront();
  559.             title.BringToFront();
  560.         }
  561.         ~Navigator() { }
  562.         #endregion
  563.  
  564.         #region Events
  565.         private void img_Click(object sender, EventArgs e)
  566.         {
  567.             // UP
  568.             if (fc.PosCheck(Cursor.Position, new Point(65 + location.X, 35 + location.Y), new Point(95 + location.X, 80 + location.Y)) == true)
  569.                 if (top - (step - 1) > 0)
  570.                 {
  571.                     map.Generate(new Point(50, 50), new Point(left, top -= step), size, true);
  572.                     mmap.locon.Top -= step * 5;
  573.                 }
  574.                 else
  575.                 {
  576.                     map.Generate(new Point(50, 50), new Point(left, top = 0), size, true);
  577.                     mmap.locon.Top = mmap.maxLEFTTOP.Y;
  578.                 }
  579.             else
  580.  
  581.                 // DOWN
  582.                 if (fc.PosCheck(Cursor.Position, new Point(60 + location.X, 105 + location.Y), new Point(100 + location.X, 150 + location.Y)) == true)
  583.                     if ((map.mapsize + top) + (step - 1) < map.matricasize)
  584.                     {
  585.                         map.Generate(new Point(50, 50), new Point(left, top += step), size, true);
  586.                         mmap.locon.Top += step * 5;
  587.                     }
  588.                     else
  589.                     {
  590.                         map.Generate(new Point(50, 50), new Point(left, top = (map.matricasize - map.mapsize)), size, true);
  591.                         mmap.locon.Top = mmap.maxRIGHTDOWN.Y;
  592.                     }
  593.                 else
  594.  
  595.                     // RIGHT
  596.                     if (fc.PosCheck(Cursor.Position, new Point(100 + location.X, 75 + location.Y), new Point(150 + location.X, 110 + location.Y)) == true)
  597.                         if ((map.mapsize + left) + (step - 1) < map.matricasize)
  598.                         {
  599.                             map.Generate(new Point(50, 50), new Point(left += step, top), size, true);
  600.                             mmap.locon.Left += step * 5;
  601.                         }
  602.                         else
  603.                         {
  604.                             map.Generate(new Point(50, 50), new Point(left = (map.matricasize - map.mapsize), top), size, true);
  605.                             mmap.locon.Left = mmap.maxRIGHTDOWN.X;
  606.                         }
  607.                     else
  608.  
  609.                         // LEFT
  610.                         if (fc.PosCheck(Cursor.Position, new Point(10 + location.X, 75 + location.Y), new Point(60 + location.X, 110 + location.Y)) == true)
  611.                             if (left - (step - 1) > 0)
  612.                             {
  613.                                 map.Generate(new Point(50, 50), new Point(left -= step, top), size, true);
  614.                                 mmap.locon.Left -= step * 5;
  615.                             }
  616.                             else
  617.                             {
  618.                                 map.Generate(new Point(50, 50), new Point(left = 0, top), size, true);
  619.                                 mmap.locon.Left = mmap.maxLEFTTOP.X;
  620.                             }
  621.                         else
  622.  
  623.                             // MINUS
  624.                             if (fc.PosCheck(Cursor.Position, new Point(85 + location.X, 165 + location.Y), new Point(115 + location.X, 180 + location.Y)) == true)
  625.                                 if (step > 1)
  626.                                     label.Text = "Step Size: " + (--step).ToString();
  627.                                 else { }
  628.                             else
  629.  
  630.                                 // PLUS
  631.                                 if (fc.PosCheck(Cursor.Position, new Point(120 + location.X, 160 + location.Y), new Point(145 + location.X, 180 + location.Y)) == true)
  632.                                     if (step < 5)
  633.                                         label.Text = "Step Size: " + (++step).ToString();
  634.         }
  635.         #endregion
  636.     }
  637.  
  638.     #region State
  639.     public enum State
  640.     {
  641.         Normal = 0,
  642.         Pressed
  643.     }
  644.     #endregion
  645.  
  646.     #region MouseState
  647.     class MouseState
  648.     {
  649.         public MouseState()
  650.         {
  651.         }
  652.     }
  653.     #endregion
  654.  
  655.     class MiniMap
  656.     {
  657.         #region Variable
  658.         public PictureBox locon;
  659.         public Point maxLEFTTOP;
  660.         public Point maxRIGHTDOWN;
  661.         #endregion
  662.  
  663.         #region MiniMap
  664.         public MiniMap(Point start, Size size, Form form)
  665.         {
  666.             Objector obj = new Objector();
  667.             Scr scr = new Scr();
  668.  
  669.             PictureBox win = obj.OPictureBox(start, Image.FromFile(@"images/other/minimap/minimap.bmp"));
  670.             form.Controls.Add(win);
  671.             win.BringToFront();
  672.  
  673.             PictureBox loc = obj.OPictureBox(new Point(start.X + 11, start.Y + 17), Image.FromFile(@"images/other/minimap/loc.bmp"));
  674.             loc.Size = size;
  675.             loc.BackgroundImage = loc.Image;
  676.             form.Controls.Add(loc);
  677.             loc.BringToFront();
  678.  
  679.             locon = obj.OPictureBox(new Point(start.X + 11, start.Y + 17), Image.FromFile(@"images/other/minimap/locon.bmp"));
  680.             locon.Size = new Size(scr.Get() * 5, scr.Get() * 5);
  681.             locon.BackgroundImage = locon.Image;
  682.             form.Controls.Add(locon);
  683.             locon.BringToFront();
  684.  
  685.             maxLEFTTOP = new Point(start.X + 11, start.Y + 17);
  686.             maxRIGHTDOWN = new Point((start.X + 11 + loc.Width) - (scr.Get() * 5), (start.Y + 17 + loc.Height) - (scr.Get() * 5));
  687.         }
  688.         ~MiniMap() { }
  689.         #endregion
  690.     }
  691.  
  692.     class Messenger
  693.     {
  694.         #region Variable
  695.         public bool UsersResult;
  696.         private Form Forma;
  697.         private PictureBox[] PicArray = new PictureBox[4];
  698.         private Label[] Labels = new Label[5];
  699.         private Objector obj = new Objector();
  700.         #endregion
  701.  
  702.         #region Messenger
  703.         public Messenger() { }
  704.         ~Messenger() { }
  705.         #endregion
  706.  
  707.         #region ShowMessage
  708.         public void ShowMessage(string Title, string Text, Boolean YesNo)
  709.         {
  710.             for (int i = 0; i < 5; i++)
  711.                 Labels[i] = new Label();
  712.  
  713.             Forma = obj.OForm(new Point((Screen.PrimaryScreen.Bounds.Width / 2) - 150, (Screen.PrimaryScreen.Bounds.Height / 2) - 80), new Size(300, 160), false);
  714.             Forma.FormBorderStyle = FormBorderStyle.None;
  715.  
  716.             Cursor myCursor = new Cursor(@"images/other/cursor.cur");
  717.             Forma.Cursor = myCursor;
  718.  
  719.             PicArray[0] = obj.OPictureBox(new Point(0, 0), Image.FromFile(@"images/msg/left_1.bmp"));
  720.             Forma.Controls.Add(PicArray[0]);
  721.  
  722.             PicArray[1] = obj.OPictureBox(new Point(25, 0), Image.FromFile(@"images/msg/middle.bmp"));
  723.             PicArray[1].BackgroundImage = PicArray[1].Image;
  724.             PicArray[1].Width = 300 - 50;
  725.             Forma.Controls.Add(PicArray[1]);
  726.  
  727.             PicArray[2] = obj.OPictureBox(new Point(275, 0), Image.FromFile(@"images/msg/right_1.bmp"));
  728.             Forma.Controls.Add(PicArray[2]);
  729.             PicArray[2].Click += new EventHandler(Pic_Click);
  730.  
  731.             Labels[0] = obj.OLabel(new Point(3, 4), Color.FromArgb(49, 75, 108), Title);
  732.             SetStyle(Labels[0], false);
  733.             Labels[0].Size = new Size(250, 20);
  734.             Labels[0].TextAlign = ContentAlignment.MiddleLeft;
  735.  
  736.             string TextCorrect = "";
  737.  
  738.             if (Text.Length < 29)
  739.                 TextCorrect = Text;
  740.             else
  741.             {
  742.                 int i;
  743.                 for (i = 0; i <= 20; i++)
  744.                     TextCorrect += Text[i];
  745.  
  746.                 while ((i != Text.Length) && (Text[i] != ' '))
  747.                     TextCorrect += Text[i++];
  748.  
  749.                 TextCorrect += "\n";
  750.                 i++;
  751.  
  752.                 while (i < Text.Length)
  753.                     TextCorrect += Text[i++];
  754.             }
  755.  
  756.             Labels[1] = obj.OLabel(new Point(5, 55), Color.FromArgb(49, 75, 108), TextCorrect);
  757.             SetStyle(Labels[1], false);
  758.             Labels[1].Size = new Size(Forma.Width - 10, 50);
  759.  
  760.             if (YesNo == false)
  761.             {
  762.                 Labels[2] = obj.OLabel(new Point((Forma.Width - Labels[2].Width + 50) / 2, 120), Color.FromArgb(49, 75, 108), "OK");
  763.                 Labels[2].Click += new EventHandler(labels2_Click);
  764.                 SetStyle(Labels[2], true);
  765.             }
  766.             else
  767.             {
  768.                 Labels[2] = obj.OLabel(new Point(((Forma.Width - Labels[2].Width + 50) / 2) - 30, 120), Color.FromArgb(49, 75, 108), "Yes");
  769.                 Labels[2].Click += new EventHandler(labels2_Click);
  770.                 SetStyle(Labels[2], true);
  771.  
  772.                 Labels[3] = obj.OLabel(new Point(((Forma.Width - Labels[3].Width + 50) / 2) + 30, 120), Color.FromArgb(49, 75, 108), "No");
  773.                 Labels[3].Click += new EventHandler(labels3_Click);
  774.                 SetStyle(Labels[3], true);
  775.             }
  776.  
  777.             Forma.ShowDialog();
  778.         }
  779.  
  780.         #endregion
  781.  
  782.         #region SetStyle
  783.         private void SetStyle(object sender, bool board)
  784.         {
  785.             Label get = (sender as Label);
  786.             if (board == true)
  787.                 get.BorderStyle = BorderStyle.FixedSingle;
  788.             get.Size = new Size(40, 25);
  789.             get.Font = new Font("Comic Sans MS", 11F, FontStyle.Bold, GraphicsUnit.Point, ((System.Byte)(0)));
  790.             get.TextAlign = ContentAlignment.MiddleCenter;
  791.             Forma.Controls.Add(get);
  792.             get.BringToFront();
  793.         }
  794.         #endregion
  795.  
  796.         #region Events
  797.         void Pic_Click(object sender, EventArgs e)
  798.         {
  799.             Functions fc = new Functions();
  800.  
  801.             if (fc.PosCheck(new Point(Cursor.Position.X - Forma.Location.X, Cursor.Position.Y - Forma.Location.Y), new Point(275, 0), new Point(300, 25)) == true)
  802.             {
  803.                 UsersResult = false;
  804.                 Forma.Close();
  805.             }
  806.         }
  807.  
  808.         void labels2_Click(object sender, EventArgs e)
  809.         {
  810.             UsersResult = true;
  811.             Forma.Close();
  812.         }
  813.  
  814.         void labels3_Click(object sender, EventArgs e)
  815.         {
  816.             UsersResult = false;
  817.             Forma.Close();
  818.         }
  819.         #endregion
  820.     }
  821.  
  822.     class InfoBox
  823.     {
  824.         #region Variable
  825.         private Form form;
  826.         public Label text;
  827.         #endregion
  828.  
  829.         #region InfoBox
  830.         public InfoBox(Point start, Form forma)
  831.         {
  832.             form = forma;
  833.  
  834.             //gui
  835.             Objector obj = new Objector();
  836.             PictureBox[] box = new PictureBox[3];
  837.             box[0] = obj.OPictureBox(start, Image.FromFile(@"images\infobox\left_1.bmp"));
  838.             box[1] = obj.OPictureBox(new Point(start.X+25,start.Y), Image.FromFile(@"images\infobox\middle.bmp"));
  839.             box[1].Width = 300;
  840.             box[1].BackgroundImageLayout = ImageLayout.Tile;
  841.             box[1].BackgroundImage = box[1].Image;
  842.             box[2] = obj.OPictureBox(new Point(start.X+325,start.Y), Image.FromFile(@"images\infobox\right_1.bmp"));
  843.  
  844.             for (int i = 0; i < 3; i++)
  845.             {
  846.                 form.Controls.Add(box[i]);
  847.                 box[i].BringToFront();
  848.             }
  849.  
  850.             Label label = obj.OLabel(new Point(start.X + 5, start.Y + 5), Color.FromArgb(13, 31, 107), "Info Box");
  851.             label.Height = 20;
  852.             label.ForeColor = Color.White;
  853.             label.Font = new Font("Tahoma", 12);
  854.             form.Controls.Add(label);
  855.             label.BringToFront();
  856.  
  857.             text = obj.OLabel(new Point(start.X + 10, start.Y + 30), Color.FromArgb(33, 53, 139), "Click on the map! For more information.");
  858.             text.Size = new Size(330, 168);
  859.             text.ForeColor = Color.LightGray;
  860.             text.Font = new Font("Tahoma", 9);
  861.             form.Controls.Add(text);
  862.             text.BringToFront();
  863.  
  864.         }
  865.         ~InfoBox() { }
  866.         #endregion
  867.     }
  868.  
  869.     class Gui
  870.     {
  871.         #region Variable
  872.         private Form form;
  873.         private Objector obj = new Objector();
  874.         private int scrW;
  875.         private int scrH;
  876.         #endregion
  877.  
  878.         #region GUI
  879.         public Gui(Form forma)
  880.         {
  881.             form = forma;
  882.             scrW = Screen.PrimaryScreen.Bounds.Width;
  883.             scrH = Screen.PrimaryScreen.Bounds.Height;
  884.  
  885.             Top();
  886.             Left();
  887.             Down();
  888.             Right();
  889.         }
  890.         #endregion
  891.  
  892.         #region Top
  893.         private void Top()
  894.         {
  895.             PictureBox[] top = new PictureBox[2];
  896.  
  897.             top[1] = obj.OPictureBox(new Point(scrW, 0), Image.FromFile(@"images/gui/top_3.jpg"));
  898.             top[1].Left -= top[1].Image.Width;
  899.             top[0] = obj.OPictureBox(new Point(0, 0), Image.FromFile(@"images/gui/top_2.jpg"));
  900.             top[0].BackgroundImage = top[0].Image;
  901.             top[0].Width = scrW - (top[1].Image.Width);
  902.             top[1].Click +=new EventHandler(top_Click);
  903.  
  904.             for (int i = 0; i < 2; i++)
  905.                 form.Controls.Add(top[i]);
  906.  
  907.             Label label = obj.OLabel(new Point(15, 14), Color.FromArgb(22, 78, 133), "The Pizza - Serious Business");
  908.             label.Font = new Font("Tahoma", 15);
  909.             label.ForeColor = Color.White;
  910.             label.Width = 400;
  911.             form.Controls.Add(label);
  912.             label.BringToFront();
  913.         }
  914.         #endregion
  915.  
  916.         #region Left
  917.         private void Left()
  918.         {
  919.             PictureBox left = obj.OPictureBox(new Point(0, 50), Image.FromFile(@"images/gui/left_1.jpg"));
  920.             left.BackgroundImage = left.Image;
  921.             left.Height = scrH - (50 + 150);
  922.             left.Top = 50;
  923.  
  924.             form.Controls.Add(left);
  925.         }
  926.         #endregion
  927.  
  928.         #region Down
  929.         private void Down()
  930.         {
  931.             PictureBox down = obj.OPictureBox(new Point(0, scrH), Image.FromFile(@"images/gui/down_1.jpg"));
  932.             down.Top -= down.Height;
  933.             down.BackgroundImage = down.Image;
  934.             down.Width = scrW;
  935.            
  936.             form.Controls.Add(down);
  937.         }
  938.         #endregion
  939.  
  940.         #region Right
  941.         private void Right()
  942.         {
  943.             PictureBox right = obj.OPictureBox(new Point(scrW - 50, 50), Image.FromFile(@"images/gui/right_1.jpg"));
  944.             right.BackgroundImage = right.Image;
  945.             right.Height = scrH - (50 + 150);
  946.  
  947.             form.Controls.Add(right);
  948.         }
  949.         #endregion
  950.  
  951.         #region Events
  952.         private void top_Click(object sender, EventArgs e)
  953.         {
  954.             PictureBox img = (sender as PictureBox);
  955.  
  956.             Functions fc = new Functions();
  957.  
  958.             if (fc.PosCheck(Cursor.Position, new Point(scrW - img.Width, 0), img.Location + img.Size) == true)
  959.                 form.Close();
  960.         }
  961.         #endregion
  962.     }
  963.  
  964.     class Functions
  965.     {
  966.         #region Functions
  967.         public Functions()
  968.         { }
  969.         ~Functions() { }
  970.         #endregion
  971.  
  972.         #region ReadWord
  973.         public string ReadWord(int line, int word, string text, char sign, bool only_line)
  974.         {
  975.             string buf = "";
  976.             string text_line = "";
  977.             int line_nr = 0;
  978.             int sign_nr = 1;
  979.             bool end = false;
  980.  
  981.             --line;
  982.             if (word > 0)
  983.             {
  984.                 for (int i = 0; i < text.Length; i++)
  985.                 {
  986.                     if (line != 0)
  987.                     {
  988.                         if (text[i] == '\n')
  989.                             line_nr++;
  990.                         else
  991.                             continue;
  992.  
  993.                         if (line_nr == line)
  994.                         {
  995.                             ++i;
  996.                             while ((i != text.Length) && (text[i] != '\n') && (text[i] != '\r'))
  997.                                 text_line += text[i++];
  998.  
  999.                             if (only_line != false)
  1000.                                 return text_line;
  1001.  
  1002.                             break;
  1003.                         }
  1004.                     }
  1005.                     else
  1006.                     {
  1007.                         while ((i != text.Length) && (text[i] != '\n') && (text[i] != '\r'))
  1008.                             text_line += text[i++];
  1009.  
  1010.                         if (only_line != false)
  1011.                             return text_line;
  1012.  
  1013.                         break;
  1014.                     }
  1015.                 }
  1016.  
  1017.                 for (int i = 0; i < text_line.Length; i++)
  1018.                 {
  1019.                     if (word == 1)
  1020.                     {
  1021.                         while ((i != text_line.Length) && (text_line[i] != sign) && (text[i] != '\n') && (text[i] != '\r'))
  1022.                             buf += text_line[i++];
  1023.  
  1024.                         return buf;
  1025.                     }
  1026.  
  1027.                     else
  1028.                     {
  1029.                         for (int j = 0; j < text_line.Length; j++)
  1030.                         {
  1031.                             while (sign_nr != word)
  1032.                                 if (text_line[j++] == sign)
  1033.                                     sign_nr++;
  1034.  
  1035.                             while ((j != text_line.Length) && (text_line[j] != '\n') && (text_line[j] != sign))
  1036.                                 buf += text_line[j++];
  1037.  
  1038.                             end = true;
  1039.  
  1040.                             if (end == true)
  1041.                                 break;
  1042.                         }
  1043.                     }
  1044.                     if (end == true)
  1045.                         break;
  1046.                 }
  1047.             }
  1048.             else
  1049.                 return null;
  1050.  
  1051.             if (buf != "")
  1052.                 return buf;
  1053.             else
  1054.                 return null;
  1055.         }
  1056.         #endregion
  1057.  
  1058.         #region ChangeWord
  1059.         public string ChangeWord(int line, int word, string text, string newWord, char sign)
  1060.         {
  1061.             string buf = "";
  1062.             string text_line = "";
  1063.             int line_nr = 0;
  1064.             int sign_nr = 1;
  1065.             bool end = false;
  1066.  
  1067.             --line;
  1068.             if (word > 0)
  1069.             {
  1070.                 for (int i = 0; i < text.Length; i++)
  1071.                 {
  1072.                     if (line != 0)
  1073.                     {
  1074.                         if (text[i] == '\n')
  1075.                             line_nr++;
  1076.                         else
  1077.                             continue;
  1078.  
  1079.                         if (line_nr == line)
  1080.                         {
  1081.                             ++i;
  1082.                             while ((i != text.Length) && (text[i] != '\n') && (text[i] != '\r'))
  1083.                                 text_line += text[i++];
  1084.  
  1085.                             break;
  1086.                         }
  1087.                     }
  1088.                     else
  1089.                     {
  1090.                         while ((i != text.Length) && (text[i] != '\n') && (text[i] != '\r'))
  1091.                             text_line += text[i++];
  1092.  
  1093.                         break;
  1094.                     }
  1095.                 }
  1096.  
  1097.                 for (int i = 0; i < text_line.Length; i++)
  1098.                 {
  1099.                     if (word == 1)
  1100.                     {
  1101.                         while (text_line[i] != sign)
  1102.                             i++;
  1103.  
  1104.                         while ((i != text_line.Length) && (text_line[i] != '\n'))
  1105.                             buf += text_line[i++];
  1106.  
  1107.                         buf = newWord + buf;
  1108.                     }
  1109.                     else
  1110.                     {
  1111.                         for (int j = 0; j < text_line.Length; j++)
  1112.                         {
  1113.                             while (sign_nr != word)
  1114.                             {
  1115.                                 buf += text_line[j];
  1116.                                 if (text_line[j++] == sign)
  1117.                                     sign_nr++;
  1118.                             }
  1119.  
  1120.                             buf += newWord;
  1121.  
  1122.                             while ((j != text_line.Length) && (text_line[j] != '\n') && (text_line[j] != sign))
  1123.                                 j++;
  1124.  
  1125.                             while (j != text_line.Length)
  1126.                                 buf += text_line[j++];
  1127.  
  1128.                             end = true;
  1129.  
  1130.                             if (end != false)
  1131.                                 break;
  1132.                         }
  1133.                     }
  1134.                     if (end != false)
  1135.                         break;
  1136.                 }
  1137.             }
  1138.             else
  1139.                 return null;
  1140.  
  1141.             int curline = 0;
  1142.             string all = "";
  1143.  
  1144.             for (int i = 0; i < text.Length; i++)
  1145.             {
  1146.                 if (text[i] == '\n')
  1147.                     curline++;
  1148.  
  1149.                 if (curline == line_nr)
  1150.                 {
  1151.                     all += buf;
  1152.  
  1153.                     while ((++i != text.Length) && (text[i] != '\n'))
  1154.                         continue;
  1155.  
  1156.                     while (i != text.Length)
  1157.                         all += text[i++];
  1158.  
  1159.                     break;
  1160.                 }
  1161.  
  1162.                 all += text[i];
  1163.             }
  1164.  
  1165.             if (all != "")
  1166.                 return all;
  1167.             else
  1168.                 return null;
  1169.         }
  1170.         #endregion
  1171.  
  1172.         #region PosCheck
  1173.         public bool PosCheck(System.Drawing.Point cur, System.Drawing.Point field, System.Drawing.Point fieldmax)
  1174.         {
  1175.  
  1176.             if ((cur.X > field.X) && (cur.X < fieldmax.X))
  1177.                 if ((cur.Y > field.Y) && (cur.Y < fieldmax.Y))
  1178.                     return true;
  1179.                 else
  1180.                     return false;
  1181.             else
  1182.                 return false;
  1183.         }
  1184.         #endregion
  1185.  
  1186.         #region LineCount
  1187.         public int LineCount(string text)
  1188.         {
  1189.             int line = 0;
  1190.  
  1191.             for (int i = 0; i < text.Length; i++)
  1192.                 if (text[i] == '\n')
  1193.                     ++line;
  1194.  
  1195.             return line;
  1196.         }
  1197.         #endregion
  1198.     }
  1199.  
  1200.     class Coder
  1201.     {
  1202.         #region Coder
  1203.         public Coder() { }
  1204.         ~Coder() { }
  1205.         #endregion
  1206.  
  1207.         #region ToCode
  1208.         public string ToCode(string SourceData)
  1209.         {
  1210.             int charASCII;
  1211.             int Step;
  1212.             string Data;
  1213.             string CodedData = "";
  1214.             Data = SourceData;
  1215.  
  1216.             for (int i = 0; i < Data.Length;i++)
  1217.             {
  1218.                 if ((Data[i] == '\n') || (Data[i] == '\r'))
  1219.                 {
  1220.                     CodedData = CodedData + Data[i];
  1221.                     continue;
  1222.                 }
  1223.  
  1224.                 charASCII = (int)Data[i];
  1225.                 Step = ((((Data.Length + i) % 7) * 52) % 92) + 33;
  1226.  
  1227.                 if (charASCII + Step > 126)
  1228.                 {
  1229.                     Step = Step - (126 - charASCII);
  1230.                     charASCII = Step + 33;
  1231.                 }
  1232.                 else
  1233.                     charASCII = charASCII + Step;
  1234.  
  1235.                 CodedData = CodedData + Convert.ToChar(charASCII);
  1236.             }
  1237.  
  1238.             return CodedData;
  1239.         }
  1240.         #endregion
  1241.  
  1242.         #region UnCode
  1243.         public string UnCode(string SourceData)
  1244.         {
  1245.             int charASCII;
  1246.             int Step;
  1247.             string Data;
  1248.             string UnCodedData = "";
  1249.             Data = SourceData;
  1250.  
  1251.             for (int i = 0; i < Data.Length; i++)
  1252.             {
  1253.                 if ((Data[i] == '\n') || (Data[i] == '\r'))
  1254.                 {
  1255.                     UnCodedData = UnCodedData + Data[i];
  1256.                     continue;
  1257.                 }
  1258.  
  1259.                 charASCII = (int)Data[i];
  1260.                 Step = ((((Data.Length + i) % 7) * 52) % 92) + 33;
  1261.  
  1262.                 if (charASCII - Step < 33)
  1263.                 {
  1264.                     Step = Step - charASCII;
  1265.                     charASCII = 126 - Step - 33;
  1266.                 }
  1267.                 else
  1268.                     charASCII = charASCII - Step;
  1269.  
  1270.                 UnCodedData = UnCodedData + Convert.ToChar(charASCII);
  1271.             }
  1272.  
  1273.             return UnCodedData;
  1274.         }
  1275.         #endregion
  1276.     }
  1277.  
  1278.     class PopMeniu
  1279.     {
  1280.         #region Variable
  1281.         private const int buttons = 5;
  1282.         private Label[] pop = new Label[buttons];
  1283.         private Form1 form;
  1284.         private int time;
  1285.         private Timer hide = new Timer();
  1286.         private MapEngine _engine;
  1287.         #endregion
  1288.  
  1289.         #region PopMeniu
  1290.         public PopMeniu(Form1 forma, MapEngine engine)
  1291.         {
  1292.             form = forma;
  1293.             _engine = engine;
  1294.  
  1295.             Objector obj = new Objector();
  1296.             string[] names = new string[buttons] { "    MENIU", "Create", "Delete", "Information", "Close" };
  1297.  
  1298.             for (int i = 0; i < buttons; i++)
  1299.             {
  1300.                 pop[i] = obj.OLabel(new Point(Cursor.Position.X, Cursor.Position.Y +(i*20)), Color.LightCoral, names[i]);
  1301.                 pop[i].Font = new Font("Tahoma", 12);
  1302.                 pop[i].Tag = i;
  1303.                 pop[i].BorderStyle = BorderStyle.FixedSingle;
  1304.                 pop[i].MouseEnter +=new EventHandler(pop_enter);
  1305.                 pop[i].MouseLeave +=new EventHandler(pop_leave);
  1306.                 form.Controls.Add(pop[i]);
  1307.                 pop[i].BringToFront();
  1308.             }    
  1309.  
  1310.             pop[4].MouseClick +=new MouseEventHandler(close_click);
  1311.             pop[1].MouseClick +=new MouseEventHandler(create_click);
  1312.  
  1313.             pop[0].BackColor = Color.Black;
  1314.             pop[0].ForeColor = Color.White;
  1315.  
  1316.             Timer hide = new Timer();
  1317.             hide.Interval = 800;
  1318.             hide.Tick +=new EventHandler(hide_Tick);
  1319.             hide.Enabled = true;
  1320.         }
  1321.         ~PopMeniu() { }
  1322.         #endregion
  1323.  
  1324.         #region Clear
  1325.         private void Clear()
  1326.         {
  1327.             for (int i = 0; i < buttons; i++)
  1328.             {
  1329.                 form.Controls.Remove(pop[i]);
  1330.                 pop[i] = null;
  1331.             }
  1332.  
  1333.             hide = null;
  1334.  
  1335.             GC.Collect();
  1336.         }
  1337.         #endregion
  1338.  
  1339.         #region Events
  1340.         //Hover
  1341.         private void pop_enter(object sender, EventArgs e)
  1342.         {
  1343.             if ((sender as Label).Tag.ToString() != "0")
  1344.                 (sender as Label).BackColor = Color.LightGray;
  1345.         }
  1346.         private void pop_leave(object sender, EventArgs e)
  1347.         {
  1348.             if ((sender as Label).Tag.ToString() != "0")
  1349.                 (sender as Label).BackColor = Color.LightCoral;
  1350.         }
  1351.  
  1352.         //Click
  1353.         private void close_click(object sender, MouseEventArgs e)
  1354.         {
  1355.             Clear();
  1356.         }
  1357.         private void create_click(object sender, MouseEventArgs e)
  1358.         {
  1359.             BuySystem buysystem = new BuySystem(form, _engine);
  1360.             Clear();
  1361.         }
  1362.  
  1363.         //Tick
  1364.         private void hide_Tick(object sender, EventArgs e)
  1365.         {
  1366.             if(time++==2)
  1367.             {
  1368.                 Clear();
  1369.                 (sender as Timer).Enabled = false;
  1370.                 (sender as Timer).Dispose();
  1371.             }
  1372.         }
  1373.         #endregion
  1374.     }
  1375.  
  1376.     public partial class MapEngine
  1377.     {
  1378.         #region Variable
  1379.         //private
  1380.         private Objector obj = new Objector();
  1381.         private Form1 form;
  1382.         private PictureBox locator;
  1383.         private string mapinfo;
  1384.         private string _mapinfo;
  1385.         private string listinfo;
  1386.         private Functions fc = new Functions();
  1387.         private InfoBox infobox;
  1388.  
  1389.         //public
  1390.         public int mapsize;
  1391.         public int matricasize;
  1392.         public int currentimg;
  1393.         public PictureBox[] img = new PictureBox[0];
  1394.         #endregion
  1395.  
  1396.         #region MapEngine
  1397.         public MapEngine(string file, string map, bool locator, object forma)
  1398.         {
  1399.             form = (forma as Form1);
  1400.             Scr scr = new Scr();
  1401.  
  1402.             infobox = new InfoBox(new Point((50 * scr.Get()) + 52, (Screen.PrimaryScreen.Bounds.Height - 352)), form);
  1403.  
  1404.             SuperRw rw = new SuperRw();
  1405.             listinfo = rw.Read(file);
  1406.             mapinfo = rw.Read(map);
  1407.  
  1408.             matricasize = fc.LineCount(mapinfo) + 1;
  1409.  
  1410.             if (locator != false)
  1411.                 Locator();
  1412.  
  1413.         }
  1414.         ~MapEngine() { }
  1415.         #endregion
  1416.  
  1417.         #region Generate
  1418.         public void Generate(Point start, Point skip, int size, bool reload)
  1419.         {
  1420.             mapsize = size;
  1421.  
  1422.             if (reload != true)
  1423.                 img = new PictureBox[size * size];
  1424.  
  1425.             string p_map = "";
  1426.             string numbers = "";
  1427.             int curskip = 0;
  1428.             int nr = 0;
  1429.             int a = 0;
  1430.             int b = 0;
  1431.             int step = 0;
  1432.  
  1433.             for (int i = 0; i < mapinfo.Length; )
  1434.             {
  1435.                 while (curskip != skip.Y)
  1436.                     if (mapinfo[i++] == '\n')
  1437.                         curskip++;
  1438.  
  1439.                 i += (skip.X * 3);
  1440.                 curskip = 0;
  1441.  
  1442.                 while (i != mapinfo.Length)
  1443.                 {
  1444.                     p_map += mapinfo[i];
  1445.  
  1446.                     if (++curskip == 3)
  1447.                     {
  1448.                         curskip = 0;
  1449.                         step++;
  1450.                     }
  1451.  
  1452.                     if (step == size)
  1453.                     {
  1454.                         while ((i != mapinfo.Length) && (mapinfo[i] != '\n'))
  1455.                             i++;
  1456.  
  1457.                         if (i != mapinfo.Length)
  1458.                         {
  1459.                             p_map += "\r\n";
  1460.                             i += (skip.X * 3);
  1461.                         }
  1462.  
  1463.                         step = 0;
  1464.                     }
  1465.  
  1466.                     if (i != mapinfo.Length)
  1467.                         i++;
  1468.                 }
  1469.  
  1470.                 break;
  1471.             }
  1472.  
  1473.             curskip = 0;
  1474.  
  1475.             for (int i = 0; i <= p_map.Length; i++)
  1476.                 if ((i != p_map.Length) && (p_map[i] != '\n') && (p_map[i] != '\r'))
  1477.                 {
  1478.                     curskip++;
  1479.                     numbers += p_map[i];
  1480.                     if (curskip == 2)
  1481.                     {
  1482.                         if (nr == size * size)
  1483.                             break;
  1484.  
  1485.                         if (reload != true)
  1486.                         {
  1487.                             img[nr] = obj.OPictureBox(new Point(((50 * a) + start.X), (50 * b) + start.Y), GetImg(numbers, listinfo));
  1488.                             img[nr].Tag = nr;
  1489.                             img[nr].MouseMove += new MouseEventHandler(img_MouseMove);
  1490.                             img[nr].MouseClick += new MouseEventHandler(img_Click);
  1491.                         }
  1492.                         else
  1493.                             img[nr].Image = GetImg(numbers, listinfo);
  1494.  
  1495.                         img[nr].Name = GetPath(numbers, listinfo);
  1496.  
  1497.                         numbers = p_map[++i].ToString();
  1498.  
  1499.                         Rotate(img[nr], numbers);
  1500.  
  1501.                         curskip = 0;
  1502.                         numbers = "";
  1503.                         if (reload != true)
  1504.                             form.Controls.Add(img[nr]);
  1505.                         a++;
  1506.                         nr++;
  1507.  
  1508.                         if (a == size)
  1509.                         {
  1510.                             b++;
  1511.                             a = 0;
  1512.                         }
  1513.                     }
  1514.                 }
  1515.  
  1516.             _mapinfo = p_map;
  1517.         }
  1518.         #endregion
  1519.  
  1520.         #region Clean
  1521.         public void Clean()
  1522.         {
  1523.             for (int i = 0; i < mapsize * mapsize; i++)
  1524.                 form.Controls.Remove(img[i]);
  1525.         }
  1526.         #endregion
  1527.  
  1528.         #region Locator
  1529.         private void Locator()
  1530.         {
  1531.             locator = obj.OPictureBox(new Point(0, 0), Image.FromFile(@"images/other/locator.bmp"));
  1532.  
  1533.             form.Controls.Add(locator);
  1534.         }
  1535.         #endregion
  1536.  
  1537.         #region img_Events
  1538.         private void img_MouseMove(object sender, MouseEventArgs e)
  1539.         {
  1540.             PictureBox img = (sender as PictureBox);
  1541.  
  1542.             if ((e.Location.X + img.Left > img.Left) && (e.Location.X + img.Left < img.Left + 50))
  1543.                 if ((e.Location.Y + img.Top > img.Top) && (e.Location.Y + img.Top < img.Top + 50))
  1544.                 {
  1545.                     locator.Location = new Point(img.Left + 20, img.Top + 20);
  1546.                     currentimg = Convert.ToInt32(img.Tag);
  1547.                 }
  1548.         }
  1549.         #endregion
  1550.  
  1551.         #region Rotate
  1552.         private PictureBox Rotate(PictureBox img, string numbers)
  1553.         {
  1554.             if (numbers == "1")
  1555.                 img.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
  1556.             if (numbers == "2")
  1557.                 img.Image.RotateFlip(RotateFlipType.Rotate180FlipNone);
  1558.             if (numbers == "3")
  1559.                 img.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
  1560.             if (numbers == "4")
  1561.                 img.Image.RotateFlip(RotateFlipType.Rotate90FlipX);
  1562.  
  1563.             return img;
  1564.         }
  1565.         #endregion
  1566.  
  1567.         #region GetImg
  1568.         private Image GetImg(string nr, string text)
  1569.         {
  1570.             for (int i = 0; i < fc.LineCount(text) + 2; i++)
  1571.                 if (nr == fc.ReadWord(i, 1, text, ':', false))
  1572.                     return Image.FromFile(@"images/" + fc.ReadWord(i, 2, text, ':', false) + ".bmp");
  1573.  
  1574.             return null;
  1575.         }
  1576.         #endregion
  1577.  
  1578.         #region GetPath
  1579.         private string GetPath(string nr, string text)
  1580.         {
  1581.             for (int i = 0; i < fc.LineCount(text) + 2; i++)
  1582.                 if (nr == fc.ReadWord(i, 1, text, ':', false))
  1583.                     return "images/" + fc.ReadWord(i, 2, text, ':', false);
  1584.  
  1585.             return null;
  1586.         }
  1587.         #endregion
  1588.  
  1589.         #region Events
  1590.         private void img_Click(object sender, MouseEventArgs e)
  1591.         {
  1592.             PictureBox path = (sender as PictureBox);
  1593.  
  1594.             Skipper skipper = new Skipper();
  1595.  
  1596.             Messenger msg = new Messenger();
  1597.             if (e.Button == MouseButtons.Left)
  1598.                 infobox.text.Text = "Path: " + path.Name + "   \n\rTag: " + currentimg.ToString() + "."
  1599.                  + "\n\rNr from matrica: " + skipper.Get(_mapinfo, currentimg + 1) + ". \n\rMatrica:\n\r" + _mapinfo;
  1600.  
  1601.             if (e.Button == MouseButtons.Right)
  1602.             {
  1603.                 PopMeniu pop = new PopMeniu(form, this);
  1604.             }
  1605.         }
  1606.         #endregion
  1607.     }
  1608.  
  1609.     public interface IAtrributs
  1610.     {
  1611.         #region Properties
  1612.         int money { get; set; }
  1613.         int population { get; set; }
  1614.         int rank { get; set; }
  1615.         int money_income { get; set; }
  1616.         int people_income { get; set; }
  1617.         int tax { get; set; }
  1618.         #endregion
  1619.     }
  1620.  
  1621.     public class Attributs : IAtrributs
  1622.     {
  1623.         #region Variable
  1624.         private int _money;
  1625.         private int _population;
  1626.         private int _rank;
  1627.         private int _money_income;
  1628.         private int _people_income;
  1629.         private int _tax;
  1630.         private int labels;
  1631.         private Label[] lattr = new Label[7];
  1632.  
  1633.         public int money
  1634.         {
  1635.             get
  1636.             {
  1637.                 return _money;
  1638.             }
  1639.             set
  1640.             {
  1641.                 _money = value;
  1642.             }
  1643.         }
  1644.  
  1645.         public int population
  1646.         {
  1647.             get
  1648.             {
  1649.                 return _population;
  1650.             }
  1651.             set
  1652.             {
  1653.                 _population = value;
  1654.             }
  1655.         }
  1656.  
  1657.         public int rank
  1658.         {
  1659.             get
  1660.             {
  1661.                 return _rank;
  1662.             }
  1663.             set
  1664.             {
  1665.                 _rank = value;
  1666.             }
  1667.         }
  1668.  
  1669.         public int money_income
  1670.         {
  1671.             get
  1672.             {
  1673.                 return _money_income;
  1674.             }
  1675.             set
  1676.             {
  1677.                 _money_income = value;
  1678.             }
  1679.         }
  1680.  
  1681.         public int people_income
  1682.         {
  1683.             get
  1684.             {
  1685.                 return _people_income;
  1686.             }
  1687.             set
  1688.             {
  1689.                 _people_income = value;
  1690.             }
  1691.         }
  1692.  
  1693.         public int tax
  1694.         {
  1695.             get
  1696.             {
  1697.                 return _tax;
  1698.             }
  1699.             set
  1700.             {
  1701.                 _tax = value;
  1702.             }
  1703.         }
  1704.         #endregion
  1705.  
  1706.         #region Attributs
  1707.         public Attributs(int start_money, Form form)
  1708.         {
  1709.             labels = 7;
  1710.             money = start_money;
  1711.             population = 1;
  1712.             rank = 0;
  1713.             money_income = 10;
  1714.             people_income = 1;
  1715.             tax = 10;
  1716.             Gui(form);
  1717.         }
  1718.         ~Attributs() { }
  1719.         #endregion
  1720.  
  1721.         #region GUI
  1722.         private void Gui(Form form)
  1723.         {
  1724.             Objector obj = new Objector();
  1725.  
  1726.             for (int i = 0; i < labels; i++)
  1727.                 lattr[i] = new Label();
  1728.  
  1729.             int scrH = Screen.PrimaryScreen.Bounds.Height;
  1730.             Color bg = Color.FromArgb(22, 78, 133);
  1731.  
  1732.             lattr[0] = obj.OLabel(new Point(250, scrH - 100), bg, "Money: " + money.ToString() + "$.");
  1733.             lattr[1] = obj.OLabel(new Point(250, scrH - 75), bg, "Population: " + population.ToString() + "/100.");
  1734.             lattr[2] = obj.OLabel(new Point(250, scrH - 50), bg, "Rank: " + rank.ToString() + ".");
  1735.             lattr[3] = obj.OLabel(new Point(410, scrH - 100), bg, "Money Income: " + money_income.ToString() + "$/Day.");
  1736.             lattr[4] = obj.OLabel(new Point(410, scrH - 75), bg, "People Income: " + people_income.ToString() + "/Day.");
  1737.             lattr[5] = obj.OLabel(new Point(410, scrH - 50), bg, "TAX: " + tax.ToString() + "/Day");
  1738.             lattr[6] = obj.OLabel(new Point(230, scrH - 125), bg, "STATISTICS: ");
  1739.  
  1740.             for (int i = 0; i < labels; i++)
  1741.             {
  1742.                 lattr[i].ForeColor = Color.White;
  1743.                 lattr[i].Width = 250;
  1744.                 lattr[i].Font = new Font("Tahoma", 12);
  1745.                 form.Controls.Add(lattr[i]);
  1746.                 lattr[i].BringToFront();
  1747.             }
  1748.         }
  1749.         #endregion
  1750.  
  1751.         #region Other
  1752.         public void Reload()
  1753.         {
  1754.             lattr[0].Text = "Money: " + money.ToString() + ".";
  1755.             lattr[1].Text = "Population: " + population.ToString() + "/100.";
  1756.             lattr[2].Text = "Rank: " + rank.ToString() + ".";
  1757.             lattr[3].Text = "Money Income: " + money_income.ToString() + "$/Day.";
  1758.             lattr[4].Text = "People Income: " + money_income.ToString() + "/Day.";
  1759.             lattr[5].Text = "TAX: " + tax.ToString() + "/Day.";
  1760.         }
  1761.         #endregion
  1762.     }
  1763.  
  1764.     class MMeniu
  1765.     {
  1766.         #region Variables
  1767.         //public
  1768.         public string Username = "";
  1769.         public string Password = "";
  1770.         public string Email = "";
  1771.         public bool Registration;
  1772.  
  1773.         //private
  1774.         private Form1 form;
  1775.         private Form MainForm = new Form();
  1776.         private PictureBox[] MainFormPics = new PictureBox[3];
  1777.         private Label[] MeniuPoints = new Label[6];
  1778.         private Panel[] MeniuPanels = new Panel[6];
  1779.         private Label TopLabel = new Label();
  1780.         private Label ExitLabel = new Label();
  1781.  
  1782.         //Login meniu
  1783.         private Label[] Meniu1Labels = new Label[6];
  1784.         private TextBox[] Meniu1TextBoxs = new TextBox[2];
  1785.         private CheckBox Meniu1Check = new CheckBox();
  1786.         private int Checkcounter = 1;
  1787.            
  1788.         // Register meniu point
  1789.         private Label[] Meniu2Labels = new Label[7];
  1790.         private TextBox[] Meniu2TextBoxs = new TextBox[4];
  1791.  
  1792.         // About meniu point
  1793.         private Label AboutText = new Label();
  1794.        
  1795.         // Useful objects
  1796.         private Objector obj = new Objector();
  1797.         private Messenger msg = new Messenger();
  1798.         private SuperRw SRw = new SuperRw();
  1799.         private Functions fc = new Functions();
  1800.         #endregion
  1801.  
  1802.         #region MMeniu
  1803.         public MMeniu(Form1 forma)
  1804.         {
  1805.             form = forma;
  1806.  
  1807.             MainForm = obj.OForm(new Point((Screen.PrimaryScreen.Bounds.Width / 2) - 175, (Screen.PrimaryScreen.Bounds.Height / 2) - 200), new Size(350, 400), false);
  1808.             MainForm.BackColor = Color.FromArgb(49, 75, 108);
  1809.  
  1810.             Cursor myCursor = new Cursor(@"images/other/cursor.cur");
  1811.             MainForm.Cursor = myCursor;
  1812.  
  1813.             MainFormPics[0] = obj.OPictureBox(new Point(0, 0), Image.FromFile(@"images/mmeniu/MainForm_Left.bmp"));
  1814.             MainFormPics[1] = obj.OPictureBox(new Point(MainFormPics[0].Width, 0), Image.FromFile(@"images/mmeniu/MainForm_Middle.bmp"));
  1815.             MainFormPics[1].Width = MainForm.Width - 2 * MainFormPics[0].Width;
  1816.             MainFormPics[1].BackgroundImage = MainFormPics[1].Image;
  1817.             MainFormPics[2] = obj.OPictureBox(new Point(MainForm.Width - MainFormPics[0].Width , 0), Image.FromFile(@"images/mmeniu/MainForm_Right.bmp"));
  1818.            
  1819.             for (int i = 0; i < 3; i++)
  1820.                 MainForm.Controls.Add(MainFormPics[i]);
  1821.  
  1822.             MeniuPoints[0] = obj.OLabel(new Point(2, 27), Color.FromArgb(49, 75, 108), "Ranking");
  1823.             MeniuPoints[1] = obj.OLabel(new Point(85, 27), Color.FromArgb(49, 75, 108), "Stats");
  1824.             MeniuPoints[2] = obj.OLabel(new Point(85*2, 27), Color.FromArgb(49, 75, 108), "Options");
  1825.             MeniuPoints[3] = obj.OLabel(new Point(85*3, 27), Color.FromArgb(49, 75, 108), "About");
  1826.             MeniuPoints[4] = obj.OLabel(new Point(2, 56), Color.FromArgb(49, 75, 108), "Login");
  1827.             MeniuPoints[5] = obj.OLabel(new Point(170, 56), Color.FromArgb(49, 75, 108), "Register");
  1828.  
  1829.             for (int i = 0; i <= 3; i++)
  1830.             {
  1831.                 SetStyle(MeniuPoints[i], true, true, 13F,new Size(93, 30));
  1832.                 MainForm.Controls.Add(MeniuPoints[i]);
  1833.                 MeniuPoints[i].BringToFront();
  1834.             }
  1835.  
  1836.             for (int i = 4; i < 6; i++)
  1837.             {
  1838.                 SetStyle(MeniuPoints[i], true, true, 15F, new Size(93, 30));
  1839.                 MeniuPoints[i].Width = 178;
  1840.                 MainForm.Controls.Add(MeniuPoints[i]);
  1841.                 MeniuPoints[i].BringToFront();
  1842.             }
  1843.  
  1844.             for (int i = 0; i < 6; i++)
  1845.             {
  1846.                 MeniuPanels[i] = obj.OPanel(new Point(4, 88), new Size(342, 300), Color.FromArgb(49, 75, 108));
  1847.                 MainForm.Controls.Add(MeniuPanels[i]);
  1848.                 MeniuPanels[i].Visible = false;
  1849.             }
  1850.  
  1851.             MeniuPanels[0].BringToFront();
  1852.             MeniuPanels[0].Visible = true;
  1853.             MeniuPoints[4].BackColor = Color.FromArgb(10, 100, 120);
  1854.  
  1855.             TopLabel = obj.OLabel(new Point(3, 3), Color.FromArgb(49, 75, 108), "The Pizza - Serious Business");
  1856.             SetStyle(TopLabel, false, false, 11F, new Size(300, 20));
  1857.             MainForm.Controls.Add(TopLabel);
  1858.             TopLabel.BringToFront();
  1859.  
  1860.             ExitLabel = obj.OLabel(new Point(270, 360), Color.FromArgb(49, 75, 108), "Exit");
  1861.             SetStyle(ExitLabel, true, true, 11F, new Size(70,25));
  1862.             MainForm.Controls.Add(ExitLabel);
  1863.  
  1864.             // Events
  1865.             MainFormPics[2].Click += new EventHandler(MainFormPics2_Click);
  1866.             ExitLabel.Click += new EventHandler(ExitLabel_Click);
  1867.  
  1868.             MeniuPoints[0].Click += new EventHandler(MeniuPoints0_Click);
  1869.             MeniuPoints[1].Click += new EventHandler(MeniuPoints1_Click);
  1870.             MeniuPoints[2].Click += new EventHandler(MeniuPoints2_Click);
  1871.             MeniuPoints[3].Click += new EventHandler(MeniuPoints3_Click);
  1872.             MeniuPoints[4].Click += new EventHandler(MeniuPoints4_Click);
  1873.             MeniuPoints[5].Click += new EventHandler(MeniuPoints5_Click);
  1874.            
  1875.             SetLogin();
  1876.             SetRegistration();
  1877.             SetAbout();
  1878.             ExitLabel.BringToFront();
  1879.         }
  1880.         ~MMeniu() { }
  1881.         #endregion
  1882.  
  1883.         #region SetLogin
  1884.         private void SetLogin()
  1885.         {
  1886.             Meniu1Labels[0] = obj.OLabel(new Point(10,10), Color.FromArgb(49, 75, 108), "Username");
  1887.             Meniu1Labels[1] = obj.OLabel(new Point(10,70), Color.FromArgb(49, 75, 108), "Password");
  1888.             Meniu1Labels[2] = obj.OLabel(new Point(85, 180), Color.FromArgb(49, 75, 108), "OK");
  1889.             Meniu1Labels[3] = obj.OLabel(new Point(175, 180), Color.FromArgb(49, 75, 108), "Clear");
  1890.  
  1891.             for (int i = 0; i < 2; i++)
  1892.                 SetStyle(Meniu1Labels[i], false, true, 10F,new Size(93, 30));
  1893.  
  1894.             for (int i = 2; i < 4; i++)
  1895.                 SetStyle(Meniu1Labels[i], true, true, 11F, new Size(70, 25));
  1896.  
  1897.             for (int i = 0; i < 4; i++)
  1898.             {
  1899.                 MeniuPanels[0].Controls.Add(Meniu1Labels[i]);
  1900.                 Meniu1Labels[i].BringToFront();
  1901.             }
  1902.  
  1903.             Meniu1TextBoxs[0] = obj.OTextBox(new Point(23, 45), 140, BorderStyle.FixedSingle);
  1904.             Meniu1TextBoxs[1] = obj.OTextBox(new Point(23, 105), 140, BorderStyle.FixedSingle);
  1905.             Meniu1TextBoxs[1].PasswordChar = '*';
  1906.  
  1907.             for (int i = 0; i < 2; i++)
  1908.             {
  1909.                 MeniuPanels[0].Controls.Add(Meniu1TextBoxs[i]);
  1910.                 Meniu1TextBoxs[i].BringToFront();
  1911.             }
  1912.  
  1913.             Meniu1Check.Location = new Point(23, 136);
  1914.             Meniu1Check.Text = "Remember me";
  1915.             Meniu1Check.Width = 120;
  1916.             Meniu1Check.Font = new Font("Comic Sans MS", 9F, FontStyle.Bold, GraphicsUnit.Point, ((System.Byte)(0)));
  1917.             Meniu1Check.BringToFront();
  1918.  
  1919.             //Events
  1920.             Meniu1Labels[2].Click += new EventHandler(Meniu1Labels2_Click);
  1921.             Meniu1Labels[3].Click += new EventHandler(Meniu1Labels3_Click);
  1922.             Meniu1Check.CheckStateChanged += new EventHandler(Meniu1Check_CheckStateChanged);
  1923.  
  1924.             MeniuPanels[0].Controls.Add(Meniu1Check);
  1925.             MeniuPanels[0].BringToFront();      
  1926.      
  1927.             //fortest
  1928.             string file = SRw.Read("info/remember.txt");
  1929.             Meniu1TextBoxs[0].Text = fc.ReadWord(1, 1, file, ':', false);
  1930.             Meniu1TextBoxs[1].Text = fc.ReadWord(1, 2, file, ':', false);
  1931.  
  1932.             if (Meniu1TextBoxs[0].Text != "")
  1933.                 Meniu1Check.Checked = true;
  1934.         }
  1935.         #endregion
  1936.  
  1937.         #region SetRegistration
  1938.         private void SetRegistration()
  1939.         {
  1940.             Meniu2Labels[0] = obj.OLabel(new Point(23, 10), Color.FromArgb(49, 75, 108), "Username");
  1941.             Meniu2Labels[1] = obj.OLabel(new Point(23, 70), Color.FromArgb(49, 75, 108), "Password");
  1942.             Meniu2Labels[2] = obj.OLabel(new Point(23, 130), Color.FromArgb(49, 75, 108), "Repeat Password");
  1943.             Meniu2Labels[3] = obj.OLabel(new Point(23, 190), Color.FromArgb(49, 75, 108), "Email");
  1944.             Meniu2Labels[4] = obj.OLabel(new Point(85, 272), Color.FromArgb(49, 75, 108), "OK");
  1945.             Meniu2Labels[5] = obj.OLabel(new Point(175, 272), Color.FromArgb(49, 75, 108), "Clear");
  1946.              
  1947.  
  1948.             for (int i = 0; i < 4; i++)
  1949.                 SetStyle(Meniu2Labels[i], false, false, 10F, new Size(150, 30));
  1950.  
  1951.             for (int i = 4; i < 6; i++)
  1952.                 SetStyle(Meniu2Labels[i], true, true, 11F, new Size(70, 25));
  1953.  
  1954.             for (int i = 0; i < 6; i++)
  1955.             {
  1956.                 MeniuPanels[1].Controls.Add(Meniu2Labels[i]);
  1957.                 Meniu2Labels[i].BringToFront();
  1958.             }
  1959.  
  1960.             Meniu2TextBoxs[0] = obj.OTextBox(new Point(23, 40), 140, BorderStyle.FixedSingle);
  1961.             Meniu2TextBoxs[1] = obj.OTextBox(new Point(23, 96), 140, BorderStyle.FixedSingle);
  1962.             Meniu2TextBoxs[1].PasswordChar = '*';
  1963.             Meniu2TextBoxs[2] = obj.OTextBox(new Point(23, 152), 140, BorderStyle.FixedSingle);
  1964.             Meniu2TextBoxs[2].PasswordChar = '*';
  1965.             Meniu2TextBoxs[3] = obj.OTextBox(new Point(23, 212), 140, BorderStyle.FixedSingle);
  1966.  
  1967.             for (int i = 0; i < 4; i++)
  1968.             {
  1969.                 MeniuPanels[1].Controls.Add(Meniu2TextBoxs[i]);
  1970.                 Meniu2TextBoxs[i].BringToFront();
  1971.             }
  1972.  
  1973.             // Events
  1974.             Meniu2Labels[4].Click += new EventHandler(Meniu2Labels4_Click);
  1975.             Meniu2Labels[5].Click += new EventHandler(Meniu2Labels5_Click);
  1976.         }
  1977.         #endregion
  1978.  
  1979.         #region SetAbout
  1980.         private void SetAbout()
  1981.         {
  1982.             AboutText = obj.OLabel(new Point(5, 5), Color.FromArgb(49, 75, 108), "This is About meniu point");
  1983.             SetStyle(AboutText, false, false, 10F, new Size(300, 200));
  1984.             MeniuPanels[2].Controls.Add(AboutText);
  1985.         }
  1986.         #endregion
  1987.  
  1988.         #region SetStyle
  1989.         private void SetStyle(object sender, bool board, bool Align, float TextSize, Size size)
  1990.         {
  1991.             Label get = (sender as Label);
  1992.             if (board == true)
  1993.                 get.BorderStyle = BorderStyle.FixedSingle;
  1994.             get.Size = size;
  1995.             get.Font = new Font("Comic Sans MS",TextSize, FontStyle.Bold, GraphicsUnit.Point, ((System.Byte)(0)));
  1996.             if (Align == true)
  1997.                 get.TextAlign = ContentAlignment.MiddleCenter;
  1998.             get.BringToFront();
  1999.         }
  2000.         #endregion
  2001.  
  2002.         #region ShowMeniu
  2003.         public void ShowMeniu()
  2004.         {
  2005.             MainForm.Show();
  2006.         }
  2007.         #endregion
  2008.  
  2009.         #region Events
  2010.         #region MainForm Events
  2011.         private void MainFormPics2_Click(object sender, EventArgs e)
  2012.         {
  2013.             if (fc.PosCheck(new Point(Cursor.Position.X - MainForm.Location.X, Cursor.Position.Y - MainForm.Location.Y), new Point(325, 0), new Point(350, 25)) == true)
  2014.                 MainForm.Close();
  2015.         }
  2016.  
  2017.         private void ExitLabel_Click(object sender, EventArgs e)
  2018.         {
  2019.             MainForm.Close();
  2020.             form.Close();
  2021.         }
  2022.         #endregion
  2023.  
  2024.         #region Login Events
  2025.         private void MeniuPoints4_Click(object sender, EventArgs e)
  2026.         {
  2027.             for (int i = 0; i < 6; i++)
  2028.             {
  2029.                 MeniuPoints[i].BackColor = Color.FromArgb(49, 75, 108);
  2030.                 MeniuPanels[i].Visible = false;
  2031.             }
  2032.             MeniuPanels[0].BringToFront();
  2033.             ExitLabel.BringToFront();
  2034.             MeniuPanels[0].Visible = true;
  2035.             MeniuPoints[4].BackColor = Color.FromArgb(10, 100, 120);
  2036.         }
  2037.  
  2038.         private void Meniu1Labels2_Click(object sender, EventArgs e)
  2039.         {
  2040.             if ((Meniu1TextBoxs[0].Text == "") || (Meniu1TextBoxs[1].Text == "")) msg.ShowMessage("Error", "Please fill all the gaps.", false);
  2041.             else
  2042.             {
  2043.                 Username = Meniu1TextBoxs[0].Text;
  2044.                 Password = Meniu1TextBoxs[1].Text;
  2045.  
  2046.                 if (Check(Username, Password) == true)
  2047.                 {
  2048.  
  2049.                     if ((Checkcounter % 2) == 0)
  2050.                         SRw.Write(Meniu1TextBoxs[0].Text + ":" + Meniu1TextBoxs[1].Text, "info/remember.txt");
  2051.                     else
  2052.                         SRw.Write("", "info/remember.txt");
  2053.  
  2054.                     msg.ShowMessage("Login", "Login was successful.", false);
  2055.  
  2056.                     MainForm.Visible = false;
  2057.  
  2058.                     form.create();
  2059.                 }
  2060.                 else
  2061.                     msg.ShowMessage("Login", "Login Failed.", false);
  2062.             }
  2063.         }
  2064.  
  2065.         private bool Check(string user, string password)
  2066.         {
  2067.             string path = "info/users/" + user + ".txt";
  2068.  
  2069.             if (File.Exists(path) == true)
  2070.             {
  2071.                 string file = SRw.Read(path);
  2072.  
  2073.                 if (fc.ReadWord(1, 2, file, ':', false) == password)
  2074.                     return true;
  2075.                 else
  2076.                     return false;
  2077.             }
  2078.             else
  2079.                 return false;
  2080.         }
  2081.  
  2082.         private void Meniu1Labels3_Click(object sender, EventArgs e)
  2083.         {
  2084.             Meniu1TextBoxs[0].Text = "";
  2085.             Meniu1TextBoxs[1].Text = "";
  2086.         }
  2087.  
  2088.         private void Meniu1Check_CheckStateChanged(object sender, EventArgs e)
  2089.         {
  2090.             Checkcounter++;
  2091.         }
  2092.         #endregion
  2093.  
  2094.         #region Register Events
  2095.         private void MeniuPoints5_Click(object sender, EventArgs e)
  2096.         {
  2097.             for (int i = 0; i < 6; i++)
  2098.             {
  2099.                 MeniuPoints[i].BackColor = Color.FromArgb(49, 75, 108);
  2100.                 MeniuPanels[i].Visible = false;
  2101.             }
  2102.             MeniuPanels[1].BringToFront();
  2103.             ExitLabel.BringToFront();
  2104.             MeniuPanels[1].Visible = true;
  2105.             MeniuPoints[5].BackColor = Color.FromArgb(10, 100, 120);
  2106.         }
  2107.  
  2108.         private void Meniu2Labels4_Click(object sender, EventArgs e)
  2109.         {
  2110.             if (Meniu2TextBoxs[1].Text == Meniu2TextBoxs[2].Text)
  2111.             {
  2112.                 if ((Meniu2TextBoxs[0].Text == "") || (Meniu2TextBoxs[1].Text == "") || (Meniu2TextBoxs[2].Text == "") || (Meniu2TextBoxs[3].Text == "" ))
  2113.                 {
  2114.                     msg.ShowMessage("Error", "Please fill all the gaps.",false);
  2115.                 }
  2116.                 else
  2117.                 {
  2118.                     Registration = true;
  2119.                     Username = Meniu2TextBoxs[0].Text;
  2120.                     Password = Meniu2TextBoxs[1].Text;
  2121.                     Email = Meniu2TextBoxs[3].Text;
  2122.  
  2123.                     if (Create(Username, Password, Email) == true)
  2124.                     {
  2125.                         msg.ShowMessage("Registration", "Registration is Successful.", false);
  2126.  
  2127.                         for (int i = 0; i < 4; i++)
  2128.                             Meniu2TextBoxs[i].Text = "";
  2129.                     }
  2130.                     else
  2131.                         msg.ShowMessage("Registration", "Failed to Create.", false);
  2132.                 }
  2133.             }
  2134.             else
  2135.                 msg.ShowMessage("Registration", "Passwords don't match.", false);
  2136.         }
  2137.  
  2138.         private bool Create(string user, string password, string email)
  2139.         {
  2140.             string path = "info/users/" + user + ".txt";
  2141.  
  2142.             if (File.Exists(@path) == true)
  2143.                 return false;
  2144.             else
  2145.             {
  2146.                 string save = user + ":" + password + ":" + email + ":1000";
  2147.                 SRw.Write(save, path);
  2148.                 return true;
  2149.             }
  2150.         }
  2151.  
  2152.         private void Meniu2Labels5_Click(object sender, EventArgs e)
  2153.         {
  2154.             for (int i = 0; i < 4; i++)
  2155.                 Meniu2TextBoxs[i].Text = "";
  2156.         }
  2157.         #endregion
  2158.  
  2159.         #region About Events
  2160.         private void MeniuPoints3_Click(object sender, EventArgs e)
  2161.         {
  2162.             for (int i = 0; i < 6; i++)
  2163.             {
  2164.                 MeniuPoints[i].BackColor = Color.FromArgb(49, 75, 108);
  2165.                 MeniuPanels[i].Visible = false;
  2166.             }
  2167.                
  2168.             MeniuPanels[2].BringToFront();
  2169.             ExitLabel.BringToFront();
  2170.             MeniuPanels[2].Visible = true;
  2171.             MeniuPoints[3].BackColor = Color.FromArgb(10, 100, 120);
  2172.         }
  2173.         #endregion
  2174.  
  2175.         #region Options Events
  2176.         private void MeniuPoints2_Click(object sender, EventArgs e)
  2177.         {
  2178.             for (int i = 0; i < 6; i++)
  2179.             {
  2180.                 MeniuPoints[i].BackColor = Color.FromArgb(49, 75, 108);
  2181.                 MeniuPanels[i].Visible = false;
  2182.             }
  2183.  
  2184.             MeniuPanels[3].BringToFront();
  2185.             ExitLabel.BringToFront();
  2186.             MeniuPanels[3].Visible = true;
  2187.             MeniuPoints[2].BackColor = Color.FromArgb(10, 100, 120);
  2188.         }
  2189.         #endregion
  2190.  
  2191.         #region Stats Events
  2192.         private void MeniuPoints1_Click(object sender, EventArgs e)
  2193.         {
  2194.             for (int i = 0; i < 6; i++)
  2195.             {
  2196.                 MeniuPoints[i].BackColor = Color.FromArgb(49, 75, 108);
  2197.                 MeniuPanels[i].Visible = false;
  2198.             }
  2199.  
  2200.             MeniuPanels[4].BringToFront();
  2201.             ExitLabel.BringToFront();
  2202.             MeniuPanels[4].Visible = true;
  2203.             MeniuPoints[1].BackColor = Color.FromArgb(10, 100, 120);
  2204.         }
  2205.         #endregion
  2206.  
  2207.         #region Ranking Events
  2208.         private void MeniuPoints0_Click(object sender, EventArgs e)
  2209.         {
  2210.             for (int i = 0; i < 6; i++)
  2211.             {
  2212.                 MeniuPoints[i].BackColor = Color.FromArgb(49, 75, 108);
  2213.                 MeniuPanels[i].Visible = false;
  2214.             }
  2215.  
  2216.             MeniuPanels[5].BringToFront();
  2217.             ExitLabel.BringToFront();
  2218.             MeniuPanels[5].Visible = true;
  2219.             MeniuPoints[0].BackColor = Color.FromArgb(10, 100, 120);
  2220.  
  2221.             Ranking rank = new Ranking();
  2222.  
  2223.             Label ranks = obj.OLabel(new Point(10, 10), Color.FromArgb(49, 75, 108), "Ranking:\r\n\r\n"+
  2224.                rank.ShowRanking(SRw.Read("info/ranking.txt"), 0, true));
  2225.  
  2226.             MeniuPanels[5].Controls.Add(ranks);
  2227.             ranks.ForeColor = Color.LightGray;
  2228.             ranks.Size = new Size(300, 500);
  2229.             ranks.Font = new Font("Tahoma", 12);
  2230.             ranks.BringToFront();
  2231.         }
  2232.         #endregion
  2233.         #endregion
  2234.     }
  2235.  
  2236.     class BuySystem
  2237.     {
  2238.         #region Variable
  2239.         private PictureBox[] img = new PictureBox[3];
  2240.         private PictureBox[] block = new PictureBox[0];
  2241.         private Panel panel = new Panel();
  2242.         private SuperRw rw = new SuperRw();
  2243.         private Functions fc = new Functions();
  2244.         private Messenger msg = new Messenger();
  2245.         private PictureBox show;
  2246.         private Label info;
  2247.         private Form form;
  2248.         private MapEngine _engine;
  2249.         private string size;
  2250.         #endregion
  2251.  
  2252.         #region BuySystem
  2253.         public BuySystem(Form forma, object sender)
  2254.         {
  2255.             Objector obj = new Objector();
  2256.             form = forma;
  2257.             _engine = (sender as MapEngine);
  2258.            
  2259.             panel = obj.OPanel(new Point(120, 120), new Size(500, 350), Color.Black);
  2260.             form.Controls.Add(panel);
  2261.             panel.BringToFront();
  2262.  
  2263.             img[0] = obj.OPictureBox(new Point(0, 0), Image.FromFile(@"images/buy/left_1.bmp"));
  2264.             img[1] = obj.OPictureBox(new Point(25, 0), Image.FromFile(@"images/buy/middle.bmp"));
  2265.             img[1].Width = 450;
  2266.             img[1].BackgroundImage = img[1].Image;
  2267.             img[2] = obj.OPictureBox(new Point(475, 0), Image.FromFile(@"images/buy/right_1.bmp"));
  2268.  
  2269.             for (int i = 0; i < 3; i++)
  2270.                 panel.Controls.Add(img[i]);
  2271.  
  2272.             show = obj.OPictureBox(new Point(60, 60), Image.FromFile(@"images/buy_list/test.bmp"));
  2273.             panel.Controls.Add(show);
  2274.             show.BringToFront();
  2275.  
  2276.             Label label = obj.OLabel(new Point(5, 5), Color.FromArgb(13, 31, 107), "Buy System");
  2277.             label.Height = 20;
  2278.             SetStyle(label);
  2279.  
  2280.             Label list = obj.OLabel(new Point(300, 40), Color.FromArgb(33, 53, 139), "List of Items:");
  2281.             list.Size = new Size(140, 20);
  2282.             SetStyle(list);
  2283.  
  2284.             info = obj.OLabel(new Point(60, 220), Color.FromArgb(33, 53, 139), "_info_");
  2285.             SetStyle(info);
  2286.             info.Size = new Size(200, 80);
  2287.             info.Font = new Font("Tahoma", 10);
  2288.  
  2289.             Label[] button = new Label[2];
  2290.             button[0] = obj.OLabel(new Point(40, 300), Color.FromArgb(33, 53, 139), "Buy");
  2291.             button[0].Click +=new EventHandler(Buy);
  2292.             button[1] = obj.OLabel(new Point(130, 300), Color.FromArgb(33, 53, 139), "Close");
  2293.             button[1].Click += new EventHandler(Close);
  2294.  
  2295.             for (int i = 0; i < 2; i++)
  2296.             {
  2297.                 button[i].BorderStyle = BorderStyle.FixedSingle;
  2298.                 SetStyle(button[i]);
  2299.             }
  2300.  
  2301.             ListBox listbox = obj.OListBox(new Point(300, 60), new Size(170, 270), Color.Black);
  2302.             listbox.ForeColor = Color.LightGray;
  2303.             listbox.Font = new Font("Tahoma", 12);
  2304.             listbox.Click +=new EventHandler(listbox_Click);
  2305.  
  2306.             string stinfo = rw.Read(@"info/buy_info.txt");
  2307.             int lines = fc.LineCount(stinfo) + 1;
  2308.  
  2309.             for (int i = 1; i <= lines; i++)
  2310.                 listbox.Items.Add(fc.ReadWord(i, 1, stinfo, ':', false));
  2311.  
  2312.             listbox.SelectedIndex = 1;
  2313.  
  2314.             change(stinfo, lines+2, listbox);
  2315.             panel.Controls.Add(listbox);
  2316.             listbox.BringToFront();
  2317.         }
  2318.         ~BuySystem() { }
  2319.         #endregion
  2320.  
  2321.         #region SetStyle
  2322.         private void SetStyle(object sender)
  2323.         {
  2324.             Label label = (sender as Label);
  2325.             label.Font = new Font("Tahoma", 12);
  2326.             label.ForeColor = Color.White;
  2327.             panel.Controls.Add(label);
  2328.             label.BringToFront();
  2329.         }
  2330.         #endregion
  2331.  
  2332.         #region Events
  2333.         private void listbox_Click(object sender, EventArgs e)
  2334.         {
  2335.             string _info = rw.Read(@"info/buy_info.txt");
  2336.             int _lines = fc.LineCount(_info) + 2;
  2337.  
  2338.             change(_info, _lines, sender);
  2339.         }
  2340.  
  2341.         private void change(string _info, int _lines, object sender)
  2342.         {
  2343.             for (int i = 0; i < _lines; i++)
  2344.                 if (fc.ReadWord(i, 1, _info, ':', false) == (sender as ListBox).Items[(sender as ListBox).SelectedIndex].ToString())
  2345.                 {
  2346.                     info.Text = "Cost: " + fc.ReadWord(i, 2, _info, ':', false) + " $\r\nLevel: " + fc.ReadWord(i, 3, _info, ':', false) + ".\r\n" +
  2347.                         "Size: " + (size=(fc.ReadWord(i, 4, _info, ':', false))) + "^2 Blocks.\r\nAbout: " + fc.ReadWord(i, 5, _info, ':', false) + ".";
  2348.  
  2349.                     show.Image = Image.FromFile(@"images/buy_list/" + fc.ReadWord(i, 6, _info, ':', false));
  2350.                 }
  2351.         }
  2352.  
  2353.         private void Buy(object sender, EventArgs e)
  2354.         {
  2355.             msg.ShowMessage("Buy", "Under Construction. Continue?", true);
  2356.  
  2357.             if (msg.UsersResult)
  2358.             {
  2359.                 panel.Controls.Clear();
  2360.                 panel.Visible = false;
  2361.                 CreateBlocks(Convert.ToInt32(size));
  2362.             }
  2363.         }
  2364.  
  2365.         private void BlockMove(object sender, MouseEventArgs e)
  2366.         {
  2367.             int sz = Convert.ToInt32(size);
  2368.             PictureBox img = (sender as PictureBox);
  2369.             int a = 0;
  2370.             int b = 0;
  2371.             int c = 0;
  2372.             int nr = 0;
  2373.             int skip = 0;
  2374.  
  2375.             for (int i = 0; i < (sz * sz); i++)
  2376.             {
  2377.                 block[i].Location = new Point((50 * a++) + img.Left + 15, (50 * b) + img.Top + 15);
  2378.  
  2379.                 if ((_engine.currentimg + (c + 1)) <= (_engine.mapsize * _engine.mapsize))
  2380.                     if ((_engine.img[_engine.currentimg + c++].Name) != "images/out/grass")
  2381.                         block[i].Image = Image.FromFile(@"images/buy/block_red.bmp");
  2382.                     else
  2383.                         block[i].Image = Image.FromFile(@"images/buy/block.bmp");
  2384.  
  2385.                 nr = _engine.currentimg;
  2386.  
  2387.                 while (nr >= _engine.mapsize)
  2388.                     nr -= _engine.mapsize;
  2389.  
  2390.                 skip = _engine.mapsize - (nr + 1) - sz;
  2391.  
  2392.                 if (a == sz)
  2393.                 {
  2394.                     c += (nr + 1) + skip;
  2395.                     b++;
  2396.                     a = 0;
  2397.                 }
  2398.             }
  2399.         }
  2400.         #endregion
  2401.  
  2402.         #region CreateBlocks
  2403.         private void CreateBlocks(int size)
  2404.         {
  2405.             msg.ShowMessage("Blocks", "There is " + (size*size).ToString() + " block(s).", false);
  2406.            
  2407.             Objector obj = new Objector();
  2408.             block = new PictureBox[size*size];
  2409.             int a=0;
  2410.             int b=0;
  2411.  
  2412.             for (int i = 0; i < System.Math.Pow(_engine.mapsize, 2); i++)
  2413.                 _engine.img[i].MouseMove += new MouseEventHandler(BlockMove);
  2414.  
  2415.             for (int i = 0; i < (size*size); i++)
  2416.             {
  2417.                 a++;
  2418.                 block[i] = obj.OPictureBox(new Point((a*50)+200, (b*50)+200), Image.FromFile(@"images/buy/block.bmp"));
  2419.  
  2420.                 if (a == size)
  2421.                 {
  2422.                     b++;
  2423.                     a = 0;
  2424.                 }
  2425.  
  2426.                 form.Controls.Add(block[i]);
  2427.                 block[i].BringToFront();
  2428.             }
  2429.         }
  2430.         #endregion
  2431.  
  2432.         #region Close
  2433.         private void Close(object sender, EventArgs e)
  2434.         {
  2435.             panel.Controls.Clear();
  2436.             panel.Visible = false;
  2437.         }
  2438.         #endregion
  2439.     }
  2440. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement