Ejemplo n.º 1
0
 private void buttonOutputRoomInfo_Click(object sender, EventArgs e)
 {
     try
     {
         var           deserializeRoom = XmlSerializeWrapper.Deserialize <Room>("room.xml");
         StringBuilder roomInfo        = new StringBuilder();
         roomInfo.AppendLine($"Название комнаты: {deserializeRoom.Name}");
         roomInfo.AppendLine($"Метраж комнаты: {deserializeRoom.Footage}");
         roomInfo.AppendLine($"Количество окон: {deserializeRoom.AmountWindows}");
         roomInfo.AppendLine($"Сторона окон: {deserializeRoom.SideWindows}");
         textBoxRoomInfo.Text = roomInfo.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show($"{ex.Message}");
     }
 }
Ejemplo n.º 2
0
        private void buttonOutputInfo_Click(object sender, EventArgs e)
        {
            List <Flat> flatsCollection = XmlSerializeWrapper.Deserialize <List <Flat> >("flat.xml");
            int         counterFlats    = 0;

            textBoxFlatInfo.Text = string.Empty;
            foreach (var flat in flatsCollection)
            {
                counterFlats++;
                StringBuilder outputLine = new StringBuilder();
                outputLine.AppendLine($"Квартира [ {counterFlats} ]");
                outputLine.AppendLine("Метраж квартиры :" + flat.Footage.ToString() + ";");
                outputLine.AppendLine(labelRooms.Text + ":" + flat.AmountOfRooms.ToString() + ";");
                outputLine.AppendLine("Комнаты: ");
                if (flat.Balcony)
                {
                    outputLine.AppendLine(" - Балкон;");
                }
                if (flat.Basement)
                {
                    outputLine.AppendLine(" - Подвал;");
                }
                if (flat.Bathroom)
                {
                    outputLine.AppendLine(" - Ванная комната;");
                }
                if (flat.Kitchen)
                {
                    outputLine.AppendLine(" - Кухня");
                }
                if (flat.LivingRoom)
                {
                    outputLine.AppendLine(" - Спальня");
                }
                outputLine.AppendLine(labelYear.Text + " : " + flat.Year + ";");
                outputLine.AppendLine(labelMaterial.Text + " : " + flat.Material + ";");
                outputLine.AppendLine(labelFloor.Text + " : " + flat.Floor + ";");
                outputLine.AppendLine("Адрес:" + flat.address.Country + "\n" + flat.address.District + "," + flat.address.Street + "\n д." +
                                      flat.address.HouseNumber + ", кв." + flat.address.FlatNumber + ";");
                outputLine.AppendLine(labelCostFlat.Text + " : " + flat.Cost + "$ ;");
                outputLine.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
                textBoxFlatInfo.Text += outputLine.ToString();
            }
            toolStripStatusLabelAction.Text = "Вывод из файла";
        }