コード例 #1
0
        private void updateCell(DataGridViewCell cell, bool sync)
        {
            TaskRow taskRow = cell.OwningRow.Tag as TaskRow;

            System.Diagnostics.Debug.WriteLine(String.Format("Bitches {0}", cell.OwningColumn.HeaderText));
            if (taskRow.has_key(cell.OwningColumn.HeaderText))
            {
                Hashtable data = taskRow[cell.OwningColumn.HeaderText];
                cell.Value = data["value"];
                cell.Style = null;
                if (sync == false)
                {
                    cell.Style.ForeColor          = System.Drawing.Color.Gray;
                    cell.Style.SelectionForeColor = System.Drawing.Color.Gray;
                }
                else if (syncCheckboxes.ContainsKey(cell.OwningColumn.Index) && (syncCheckboxes[cell.OwningColumn.Index].Checked == false))
                {
                    cell.Style.ForeColor          = System.Drawing.Color.Gray;
                    cell.Style.SelectionForeColor = System.Drawing.Color.Gray;
                }
                else if ((bool)data["errored"] == true)
                {
                    cell.Style.ForeColor          = System.Drawing.Color.Red;
                    cell.Style.SelectionForeColor = System.Drawing.Color.Red;
                    cell.Style.BackColor          = System.Drawing.Color.Bisque;
                }
                else if ((bool)data["different"] == true)
                {
                    cell.Style.ForeColor          = System.Drawing.Color.DarkGreen;
                    cell.Style.SelectionForeColor = System.Drawing.Color.DarkGreen;
                    cell.Style.BackColor          = System.Drawing.Color.Honeydew;
                }
            }
        }
コード例 #2
0
        private void updateRowStatus(DataGridViewRow row, bool syncChanged = false)
        {
            TaskRow taskRow   = row.Tag as TaskRow;
            String  oldStatus = row.Cells[StatusColumn.Index].Value as String;
            String  newStatus = taskRow.status;

            row.Cells[StatusColumn.Index].Value = newStatus;
            row.Cells[StatusColumn.Index].Style = null;
            row.Visible = (!filterOutRow(row) && (newStatus != "Skip"));
            bool sync = (row.Cells[SyncColumn.Index].Value != null) && ((bool)row.Cells[SyncColumn.Index].Value == true);

            if (sync == false)
            {
                row.Cells[StatusColumn.Index].Style.ForeColor          = System.Drawing.Color.Gray;
                row.Cells[StatusColumn.Index].Style.SelectionForeColor = System.Drawing.Color.Gray;
            }
            else
            {
                switch (newStatus)
                {
                case "Error":
                case "Omit":
                case "Remove":
                    row.Cells[StatusColumn.Index].Style.ForeColor          = System.Drawing.Color.Red;
                    row.Cells[StatusColumn.Index].Style.SelectionForeColor = System.Drawing.Color.Red;
                    break;

                case "Create":
                    row.Cells[StatusColumn.Index].Style.ForeColor          = System.Drawing.Color.Green;
                    row.Cells[StatusColumn.Index].Style.SelectionForeColor = System.Drawing.Color.Green;
                    break;

                case "Update":
                    row.Cells[StatusColumn.Index].Style.ForeColor          = System.Drawing.Color.Blue;
                    row.Cells[StatusColumn.Index].Style.SelectionForeColor = System.Drawing.Color.Blue;
                    break;

                case "Skip":
                    row.Cells[StatusColumn.Index].Style.ForeColor          = System.Drawing.Color.MediumTurquoise;
                    row.Cells[StatusColumn.Index].Style.SelectionForeColor = System.Drawing.Color.MediumTurquoise;
                    break;

                default:
                    throw new Exception("Unknown row status: " + status);
                }
            } // sync

            // update status bar
            if (oldStatus != newStatus)
            {
                if (oldStatus != null && statusCounts.ContainsKey(oldStatus) && (statusCounts[oldStatus] > 0))
                {
                    statusCounts[oldStatus]--;
                }
                statusCounts[newStatus]++;
            }
            else
            {
                if (syncChanged)
                {
                    int adjustment = (sync) ? 1 : -1;
                    statusCounts[newStatus] += adjustment;
                    statusCounts["Skip"]    -= adjustment;
                }
            }
            status.Items[0].Text = String.Format(
                "{0} tasks.   {1} updates. {2} creates. {3} omits. {4} removes. {5} errors. {6} skipped.",
                statusCounts["Total"],
                statusCounts["Update"],
                statusCounts["Create"],
                statusCounts["Omit"],
                statusCounts["Remove"],
                statusCounts["Error"],
                statusCounts["Skip"]
                );
        }