public void CreateLevel()
        {
            string[] s = File.ReadAllLines(fileName);
            //File.Encrypt(st + currentLevel + ".lv");
            //File.Decrypt(st + currentLevel + ".lv");

            lenghtLevel = s[0].Length * 40;
            int x = 0;
            int y = 0;
            foreach (string str in s)
            {
                foreach (char c in str)
                {
                    Rectangle rect = new Rectangle(x, y, 40, 40);
                    switch (c)
                    {
                        #region Block
                        case 'X':
                            {
                                GObject block = new GObject(blockTexture[0], rect);
                                block.type = "block1";
                                blocks.Add(block);
                            } break;
                        case 'Y':
                            {
                                GObject block = new GObject(blockTexture[1], rect);
                                block.type = "block2";
                                blocks.Add(block);
                            } break;
                        case 'B':
                            {
                                GObject block = new GObject(blockTexture[2], new Rectangle(x, y, 41, 184));
                                block.type = "bamboo";
                                blocks.Add(block);
                            } break;
                        case 'S':
                            {
                                GObject block = new GObject(blockTexture[3], new Rectangle(x, y, 41, 92));
                                block.type = "bambootopSliceHorizontal";
                                blocks.Add(block);
                            } break;
                        case 'H':
                            {
                                GObject block = new GObject(blockTexture[4], new Rectangle(x, y, 280, 220));
                                block.type = "hause1";
                                blocks.Add(block);
                            } break;
                        #endregion
                        #region Bonus
                        case 'a':
                            {
                                GObject bon = new GObject(bonusTexture[0], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height / 2));
                                bon.type = "apple";
                                bonus.Add(bon);
                            } break;
                        case 'b':
                            {
                                GObject bon = new GObject(bonusTexture[1], rect);
                                bon.type = "beetle";
                                bonus.Add(bon);
                            } break;
                        case 'h':
                            {
                                GObject bon = new GObject(bonusTexture[2], new Rectangle(x, y,
                                                                 rect.Width, rect.Height / 2));
                                bon.type = "hand";
                                bonus.Add(bon);
                            } break;
                        case 'c':
                            {
                                GObject bon = new GObject(bonusTexture[3], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height / 2));
                                bon.type = "heart";
                                bonus.Add(bon);
                            } break;
                        case 'm':
                            {
                                GObject bon = new GObject(bonusTexture[4], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height));
                                bon.type = "men";
                                bonus.Add(bon);
                            } break;
                        case 'r':
                            {
                                GObject bon = new GObject(bonusTexture[5], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height / 2));
                                bon.type = "ruby";
                                bonus.Add(bon);
                            } break;
                        case 'A':
                            {
                                GObject bon = new GObject(bonusTexture[6], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height / 2));
                                bon.type = "box1";
                                bonus.Add(bon);
                            } break;
                        #endregion
                        #region Gum

                        case 'M':
                            {
                                GObject gum = new GObject(gumTexture[0], new Rectangle(x, y, 70, 70));
                                gum.type = "menper";
                                gums.Add(gum);
                            } break;
                        case 'R':
                            {
                                GObject gum = new GObject(gumTexture[1], new Rectangle(x, y, 70, 70));
                                gum.type = "robot";
                                gums.Add(gum);
                            } break;
                        case 'G':
                            {
                                GObject gum = new GObject(gumTexture[4], new Rectangle(x, y, 70, 70));
                                gum.type = "monkey";
                                gums.Add(gum);
                            } break;
                        case 'C':
                            {
                                GObject gum = new GObject(gumTexture[3], new Rectangle(x, y, 70, 70));
                                gum.type = "handG";
                                gums.Add(gum);

                            } break;
                        case 'K':
                            {
                                GObject gum = new GObject(gumTexture[5], new Rectangle(x, y, 70, 70));
                                gum.type = "rock";
                                gums.Add(gum);

                            } break;
                        case 'g':
                            {
                                GObject gum = new GObject(gumTexture[2], new Rectangle(x, y, 70, 70));
                                gum.type = "ghost";
                                gums.Add(gum);
                            } break;
                        #endregion
                    }

                    x += 40;
                }
                x = 0;
                y += 40;
            }
        }
 private void AddButton_Click(object sender, RoutedEventArgs e)
 {
     if (!Save.IsEnabled)
     {
         MessageBox.Show("Спочатку створіть або відкрийте новий рівень!", "!",
                          MessageBoxButton.OK, MessageBoxImage.Exclamation);
         return ;
     }
     try
     {
         if (scrollBar1.Maximum != level.lenghtLevel || inputBox.lenghtLevel != level.lenghtLevel)
             scrollBar1.Maximum = level.lenghtLevel = inputBox.lenghtLevel;
     }
     catch (System.Exception ex) { }
     try
     {
         if (tabControl1.SelectedIndex == 0)
         {
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(200 + ScrollX, 200, 40, 40);
             if (listView1.SelectedIndex == 2)
             { rect.Width = 41; rect.Height = 184; }
             if (listView1.SelectedIndex == 3)
             { rect.Width = 41; rect.Height = 92; }
             if (listView1.SelectedIndex == 4)
             { rect.Width = 280; rect.Height = 220; }
             GObject block = new GObject(level.blockTexture[listView1.SelectedIndex], rect);
             block.type = table.nameElements[listView1.SelectedIndex];
             level.blocks.Add(block);
         }
         if (tabControl1.SelectedIndex == 1)
         {
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(300 + ScrollX, 200, 20, 20);
             GObject bonus = new GObject(level.bonusTexture[listView2.SelectedIndex], rect);
             bonus.type = table.nameBonus[listView2.SelectedIndex];
             level.bonus.Add(bonus);
         }
         if (tabControl1.SelectedIndex == 2)
         {
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(400 + ScrollX, 200, 70, 70);
             GObject gum = new GObject(level.gumTexture[listView3.SelectedIndex], rect);
             gum.type = table.nameGums[listView3.SelectedIndex];
             level.gums.Add(gum);
         }
         if (!level.timerLevel.IsEnabled) level.timerLevel.Start();
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("Спочатку виберіть елемент!",")", MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
     //level.Draw();
 }
 char translationInABC(GObject gobj)
 {
     switch (gobj.type)
     {
         case "block1": return 'X';
         case "block2": return 'Y';
         case "bamboo": return 'B';
         case "bambootopSliceHorizontal": return 'S';
         case "hause1": return 'H';
         case "apple": return 'a';
         case "beetle": return 'b';
         case "hand": return 'h';
         case "heart": return 'c';
         case "men": return 'm';
         case "ruby": return 'r';
         case "box1": return 'A';
         case "menper": return 'M';
         case "robot": return 'R';
         case "monkey": return 'G';
         case "handG": return 'C';
         case "rock": return 'K';
         case "ghost": return 'g';
         default : return' ';
     }
 }
 private void Add_MouseButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (!Save.IsEnabled)
     {
         MessageBox.Show("Спочатку створіть або відкрийте новий рівень!", "!",
                          MessageBoxButton.OK, MessageBoxImage.Exclamation);
         return;
     }
     try
     {
         if (scrollBar1.Maximum != level.lenghtLevel || inputBox.lenghtLevel != level.lenghtLevel)
             scrollBar1.Maximum = level.lenghtLevel = inputBox.lenghtLevel;
     }
     catch (System.Exception ex) { }
     try
     {
         if (tabControl1.SelectedIndex == 0)
         {
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(pozMause.x + ScrollX, pozMause.y, 40, 40);
             if (listView1.SelectedIndex == 2)
             { rect.Width = 41; rect.Height = 184; }
             if (listView1.SelectedIndex == 3)
             { rect.Width = 41; rect.Height = 92; }
             if (listView1.SelectedIndex == 4)
             { rect.Width = 280; rect.Height = 220; }
             GObject block = new GObject(level.blockTexture[listView1.SelectedIndex], rect);
             block.type = table.nameElements[listView1.SelectedIndex];
             if (!block.Bounds.IntersectsWith(rectElem))
                 level.blocks.Add(block);
             rectElem = block.Bounds;
             rectElem.Width = rectElem.Width - rectElem.Width / 10;
             rectElem.Height = rectElem.Height - rectElem.Height / 10;
         }
         if (tabControl1.SelectedIndex == 1)
         {
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(pozMause.x + ScrollX, pozMause.y, 20, 20);
             GObject bonus = new GObject(level.bonusTexture[listView2.SelectedIndex], rect);
             bonus.type = table.nameBonus[listView2.SelectedIndex];
             if (!bonus.Bounds.IntersectsWith(rectElem))
                 level.bonus.Add(bonus);
             rectElem = bonus.Bounds;
             rectElem.Width = rectElem.Width - rectElem.Width / 10;
             rectElem.Height = rectElem.Height - rectElem.Height / 10;
         }
         if (tabControl1.SelectedIndex == 2)
         {
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(pozMause.x + ScrollX, pozMause.y, 70, 70);
             GObject gum = new GObject(level.gumTexture[listView3.SelectedIndex], rect);
             gum.type = table.nameGums[listView3.SelectedIndex];
             if (!gum.Bounds.IntersectsWith(rectElem))
                 level.gums.Add(gum);
             rectElem = gum.Bounds;
             rectElem.Width = rectElem.Width - rectElem.Width / 10;
             rectElem.Height = rectElem.Height - rectElem.Height / 10;
         }
         if (!level.timerLevel.IsEnabled) level.timerLevel.Start();
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("Спочатку виберіть елемент!", ")", MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
 }