Ejemplo n.º 1
0
        void UpdateRowTime(int row)
        {
            TrackedRaid raid = (TrackedRaid)dataGridView1.Rows[row].Cells[2].Tag;

            if (raid == null)
            {
                dataGridView1.Rows[row].Cells[2].Value =
                    dataGridView1.Rows[row].Cells[3].Value
                    = null;

                dataGridView1.Rows[row].Cells[3].Style.BackColor = Color.White;

                return;
            }

            dataGridView1.Rows[row].Cells[2].Value = raid.LastSeen;
            var next = raid.Next();

            dataGridView1.Rows[row].Cells[3].Value = next;

            if ((next - DateTime.Now).Days == 0)
            {
                dataGridView1.Rows[row].Cells[3].Style.BackColor = Color.PaleVioletRed;
            }
        }
Ejemplo n.º 2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2)
            {
                var cell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
                var raid = (DataReader.Raid)dataGridView1.Rows[e.RowIndex].Tag;

                TrackedRaid trackedRaid = null;
                if (cell.Tag != null)
                {
                    trackedRaid = (TrackedRaid)cell.Tag;
                }



                var timePicker = new Form_DateTimePicker();
                timePicker.StartPosition = FormStartPosition.Manual;
                timePicker.Location      = Cursor.Position;

                if (trackedRaid != null)
                {
                    timePicker.SetDateTime(trackedRaid.LastSeen);
                }

                timePicker.FormClosing += (s, ee) =>
                {
                    switch (timePicker.DialogResult)
                    {
                    case DialogResult.OK:
                        if (trackedRaid == null)
                        {
                            trackedRaid = new TrackedRaid(raid, timePicker.SelectedTime);
                            cell.Tag    = trackedRaid;
                            TrackedRaids.Add(trackedRaid);
                        }
                        else
                        {
                            trackedRaid.LastSeen = timePicker.SelectedTime;
                        }

                        UpdateRowTime(e.RowIndex);
                        break;

                    case DialogResult.Abort:
                        if (trackedRaid != null)
                        {
                            cell.Tag = null;
                            TrackedRaids.Remove(trackedRaid);
                            UpdateRowTime(e.RowIndex);
                        }

                        break;
                    }

                    dataGridView1.Invalidate();

                    if (timePicker.DialogResult != DialogResult.None)
                    {
                        SaveXML();
                    }
                };

                timePicker.Show();
            }
        }