public win_hopper(DesignerCanvas a, bool isnew = false) { hopperitem = new Dev_Hopper(a.GetPositionID(DesignerCanvas.DeviceType.DEV_HOPPER)); InitializeComponent(); isNew = isnew; this.DataContext = this.hopperitem; for (int i = 0; i < this.cb_type.Items.Count; i++) { int value = Convert.ToInt32((string)(this.cb_type.Items[i] as ComboBoxItem).Tag, 16); if (value == hopperitem.Powder_type) { this.cb_type.SelectedIndex = i; break; } } for (int i = 0; i < this.cb_max_cap.Items.Count; i++) { int value = Convert.ToInt32((string)(this.cb_max_cap.Items[i] as ComboBoxItem).Tag, 10); if (value == hopperitem.Max_capability) { this.cb_max_cap.SelectedIndex = i; break; } } }
private void Button_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; int cmd = Convert.ToInt32(b.CommandParameter); if (cmd == Constant.CMD_ADD) { if (_DesignerCanvas.isValid(DesignerCanvas.DeviceType.DEV_HOPPER)) { _win_hopper = new win_hopper(_DesignerCanvas, true); _win_hopper.Owner = this; _win_hopper.WindowStartupLocation = WindowStartupLocation.CenterOwner; _win_hopper.btn_save.Click += Btn_save_Click; _win_hopper.ShowDialog(); } else { MessageBox.Show("Too many hopper!"); } } else if (cmd == Constant.CMD_EDIT) { int id = Convert.ToInt32(b.Tag); _win_hopper = new win_hopper(_attach_dev.First(c => c.DeviceID == id)); _win_hopper.Owner = this; _win_hopper.WindowStartupLocation = WindowStartupLocation.CenterOwner; _win_hopper.btn_save.Click += Btn_save_Click; _win_hopper.ShowDialog(); } else if (cmd == Constant.CMD_DEL) { int id = Convert.ToInt32(b.Tag); Dev_Hopper item = _attach_dev.First(c => c.DeviceID == id); _DesignerCanvas.ReleasePositionID(item.Position_id, DesignerCanvas.DeviceType.DEV_HOPPER); _attach_dev.Remove(item); } }
public win_hopper(Dev_Hopper hopperitem) { this.hopperitem = hopperitem; InitializeComponent(); this.DataContext = this.hopperitem; for (int i = 0; i < this.cb_type.Items.Count; i++) { int value = Convert.ToInt32((string)(this.cb_type.Items[i] as ComboBoxItem).Tag, 16); if (value == hopperitem.Powder_type) { this.cb_type.SelectedIndex = i; break; } } for (int i = 0; i < this.cb_max_cap.Items.Count; i++) { int value = Convert.ToInt32((string)(this.cb_max_cap.Items[i] as ComboBoxItem).Tag, 10); if (value == hopperitem.Max_capability) { this.cb_max_cap.SelectedIndex = i; break; } } }