Exemple #1
0
        public List <Panel> ParsePanel(form_previewForm previewForm, int xDimension, int yDimension)
        {
            Panel panel;

            tp = new TileParser();
            const int EDGE = 12;
            const int LOCATION = 2;
            int       xLocation = LOCATION, yLocation = LOCATION;

            for (int x = 0; x < xDimension; x++)
            {
                if (x > 0)
                {
                    xLocation += EDGE;
                }
                yLocation = LOCATION;
                for (int y = 0; y < yDimension; y++)
                {
                    if (y > 0)
                    {
                        yLocation += EDGE;
                    }
                    panel             = new Panel();
                    panel.Size        = new Size(EDGE, EDGE);
                    panel.Location    = new Point(xLocation, yLocation);
                    panel.BackColor   = Color.Gray;
                    panel.Name        = "panel_" + x.ToString() + "_" + y.ToString();
                    panel.BorderStyle = BorderStyle.FixedSingle;
                    previewForm.Controls.Add(panel);
                    pList.Add(panel);
                }
            }
            return(pList);
        }
Exemple #2
0
 public void UpdatePanels(int hScrollValue, int vScrollValue, int[,] m, List <Panel> formPanels)
 {
     tp = new TileParser();
     x  = hScrollValue;
     y  = vScrollValue;
     try
     {
         int[]    coordinates = { 0, 0 };
         string[] numbers;
         int      counter = 0;
         foreach (Panel panel in formPanels)
         {
             counter = 0;
             numbers = Regex.Split(panel.Name, @"\D+");
             foreach (string value in numbers)
             {
                 if (!string.IsNullOrEmpty(value))
                 {
                     coordinates[counter] = int.Parse(value);
                     counter++;
                 }
             }
             counter = 0;
             tp.IntToTile(panel, coordinates[0] + x, coordinates[1] + y, m);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #3
0
 private void MapEditor_Load(object sender, EventArgs e)
 {
     try
     {
         rbutton_click_Click(sender, e);
         x = Int32.Parse(cmbox_xDimension.SelectedItem.ToString());
         y = Int32.Parse(cmbox_yDimension.SelectedItem.ToString());
         pList.Clear();
         pp    = new PanelParser();
         tp    = new TileParser();
         fp    = new FileParser();
         pList = pp.ParsePanel(this, 23, 13);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }