Beispiel #1
0
        protected override void DrawItemBackgroundOn(Gdi gMem, NativeItemData item, Rectangle rItem, int nItem, bool isSelected)
        {
            gMem.FillRect(rItem, Color.White);

            if (nItem == 0)
            {
                rItem = new Rectangle(rItem.Left, rItem.Top + UISettings.CalcPix(5), rItem.Width, rItem.Height - UISettings.CalcPix(10));
            }
            else
            {
                rItem = new Rectangle(rItem.Left, rItem.Top, rItem.Width, rItem.Height - UISettings.CalcPix(5));
            }

            if (_paintedButton == null || isSelected || item.PrimaryText == Resources.ExtraView_ExitButtonTitle)
            {
                if (item.PrimaryText == Resources.ExtraView_ExitButtonTitle)
                {
                    if (isSelected)
                    {
                        DrawWideButton(rItem, gMem, MasterForm.SkinManager.GetImage("PhotoUpload1Pressed"),
                                       MasterForm.SkinManager.GetImage("PhotoUpload3Pressed"),
                                       MasterForm.SkinManager.GetImage("PhotoUpload2Pressed"));
                    }
                    else
                    {
                        DrawWideButton(rItem, gMem, MasterForm.SkinManager.GetImage("PhotoUpload1"),
                                       MasterForm.SkinManager.GetImage("PhotoUpload3"),
                                       MasterForm.SkinManager.GetImage("PhotoUpload2"));
                    }
                }
                else
                {
                    if (isSelected)
                    {
                        DrawWideButton(rItem, gMem, MasterForm.SkinManager.GetImage("EventList1Pressed"),
                                       MasterForm.SkinManager.GetImage("EventList3Pressed"),
                                       MasterForm.SkinManager.GetImage("EventList2Pressed"));
                    }
                    else
                    {
                        DrawWideButton(rItem, gMem, MasterForm.SkinManager.GetImage("EventList1"),
                                       MasterForm.SkinManager.GetImage("EventList3"),
                                       MasterForm.SkinManager.GetImage("EventList2"));
                    }
                }

                if (_paintedButton == null & !isSelected & rItem.Top > 0)
                {
                    _paintedButton = new Bitmap(rItem.Width, rItem.Height);
                    gMem.CopyImageTo(_paintedButton, 0, 0, rItem.Width, rItem.Height,
                                     rItem.Left, rItem.Top);
                }
            }
            else
            {
                gMem.DrawImage(_paintedButton, rItem.Left, rItem.Top);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Draw background in list
 /// </summary>
 /// <param name="gMem">Graphics</param>
 /// <param name="rListRect">Client rectangle to fill background</param>
 protected virtual void DrawBackground(Gdi gMem, Rectangle rListRect)
 {
     if (BackgroundImage != null)
     {
         gMem.DrawImage(BackgroundImage, rListRect.X, rListRect.Y, rListRect.Width, rListRect.Height, rListRect.X, rListRect.Y);
     }
     else
     {
         gMem.FillRect(rListRect, BackColor);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Draw background in list
 /// </summary>
 /// <param name="gMem">Graphics</param>
 /// <param name="rListRect">Client rectangle to fill background</param>
 /// <param name="offset">Offset for the beginning of the item list</param>
 protected virtual void DrawBackground(Gdi gMem, Rectangle rListRect, int offset)
 {
     if (BackgroundImage != null)
     {
         gMem.DrawImage(BackgroundImage, 0, 0, rListRect.Width, rListRect.Height);
     }
     else
     if (BackColor != Color.Empty)
     {
         gMem.FillRect(rListRect, BackColor);
     }
 }
Beispiel #4
0
        protected override void DrawItemBackgroundOn(Gdi gMem, NativeItemData item, Rectangle rItem, int nItem, bool isSelected)
        {
            gMem.FillRect(rItem, Color.White);

            if (nItem == 0)
            {
                rItem = new Rectangle(rItem.Left, rItem.Top + UISettings.CalcPix(5), rItem.Width, rItem.Height - UISettings.CalcPix(10));
            }
            else
            {
                rItem = new Rectangle(rItem.Left, rItem.Top, rItem.Width, rItem.Height - UISettings.CalcPix(5));
            }

            if (_paintedButton == null || isSelected)
            {
                if (isSelected)
                {
                    DrawWideButton(rItem, gMem, MasterForm.SkinManager.GetImage("WideButton1Pressed"),
                                   MasterForm.SkinManager.GetImage("WideButton3Pressed"),
                                   MasterForm.SkinManager.GetImage("WideButton2Pressed"));
                }
                else
                {
                    DrawWideButton(rItem, gMem, MasterForm.SkinManager.GetImage("WideButton1"),
                                   MasterForm.SkinManager.GetImage("WideButton3"),
                                   MasterForm.SkinManager.GetImage("WideButton2"));
                }

                if (_paintedButton == null & !isSelected & rItem.Top > 0)
                {
                    _paintedButton = new Bitmap(rItem.Width, rItem.Height);
                    gMem.CopyImageTo(_paintedButton, 0, 0, rItem.Width, rItem.Height,
                                     rItem.Left, rItem.Top);
                }
            }
            else
            {
                gMem.DrawImage(_paintedButton, rItem.Left, rItem.Top);
            }
        }
Beispiel #5
0
        protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem)
        {
            NativeItemData item = nativeItem;

            bool isSelected = ShowSelectedItem ? nItem == _SelectedIndex : false;

            if (!(nItem > 1))
            {
                isSelected = false;
            }

            //bool isSelected;

            //if (SelectedIndex == nItem)
            //{

            //}

            //if nItem

            //if (SelectedIndex == nItem)
            //{
            //    isSe
            //}

            //

            //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.Top, rItem.Width, 1);
            //g.FillRect(rSep, Gdi.CreateSolidBrush(Color.FromArgb(205, 205, 205)));

            // загрузка изображения...
            if (!string.IsNullOrEmpty(item.PrimaryImageURL))
            {
                if (!item.PrimaryImageURL.Equals("clear"))
                {
                    IImage newIImage = null;

                    ImageHelper.LoadImageFromFile(item.PrimaryImageURL, out newIImage);

                    item.PrimaryImage = newIImage;
                }
                else
                {
                    item.PrimaryImage = MasterForm.SkinManager.GetImage("ImageNull");
                }

                if (item.PrimaryImage != null)
                {
                    ImageInfo ii;
                    item.PrimaryImage.GetImageInfo(out ii);
                    Size imageSize = new Size((int)ii.Width, (int)ii.Height);
                    item.Icon = new Bitmap(imageSize.Width, imageSize.Height);
                    //Create cached image
                    using (Graphics gr = Graphics.FromImage(item.Icon))
                    {
                        IntPtr    grPtr = gr.GetHdc();
                        Rectangle rect  = new Rectangle(0, 0, imageSize.Width, imageSize.Height);
                        item.PrimaryImage.Draw(grPtr, ref rect, IntPtr.Zero);
                        gr.ReleaseHdc(grPtr);
                    }
                }

                item.PrimaryImageURL = string.Empty;
            }

            if (item.Icon != null) // если есть изображение, то айтем первого типа
            {
                g.DrawImage(item.Icon, rItem.Left + (rItem.Width - item.Icon.Width) / 2, rItem.Top + (rItem.Height - item.Icon.Height) / 2);
                //g.DrawImageAlphaChannel(item.PrimaryImage, rItem.Left + (rItem.Width - item.ImageSize.Width) / 2, rItem.Top + (rItem.Height - item.ImageSize.Height) / 2);
            }
            else // 2 или 3
            {
                // полоска
                Rectangle rSep = new Rectangle(rItem.Left, rItem.Top, rItem.Width, 1);
                g.FillRect(rSep, Gdi.CreateSolidBrush(Color.FromArgb(205, 205, 205)));

                int topIndent  = rItem.Top + item.InfoTopIndents[0];
                int leftIndent = rItem.Left + item.InfoLeftIndents[0];

                if (nItem == 1 || nItem == 2)
                {
                    topIndent += Settings.GroupPixHeight;
                }

                if (!string.IsNullOrEmpty(item.PrimaryText))
                {
                    g.Font      = _priFont;
                    g.TextAlign = Win32.TextAlign.TA_LEFT;
                    g.TextColor = Color.Black;

                    if (isSelected)
                    {
                        g.TextColor = Color.White;
                    }

                    g.ExtTextOut(leftIndent, topIndent, item.PrimaryText);
                }

                leftIndent = rItem.Left + item.InfoLeftIndents[0];
                topIndent  = rItem.Top + item.InfoTopIndents[1];

                if (nItem == 2)
                {
                    topIndent += Settings.GroupPixHeight;
                }

                if (item.SecondaryTextLines != null && item.SecondaryTextLines.Count > 0)
                {
                    g.Font      = _secFont;
                    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);
                    }
                }

                // дата
                topIndent  = rItem.Top + item.InfoTopIndents[0];
                leftIndent = rItem.Right - item.InfoLeftIndents[2];

                if (nItem == 2)
                {
                    topIndent += Settings.GroupPixHeight;
                }

                if (!string.IsNullOrEmpty(item.TertiaryText))
                {
                    g.Font      = _secFont;
                    g.TextAlign = Win32.TextAlign.TA_RIGHT;
                    g.TextColor = Color.FromArgb(51, 153, 255);

                    if (isSelected)
                    {
                        g.TextColor = Color.White;
                    }

                    g.ExtTextOut(leftIndent, topIndent, item.TertiaryText);
                }
            }
        }
        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);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Отрисовка
        /// </summary>
        protected override void OnRender(Gdi gMem, Rectangle clipRect)
        {
            using (Bitmap bmp = new Bitmap(clipRect.Width, clipRect.Height))
            {
                using (Graphics bgr = Graphics.FromImage(bmp)) // Рисуем все в буфере для скорости
                {
                    SizeF textSize  = string.IsNullOrEmpty(Text) ? new SizeF(0, 0) : bgr.MeasureString(Text, Font);
                    Color textColor = SwitchTextColor ? BackColor : ForeColor;

                    // Отрисовка фона
                    if (EmptyImage != null)
                    {
                        bgr.DrawImage(_emptyImageBitmap,
                                      new Rectangle(0, 0, clipRect.Width, clipRect.Height),
                                      new Rectangle(0, 0, _emptyImageBitmap.Width, _emptyImageBitmap.Height),
                                      GraphicsUnit.Pixel);
                    }

                    // Отрисовка прогресса
                    if (FullImage != null)
                    {
                        bgr.DrawImage(_fullImageBitmap,
                                      new Rectangle(0, 0, clipRect.Width * Value / Maximum, clipRect.Height),
                                      new Rectangle(0, 0, _fullImageBitmap.Width * Value / Maximum, _fullImageBitmap.Height),
                                      GraphicsUnit.Pixel);
                    }

                    Pen borderPen = new Pen(SwitchTextColor ? Color.FromArgb(88, 97, 114 /*93, 103, 121*/) : Color.Black);

                    if (NeedBorder)
                    {
                        // Обводка прямых краев

                        bgr.DrawLine(borderPen, RoundCornersRadius, 0, Width - RoundCornersRadius, 0);
                        bgr.DrawLine(borderPen, Width - 1, RoundCornersRadius - 2, Width - 1,
                                     Height - RoundCornersRadius + 2);
                        bgr.DrawLine(borderPen, RoundCornersRadius - 3, Height - 1, Width + 3 - RoundCornersRadius,
                                     Height - 1);
                        bgr.DrawLine(borderPen, 0, RoundCornersRadius, 0, Height - RoundCornersRadius);
                    }

                    //Отрисовка текста

                    float textLeft = (clipRect.Width - textSize.Width) / 2;
                    float textTop  = (clipRect.Height - textSize.Height) / 2;

                    if (!string.IsNullOrEmpty(Text))
                    {
                        bgr.DrawString(Text, Font, new SolidBrush(textColor),
                                       new RectangleF(textLeft, textTop, textSize.Width, textSize.Height));
                    }

                    // Скругление углов

                    if (RoundCornersRadius > 0)
                    {
                        // Необходимо скругление - вычисление точек границы вырезаемой области
                        int          N           = 100;
                        List <Point> points      = new List <Point>(N + 1);
                        Point[]      pointsArray = new Point[N];
                        points.Add(new Point(0, 0));

                        // Скругление верхнего левого угла кнопки

                        for (int i = 0; i < N; i++)
                        {
                            int x = i * RoundCornersRadius / (N - 1);
                            int y = (int)(RoundCornersRadius -
                                          Math.Round(Math.Sqrt(RoundCornersRadius * RoundCornersRadius -
                                                               (x - RoundCornersRadius) * (x - RoundCornersRadius))));

                            points.Add(new Point(x, y));
                        }
                        bgr.FillPolygon(new SolidBrush(Parent.BackColor), points.ToArray());

                        if (NeedBorder)
                        {
                            // Обводка верхнего левого угла кнопки

                            points.CopyTo(1, pointsArray, 0, N);
                            bgr.DrawLines(borderPen, pointsArray);
                        }

                        // Скругление верхнего правого угла кнопки

                        for (int i = 0; i < N + 1; i++)
                        {
                            points[i] = new Point(clipRect.Width - points[i].X, points[i].Y);
                        }
                        bgr.FillPolygon(new SolidBrush(Parent.BackColor), points.ToArray());

                        if (NeedBorder)
                        {
                            // Обводка верхнего правого угла кнопки

                            points.CopyTo(1, pointsArray, 0, N);
                            bgr.DrawLines(borderPen, pointsArray);
                        }

                        // Скругление нижнего правого угла кнопки

                        for (int i = 0; i < N + 1; i++)
                        {
                            points[i] = new Point(points[i].X, clipRect.Height - points[i].Y);
                        }
                        bgr.FillPolygon(new SolidBrush(Parent.BackColor), points.ToArray());

                        if (NeedBorder)
                        {
                            // Обводка нижнего правого угла кнопки

                            points.CopyTo(1, pointsArray, 0, N);
                            bgr.DrawLines(borderPen, pointsArray);
                        }

                        // Скругление нижнего левого угла кнопки

                        for (int i = 0; i < N + 1; i++)
                        {
                            points[i] = new Point(clipRect.Width - points[i].X, points[i].Y);
                        }
                        bgr.FillPolygon(new SolidBrush(Parent.BackColor), points.ToArray());

                        if (NeedBorder)
                        {
                            // Обводка нижнего левого угла кнопки

                            points.CopyTo(1, pointsArray, 0, N);
                            bgr.DrawLines(borderPen, pointsArray);
                        }
                    }
                }
                gMem.DrawImage(bmp, clipRect.Left, clipRect.Top);
            }
        }
