protected override void OnRender(Gdi graphics, Rectangle clipRect) { if (_leftBorder != null && _rightBorder != null && _topBorder != null && _bottomBorder != null) { Rectangle rect = new Rectangle(clipRect.Left + _leftBorderSize.Width, clipRect.Top + _topBorderSize.Height, clipRect.Width - _leftBorderSize.Width - _rightBorderSize.Width, _leftBorderSize.Height - _topBorderSize.Height - _bottomBorderSize.Height); if (_leftBorder != null) { graphics.DrawImageAlphaChannel(_leftBorder, clipRect.Left, clipRect.Top); } if (_rightBorder != null) { graphics.DrawImageAlphaChannel(_rightBorder, rect.Right, clipRect.Top); } if (_topBorder != null) { graphics.DrawImageAlphaChannel(_topBorder, new Rectangle(rect.Left, clipRect.Top, rect.Width, _topBorderSize.Height)); } if (_bottomBorder != null) { graphics.DrawImageAlphaChannel(_bottomBorder, new Rectangle(rect.Left, rect.Bottom, rect.Width, _topBorderSize.Height)); } if (BackColor != Color.Empty) { graphics.FillRect(rect, BackColor); } } else { //if (BackColor != Color.Empty) // graphics.FillRect(clipRect, BackColor); } if (_textbox.Visible) { // } else { _label.Render(graphics, clipRect); } }
public override void DrawItemOn(Gdi g, Rectangle rItem) { int x = rItem.Width / 2; int y = (rItem.Height - _imageSize.Height) / 2; Color color1; Color color2; g.Font = Font; if ((string)DataSource.OptionValue == DataSource.OptionValues[0]) { if (_itemLeftSelected != null) { g.DrawImageAlphaChannel(_itemLeftSelected, rItem.Left + x - _imageSize.Width, rItem.Top + y); } if (_itemRight != null) { g.DrawImageAlphaChannel(_itemRight, rItem.Left + x, rItem.Top + y); } color1 = Color.White; color2 = Color.Gray; } else { if (_itemLeft != null) { g.DrawImageAlphaChannel(_itemLeft, rItem.Left + x - _imageSize.Width, rItem.Top + y); } if (_itemRightSelected != null) { g.DrawImageAlphaChannel(_itemRightSelected, rItem.Left + x, rItem.Top + y); } color1 = Color.Gray; color2 = Color.White; } g.TextAlign = Win32.TextAlign.TA_LEFT; g.TextColor = color1; Size textSize = g.GetTextExtent(DataSource.OptionValues[0]); y = (rItem.Height - textSize.Height) / 2; int left = x - _imageSize.Width; g.ExtTextOut(rItem.Left + left, rItem.Top + y, _imageSize.Width, DataSource.OptionValues[0]); g.TextColor = color2; left = x; g.ExtTextOut(rItem.Left + left, rItem.Top + y, _imageSize.Width, DataSource.OptionValues[1]); }
public override void DrawItemOn(Gdi g, Rectangle rItem) { int y = (rItem.Height - _imageSize.Height) / 2; g.Font = Font; if (_selectButton != null) { g.DrawImageAlphaChannel(_selectButton, rItem.Right - _imageSize.Width - UISettings.CalcPix(15), rItem.Top + y); } g.TextColor = Color.FromArgb(51, 153, 255); var textSize = g.GetTextExtent((string)DataSource.OptionValue); y = (rItem.Height - textSize.Height) / 2; int x = rItem.Width - UISettings.CalcPix(20) - _imageSize.Width; if (textSize.Width < x) { x = textSize.Width; } g.DrawText((string)DataSource.OptionValue, new Win32.RECT(rItem.Right - UISettings.CalcPix(20) - _imageSize.Width - x, rItem.Top + y, x, textSize.Height), Win32.DT.LEFT | Win32.DT.TOP | Win32.DT.WORDBREAK | Win32.DT.SINGLELINE); }
protected override void DrawScreenOn(Gdi gMem, Rectangle rClip, int yListOffset) { base.DrawScreenOn(gMem, rClip, yListOffset); if (yListOffset > 0) { if (_leftButton != null) { gMem.DrawImageAlphaChannel(_leftButton, rClip.Left + _leftButtonSize.Width, rClip.Top + (Height - _leftButtonSize.Height) / 2); } } if (yListOffset + rClip.Right - rClip.Left < _ActiveListWidth) { if (_rightButton != null) { gMem.DrawImageAlphaChannel(_rightButton, rClip.Right - _rightButtonSize.Width, rClip.Top + (Height - _rightButtonSize.Height) / 2); } } }
private static void DrawWideButton(Rectangle rItem, Gdi g, IImage imgL, IImage imgR, IImage imgC) { ImageInfo iiL; ImageInfo iiR; imgL.GetImageInfo(out iiL); imgR.GetImageInfo(out iiR); int x = rItem.Left + UISettings.CalcPix(4); int y = rItem.Top; // draw left part g.DrawImageAlphaChannel(imgL, new Rectangle(x, y, (int)iiL.Width, rItem.Height)); // draw tiled center int xR = rItem.Width - UISettings.CalcPix(4) - (int)iiR.Width - (int)iiL.Width; g.DrawImageAlphaChannel(imgC, new Rectangle(x + (int)iiL.Width, y, xR, rItem.Height)); // draw right part xR = rItem.Width - UISettings.CalcPix(8) - (int)iiR.Width; g.DrawImageAlphaChannel(imgR, new Rectangle(x + xR, y, (int)iiR.Width, rItem.Height)); }
protected override void OnRender(Gdi gMem, Rectangle clipRect) { if (AlphaChannelImage != null) { if (Stretch) { gMem.DrawImageAlphaChannel(AlphaChannelImage, clipRect); } else { gMem.DrawImageAlphaChannel(AlphaChannelImage, clipRect.Left, clipRect.Top); } } else if (TransparentImage != null) { int imgWidth = TransparentImage.ImageSize.Width; int imgHeight = TransparentImage.ImageSize.Height; int destWidth = imgWidth; int destHeight = imgHeight; if (Stretch) { destWidth = clipRect.Width; destHeight = clipRect.Height; } gMem.TransparentImage(clipRect.Left, clipRect.Top, destWidth, destHeight, TransparentImage.ImageHandle, TransparentImage.ImageOffset.X, TransparentImage.ImageOffset.Y, imgWidth, imgHeight, TransparentImage.TransparentColor); } }
public override void DrawItemOn(Gdi g, Rectangle rItem) { int x = (rItem.Width - _imageSize.Width) / 2; int y = (rItem.Height - _imageSize.Height) / 2; ImageInfo ii; _checkBoxSelected.GetImageInfo(out ii); if ((bool)DataSource.OptionValue) { if (_checkBoxSelected != null) { g.DrawImageAlphaChannel(_checkBoxSelected, rItem.Right - (int)ii.Width - UISettings.CalcPix(10), rItem.Top + y); } } else { if (_checkBoxEmpty != null) { g.DrawImageAlphaChannel(_checkBoxEmpty, rItem.Right - (int)ii.Width - UISettings.CalcPix(10), rItem.Top + y); } } }
protected Bitmap CreateBitmapFromIImage(IImage img, bool isSelected) { ImageInfo ii; if (img != null) { img.GetImageInfo(out ii); } else { return(null); } int topIndent = -UISettings.CalcPix(15); //Arrow int height = Settings.ListItemPixSize; Bitmap res = new Bitmap((int)ii.Width, (int)ii.Height); using (Graphics gr = Graphics.FromImage(res)) { IntPtr ptr = gr.GetHdc(); try { using (Gdi g = Gdi.FromHdc(ptr, Rectangle.Empty)) { DrawItemBackgroundOn(g, null, new Rectangle(0, topIndent, res.Width, height), 0, isSelected); g.DrawImageAlphaChannel(img, 0, 0); } } finally { gr.ReleaseHdc(ptr); } } return(res); }
protected override void OnRender(Gdi graphics, Rectangle clipRect) { if (_leftPart != null && _rightPart != null && _centerPart != null) { var rect = new Rectangle(clipRect.Left + _leftPartSize.Width, clipRect.Top, clipRect.Width - _rightPartSize.Width - _leftPartSize.Width, clipRect.Height); if (!_pressed) { graphics.DrawImageAlphaChannel(_leftPart, clipRect.Left, clipRect.Top); graphics.DrawImageAlphaChannel(_rightPart, rect.Right, clipRect.Top); graphics.DrawImageAlphaChannel(_centerPart, rect); } else { graphics.DrawImageAlphaChannel(_leftPartPressed, clipRect.Left, clipRect.Top); graphics.DrawImageAlphaChannel(_rightPartPressed, rect.Right, clipRect.Top); graphics.DrawImageAlphaChannel(_centerPartPressed, rect); } if (!string.IsNullOrEmpty(Text)) { FontGdi font = Font; if (_pressed) { font = PressedFont; } /*else if (_selected) * font = SelectedFont;*/ Color color = FontColor; if (_pressed) { color = PressedFontColor; } /*else if (_selected) * color = SelectedFontColor;*/ graphics.Font = font; graphics.TextColor = color; Size textSize = graphics.GetTextExtent(Text); int topAdjust = 0; switch (VerticalTextAlignment) { case VerticalAlignment.Top: topAdjust = 0 + _verticalTextMargin; break; case VerticalAlignment.Bottom: topAdjust = Height - textSize.Height - _verticalTextMargin; break; case VerticalAlignment.Center: topAdjust = (Height - textSize.Height) / 2; break; } if (_dropShadow && !_pressed) { graphics.TextColor = FontColorShadow; graphics.ExtTextOut(clipRect.Left + (clipRect.Width - textSize.Width) / 2 + UISettings.CalcPix(1), clipRect.Top + topAdjust + UISettings.CalcPix(1), textSize.Width, Text); } graphics.TextColor = color; graphics.ExtTextOut(clipRect.Left + (clipRect.Width - textSize.Width) / 2, clipRect.Top + topAdjust, textSize.Width, Text); } } }
protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem) { NativeItemData item = nativeItem; bool isSelected = ShowSelectedItem ? nItem == _SelectedIndex : false; if (rItem.Height > Settings.ListItemPixSize) { rItem = new Rectangle(rItem.Left, rItem.Top + rItem.Height - Settings.ListItemPixSize, rItem.Width, Settings.ListItemPixSize); } //Фон DrawItemBackgroundOn(g, item, rItem, nItem, isSelected); //Аватарка int leftIndent = rItem.Left + item.InfoLeftIndents[0]; int topIndent = rItem.Top + item.InfoTopIndents[0]; #region выводим изображение int index = -1; for (int i = 0; i < NativeItems.Count; i++) { var ni = NativeItems[i]; if (ni.Uid == item.Uid) { index = i; break; } } if (index > -1) { if (IsItemVisible(index)) { if (!string.IsNullOrEmpty(item.PrimaryImageURL)) { if (!item.PrimaryImageURL.Equals("clear")) { IImage newIImage = null; if (File.Exists(item.PrimaryImageURL)) { ImageHelper.LoadImageFromFile(item.PrimaryImageURL, out newIImage); item.PrimaryImage = newIImage; } else { item.PrimaryImage = MasterForm.SkinManager.GetImage("ImageNull"); } } else { item.PrimaryImage = MasterForm.SkinManager.GetImage("ImageNull"); } item.PrimaryImageURL = string.Empty; } int imageMarginLeft = 0; int imageMarginTop = 0; ImageInfo newImageInfo; item.PrimaryImage.GetImageInfo(out newImageInfo); imageMarginLeft = 0; imageMarginTop = 0; g.DrawImageAlphaChannel(item.PrimaryImage, leftIndent + imageMarginLeft, topIndent + imageMarginTop); } } #endregion //полоска var rSep = new Rectangle(rItem.Left, rItem.Top, rItem.Width, 1); g.FillRect(rSep, Settings.ListItemSeparator); //Имя leftIndent = rItem.Left + item.InfoLeftIndents[1]; topIndent = rItem.Top + item.InfoTopIndents[1]; if (!string.IsNullOrEmpty(item.PrimaryText) && !string.IsNullOrEmpty(item.SecondaryText)) { g.TextAlign = Win32.TextAlign.TA_LEFT; if (isSelected) { g.TextColor = Color.White; } else { g.TextColor = Settings.ListItemTextColor; } g.Font = Settings.PrimaryTextFontGdi; Size size = g.GetTextExtent(item.PrimaryText); g.ExtTextOut(leftIndent, topIndent, item.PrimaryText); leftIndent += size.Width; g.Font = Settings.SecondaryTextFontGdi; g.ExtTextOut(leftIndent, topIndent, item.SecondaryText); } //Online leftIndent = rItem.Left + item.InfoLeftIndents[2]; topIndent = rItem.Top + item.InfoTopIndents[2]; if (!string.IsNullOrEmpty(item.TertiaryText)) { g.Font = Settings.ThirdTextFontGdi; g.TextAlign = Win32.TextAlign.TA_LEFT; if (isSelected) { g.TextColor = Color.White; } else { g.TextColor = Color.FromArgb(150, 150, 150); } g.ExtTextOut(leftIndent, topIndent, item.TertiaryText); } }
protected override void OnRender(Gdi gMem, Rectangle clipRect) { switch (Style) { case ButtonStyle.AlphaChannel: IImage img1 = null; if (_selected && !_pressed) { img1 = TransparentButtonSelected; } if (_pressed || (_selected && img1 == null)) { img1 = TransparentButtonPressed; } if (!_pressed && !_selected) { img1 = TransparentButton; } if (img1 != null) { gMem.DrawImageAlphaChannel(img1, clipRect); } break; case ButtonStyle.TransparentBackground: ImageData img2 = null; if (_selected && !_pressed) { img2 = ButtonSelected; } if (_pressed || (_selected && img2 == null)) { img2 = ButtonPressed; } if (!_pressed && !_selected) { img2 = Button; } if (img2 != null) { int imgWidth = img2.ImageSize.Width; int imgHeight = img2.ImageSize.Height; gMem.TransparentImage(clipRect.Left, clipRect.Top, clipRect.Width, clipRect.Height, img2.ImageHandle, img2.ImageOffset.X, img2.ImageOffset.Y, imgWidth, imgHeight, img2.TransparentColor); } break; default: if (_pressed || _selected) { gMem.FillRect(clipRect, BackColor); } else { gMem.FillRect(clipRect, ForeColor); } break; } if (!string.IsNullOrEmpty(Text)) { FontGdi font = Font; if (_pressed) { font = PressedFont; } else if (_selected) { font = SelectedFont; } Color color = FontColor; if (_pressed) { color = PressedFontColor; } else if (_selected) { color = SelectedFontColor; } gMem.Font = font; gMem.TextColor = color; Size textSize = gMem.GetTextExtent(Text); int topAdjust = 0; switch (VerticalTextAlignment) { case VerticalAlignment.Top: topAdjust = 0 + _verticalTextMargin; break; case VerticalAlignment.Bottom: topAdjust = Height - textSize.Height - _verticalTextMargin; break; case VerticalAlignment.Center: topAdjust = (Height - textSize.Height) / 2; break; } gMem.ExtTextOut(clipRect.Left + (clipRect.Width - textSize.Width) / 2, clipRect.Top + topAdjust, textSize.Width, Text); } }
protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem) { NativeItemData item = nativeItem; bool isSelected = ShowSelectedItem ? nItem == _SelectedIndex : false; if (rItem.Height > Settings.ListItemPixSize) { rItem = new Rectangle(rItem.Left, rItem.Top + rItem.Height - Settings.ListItemPixSize, rItem.Width, Settings.ListItemPixSize); } //фон DrawItemBackgroundOn(g, item, rItem, nItem, isSelected); //Картинка int topIndent = rItem.Top; int leftIndent = rItem.Left; #region выводим изображения int index = -1; for (int i = 0; i < NativeItems.Count; i++) { var ni = NativeItems[i]; if (ni.Uid == item.Uid) { index = i; break; } } if (index > -1) { if (IsItemVisible(index)) { if (!string.IsNullOrEmpty(item.PrimaryImageURL)) { if (!item.PrimaryImageURL.Equals("clear")) { IImage newIImage = null; //ImageHelper.LoadImageFromFile(item.PrimaryImageURL, out newIImage); //item.PrimaryImage = newIImage; if (File.Exists(item.PrimaryImageURL)) { ImageHelper.LoadImageFromFile(item.PrimaryImageURL, out newIImage); item.PrimaryImage = newIImage; } else { item.PrimaryImage = MasterForm.SkinManager.GetImage("ImageNull"); } } else { item.PrimaryImage = MasterForm.SkinManager.GetImage("ImageNull"); } item.PrimaryImageURL = string.Empty; } int imageMarginLeft = 0; int imageMarginTop = 0; ImageInfo newImageInfo; item.PrimaryImage.GetImageInfo(out newImageInfo); imageMarginLeft = 0; imageMarginTop = 0; g.DrawImageAlphaChannel(item.PrimaryImage, leftIndent + imageMarginLeft, topIndent + imageMarginTop); } } #endregion //полоска var rSep = new Rectangle(rItem.Left, rItem.Top, rItem.Width, 1); g.FillRect(rSep, Settings.ListItemSeparator); //имя topIndent = rItem.Top + item.InfoTopIndents[0]; leftIndent = rItem.Left + item.InfoLeftIndents[1]; if (!string.IsNullOrEmpty(item.PrimaryText)) { g.Font = Settings.PrimaryTextFontGdi; g.TextAlign = Win32.TextAlign.TA_LEFT; if (isSelected) { g.TextColor = Color.White; } else { g.TextColor = Settings.ListItemTextColor; } g.ExtTextOut(leftIndent, topIndent, item.PrimaryText); } //дата topIndent = rItem.Top + item.InfoTopIndents[0]; leftIndent = rItem.Right - item.InfoLeftIndents[2]; if (!string.IsNullOrEmpty(item.TertiaryText)) { g.Font = Settings.ThirdTextFontGdi; g.TextAlign = Win32.TextAlign.TA_RIGHT; if (isSelected) { g.TextColor = Color.White; } else { g.TextColor = Color.FromArgb(51, 153, 255); } g.ExtTextOut(leftIndent, topIndent, item.TertiaryText); } //Комментарий topIndent = rItem.Top + item.InfoTopIndents[1]; leftIndent = rItem.Left + item.InfoLeftIndents[1]; if (!string.IsNullOrEmpty(item.SecondaryText)) { //g.Font = Settings.SecondaryTextFontGdi; //g.TextAlign = Win32.TextAlign.TA_LEFT; //if (isSelected) g.TextColor = Color.White; //else g.TextColor = Color.FromArgb(102, 102, 102); //int colPrev = 0; //int line = Settings.SecondaryTextLinesCount; //do //{ // int col = item.SecondaryText.IndexOf('\n', colPrev); // string text; // if (col > -1) // { // text = item.SecondaryText.Substring(colPrev, col - colPrev); // } // else // { // text = item.SecondaryText.Substring(colPrev); // } // g.ExtTextOut(leftIndent, topIndent, text); // colPrev = col + 1; // line--; // topIndent += UISettings.CalcPix(11); //} //while (colPrev > 0 && line > 0); if (item.SecondaryTextLines.Count > 0) { g.Font = Settings.SecondaryTextFontGdi; g.TextAlign = Win32.TextAlign.TA_LEFT; g.TextColor = Color.FromArgb(102, 102, 102); if (isSelected) { g.TextColor = Color.White; } foreach (string line in item.SecondaryTextLines) { g.ExtTextOut(leftIndent, topIndent, line); topIndent += UISettings.CalcPix(11); } } } }
protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem) { NativeItemData item = nativeItem; if (rItem.Height > Settings.ListItemPixSize) { rItem = new Rectangle(rItem.Left, rItem.Top + rItem.Height - Settings.ListItemPixSize, rItem.Width, Settings.ListItemPixSize); } //Если выделен DrawItemBackgroundOn(g, item, rItem, nItem, SelectedIndex == nItem); var rSep = new Rectangle(rItem.Left, rItem.Bottom - 1, rItem.Width, 1); //полоска g.FillRect(rSep, Settings.ListItemSeparator); // int leftIndent = rItem.Left + Settings.TextPixMargin; int topIndent = rItem.Bottom - rItem.Height + item.InfoTopIndents[0]; // write name //Отрисовка изображения if (item.PrimaryImage != null) { g.DrawImageAlphaChannel(item.PrimaryImage, leftIndent, topIndent); } leftIndent += Settings.SecondaryIconPixWidth + Settings.TextPixMargin; //определение размеров текста g.GetTextExtent /* * Size textSize = g.GetTextExtent(vals[0] + " "); * g.ExtTextOut(rItem.Left + rItem.Width / 2 - textSize.Width, * rItem.Bottom - item.InfoTopIndents[0], * textSize.Width, * vals[0]); */ if (!string.IsNullOrEmpty(item.PrimaryText)) { g.Font = Settings.PrimaryTextFontGdi; g.TextAlign = Win32.TextAlign.TA_LEFT; g.TextColor = Settings.ListItemTextColor; g.ExtTextOut(leftIndent, topIndent, item.PrimaryText); } if (!string.IsNullOrEmpty(item.SecondaryText)) { g.Font = Settings.SecondaryTextFontGdi; g.TextAlign = Win32.TextAlign.TA_LEFT; g.TextColor = Settings.ListItemTextColor; g.ExtTextOut(leftIndent, topIndent + 10, item.SecondaryText); } if (!string.IsNullOrEmpty(item.SecondaryText)) { g.Font = Settings.SecondaryTextFontGdi; g.TextAlign = Win32.TextAlign.TA_LEFT; g.TextColor = Settings.ListItemTextColor; g.ExtTextOut(leftIndent, topIndent + 20, item.TertiaryText); } /* * if(item.SecondaryImage != null) * { * g.DrawImageAlphaChannel(item.SecondaryImage, rItem.Right - Settings.SecondaryIconPixWidth + Settings.TextPixMargin, topIndent); * } */ }
protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem) { //ImageNativeItemData item = (ImageNativeItemData) nativeItem; NativeItemData item = nativeItem; if (rItem.Height > Settings.ListItemPixSize) { rItem = new Rectangle(rItem.Left, rItem.Top + rItem.Height - Settings.ListItemPixSize, rItem.Width, Settings.ListItemPixSize); } //выделение DrawItemBackgroundOn(g, item, rItem, nItem, SelectedIndex == nItem); #region выводим изображения int index = -1; for (int i = 0; i < NativeItems.Count; i++) { var ni = NativeItems[i]; if (ni.Uid == item.Uid) { index = i; break; } } if (index > -1) { if (IsItemVisible(index)) { if (!string.IsNullOrEmpty(item.PrimaryImageURL)) { if (!item.PrimaryImageURL.Equals("clear")) { IImage newIImage = null; if (File.Exists(item.PrimaryImageURL)) { ImageHelper.LoadImageFromFile(item.PrimaryImageURL, out newIImage); item.PrimaryImage = newIImage; } else { item.PrimaryImage = MasterForm.SkinManager.GetImage("ImageNull"); } } else { item.PrimaryImage = MasterForm.SkinManager.GetImage("ImageNull"); } item.PrimaryImageURL = string.Empty; } int imageMarginLeft = 0; int imageMarginTop = 0; ImageInfo newImageInfo; item.PrimaryImage.GetImageInfo(out newImageInfo); imageMarginLeft = (rItem.Width - (int)newImageInfo.Width) / 2; imageMarginTop = (rItem.Height - (int)newImageInfo.Height) / 2; g.DrawImageAlphaChannel(item.PrimaryImage, rItem.Left + imageMarginLeft, rItem.Top + imageMarginTop); } } #endregion ////изображение //IImage img = item.SecondaryImage ?? item.PrimaryImage; //if (img != null) //{ // g.DrawImageAlphaChannel(img, rItem.Left + _imageMargin, rItem.Top + _imageMargin); //} }
protected override void DrawItemOn(Gdi g, NativeItemData nativeitem, Rectangle rItem, int nItem) { var item = (NativeItemDataMm)nativeitem; bool isSelected = ShowSelectedItem ? nItem == _SelectedIndex : false; //var primaryRect = new Rectangle(rItem.Left, rItem.Top, rItem.Width, rItem.Height - UISettings.CalcPix(5)); rItem = new Rectangle(rItem.Left, rItem.Top, rItem.Width, rItem.Height - UISettings.CalcPix(5)); DrawItemBackgroundOn(g, item, rItem, nItem, isSelected); int iconMargin = UISettings.CalcPix(15); int iconX = rItem.Left + iconMargin; // draw icon if (item.Icon != null) { ImageInfo iinfo; item.Icon.GetImageInfo(out iinfo); int iconY = rItem.Top + (rItem.Height - (int)iinfo.Height) / 2; if (item.PrimaryImage == null || isSelected) { g.DrawImageAlphaChannel(item.Icon, iconX, iconY); if (item.PrimaryImage == null & iconY > 0) { item.PrimaryImage = new Bitmap((int)iinfo.Width, (int)iinfo.Height); g.CopyImageTo(item.PrimaryImage, 0, 0, Settings.PrimaryIconPixWidth, Settings.PrimaryIconPixHeight, iconX, iconY); } } else { g.DrawImage(item.PrimaryImage, iconX, iconY); } } if (!String.IsNullOrEmpty(item.PrimaryText)) { if (item.Tag.ToString() == "New") { g.Font = FontCache.CreateFont("Tahoma", 16, FontStyle.Bold, true); if (isSelected) { g.TextColor = Color.FromArgb(255, 255, 255); } else { g.TextColor = Color.FromArgb(245, 36, 43); } } else { g.Font = FontCache.CreateFont("Tahoma", 16, FontStyle.Regular, true); if (isSelected) { g.TextColor = Color.FromArgb(255, 255, 255); } else { g.TextColor = Color.FromArgb(119, 126, 93); } } g.TextAlign = Win32.TextAlign.TA_LEFT; Size textSize = g.GetTextExtent(item.PrimaryText); g.ExtTextOut(iconX + Settings.PrimaryIconPixWidth + UISettings.CalcPix(10), rItem.Top + (rItem.Height - textSize.Height) / 2, item.PrimaryText); } }
protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem) { int topIndent; int leftIndent; NativeItemData item = nativeItem; bool isSelected = ShowSelectedItem ? nItem == _SelectedIndex : false; /*if (rItem.Height > Settings.ListItemPixSize) * { * rItem = new Rectangle(rItem.Left, * rItem.Top + rItem.Height - Settings.ListItemPixSize, * rItem.Width, * Settings.ListItemPixSize); * }*/ //фон DrawItemBackgroundOn(g, item, rItem, nItem, isSelected); //полоска var rSep = new Rectangle(rItem.Left, rItem.Top, rItem.Width, 1); g.FillRect(rSep, Settings.ListItemSeparator); //иконка + кэширование topIndent = rItem.Top + item.InfoTopIndents[0]; leftIndent = rItem.Left + item.InfoLeftIndents[0]; if (IsItemNewGroup(nItem)) { topIndent += Settings.GroupPixHeight; } if (item.PrimaryImage != null) { ImageInfo iinfo; item.PrimaryImage.GetImageInfo(out iinfo); if (item.Icon == null || isSelected) { g.DrawImageAlphaChannel(item.PrimaryImage, leftIndent, topIndent); if (item.Icon == null & topIndent > 0) { item.Icon = new Bitmap((int)iinfo.Width, (int)iinfo.Height); g.CopyImageTo(item.Icon, 0, 0, Settings.PrimaryIconPixWidth, Settings.PrimaryIconPixHeight, leftIndent, topIndent); } } else { g.DrawImage(item.Icon, leftIndent, topIndent); } } //Имя topIndent = rItem.Top + item.InfoTopIndents[0] - UISettings.CalcPix(2); leftIndent = rItem.Left + item.InfoLeftIndents[1]; if (IsItemNewGroup(nItem)) { topIndent += Settings.GroupPixHeight; } if (!string.IsNullOrEmpty(item.PrimaryText)) { g.Font = Settings.PrimaryTextFontGdi; g.TextAlign = Win32.TextAlign.TA_LEFT; if (isSelected) { g.TextColor = Color.White; } else { g.TextColor = Settings.ListItemTextColor; } g.ExtTextOut(leftIndent, topIndent, item.PrimaryText); } //Дата topIndent = rItem.Top + item.InfoTopIndents[0]; leftIndent = rItem.Right - item.InfoLeftIndents[2]; if (IsItemNewGroup(nItem)) { topIndent += Settings.GroupPixHeight; } if (!string.IsNullOrEmpty(item.TertiaryText)) { g.Font = Settings.ThirdTextFontGdi; g.TextAlign = Win32.TextAlign.TA_RIGHT; if (isSelected) { g.TextColor = Color.White; } else { g.TextColor = Color.FromArgb(51, 153, 255); } g.ExtTextOut(leftIndent, topIndent, item.TertiaryText); } ////Статус //topIndent = rItem.Top + item.InfoTopIndents[1]; //leftIndent = rItem.Left + item.InfoLeftIndents[1]; //if (!string.IsNullOrEmpty(item.SecondaryText)) //{ // g.Font = Settings.SecondaryTextFontGdi; // g.TextAlign = Win32.TextAlign.TA_LEFT; // if (isSelected) g.TextColor = Color.White; // else g.TextColor = Color.FromArgb(102, 102, 102); // int colPrev = 0; // int line = Settings.SecondaryTextLinesCount; // do // { // int col = item.SecondaryText.IndexOf('\n', colPrev); // string text; // if (col > -1) // { // text = item.SecondaryText.Substring(colPrev, col - colPrev); // } // else // { // text = item.SecondaryText.Substring(colPrev); // } // g.ExtTextOut(leftIndent, topIndent, text); // colPrev = col + 1; // line--; // topIndent += UISettings.CalcPix(11); // } // while (colPrev > 0 && line > 0); //} //if (item.SecondaryTextLines != null && item.SecondaryTextLines.Count > 0) //{ // g.Font = _secFont; // g.TextAlign = Win32.TextAlign.TA_LEFT; // g.TextColor = Color.FromArgb(102, 102, 102); // foreach (string line in item.SecondaryTextLines) // { // g.ExtTextOut(leftIndent, topIndent, line); // topIndent += UISettings.CalcPix(11); // } //} // текст сообщения leftIndent = rItem.Left + item.InfoLeftIndents[1]; topIndent = rItem.Top + item.InfoTopIndents[1]; if (IsItemNewGroup(nItem)) { topIndent += Settings.GroupPixHeight; } if (item.SecondaryTextLines.Count > 0) { g.Font = Settings.SecondaryTextFontGdi; g.TextAlign = Win32.TextAlign.TA_LEFT; g.TextColor = Color.FromArgb(102, 102, 102); if (isSelected) { g.TextColor = Color.White; } foreach (string line in item.SecondaryTextLines) { g.ExtTextOut(leftIndent, topIndent, line); topIndent += UISettings.CalcPix(11); } } }
protected override void OnRender(Gdi graphics, Rectangle clipRect) { if (_leftPart != null && _rightPart != null && _centerPart != null) { Rectangle rect = new Rectangle(clipRect.Left + _leftPartSize.Width, clipRect.Top, clipRect.Width - _rightPartSize.Width - _leftPartSize.Width, clipRect.Height); if (!_pressed) { graphics.DrawImageAlphaChannel(_leftPart, clipRect.Left, clipRect.Top); graphics.DrawImageAlphaChannel(_rightPart, rect.Right, clipRect.Top); graphics.DrawImageAlphaChannel(_centerPart, rect); } else { graphics.DrawImageAlphaChannel(_leftPartPressed, clipRect.Left, clipRect.Top); graphics.DrawImageAlphaChannel(_rightPartPressed, rect.Right, clipRect.Top); graphics.DrawImageAlphaChannel(_centerPartPressed, rect); } #region отрисовка текста комментария graphics.Font = Font; graphics.TextAlign = Galssoft.VKontakteWM.Components.Common.SystemHelpers.Win32.TextAlign.TA_LEFT; if (string.IsNullOrEmpty(_text)) { _text = string.Empty; if (string.IsNullOrEmpty(_textSubstitute)) { _textToPrint = string.Empty; } else { _textToPrint = _textSubstitute; } graphics.TextColor = FontColorUnactive; } else { _textToPrint = _text; graphics.TextColor = FontColor; } if (_pressed) { graphics.TextColor = FontColorInvert; } if (!_textOld.Equals(_textToPrint)) { _textOld = _textToPrint; _lines.Clear(); } int topIndent = 0; int totalHeight = 0; int averageHeight = 0; #region распил текста на строчки выполняется только если _lines пустой if (_lines.Count == 0) { //пилим по переносам строки... string[] lines = _textToPrint.Split('\n'); foreach (string line in lines) { int ipreviouscol = 0; string text = line; string outtext = string.Empty; int icol = text.Length; int maxChars; do { text = line.Substring(ipreviouscol); int[] extents; Size size = graphics.GetTextExtent(text, clipRect.Width - _leftPartSize.Width - _rightPartSize.Width, out extents, out maxChars); totalHeight += size.Height * 11 / 10; bool isSpace = false; //признак пробела bool isOver = false; //признак необходимости новой строки if (text.Length > maxChars) { isOver = true; //ищем последний с позиции в начало maxChars пробел int iSpace = text.LastIndexOf(' ', maxChars, maxChars); if (iSpace > -1) { isSpace = true; icol = iSpace; } else { isSpace = false; icol = maxChars; } outtext = text.Substring(0, icol); } else { isOver = false; outtext = text; } //учитываем пробел в конце строки if (isSpace) { ipreviouscol += (icol + 1); } else { ipreviouscol += icol; } //добавляем точечки if ((_lines.Count + 1) < 2) { _lines.Add(outtext); } else { if (isOver) { outtext = outtext.Remove(outtext.Length - 3, 3); if (outtext.EndsWith(" ")) { outtext = outtext.Remove(outtext.Length - 1, 1); } outtext += "..."; } _lines.Add(outtext); break; } }while (text.Length > maxChars); break; } _totalHeight = totalHeight; } #endregion totalHeight = _totalHeight; averageHeight = totalHeight / _lines.Count; foreach (string line in _lines) { //для отображения используется прямоугольник 4/5 от ширины контрола //отступ: 4 зазора от левого края //graphics.ExtTextOut(clipRect.Left + (clipRect.Width - clipRect.Width * 4 / 5) / 4, clipRect.Top + topIndent + (clipRect.Height - totalHeight) / 2, line); graphics.ExtTextOut(clipRect.Left + _leftPartSize.Width, clipRect.Top + topIndent + (clipRect.Height - totalHeight) / 2, line); topIndent += averageHeight; } #endregion } /* switch (Style) * { * case ButtonStyle.AlphaChannel: * IImage img1 = null; * if (_selected && !_pressed) * img1 = TransparentButtonSelected; * if (_pressed || (_selected && img1 == null)) * img1 = TransparentButtonPressed; * if (!_pressed && !_selected) * img1 = TransparentButton; * * if (img1 != null) * gMem.DrawImageAlphaChannel(img1, clipRect); * break; * case ButtonStyle.TransparentBackground: * ImageData img2 = null; * if (_selected && !_pressed) * img2 = ButtonSelected; * if (_pressed || (_selected && img2 == null)) * img2 = ButtonPressed; * if (!_pressed && !_selected) * img2 = Button; * * if (img2 != null) * { * int imgWidth = img2.ImageSize.Width; * int imgHeight = img2.ImageSize.Height; * gMem.TransparentImage(clipRect.Left, clipRect.Top, * clipRect.Width, * clipRect.Height, * img2.ImageHandle, * img2.ImageOffset.X, * img2.ImageOffset.Y, * imgWidth, * imgHeight, * img2.TransparentColor); * } * break; * default: * if (_pressed) * gMem.FillRect(clipRect, BackColor); * else * gMem.FillRect(clipRect, ForeColor); * break; * } * * if (!string.IsNullOrEmpty(Text)) * { * gMem.Font = Font; * gMem.TextColor = FontColor; * Size textSize = gMem.GetTextExtent(Text); * gMem.ExtTextOut(clipRect.Left + (clipRect.Width - textSize.Width) / 2, * clipRect.Top + (clipRect.Height - textSize.Height) / 2, textSize.Width, Text); * }*/ }