Ejemplo n.º 1
0
        protected override void OnRender(Gdi gMem, Rectangle clipRect)
        {
            if (_backgroundImage != null)
            {
                _backgroundImage.Render(gMem, clipRect);
            }
            else
            {
                gMem.FillRect(Rectangle, BackColor);
            }

            if (_buttons.Count > 0)
            {
                for (int i = 0; i < _buttons.Count; i++)
                {
                    _buttons[i].Instance.Render(gMem, new Rectangle(_buttons[i].Instance.Location.X,
                                                                    _buttons[i].Instance.Location.Y,
                                                                    _buttonsSize.Width, _buttonsSize.Height));
                }
            }
        }
Ejemplo n.º 2
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);
            }
        }
        protected override void DrawItemBackgroundOn(Gdi gMem, NativeItemData nativeItem, Rectangle rItem, int nItem, bool isSelected)
        {
            NativeItemData item = (NativeItemData)nativeItem;

            Color baseColor;

            baseColor = Color.FromArgb(255, 255, 255);

            if (isSelected)
            {
                gMem.GradientFill(rItem, Color.FromArgb(69, 137, 219), Color.FromArgb(50, 106, 173), FillDirection.TopToBottom);
            }
            else
            {
                BrushGdi backGround = Gdi.CreateSolidBrush(baseColor);

                if (backGround != BrushGdi.Empty)
                {
                    gMem.FillRect(rItem, backGround);
                }
            }
        }
Ejemplo n.º 4
0
        private void FlipOut(Gdi mem, Rectangle canvas, IntPtr dc, IntPtr stretchDC, double transitionPct)
        {
            int margin = (int)((double)_CanvasMiddle * transitionPct);

            using (Gdi stretch = Gdi.FromHdc(stretchDC, Rectangle.Empty))
            {
                stretch.FillRect(canvas, Color.Gainsboro);
                stretch.StretchBlt(0, 0, canvas.Width - margin * 2, canvas.Height,
                                   dc,
                                   0, 0, canvas.Width, canvas.Height, TernaryRasterOperations.SRCCOPY);
            }

            var currLine = BuildPath(_FlipOutLeftPath[margin].X, _FlipOutLeftPath[margin].Y, _FlipOutTopPath[margin].X,
                                     _FlipOutTopPath[margin].Y);

            for (int i = 0; i < currLine.Count - 1; i++)
            {
                mem.StretchBlt(currLine[i].X, currLine[i].Y, 1, canvas.Height - currLine[i].Y * 2,
                               stretchDC,
                               i, 0, 1, canvas.Height,
                               TernaryRasterOperations.SRCCOPY);
            }
        }
Ejemplo n.º 5
0
        public override void DrawScreenOn(Gdi mem, Rectangle rect)
        {
            IntPtr fromDC    = _FromGraphics.GetHdc();
            IntPtr toDC      = _ToGraphics.GetHdc();
            IntPtr stretchDC = _StretchGraphics.GetHdc();

            mem.FillRect(rect, Color.Gainsboro);

            double percent = 2 * (_transitionPct > 0.5 ? _transitionPct - 0.5 : _transitionPct);

            if (FlipDirection == TransitionType.FlipLeft)
            {
                if (_transitionPct <= 0.5)
                {
                    FlipOut(mem, rect, fromDC, stretchDC, percent);
                }
                else
                {
                    FlipIn(mem, rect, toDC, stretchDC, percent);
                }
            }
            else
            {
                if (_transitionPct <= 0.5)
                {
                    FlipIn(mem, rect, fromDC, stretchDC, 1 - percent);
                }
                else
                {
                    FlipOut(mem, rect, toDC, stretchDC, 1 - percent);
                }
            }

            _StretchGraphics.ReleaseHdc(stretchDC);
            _FromGraphics.ReleaseHdc(fromDC);
            _ToGraphics.ReleaseHdc(toDC);
        }
Ejemplo n.º 6
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);
                }
            }
        }
