Ejemplo n.º 1
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            //var larray = ((ListBox)Application.Current.Windows[0].FindName("listBox1")).Items;
            //List<Locality> listL = new List<Locality>();
            //foreach (var item in larray)
            //{
            //    if()
            //    listL.Add((Locality)item);
            //}

            Locality l    = (Locality)((ListBox)Application.Current.Windows[0].FindName("listBox1")).SelectedItem;
            ListBox  list = ((ListBox)Application.Current.Windows[0].FindName("listBox1"));

            l.RemoveProperty((Property)listBox1.SelectedItem);
            listBox1.Items.Remove((Property)listBox1.SelectedItem);
            //list.Items.Remove((Property)listBox1.SelectedItem);
            //list.Items.Clear();

            //list.Items.Add(l);
            //foreach (var item in listL)
            //{
            //    list.Items.Add(item);
            //}
            if (l.plots != null)
            {
                listBox1.Items.Clear();
                foreach (var plot in l.plots)
                {
                    listBox1.Items.Add(plot);
                }
            }
        }
Ejemplo n.º 2
0
        public Window3()
        {
            InitializeComponent();
            comboBox1.Items.Add(Appointment.AppointmentValue.Agricultural);
            comboBox1.Items.Add(Appointment.AppointmentValue.Reserved);
            comboBox1.Items.Add(Appointment.AppointmentValue.UnderBuilding);

            comboBox2.Items.Add(Description.SoilType.Chalk);
            comboBox2.Items.Add(Description.SoilType.Clay);
            comboBox2.Items.Add(Description.SoilType.Loam);
            comboBox2.Items.Add(Description.SoilType.Peat);
            comboBox2.Items.Add(Description.SoilType.Sandy);
            comboBox2.Items.Add(Description.SoilType.Silt);

            try
            {
                Locality l = (Locality)((ListBox)Application.Current.Windows[0].FindName("listBox1")).SelectedItem;

                ListBox plist  = (ListBox)Application.Current.Windows[0].FindName("listBox1");
                ListBox pslist = (ListBox)Application.Current.Windows[2].FindName("listBox1");

                if (pslist != null && pslist.Items.Count != 0)
                {
                    Property p = (Property)pslist.SelectedItem;
                    if (p != null)
                    {
                        pslist.Items.Remove(p);
                        l.RemoveProperty(p);
                        plist.Items.Remove(p);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }