コード例 #1
0
        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;
            }
        }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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;
        }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 public void GetItem(int pointId)
 {
     this.Card = PointAdapter.GetItem(pointId).ToProxy();
 }
コード例 #8
0
 public void SaveItem()
 {
     PointAdapter.SaveItem(this.Card);
 }