Beispiel #8
0
        protected override void DrawItemBackgroundOn(Gdi gMem, NativeItemData item, Rectangle rItem, int nItem, bool isSelected)
        {
            //const int height = 36;

            /*if (_paintedButton == null)
             * {
             *  _paintedButton = new Bitmap(rItem.Width, rItem.Height-4);
             *
             *  Graphics graphics = null;
             *  IntPtr hdc = IntPtr.Zero;
             *  try
             *  {
             *      graphics = Graphics.FromImage(_paintedButton);
             *      hdc = graphics.GetHdc();
             *      Rectangle rect = new Rectangle(0, 0, rItem.Width, rItem.Height);
             *      //using (Gdi g = Gdi.FromHdc(hdc, rect))
             *      using (Gdi g = Gdi.FromHdc(hdc, rItem))
             *      {
             *          //Белый фон
             *          g.GradientFill(rItem, Color.White, Color.White, FillDirection.TopToBottom);
             *
             *          //DrawWideButton(new Rectangle(0, 0, rItem.Width, height), g, MasterForm.SkinManager.GetImage("EventList1"), MasterForm.SkinManager.GetImage("EventList3"), MasterForm.SkinManager.GetImage("EventList2"));
             *          DrawWideButton(rItem, g, MasterForm.SkinManager.GetImage("EventList1"), MasterForm.SkinManager.GetImage("EventList3"), MasterForm.SkinManager.GetImage("EventList2"));
             *      }
             *  }
             *  catch(Exception ex)
             *  {
             *      _paintedButton = null;
             *      MessageBox.Show(ex.ToString());
             *      throw;
             *  }
             *  finally
             *  {
             *      if (graphics != null)
             *      {
             *          graphics.ReleaseHdc(hdc);
             *          graphics.Dispose();
             *      }
             *  }
             * }*/

            if (_paintedButton == null || isSelected)
            {
                if (isSelected)
                {
                    DrawWideButton(rItem, gMem, MasterForm.SkinManager.GetImage("EventList1Pressed"),
                                   MasterForm.SkinManager.GetImage("EventList3Pressed"), MasterForm.SkinManager.GetImage("EventList2Pressed"));
                }
                else
                {
                    DrawWideButton(rItem, gMem, MasterForm.SkinManager.GetImage("EventList1"),
                                   MasterForm.SkinManager.GetImage("EventList3"), MasterForm.SkinManager.GetImage("EventList2"));
                }
                //gMem.DrawImageAlphaChannel(item.SecondaryImage, rItem.Left, rItem.Top);

                if (_paintedButton == null & !isSelected & rItem.Top > 0)
                {
                    _paintedButton = new Bitmap(rItem.Width, rItem.Height);
                    gMem.CopyImageTo(_paintedButton, 0, 0, rItem.Width, rItem.Height,
                                     rItem.Left, rItem.Top);
                }
            }
            else
            {
                gMem.DrawImage(_paintedButton, rItem.Left, rItem.Top);
            }

            /*if (isSelected)
             * {
             *  DrawWideButton(rItem, gMem, MasterForm.SkinManager.GetImage("EventList1"), MasterForm.SkinManager.GetImage("EventList3"), MasterForm.SkinManager.GetImage("EventList2"));
             * }
             * else
             *  gMem.DrawImage(_paintedButton, rItem.Left, rItem.Top);*/
        }
