private void dgvModelCatrige_SelectionChanged(object sender, EventArgs e) { DataGridViewRow selectedRow = null; if (dgvModelCatrige.SelectedRows.Count > 0) { selectedRow = dgvModelCatrige.SelectedRows[0]; } if (selectedRow == null) { return; } LabID.Text = selectedRow.Cells["CatrigeModelID"].Value.ToString(); CatrigeModelNameTB.Text = selectedRow.Cells["CatirgeModelName"].Value.ToString(); ColorCB.SelectedIndex = ColorCB.FindStringExact(selectedRow.Cells["CatrigeColor"].Value.ToString()); }
public PlayerSetting(MapEditor _mapEditor, int playerID) { InitializeComponent(); PlayerIndex.Text = "플레이어 " + (playerID + 1).ToString(); playerBinding = new PlayerBinding(_mapEditor, playerID); _mapEditor.mapDataBinding.playerBindings.Add(playerBinding); this.DataContext = playerBinding; for (int i = 0; i < MapData.ColorName.Length; i++) { ComboBoxItem comboBoxItem = new ComboBoxItem(); DockPanel dockPanel = new DockPanel(); dockPanel.Width = 80; TextBlock textBlock = new TextBlock(); textBlock.Text = MapData.ColorName[i]; textBlock.VerticalAlignment = VerticalAlignment.Center; Border border = new Border(); border.Width = 24; border.Height = 24; border.Margin = new Thickness(-10, -4, 4, -4); Color color = Color.FromRgb(MapData.PlayerColors[i].R, MapData.PlayerColors[i].G, MapData.PlayerColors[i].B); border.Background = new SolidColorBrush(color); dockPanel.Children.Add(border); dockPanel.Children.Add(textBlock); comboBoxItem.Content = dockPanel; ColorCB.Items.Add(comboBoxItem); } { ComboBoxItem comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = "랜덤 색상"; ColorCB.Items.Add(comboBoxItem); } { ComboBoxItem comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = "플레이어 선택"; ColorCB.Items.Add(comboBoxItem); } { ComboBoxItem comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = "커스텀 RGB"; ColorCB.Items.Add(comboBoxItem); } { Binding myBinding = new Binding("Owner"); myBinding.Mode = BindingMode.TwoWay; myBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; OwnerCB.SetBinding(ComboBox.SelectedIndexProperty, myBinding); } { Binding myBinding = new Binding("Race"); myBinding.Mode = BindingMode.TwoWay; myBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; RaceCB.SetBinding(ComboBox.SelectedIndexProperty, myBinding); } { Binding myBinding = new Binding("Color"); myBinding.Mode = BindingMode.TwoWay; myBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; ColorCB.SetBinding(ComboBox.SelectedIndexProperty, myBinding); } { Binding myBinding = new Binding("BackColor"); myBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; Colorize.SetBinding(Button.BackgroundProperty, myBinding); } }
public AddElement(int mode) { InitializeComponent(); Mode = mode; switch (mode) { case 0: ElementPicture.Image = Image.FromFile("horse-head.png"); ElementName.Text = "Add horse"; TrainerTB.Hide(); trainerLbl.Hide(); for (int i = 1; i < 9; i++) { foreach (Control cntrl in flowLayoutPanel1.Controls) { if (cntrl.Name.Equals($"prtcp{i}")) { cntrl.Hide(); } if (cntrl.Name.Equals($"prtcp{i}zone")) { cntrl.Hide(); break; } } } break; case 1: ElementPicture.Image = Image.FromFile("horserider_horse_race-512-1.png"); ElementName.Text = "Add rider"; ColorCB.Hide(); colorlbl.Hide(); WeigthTB.Hide(); weigthlbl.Hide(); HeightTB.Hide(); heightlbl.Hide(); BirthDateMTB.Hide(); birthdatelbl.Hide(); MotherTB.Hide(); motherlbl.Hide(); FatherTB.Hide(); fatherlbl.Hide(); for (int i = 1; i < 9; i++) { foreach (Control cntrl in flowLayoutPanel1.Controls) { if (cntrl.Name.Equals($"prtcp{i}")) { cntrl.Hide(); } if (cntrl.Name.Equals($"prtcp{i}zone")) { cntrl.Hide(); break; } } } break; case 2: ElementPicture.Image = Image.FromFile("icon.png"); ElementName.Text = "Add lap"; AddButton.Image = Image.FromFile("horse-running-silhouette-facing-right.png"); AddButton.ImageAlign = ContentAlignment.MiddleCenter; ColorCB.Hide(); colorlbl.Hide(); WeigthTB.Hide(); weigthlbl.Hide(); HeightTB.Hide(); heightlbl.Hide(); BirthDateMTB.Hide(); birthdatelbl.Hide(); MotherTB.Hide(); motherlbl.Hide(); FatherTB.Hide(); fatherlbl.Hide(); TrainerTB.Hide(); trainerLbl.Hide(); sexlbl.Hide(); SexCB.Hide(); break; } }