Ejemplo n.º 8
0
        protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem)
        {
            //Дефолтный цвет для Enabled элементов
            g.TextColor = Settings.ListItemTextColor;

            #region Отображение disabled элементов
            bool isNotifficationOff = false;
            foreach (var item in Items)
            {
                if (item.OptionName == nativeItem.PrimaryText)
                {
                    //Выясняем стоит ли BackgroundNotification в Off
                    foreach (var item2 in Items)
                    {
                        if (item2.OptionName == Resources.BackgroundNotification &&
                            (string)item2.OptionValue == Resources.Settings_Off)
                        {
                            isNotifficationOff = true;
                        }
                    }

                    if (item.OptionName == Resources.Settings_Messages)
                    {
                        //((CheckBoxNativeItemData) nativeItem).CheckBoxSelected = MasterForm.SkinManager.GetImage("SettingsUnavailable");
                        g.TextColor = Color.FromArgb(213, 213, 213);
                    }
                    if (item.OptionName == Resources.Settings_Comments && isNotifficationOff)
                    {
                        //((CheckBoxNativeItemData) nativeItem).CheckBoxSelected = MasterForm.SkinManager.GetImage("SettingsUnavailable");
                        g.TextColor = Color.FromArgb(213, 213, 213);
                    }
                    if (item.OptionName == Resources.Settings_Friends && isNotifficationOff)
                    {
                        //((CheckBoxNativeItemData) nativeItem).CheckBoxSelected = MasterForm.SkinManager.GetImage("SettingsUnavailable");
                        g.TextColor = Color.FromArgb(213, 213, 213);
                    }
                    if (item.OptionName == Resources.Settings_FriendsNews && isNotifficationOff)
                    {
                        //((CheckBoxNativeItemData) nativeItem).CheckBoxSelected = MasterForm.SkinManager.GetImage("SettingsUnavailable");
                        g.TextColor = Color.FromArgb(213, 213, 213);
                    }
                    if (item.OptionName == Resources.Settings_FriendsPhotos && isNotifficationOff)
                    {
                        //((CheckBoxNativeItemData) nativeItem).CheckBoxSelected = MasterForm.SkinManager.GetImage("SettingsUnavailable");
                        g.TextColor = Color.FromArgb(213, 213, 213);
                    }
                    if (item.OptionName == Resources.Settings_WallMessages && isNotifficationOff)
                    {
                        //((CheckBoxNativeItemData) nativeItem).CheckBoxSelected = MasterForm.SkinManager.GetImage("SettingsUnavailable");
                        g.TextColor = Color.FromArgb(213, 213, 213);
                    }
                }
            }
            #endregion

            if (rItem.Height > Settings.ListItemPixSize)
            {
                rItem = new Rectangle(rItem.Left,
                                      rItem.Top + rItem.Height - Settings.ListItemPixSize,
                                      rItem.Width,
                                      Settings.ListItemPixSize);
            }
            //Не надо делать выделение
            DrawItemBackgroundOn(g, nativeItem, rItem, nItem, /*nItem == SelectedIndex*/ false);

            var rSep = new Rectangle(rItem.Left, rItem.Bottom - 1, rItem.Width, 1);
            g.FillRect(rSep, Settings.ListItemSeparator);

            // write name
            if (!string.IsNullOrEmpty(nativeItem.PrimaryText))
            {
                g.Font      = Settings.PrimaryTextFontGdi;
                g.TextAlign = Win32.TextAlign.TA_LEFT;
                g.ExtTextOut(rItem.Left + nativeItem.InfoLeftIndents[0],
                             rItem.Top + nativeItem.InfoTopIndents[0],
                             nativeItem.PrimaryText);
            }

            base.DrawItemOn(g, nativeItem, rItem, nItem);
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
        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;

            //фон
            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.Right - item.InfoLeftIndents[1];

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

            if (!string.IsNullOrEmpty(item.TertiaryText))
            {
                g.Font      = Settings.ThirdTextFontGdi;
                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);
            }

            // текст сообщения
            leftIndent = rItem.Left + item.InfoLeftIndents[0];
            topIndent  = rItem.Top + item.InfoTopIndents[0];

            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);
                }
            }
        }
Ejemplo n.º 11
0
        protected override void OnRender(Gdi graphics, Rectangle clipRect)
        {
            //graphics.DrawText(_message,
            //  new Win32.RECT(_textRectangle.X,
            //                 _textRectangle.Y,
            //                 _textRectangle.Width,
            //                 _textRectangle.Height),
            //  Win32.DT.LEFT | Win32.DT.TOP | Win32.DT.WORDBREAK);


            clipRect.Intersect(this.Rectangle);
            if (clipRect.IsEmpty)
            {
                return;
            }

            //base.OnRender(graphics, clipRect);

            //SetupDefaultClip(g);
            float topAdjust = 0;

            switch (VerticalTextAlignment)
            {
            case VerticalAlignment.Top:
                topAdjust = 0;
                break;

            case VerticalAlignment.Bottom:
                //topAdjust = ClientHeight - _totalHeight;
                topAdjust = Height - _totalHeight;
                break;

            case VerticalAlignment.Center:
                //topAdjust = (ClientHeight - _totalHeight) / 2;
                topAdjust = (Height - _totalHeight) / 2;
                break;
            }

            if (BackColor != Color.Transparent)
            {
                graphics.FillRect(
                    //new Rectangle(e.Origin.X, e.Origin.Y, ClientWidth, ClientHeigh),
                    clipRect,
                    BackColor);
            }

            foreach (LineBreak lineBreak in _lineBreaks)
            {
                float leftAdjust = 0;
                switch (HorizontalTextAlignment)
                {
                case HorizontalAlignment.Left:
                    leftAdjust = 0;
                    break;

                case HorizontalAlignment.Right:
                    //leftAdjust = ClientWidth - lineBreak.Width;
                    leftAdjust = Width - lineBreak.Width;
                    break;

                case HorizontalAlignment.Center:
                    //leftAdjust = (ClientWidth - lineBreak.Width) / 2.0f;
                    leftAdjust = (Width - lineBreak.Width) / 2.0f;
                    break;
                }

                Rectangle drawRect = new Rectangle(this.Left + Margin.Left + (int)leftAdjust,
                                                   this.Top + Margin.Top + (int)topAdjust, (int)lineBreak.Width, (int)lineBreak.Height);
                if (clipRect.IntersectsWith(drawRect))
                {
                    graphics.Font      = Font;
                    graphics.TextColor = ForeColor;
                    //graphics.
                    //TODO: chhange all this code to only one single DrawText
                    graphics.ExtTextOut(drawRect.Left, drawRect.Top, drawRect.Width,
                                        lineBreak.Text);
                    //	new Galssoft.WM.Components.SystemHelpers.Win32.RECT(drawRect), Galssoft.WM.Components.SystemHelpers.Win32.DT.LEFT);
                    //Font, myForeBrush, e.Origin.X + leftAdjust, e.Origin.Y + topAdjust);
                }
                topAdjust += lineBreak.Height;
                if (topAdjust > Height)
                {
                    break;
                }
            }
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        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)
        {
            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)
        {
            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);
                }
            }
        }