private async void button4_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; PointProxy pointProxy = new PointProxy() { X = Convert.ToInt32(XTextBox.Text), Y = Convert.ToInt32(YTextBox.Text), Argb = ColorButton.BackColor.ToArgb(), PointListId = (comboBox1.SelectedItem as PointListProxy).Id }; await PointAdapter.SaveItemAsync(pointProxy); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } finally { this.Cursor = Cursors.Arrow; } }
private void dataGridView2_CellLeave(object sender, DataGridViewCellEventArgs e) { try { if (_isBusy) { return; } this.Cursor = Cursors.WaitCursor; dataGridView2.EndEdit(); List <PointProxy> pointList = (pointProxyBindingSource.DataSource as List <PointProxy>); if (pointList.Count <= 0) { return; } PointProxy point = pointList[e.RowIndex]; if (point.X <= 0 || point.Y <= 0 || point.PointListId <= 0) { return; } point.Id = PointAdapter.SaveItem(point).PointId; } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } finally { this.Cursor = Cursors.Arrow; } }
private async Task <PointListProxy> CreatePoints() { PointListProxy pointListProxy = new PointListProxy() { Name = "Random" + DateTime.Now.ToString(), Points = new List <PointProxy>() }; PointList pointList = await PointListAdapter.SaveItemAsync(pointListProxy); pointListProxy.Id = pointList.PointListId; for (int i = 0; i < _settings.PointsCount; i++) { PointProxy pointProxy = new PointProxy() { X = _random.Next(1, 100), Y = _random.Next(1, 100), Width = 20, Height = 20, PointListId = pointList.PointListId, Argb = Color.Yellow.ToArgb() }; pointListProxy.Points.Add(pointProxy); await PointAdapter.SaveItemAsync(pointProxy); } await PointListAdapter.SaveItemAsync(pointListProxy); return(pointListProxy); }
private async void button2_Click(object sender, EventArgs e) { _isBusy = true; this.Cursor = Cursors.WaitCursor; pointProxyBindingSource.DataSource = await PointAdapter.GetItemsAsync(); this.Cursor = Cursors.Arrow; _isBusy = false; }
private void dataGridView2_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { try { this.Cursor = Cursors.WaitCursor; PointProxy pointProxy = (pointProxyBindingSource.DataSource as List <PointProxy>)[e.Row.Index]; PointAdapter.RemoveItem(pointProxy); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } finally { this.Cursor = Cursors.Arrow; } }
private async void DataForm_Load(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; _isBusy = true; pointProxyBindingSource.DataSource = await PointAdapter.GetItemsAsync(); pointListProxyBindingSource.DataSource = await PointListAdapter.GetItemsAsync(); this.Cursor = Cursors.Arrow; } catch (FileNotFoundException ioEx) { MessageBox.Show("Please set database file in settings", ioEx.Message); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } }
public void GetItem(int pointId) { this.Card = PointAdapter.GetItem(pointId).ToProxy(); }
public void SaveItem() { PointAdapter.SaveItem(this.Card); }