Beispiel #9
0
        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)
        {
            NativeItemDataNew item = (NativeItemDataNew)nativeItem;

            bool isSelected = ShowSelectedItem ? nItem == _SelectedIndex : false;

            //Подложка айтема
            DrawItemBackgroundOn(g, item, rItem, nItem, isSelected);

            //полоска
            var rSep = new Rectangle(rItem.Left, rItem.Top, rItem.Width, 1);

            g.FillRect(rSep, Gdi.CreateSolidBrush(Color.FromArgb(219, 219, 219)));

            //IsItemHighlight icon + кэширование
            int leftIndent = rItem.Left + item.InfoLeftIndents[0] + UISettings.CalcPix(1);
            int topIndent  = rItem.Top + item.InfoTopIndents[0] + UISettings.CalcPix(3);

            if (item.IsItemHighlight && item.PrimaryImage != null)
            {
                ImageInfo iinfo;
                item.PrimaryImage.GetImageInfo(out iinfo);

                if (item.OutboxIcon == null || isSelected)
                {
                    //g.DrawImageAlphaChannel(item.PrimaryImage, leftIndent, topIndent);

                    if (item.OutboxIcon == null & topIndent > 0)
                    {
                        item.OutboxIcon = new Bitmap((int)iinfo.Width, (int)iinfo.Height);
                        g.CopyImageTo(item.OutboxIcon, 0, 0, Settings.PrimaryIconPixWidth, Settings.PrimaryIconPixHeight, leftIndent, topIndent);
                    }
                }
                else
                {
                    g.DrawImage(item.OutboxIcon, leftIndent, topIndent);
                }
            }

            //Имя Фамилия
            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*/ UISettings.CalcPix(7), topIndent, item.PrimaryText);
            }

            //Дата
            topIndent  = rItem.Top + item.InfoTopIndents[0] + UISettings.CalcPix(1); //из-за разных шрифтов
            leftIndent = rItem.Right - item.InfoLeftIndents[3];
            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);
            }

            //bool needTab = false;

            //Я:
            topIndent  = rItem.Top + item.InfoTopIndents[1];
            leftIndent = rItem.Left + UISettings.CalcPix(7); //rItem.Left + item.InfoLeftIndents[1];
            if (item.IsOutboxIconSet)
            {
                g.Font      = Settings.PrimaryText2FontGdi;
                g.TextAlign = Win32.TextAlign.TA_LEFT;
                if (isSelected)
                {
                    g.TextColor = Color.White;
                }
                else
                {
                    g.TextColor = Settings.ListItemTextColor;
                }
                g.ExtTextOut(leftIndent, topIndent, Resources.OutboxText);

                //Отступ для текста сообщения
                //leftIndent = rItem.Left + item.InfoLeftIndents[2];
                leftIndent = rItem.Left + UISettings.CalcPix(22);
            }



            //Текст сообщения
            if (item.SecondaryTextLines.Count > 0)
            {
                g.Font      = Settings.SecondaryTextFontGdi;
                g.TextAlign = Win32.TextAlign.TA_LEFT;
                if (isSelected)
                {
                    g.TextColor = Color.White;
                }
                else
                {
                    g.TextColor = Color.FromArgb(102, 102, 102);
                }

                foreach (string line in item.SecondaryTextLines)
                {
                    g.ExtTextOut(leftIndent, topIndent, line);

                    topIndent += UISettings.CalcPix(11);
                }
            }

            //Arrow
            topIndent  = rItem.Top + item.InfoTopIndents[2];
            leftIndent = rItem.Right - item.InfoLeftIndents[4];

            //if (isSelected) g.DrawImageAlphaChannel(MasterForm.SkinManager.GetImage("MessagesArrowPressed"), leftIndent, topIndent);
            //else g.DrawImageAlphaChannel(MasterForm.SkinManager.GetImage("MessagesArrow"), leftIndent, topIndent);
            if (_cachedImages != null && _cachedImages.Count > 1)
            {
                if (isSelected)
                {
                    g.DrawImage(_cachedImages[1], leftIndent, topIndent);
                }
                else
                {
                    g.DrawImage(_cachedImages[0], leftIndent, topIndent);
                }
            }
        }