//============================================================================* // cChargeList() - Copy Constructor //============================================================================* public cChargeList(cChargeList ChargeList) { foreach (cCharge Charge in ChargeList) { cCharge NewCharge = new cCharge(Charge); Add(NewCharge); } Sort(new cChargeComparer()); }
//============================================================================* // cLoad() - Copy Constructor //============================================================================* public cLoad(cLoad Load) { m_eFirearmType = Load.m_eFirearmType; m_Caliber = Load.m_Caliber; m_Bullet = Load.m_Bullet; m_Powder = Load.m_Powder; m_Case = Load.m_Case; m_Primer = Load.m_Primer; m_fChecked = Load.m_fChecked; m_fIdentity = Load.m_fIdentity; m_ChargeList = new cChargeList(Load.m_ChargeList); }
//============================================================================* // OnDrawSubItem() //============================================================================* protected override void OnDrawSubItem(DrawListViewSubItemEventArgs args) { if (args.ColumnIndex < 3) { args.DrawDefault = true; return; } cLoad Load = (cLoad)args.Item.Tag; cChargeList ChargeList = Load.ChargeList; cCharge Charge = ChargeList[args.ColumnIndex - 3]; Color StartColor = cm_StartColor; Color EndColor = cm_EndColor; if (args.ColumnIndex == 3) { if (ChargeList.Count > 1) { EndColor = cm_MidColor; } } else { StartColor = cm_MidColor; if (ChargeList.Count > args.ColumnIndex - 2) { EndColor = cm_MidColor; } } LinearGradientBrush brush = new LinearGradientBrush(args.Bounds, StartColor, EndColor, LinearGradientMode.Horizontal); args.Graphics.FillRectangle(brush, args.Bounds); SizeF TextSize = args.Graphics.MeasureString(args.SubItem.Text, SystemFonts.DefaultFont, args.Bounds.Width); float x = args.Bounds.Left + (args.Bounds.Width / 2) - (TextSize.Width / 2) - (Charge.Favorite ? (Properties.Resources.Favorite.Width / 2) : 0); float y = args.Bounds.Top + (args.Bounds.Height / 2) - (TextSize.Height / 2); if (StartColor == cm_StartColor && EndColor == cm_MidColor) { x = args.Bounds.Left; } if (StartColor == cm_MidColor && EndColor == cm_EndColor) { x = args.Bounds.Left + args.Bounds.Width - TextSize.Width; if (Charge.Favorite && EndColor != cm_EndColor) { x -= Properties.Resources.Favorite.Width; } if (Charge.Reject && EndColor != cm_EndColor) { x -= Properties.Resources.Reject.Width; } } Brush ItemBrush = SystemBrushes.WindowText; if (StartColor == cm_StartColor || EndColor == cm_EndColor) { ItemBrush = SystemBrushes.HighlightText; } Font TextFont; if (Charge.Reject) { TextFont = new Font(SystemFonts.DefaultFont, FontStyle.Strikeout); } else { if (Charge.Favorite) { TextFont = new Font(SystemFonts.DefaultFont, FontStyle.Bold); } else { TextFont = new Font(SystemFonts.DefaultFont, FontStyle.Regular); } } args.Graphics.DrawString(args.SubItem.Text, TextFont, ItemBrush, x, y); if (Charge.Favorite) { Bitmap FavoriteBitmap = Properties.Resources.Favorite; FavoriteBitmap.MakeTransparent(Color.White); if (EndColor == cm_EndColor) { args.Graphics.DrawImage(FavoriteBitmap, x - FavoriteBitmap.Width, y, FavoriteBitmap.Width, FavoriteBitmap.Height); } else { args.Graphics.DrawImage(FavoriteBitmap, x + TextSize.Width, y, FavoriteBitmap.Width, FavoriteBitmap.Height); } } if (Charge.Reject) { Bitmap RejectBitmap = Properties.Resources.Reject; RejectBitmap.MakeTransparent(Color.White); if (EndColor == cm_EndColor) { args.Graphics.DrawImage(RejectBitmap, x - RejectBitmap.Width, y, RejectBitmap.Width, RejectBitmap.Height); } else { args.Graphics.DrawImage(RejectBitmap, x + TextSize.Width, y, RejectBitmap.Width, RejectBitmap.Height); } } }