Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        protected override void DrawItemOn(Gdi g, NativeItemData nativeitem, Rectangle rItem, int nItem)
        {
            var item = (NativeItemDataMm)nativeitem;

            //if (nItem == ItemCount - 1)
            //    rItem = new Rectangle(rItem.Left, rItem.Top, rItem.Width, rItem.Height);
            //else


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

            DrawItemBackgroundOn(g, item, rItem, nItem, isSelected);

            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));
            }

            int iconMargin = UISettings.CalcPix(15);
            int iconX      = rItem.Left + iconMargin;

            //Для кнопки выход не рисуем иконку

            /*
             * if (item.PrimaryText != Resources.ExtraView_ExitButtonTitle)
             * {
             *  // 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))
            {
                g.Font = FontCache.CreateFont("Tahoma", 16, FontStyle.Regular, true);


                g.TextAlign = Win32.TextAlign.TA_LEFT;
                Size textSize = g.GetTextExtent(item.PrimaryText);

                //Для кнопки выход текст по центру
                if (item.PrimaryText == Resources.ExtraView_ExitButtonTitle)
                {
                    if (isSelected)
                    {
                        g.TextColor = Color.FromArgb(255, 255, 255);
                    }
                    else
                    {
                        g.TextColor = Color.FromArgb(145, 145, 145);
                    }
                    g.ExtTextOut(rItem.Left + (rItem.Width - textSize.Width) / 2, rItem.Top + (rItem.Height - textSize.Height) / 2,
                                 item.PrimaryText);
                }
                else
                {
                    if (isSelected)
                    {
                        g.TextColor = Color.FromArgb(255, 255, 255);
                    }
                    else
                    {
                        g.TextColor = Color.FromArgb(119, 126, 93);
                    }
                    g.ExtTextOut(UISettings.CalcPix(20),
                                 rItem.Top + (rItem.Height - textSize.Height) / 2, item.PrimaryText);
                }
            }
        }
        protected override void DrawGroupHeaderOn(Gdi gMem, int item, Rectangle rHeaderArea)
        {
            //// Draw Group Header Text
            //gMem.Font = Settings.GroupFont;
            //gMem.TextAlign = Win32.TextAlign.TA_RIGHT;
            ////gMem.TextColor = Color.FromArgb(150, 150, 150);
            ////gMem.ExtTextOut(rHeaderArea.Right - UISettings.CalcPix(10) + 1,
            ////                rHeaderArea.Top + Settings.GroupPixTopMargin * 2 + 1,
            ////                GetItemAtIndex(item).Group, true);

            //gMem.TextColor = Settings.ListGroupTextColor;
            //gMem.ExtTextOut(rHeaderArea.Right - UISettings.CalcPix(10),
            //                rHeaderArea.Top + Settings.GroupPixTopMargin * 2,
            //                GetItemAtIndex(item).Group, true);

            //gMem.Font = Settings.GroupFont;
            //gMem.TextAlign = Win32.TextAlign.TA_RIGHT;
            //gMem.TextColor = Settings.ListGroupTextColor;

            //Size newSize = gMem.GetTextExtent(GetItemAtIndex(item).Group);

            //gMem.ExtTextOut(rHeaderArea.Right - UISettings.CalcPix(10), rHeaderArea.Top + (rHeaderArea.Height - newSize.Height) / 2, GetItemAtIndex(item).Group, true);

            gMem.Font      = Settings.GroupFont;
            gMem.TextAlign = Win32.TextAlign.TA_RIGHT;

            Size newSize = gMem.GetTextExtent(GetItemAtIndex(item).Group);

            gMem.TextColor = Color.FromArgb(150, 150, 150);
            gMem.ExtTextOut(rHeaderArea.Right - UISettings.CalcPix(10) + UISettings.CalcPix(1), rHeaderArea.Top + (rHeaderArea.Height - newSize.Height) / 2 + UISettings.CalcPix(1), GetItemAtIndex(item).Group);

            gMem.TextColor = Settings.ListGroupTextColor;
            gMem.ExtTextOut(rHeaderArea.Right - UISettings.CalcPix(10), rHeaderArea.Top + (rHeaderArea.Height - newSize.Height) / 2, GetItemAtIndex(item).Group);
        }
        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 List <NativeItemData> BuildNativeControlItems()
        {
            var newListData = new List <NativeItemData>(Items.Count);

            if (Items != null)
            {
                var hdcMem = OffScreenGraphics.GetHdc();

                try
                {
                    using (Gdi g = Gdi.FromHdc(hdcMem, Rectangle.Empty))
                    {
                        g.Font      = Settings.SecondaryTextFontGdi;
                        g.TextAlign = Win32.TextAlign.TA_LEFT;

                        for (int i = 0; i < Items.Count; i++)
                        {
                            string photo = string.Empty;

                            if (Items[i].IsPhotoLoaded)
                            {
                                photo = Items[i].Photo;
                            }
                            else
                            {
                                photo = "clear";
                            }

                            NativeItemData newNativeItemData = new KineticListView <PhotoCommentsUpdatesViewItem> .NativeItemData
                            {
                                Uid   = Items[i].Uid,
                                Group = Items[i].Group,

                                PrimaryText   = Items[i].SenderName,
                                SecondaryText = Items[i].Comment,
                                TertiaryText  = Items[i].CommentSetDate.ToString("HH:mm"),

                                SecondaryTextLines = TextFormatHelper.CutTextToLines(Items[i].Comment, UISettings.CalcPix(170), 2, g),

                                PrimaryImageURL = photo,

                                InfoLeftIndents = new int[3],
                                InfoTopIndents  = new int[2]
                            };

                            newListData.Add(newNativeItemData);
                        }
                    }
                }
                finally
                {
                    OffScreenGraphics.ReleaseHdc(hdcMem);
                }
            }

            return(newListData);
        }
Exemplo n.º 6
0
        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 - _rightPartSize.Width - UISettings.CalcPix(5), 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 + UISettings.CalcPix(5), clipRect.Top + topIndent + (clipRect.Height - totalHeight) / 2, line);

                    topIndent += averageHeight;
                }

                #endregion
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.mainMenu         = new System.Windows.Forms.MainMenu();
            this.menuItemSend     = new System.Windows.Forms.MenuItem();
            this.menuItemCancel   = new System.Windows.Forms.MenuItem();
            this.contextMenu      = new ContextMenu();
            this.miCut            = new MenuItem();
            this.miCopy           = new MenuItem();
            this.miPaste          = new MenuItem();
            this.tbxMessageData   = new TextBox();
            this.headerText       = new UILabel();
            this.headerShadowText = new UILabel();
            this.header           = new GraphicsImage();
            this.logo             = new GraphicsImage();
            this.friendsLogo      = new UIButton(ButtonStyle.AlphaChannel);

            this.SuspendLayout();

            //
            // header
            //
            this.header.Name     = "header";
            this.header.Location = new Point(0, 0);
            this.header.Stretch  = true;
            this.header.Anchor   = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

            //
            // logo
            //
            this.logo.Name     = "logo";
            this.logo.Location = new Point(6, 7);
            this.logo.Stretch  = false;
            this.logo.Anchor   = AnchorStyles.Left | AnchorStyles.Top;

            //
            // friendLogo
            //
            this.friendsLogo.Name = "friendLogo";
            //this.friendsLogo.Location = new Point(210, 4);
            this.friendsLogo.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.friendsLogo.Click += new EventHandler(FriendsLogoClick);

            //
            // headerText
            //
            this.headerText.Name                    = "headerText";
            this.headerText.Location                = new Point(0, 0);
            this.headerText.Size                    = new Size(240, 36);
            this.headerText.Font                    = FontCache.CreateFont("Tahoma", 14, FontStyle.Bold);
            this.headerText.ForeColor               = Color.White;
            this.headerText.VerticalTextAlignment   = VerticalAlignment.Center;
            this.headerText.HorizontalTextAlignment = Galssoft.VKontakteWM.Components.UI.HorizontalAlignment.Center;
            this.headerText.Text                    = Resources.ChangeCommentView_Title;
            this.headerText.Anchor                  = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

            //
            // headerShadowText
            //
            this.headerShadowText.Name                    = "headerShadowText";
            this.headerShadowText.Location                = new Point(0, 0);
            this.headerShadowText.Size                    = new Size(240, 36);
            this.headerShadowText.Font                    = FontCache.CreateFont("Tahoma", 14, FontStyle.Bold);
            this.headerShadowText.ForeColor               = Color.Black;
            this.headerShadowText.VerticalTextAlignment   = VerticalAlignment.Center;
            this.headerShadowText.HorizontalTextAlignment = Galssoft.VKontakteWM.Components.UI.HorizontalAlignment.Center;
            this.headerShadowText.Text                    = Resources.ChangeCommentView_Title;
            this.headerShadowText.Anchor                  = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

            //
            // tbxCommentText
            //
            tbxMessageData.Name        = "tbxCommentText";
            tbxMessageData.Location    = new Point(0, 36);
            tbxMessageData.Size        = new Size(240, 232);
            tbxMessageData.Multiline   = true;
            tbxMessageData.Font        = new System.Drawing.Font("Tahoma", 12, FontStyle.Regular);
            tbxMessageData.BorderStyle = BorderStyle.None;
            tbxMessageData.Anchor      = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top;
            tbxMessageData.ContextMenu = this.contextMenu;
            tbxMessageData.ScrollBars  = ScrollBars.Vertical;
            tbxMessageData.WordWrap    = true;

            //
            // mainMenu1
            //
            this.mainMenu.MenuItems.Add(this.menuItemCancel);
            this.mainMenu.MenuItems.Add(this.menuItemSend);

            //
            // menuItemSend
            //
            this.menuItemSend.Text   = Resources.SendCommentSend;
            this.menuItemSend.Click += new System.EventHandler(ButtonSendClick);

            //
            // menuItemCancel
            //
            this.menuItemCancel.Text   = Resources.MessagesList_Designer_menuItemCancel_Text;
            this.menuItemCancel.Click += new System.EventHandler(ButtonCancelClick);

            //
            // contextMenu
            //
            this.contextMenu.MenuItems.Add(this.miCut);
            this.contextMenu.MenuItems.Add(this.miCopy);
            this.contextMenu.MenuItems.Add(this.miPaste);
            this.contextMenu.Popup += new EventHandler(ContextMenuPopup);

            //
            // miCut
            //
            this.miCut.Text   = Resources.CutToClipboard;
            this.miCut.Click += new EventHandler(MiCutClick);

            //
            // miCopy
            //
            this.miCopy.Text   = Resources.CopyToClipboard;
            this.miCopy.Click += new EventHandler(MiCopyClick);

            //
            // miPaste
            //
            this.miPaste.Text   = Resources.PasteFromClipboard;
            this.miPaste.Click += new EventHandler(MiPasteClick);

            //
            // this
            //
            this.Size = new Size(240, 268);
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Dpi;
            this.BackColor           = Color.White;
            this.GotFocus           += new EventHandler(MessageSendViewGotFocus);
            this.AutoScroll          = true;

            this.Canvas.Children.Add(header);
            this.Canvas.Children.Add(logo);
            //this.Canvas.Children.Add(friendsLogo);
            this.Canvas.Children.Add(headerShadowText);
            this.Canvas.Children.Add(headerText);

            this.Controls.Add(tbxMessageData);

            this.Canvas.RecalcDPIScaling();
            this.ResumeLayout(false);

            this.headerShadowText.Location = new Point(this.headerShadowText.Location.X, this.headerShadowText.Location.Y - UISettings.CalcPix(1));

            this.header.AlphaChannelImage             = MasterForm.SkinManager.GetImage("Header");
            this.logo.AlphaChannelImage               = MasterForm.SkinManager.GetImage("HeaderLogo");
            this.friendsLogo.TransparentButton        = MasterForm.SkinManager.GetImage("FriendsLogo");
            this.friendsLogo.TransparentButtonPressed = MasterForm.SkinManager.GetImage("FriendsLogoPressed");
        }
        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);
                }
            }
        }
        protected override List <NativeItemData> BuildNativeControlItems()
        {
            var newListData = new List <NativeItemData>(Items.Count);

            if (Items != null)
            {
                for (int i = 0; i < Items.Count; i++)
                {
                    List <string> secondaryTextLines = new List <string>();

                    var hdcMem = OffScreenGraphics.GetHdc();

                    try
                    {
                        using (Gdi g = Gdi.FromHdc(hdcMem, Rectangle.Empty))
                        {
                            g.Font      = Settings.SecondaryTextFontGdi;
                            g.TextAlign = Win32.TextAlign.TA_LEFT;

                            secondaryTextLines = TextFormatHelper.CutTextToLines(Items[i].MessageText, UISettings.CalcPix(192), 2, g);
                        }
                    }
                    finally
                    {
                        OffScreenGraphics.ReleaseHdc(hdcMem);
                    }

                    NativeItemDataNew newNativeItemData = new NativeItemDataNew
                    {
                        Uid = Items[i].Uid,

                        PrimaryText   = Items[i].UserName,
                        SecondaryText = Items[i].MessageText,
                        TertiaryText  = Items[i].MessageWroteDateString,

                        SecondaryTextLines = secondaryTextLines,

                        IsItemHighlight = Items[i].IsMessageNew,
                        IsOutboxIconSet = Items[i].IsMessageOutbox,

                        Tag          = Items[i].UserID,
                        PrimaryImage = null,//MasterForm.SkinManager.GetImage("IsOutputMessage"),

                        InfoLeftIndents = new int[5],
                        InfoTopIndents  = new int[3]
                    };

                    newListData.Add(newNativeItemData);
                }
            }

            return(newListData);
        }