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; } }
public static async Task <Point> SaveItemAsync(PointProxy pointProxy) { Point point = CreatePoint(pointProxy); await LocalContext.Instance.SaveChangesAsync(); return(point); }
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 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; } }
public static Point SaveItem(PointProxy pointProxy) { Point point = CreatePoint(pointProxy); LocalContext.Instance.SaveChanges(); return(point); }
public static void RemoveItem(PointProxy pointProxy) { Point point = GetItem(pointProxy.Id); if (point == null) { return; } LocalContext.Instance.Points.Remove(point); LocalContext.Instance.SaveChanges(); }
private async Task ShowPoint(PointProxy point) { await Task.Factory.StartNew(() => { if (point.Color.Name == "0") { point.Argb = Color.Yellow.ToArgb(); } _graphics.FillEllipse(new SolidBrush(point.Color), new Rectangle(point.X * this.Width / 100, point.Y * this.Height / 100, point.Width, point.Height)); Thread.Sleep(_settings.DisplayTime); _graphics.Clear(_settings.BackgroundColor); Thread.Sleep(_settings.Interval); }); }
public PointProxy ToProxy() { PointProxy pointProxy = new PointProxy() { Id = this.PointId, X = this.X, Y = this.Y, Width = this.Width, Height = this.Height, PointListId = this.PointListId, Argb = this.Argb, }; return(pointProxy); }
private void dataGridView2_CellEnter(object sender, DataGridViewCellEventArgs e) { if (dataGridView2.Columns[e.ColumnIndex].HeaderText == "Color") { if (colorDialog1.ShowDialog() == DialogResult.OK) { List <PointProxy> pointList = (pointProxyBindingSource.DataSource as List <PointProxy>); if (pointList.Count <= 0) { return; } PointProxy point = pointList[e.RowIndex]; point.Argb = colorDialog1.Color.ToArgb(); } } }
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 static Point CreatePoint(PointProxy pointProxy) { Point point = GetItem(pointProxy.Id); if (point == null) { point = new Point(); LocalContext.Instance.Points.Add(point); } point.PointId = pointProxy.Id; point.X = pointProxy.X; point.Y = pointProxy.Y; point.Width = pointProxy.Width; point.Height = pointProxy.Height; point.Argb = pointProxy.Argb; point.PointListId = pointProxy.PointListId; return(point); }
public void GetItem(int pointId) { this.Card = PointAdapter.GetItem(pointId).ToProxy(); }