public void AddRow(string info, PornDatabase.PornItemType itype, PornDatabase.PornItemStatus status) { DataRow dr = _pornItemDataTable.NewRow(); if (!_viewProtectionLogs) { dr.SetField <bool>("checked", _ifCheckAll); } dr.SetField <string>("info", info); //dr.SetField<string>("desc", "12"); dr.SetField <PornDatabase.PornItemStatus>("status", status); dr.SetField <PornDatabase.PornItemType>("item_type", itype); dr.SetField <DateTime>("created_at", DateTime.Now); _pornItemDataTable.Rows.Add(dr); if (_showLastestItem) { try { _dataGridView.CurrentCell = _dataGridView.Rows[0].Cells["info"]; } catch (Exception exp) { log.Error(exp.ToString()); } } }
void PornDataGridViewOnCellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } DataGridView dgView = (DataGridView)(sender); // no need to add TaskTime... if (e.ColumnIndex == dgView.Columns["created_at"].Index) { try { DateTime dsutc = (DateTime)e.Value; e.Value = TimeZoneInfo.ConvertTimeFromUtc(dsutc, TimeZoneInfo.Local); } catch (Exception ex) { log.Equals(ex.ToString()); } } else if (e.ColumnIndex == dgView.Columns["item_type"].Index) { PornDatabase.PornItemType type = (PornDatabase.PornItemType)(Int64) e.Value; if (type == PornDatabase.PornItemType.Undefined) { e.Value = "未知"; } else if (type == PornDatabase.PornItemType.PornDomain) { e.Value = "不良网站"; } else if (type == PornDatabase.PornItemType.NetworkImage) { e.Value = "网络图片"; } else if (type == PornDatabase.PornItemType.NetworkVideo) { e.Value = "网络视频"; } else if (type == PornDatabase.PornItemType.LocalImage) { e.Value = "本地图片"; } else if (type == PornDatabase.PornItemType.LocalVideo) { e.Value = "本地视频"; } } else if (e.ColumnIndex == dgView.Columns["status"].Index) { PornDatabase.PornItemStatus status = (PornDatabase.PornItemStatus)(Int64) e.Value; if (status == PornDatabase.PornItemStatus.Undefined) { e.Value = "未知"; } else if (status == PornDatabase.PornItemStatus.Normal) { e.Value = "已屏蔽"; } else if (status == PornDatabase.PornItemStatus.Trusted) { e.Value = "已信任"; } } }