Ejemplo n.º 1
0
        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case "Count":
                        reader.Read();
                        _count = Int32.Parse(reader.Value);
                        break;

                    case "Lumbers":
                        _lumbers = Lumber.ReadWoodsList(reader);
                        CalculateTotalPrice();
                        break;
                    }
                }
                if (reader.Name.Equals("Workshop"))
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private void Create_Button_Click(object sender, RoutedEventArgs e)
        {
            Lumber    newLumber   = new Lumber();
            lumberWPF lumberModal = new lumberWPF(newLumber);

            if (lumberModal.ShowDialog() == true)
            {
                workshopWP.AddLumber(newLumber);
                workshopWP.CalculateTotalPrice();
                Lumber_List.Items.Add(newLumber.ToString());
                TotalPrice_Label.Content  = workshopWP.TotalLumberPrice.ToString();
                CountObject_Label.Content = Lumber_List.Items.Count;
            }
            else
            {
                MessageBox.Show("Изменения не сохранены");
            }
        }
Ejemplo n.º 3
0
        //public object Clone()
        //{
        //    var woodClone = Wood.Clone() as Wood;
        //    return new Lumber(woodClone, SawingOption, DateOfDelivery, Marking, Quantity, Price);
        //}
        public static List <Lumber> ReadWoodsList(XmlReader reader)
        {
            List <Lumber> lumbers = new List <Lumber>();

            reader.MoveToContent();
            while (reader.Read())
            {
                if (reader.IsStartElement() && !reader.Name.Equals("Lumbers"))
                {
                    Lumber lumber = new Lumber();
                    lumber.ReadXml(reader);
                    lumbers.Add(lumber);
                }
                else
                {
                    break;
                }
            }
            return(lumbers);
        }
Ejemplo n.º 4
0
        public lumberWPF(Lumber lumber)
        {
            InitializeComponent();

            SawingOption[] option = (SawingOption[])Enum.GetValues(typeof(SawingOption));
            foreach (SawingOption soption in option)
            {
                SavingOption_ComboBox.Items.Add(soption.ToString());
            }
            lumberWP = lumber;
            woods    = Wood.ReadWoodsList("woods");
            woods.ForEach(author =>
            {
                Woods_ComboBox.Items.Add(author.ToString());
            });

            if (lumberWP != null && lumberWP.Wood != null)
            {
                Woods_ComboBox.SelectedIndex = Woods_ComboBox.Items.IndexOf(lumber.Wood.ToString());
                Marking_TextBox.Text         = lumberWP.Marking.ToString();
                Quantity_TextBox.Text        = lumberWP.Quantity.ToString();
                Price_TextBox.Text           = lumberWP.Price.ToString();
            }
        }
Ejemplo n.º 5
0
 public void RemoveLumber(Lumber lumber)
 {
     _lumbers.Remove(lumber);
 }
Ejemplo n.º 6
0
 public void AddLumber(Lumber lumber)
 {
     _lumbers.Add(lumber);
 }