コード例 #1
0
        private void AddElement_Click(object sender, RoutedEventArgs e)
        {
            var planetWindow = new PlanetWindow(new Planet());

            if (planetWindow.ShowDialog() == true)
            {
                PlanetList.Items.Add(planetWindow.planet);
            }
        }
コード例 #2
0
        private void PlanetList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var planet = PlanetList.SelectedItem as Planet;

            if (planet == null)
            {
                return;
            }
            var planetWindow = new PlanetWindow(planet);

            if (planetWindow.ShowDialog() == true)
            {
                var si = PlanetList.SelectedIndex;
                PlanetList.Items.RemoveAt(si);
                PlanetList.Items.Insert(si, planetWindow.planet);
            }
            if (PlanetList.Items.Count != 0)
            {
                DeleteElement.IsEnabled = true;
            }
        }
コード例 #3
0
        private void PlanetList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var planet = PlanetList.SelectedItem as Planet;

            if (planet == null)
            {
                return;
            }
            var planetWindow = new PlanetWindow(planet.Clone());
            var res          = planetWindow.ShowDialog();

            if (res == true)
            {
                var si = PlanetList.SelectedIndex;
                PlanetList.Items.RemoveAt(si);
                PlanetList.Items.Insert(si, planetWindow.planet);
            }
            if (PlanetList.Items.Count != 0)
            {
                DeleteElement.IsEnabled = true;
            }
        }