コード例 #1
0
        private void RLSList_Set(ref ListBoxItem lbi, ref RLSOptionsWindow dlg)
        {
            Thickness thick = new Thickness(5.0);
            Grid      gr    = new Grid();

            gr.ColumnDefinitions.Add(new ColumnDefinition());
            gr.ColumnDefinitions[0].Width = new GridLength(2.0, GridUnitType.Star);
            gr.ColumnDefinitions.Add(new ColumnDefinition());
            gr.ColumnDefinitions[1].Width = new GridLength(0.7, GridUnitType.Star);
            gr.ColumnDefinitions.Add(new ColumnDefinition());
            gr.ColumnDefinitions[2].Width = new GridLength(0.7, GridUnitType.Star);
            gr.ColumnDefinitions.Add(new ColumnDefinition());
            gr.ColumnDefinitions[3].Width = new GridLength(1.0, GridUnitType.Star);
            gr.ColumnDefinitions.Add(new ColumnDefinition());
            gr.ColumnDefinitions[4].Width = new GridLength(1.0, GridUnitType.Star);
            gr.HorizontalAlignment        = HorizontalAlignment.Stretch;
            gr.ShowGridLines = true;

            TextBlock nameTextBlock = new TextBlock();

            nameTextBlock.Text   = dlg.nameTextBox.Text;
            nameTextBlock.Margin = thick;
            Grid.SetColumn(nameTextBlock, 0);

            TextBlock typeTextBlock = new TextBlock();

            typeTextBlock.Text   = dlg.typeComboBox.Text;
            typeTextBlock.Margin = thick;
            Grid.SetColumn(typeTextBlock, 1);

            TextBlock distTextBlock = new TextBlock();

            distTextBlock.Text   = dlg.distSlider.Value.ToString() + " км";
            distTextBlock.Margin = thick;
            Grid.SetColumn(distTextBlock, 2);

            Button grdColorButton = new Button();

            grdColorButton.Background = Brushes.DarkGreen;
            grdColorButton.Margin     = thick;
            Grid.SetColumn(grdColorButton, 3);
            grdColorButton.Click += new RoutedEventHandler(ColorButton_Click);

            Button vsrColorButton = new Button();

            vsrColorButton.Background = Brushes.White;
            vsrColorButton.Margin     = thick;
            Grid.SetColumn(vsrColorButton, 4);
            vsrColorButton.Click += new RoutedEventHandler(ColorButton_Click);

            gr.Children.Add(nameTextBlock);
            gr.Children.Add(typeTextBlock);
            gr.Children.Add(distTextBlock);
            gr.Children.Add(grdColorButton);
            gr.Children.Add(vsrColorButton);

            lbi.Content = gr;
        }
コード例 #2
0
        public void AddButton_Click(object sender, RoutedEventArgs e)
        {
            RLSOptionsWindow dlg = new RLSOptionsWindow();

            dlg.ShowDialog();

            if (dlg.DialogResult.Value == true)
            {
                RLS rls = new RLS();
                rls.Set(ref dlg.rls_ui);
                rlsList.Add(rls);

                ListBoxItem lbi = new ListBoxItem();
                RLSList_Set(ref lbi, ref dlg);
                rlsListBox.Items.Add(lbi);
            }
        }
コード例 #3
0
        public void OptionsButton_Click(object sender, RoutedEventArgs e)
        {
            RLSOptionsWindow dlg = new RLSOptionsWindow();

            dlg.rls_ui.Set(rlsList[rlsListBox.SelectedIndex]);

            dlg.ShowDialog();
            if (dlg.DialogResult.Value == true)
            {
                RLS rls = new RLS();
                rls.Set(ref dlg.rls_ui);
                rlsList[rlsListBox.SelectedIndex] = rls;

                ListBoxItem lbi = new ListBoxItem();
                RLSList_Set(ref lbi, ref dlg);
                int i = rlsListBox.SelectedIndex;
                rlsListBox.Items.RemoveAt(i);
                rlsListBox.Items.Insert(i, lbi);
            }
        }