示例#1
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);
        }
        protected override void DrawItemOn(Gdi g, NativeItemData nativeItem, Rectangle rItem, int nItem)
        {
            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.TextColor = Settings.ListItemTextColor;
                g.ExtTextOut(rItem.Left + nativeItem.InfoLeftIndents[0],
                    rItem.Top + nativeItem.InfoTopIndents[0],
                    nativeItem.PrimaryText);
            }

            base.DrawItemOn(g, nativeItem, rItem, nItem);
        }
示例#3
0
文件: UIButton.cs 项目: xorkrus/vk_wm
        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);
            }
        }
示例#4
0
文件: UILabel.cs 项目: xorkrus/vk_wm
        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;
            }
        }
示例#5
0
        protected override void OnRender(Gdi graphics, Rectangle clipRect)
        {
            if (_leftBorder != null && _rightBorder != null && _topBorder != null && _bottomBorder != null)
            {
                Rectangle rect = new Rectangle(clipRect.Left + _leftBorderSize.Width,
                                               clipRect.Top + _topBorderSize.Height,
                                               clipRect.Width - _leftBorderSize.Width - _rightBorderSize.Width,
                                               _leftBorderSize.Height - _topBorderSize.Height - _bottomBorderSize.Height);

                if (_leftBorder != null)
                    graphics.DrawImageAlphaChannel(_leftBorder, clipRect.Left, clipRect.Top);
                if (_rightBorder != null)
                    graphics.DrawImageAlphaChannel(_rightBorder, rect.Right,
                                                   clipRect.Top);
                if (_topBorder != null)
                    graphics.DrawImageAlphaChannel(_topBorder,
                                                   new Rectangle(rect.Left, clipRect.Top,
                                                                 rect.Width, _topBorderSize.Height));
                if (_bottomBorder != null)
                    graphics.DrawImageAlphaChannel(_bottomBorder,
                                                   new Rectangle(rect.Left,
                                                                 rect.Bottom,
                                                                 rect.Width, _topBorderSize.Height));

                if (BackColor != Color.Empty)
                    graphics.FillRect(rect, BackColor);
            }
            else
            {
                //if (BackColor != Color.Empty)
                //    graphics.FillRect(clipRect, BackColor);
            }

            if (_textbox.Visible)
            {
                //
            }
            else
            {
                _label.Render(graphics, clipRect);
            }
        }
示例#6
0
文件: ToolBar.cs 项目: xorkrus/vk_wm
        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));
                }
            }
        }
示例#7
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);
 }
示例#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);
        }