public SelectColorForm(IColorRepo repo) { InitializeComponent(); _repo = repo; _item = new ColorBl(); Bind(); }
private void simpleButtonAddColor_Click(object sender, EventArgs e) { var form = new EditColorForm(_repo); if (form.ShowDialog() == DialogResult.OK) { _item = form._item; Bind(); form.Dispose(); } }
public EditColorForm(IColorRepo repo, ColorBl item = null) { InitializeComponent(); _repo = repo; _item = item; if (item != null) { Text = "Редактирование цвета"; } else { Text = "Новый цвет"; _item = new ColorBl(); } textEditName.DataBindings.Add("EditValue", _item, nameof(_item.Name), true, DataSourceUpdateMode.OnPropertyChanged); textEditComment.DataBindings.Add("EditValue", _item, nameof(_item.Comment), true, DataSourceUpdateMode.OnPropertyChanged); }
private void simpleButtonSave_Click(object sender, EventArgs e) { ProcessTabKey(true); if (Validation() == false) { return; } if (_item.Id == 0) { _item = _repo.Add(_item); } else { _repo.Update(_item); } DialogResult = DialogResult.OK; }
private void CreateColorLabel(ColorBl item) { layoutControl1.BeginUpdate(); try { // Create a layout item that will display a new base SimpleLabelItem simpleLabel = new SimpleLabelItem(); simpleLabel.Parent = layoutControlGroup1; simpleLabel.Name = "simpleLabelColor" + item.Id; simpleLabel.Text = $"{item.Name} ({item.Comment})"; simpleLabel.Tag = item; //simpleLabel.OptionsToolTip.ToolTip = $"{item.Name} ({item.Comment})"; //simpleLabel.OptionsToolTip.ImmediateToolTip = true; simpleLabel.DoubleClick += new System.EventHandler(this.lable_DoubleClick); simpleLabel.Move(layoutControlItemButtonColor, InsertType.Top); } finally { // Unlock and update the layout control. layoutControl1.EndUpdate(); } }
public ColorBl Update(ColorBl item) { var dto = _service.Update(item?.ToDto()); return(dto != null ? new ColorBl(dto) : null); }