Пример #1
0
        private void PopupCanvas_Paint(object sender, PaintEventArgs e)
        {
            commonSkin = CommonSkins.GetSkin(UserLookAndFeel.Default);

            SkinElementInfo elemInfo = new SkinElementInfo(commonSkin[CommonSkins.SkinToolTipWindow], popupCanvas.ClientRectangle)
            {
                Cache = new GraphicsCache(e),
                State = ObjectState.Hot
            };

            SkinElementPainter.Default.DrawObject(elemInfo);

            if (DesignMode)
            {
                return;
            }

            string[] words = input.Text == DefaultText ? new string[0] : input.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            for (var i = popupScroller.Value / lineHeight;
                 i < Math.Min(results.Count, (popupCanvas.Height + popupScroller.Value) / lineHeight + 1); i++)                         //For each visible row
            {
                bool selected = i == SelectedIndex && !resizeAnimator.Enabled && !IsAutoScrolling;
                //bool afterSelected = SelectedIndex >= 0 && i > SelectedIndex && !resizeAnimator.Enabled && !IsAutoScrolling;
                DrawRow(e.Graphics, results[i].Row, words, i * lineHeight - popupScroller.Value, selected);
            }
        }
Пример #2
0
        protected override void DoDrawGlyph(ControlGraphicsInfoArgs info, TokenEditTokenInfo tokenInfo)
        {
            base.DoDrawGlyph(info, tokenInfo);

            if (editor.Properties.CheckBoxSkinElement != null)
            {
                int index = 0;
                CustomTokenEditTokenInfo customTokenInfo = tokenInfo as CustomTokenEditTokenInfo;
                int             offset          = customTokenInfo.Checked == true ? 4 : 0;
                Rectangle       rect            = customTokenInfo.CheckBoxGlyphBounds;
                Rectangle       r               = new Rectangle(rect.X + (int)info.Graphics.ClipBounds.X, rect.Y + (int)info.Graphics.ClipBounds.Y, rect.Width, rect.Height);
                SkinElementInfo skinElementInfo = new SkinElementInfo(editor.Properties.CheckBoxSkinElement, r);
                switch (customTokenInfo.CheckBoxState)
                {
                case ObjectState.Normal:
                    index = offset;
                    break;

                case ObjectState.Hot:
                    index = offset + 1;
                    break;

                case ObjectState.Hot | ObjectState.Pressed:
                    index = offset + 2;
                    break;
                }
                skinElementInfo.ImageIndex = index;


                ImageCollection imageCollection = editor.Properties.CheckBoxSkinElement.Image.GetImages();
                info.Graphics.DrawImage(imageCollection.Images[index], new Rectangle(rect.X + (int)info.Graphics.ClipBounds.X, rect.Y + (int)info.Graphics.ClipBounds.Y, rect.Width, rect.Height));
                ObjectPainter.DrawObject(info.Cache, SkinElementPainter.Default, skinElementInfo);
            }
        }
Пример #3
0
        static void DrawSelection(ControlGraphicsInfoArgs args)
        {
            var info = (ItemSelectorViewInfo)args.ViewInfo;

            var selectionInfo = new SkinElementInfo(info.SelectionBackgroundElement, info.SelectionBounds)
            {
                ImageIndex = 1,
                Cache      = args.Cache
            };

            SkinElementPainter.Default.DrawObject(selectionInfo);
            args.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            Rectangle textArea = Rectangle.Inflate(info.SelectionBounds, -2, 0);

            info.AppearanceResult.DrawString(args.Cache, info.ResultCaption, textArea);

            var textWidth = 8 + (int)Math.Ceiling(info.AppearanceResult.CalcTextSize(args.Cache, info.ResultCaption, textArea.Width).Width);

            textArea.Width -= textWidth;
            textArea.X     += textWidth;

            foreach (var caption in info.AdditionalCaptions)
            {
                info.AppearanceResultInfo.DrawString(args.Cache, caption, textArea);

                textWidth = 4 + (int)Math.Ceiling(info.AppearanceResultInfo.CalcTextSize(args.Cache, caption, textArea.Width).Width);
                if (textWidth > textArea.Width)
                {
                    break;
                }
                textArea.Width -= textWidth;
                textArea.X     += textWidth;
            }
        }
Пример #4
0
        protected override void DrawSkinTrackLineCore(TrackBarObjectInfoArgs e, Rectangle bounds)
        {
            MultiTrackBarViewInfo viewInfo = e.ViewInfo as MultiTrackBarViewInfo;
            var trackElement = GetTrack(viewInfo);

            if (trackElement == null)
            {
                return;
            }
            var trackElementInfo = new SkinElementInfo(trackElement, bounds);

            DrawObject(e.Cache, SkinElementPainter.Default, trackElementInfo);
            if (viewInfo.Item.DrawRanges)
            {
                bounds.Y      -= trackLineRadius;
                bounds.Height += trackLineRadius * 2;
                trackElementInfo.ImageIndex = 1;
                for (int i = 0; i < viewInfo.Thumbs.Length - 1; i += 2)
                {
                    int start = viewInfo.Thumbs[i].Position.X;
                    int end   = viewInfo.Thumbs[i + 1].Position.X;
                    trackElementInfo.Bounds = new Rectangle(start, bounds.Y, end - start, bounds.Height);
                    DrawObject(e.Cache, SkinElementPainter.Default, trackElementInfo);
                }
            }
        }
Пример #5
0
        protected virtual void DrawSkinThumb(TrackBarObjectInfoArgs e, int index)
        {
            MultiTrackBarControlViewInfo viewInfo = (MultiTrackBarControlViewInfo)e.ViewInfo;
            SkinElementInfo info = new SkinElementInfo(GetTrackThumb(e.ViewInfo), GetVerticalThumbRectangle(e.ViewInfo, viewInfo.GetThumbContentBounds(index)));

            UpdateSkinThumbState(info, e, index);
            new RotateObjectPaintHelper().DrawRotated(e.Cache, info, SkinElementPainter.Default, GetRotateAngle(e.ViewInfo), true);
        }
Пример #6
0
        public override void DrawObject(ObjectInfoArgs e)
        {
            SkinElementInfo ee = e as SkinElementInfo;

            if (ee.Element == null)
            {
                return;
            }
            DrawSkinForeground(ee);
        }
        void DrawButton(ControlGraphicsInfoArgs info)
        {
            IPhoneCheckEditViewInfo view = (info.ViewInfo as IPhoneCheckEditViewInfo);
            SkinElement             e    = CommonSkins.GetSkin(view.LookAndFeel)[CommonSkins.SkinButton];
            SkinElementInfo         ei   = new SkinElementInfo(e, view.ButtonRect)
            {
                ImageIndex = view.ButtonImageIndex
            };

            ObjectPainter.DrawObject(info.Cache, SkinElementPainter.Default, ei);
        }
        public override DevExpress.Skins.SkinElementInfo GetItemInfo()
        {
            SkinElementInfo info = base.GetItemInfo();

            if (info.State != DevExpress.Utils.Drawing.ObjectState.Normal)
            {
                Rectangle rect = info.Bounds;
                info.Bounds = new Rectangle(GlyphBounds.X - glyphIndent, rect.Y, GlyphBounds.Width + 2 * glyphIndent, rect.Height);
            }
            return(info);
        }
Пример #9
0
        int CalcGalleryItemMargins()
        {
            SkinWinExplorerViewInfo viewInfo = this.galleryView.GetViewInfo() as SkinWinExplorerViewInfo;

            if (viewInfo == null)
            {
                return(0);
            }
            SkinElementInfo info   = viewInfo.GetItemBackgroundInfo();
            Rectangle       bounds = ObjectPainter.CalcBoundsByClientRectangle((GraphicsCache)null, SkinElementPainter.Default, info, new Rectangle(0, 0, 100, 100));

            return(bounds.Width - 100);
        }
Пример #10
0
 protected override void FillBackground(GraphicsCache cache, Rectangle r)
 {
     if (LookAndFeel.ActiveLookAndFeel.Style == DevExpress.LookAndFeel.LookAndFeelStyle.Skin)
     {
         SkinElement     element = CommonSkins.GetSkin(LookAndFeel)[CommonSkins.SkinForm];
         SkinElementInfo info    = new SkinElementInfo(element, r);
         ObjectPainter.DrawObject(cache, SkinElementPainter.Default, info);
     }
     else
     {
         cache.Graphics.FillRectangle(SystemBrushes.Control, r);
     }
 }
Пример #11
0
 private void DrawButtons(TileControlViewInfo viewInfo, PaintEventArgs e)
 {
     foreach (TileGroupViewInfo group in viewInfo.Groups)
     {
         Rectangle rect = GetButtonRectangle(group);
         using (GraphicsCache cache = new GraphicsCache(e)) {
             var element = SkinManager.GetSkinElement(SkinProductId.Common, UserLookAndFeel.Default, CommonSkins.SkinButton);
             var info    = new SkinElementInfo(element, rect);
             ObjectPainter.DrawObject(cache, SkinElementPainter.Default, info);
             viewInfo.PaintAppearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
             viewInfo.PaintAppearance.DrawString(cache, ButtonCaption, rect);
         }
     }
 }
        protected virtual SkinElementInfo GetCellElementInfo(CellViewInfo cell, GraphicsCache cache, bool selected)
        {
            Skin            skin = CommonSkins.GetSkin(PopupViewInfo.ownerControl.OwnerEdit.LookAndFeel.ActiveLookAndFeel);
            SkinElementInfo skinInfo;

            if (selected)
            {
                skinInfo = new SkinElementInfo(skin[CommonSkins.SkinSelection], cell.cellBounds);
            }
            else
            {
                skinInfo = new SkinElementInfo(skin[CommonSkins.SkinHighlightedItem], cell.cellBounds);
            }
            skinInfo.Cache = cache;
            return(skinInfo);
        }
Пример #13
0
        protected override void DrawButton(ButtonEditViewInfo viewInfo, EditorButtonObjectInfoArgs info)
        {
            base.DrawButton(viewInfo, info);
            TagListViewInfo         vi = viewInfo as TagListViewInfo;
            Rectangle               closeButtonRect      = TagListViewInfo.GetCloseRectangle(info.Bounds);
            SkinEditorButtonPainter currentButtonPainter = (SkinEditorButtonPainter)viewInfo.GetButtonPainter(info);
            Skin        currentSkin = EditorsSkins.GetSkin(currentButtonPainter.Provider);
            SkinElement closeButton = currentSkin[EditorsSkins.SkinCloseButton];
            CustomSkinElementPainter customSkinElementPainter = new CustomSkinElementPainter();

            if (closeButton != null)
            {
                SkinElementInfo skinInfo = new SkinElementInfo(EditorsSkins.GetSkin(currentButtonPainter.Provider)[EditorsSkins.SkinCloseButton], closeButtonRect);
                skinInfo.Cache = info.Cache;
                skinInfo.State = info.State;
                customSkinElementPainter.DrawObject(skinInfo);
            }
        }
Пример #14
0
        static void DrawHoverBackground(PopupFormGraphicsInfoArgs args)
        {
            var info = (ItemSelectorPopupFormViewInfo)args.ViewInfo;

            if (info.HoveredIndex == null)
            {
                return;
            }

            SkinElementInfo elemInfo = new SkinElementInfo(info.HoverElement,
                                                           new Rectangle(info.RowsArea.X, info.GetRowCoordinate(info.HoveredIndex.Value), info.RowsArea.Width, info.RowHeight)
                                                           );

            elemInfo.Cache      = args.Cache;
            elemInfo.State      = info.HoveredItemState;
            elemInfo.ImageIndex = info.HoveredItemState == ObjectState.Pressed ? 2 : 1;

            SkinElementPainter.Default.DrawObject(elemInfo);
        }
        public override void CalcLargeButtonViewInfo(GraphicsCache cache, RibbonItemViewInfo item)
        {
            Rectangle       glyph, bounds = item.Bounds;
            SkinElementInfo info = GetLargeButtonElementInfo(item);

            info.Bounds = bounds;
            Rectangle client = ObjectPainter.GetObjectClientRectangle(cache, SkinElementPainter.Default, info);

            glyph            = client;
            glyph.Size       = (ViewInfo as CustomRibbonViewInfo).LargeImageSize;
            glyph.X         += (client.Width - glyph.Width) / 2;
            item.GlyphBounds = glyph;
            IRibbonGroupInfo groupInfo = item.Owner as IRibbonGroupInfo;
            Rectangle        caption   = client;

            caption.Height     = GetLargeButtonTextHeight(groupInfo != null && groupInfo.IsSingleLineLargeButton);
            caption.Y          = client.Bottom - caption.Height;
            item.CaptionBounds = caption;
        }
Пример #16
0
 private void galleryView_CustomDrawItem(object sender, DevExpress.XtraGrid.Views.WinExplorer.WinExplorerViewCustomDrawItemEventArgs e)
 {
     if (!e.IsAnimated)
     {
         SkinElementInfo info = new SkinElementInfo(CustomSkinHelper.CustomGalleryBorder, e.Bounds);
         info.ImageIndex = 0;
         if (e.ItemInfo.IsHovered)
         {
             info.ImageIndex = 1;
         }
         else if (e.ItemInfo.IsPressed || e.ItemInfo.IsSelected)
         {
             info.ImageIndex = 2;
         }
         ObjectPainter.DrawObject(e.Cache, SkinElementPainter.Default, info);
     }
     e.DrawItemImage();
     e.DrawContextButtons();
     e.Handled = true;
 }
Пример #17
0
        protected void DrawClear(bool isHot, AppearanceObject app, GraphicsCache cache, Rectangle rect)
        {
            if (rect.IsEmpty)
            {
                return;
            }
            Brush br = app.GetForeBrush(cache);

            if (isHot)
            {
                SkinElementInfo skin = new SkinElementInfo(CommonSkins.GetSkin(DevExpress.LookAndFeel.UserLookAndFeel.Default.ActiveLookAndFeel)[CommonSkins.SkinHighlightedItem], rect);
                br = new SolidBrush(DevExpress.LookAndFeel.LookAndFeelHelper.GetSystemColor(
                                        DevExpress.LookAndFeel.UserLookAndFeel.Default.ActiveLookAndFeel,
                                        SystemColors.HotTrack));
                ObjectPainter.DrawObject(cache, SkinElementPainter.Default, skin);
            }
            StringFormat format = new StringFormat();

            format.Alignment = StringAlignment.Center;
            cache.DrawString("Clear", app.Font, br, rect, format);
        }
        public void DrawButton(PaintEventArgs args, ObjectState state)
        {
            using (GraphicsCache cache = new GraphicsCache(args)) {
                SkinElement     element = CommonSkins.GetSkin(UserLookAndFeel.Default)[CommonSkins.SkinButton];
                SkinElementInfo info    = new SkinElementInfo(element, ButtonRectangle);

                if (state == ObjectState.Normal)
                {
                    info.ImageIndex = 0;
                }
                if (state == ObjectState.Hot)
                {
                    info.ImageIndex = 1;
                }
                if (state == ObjectState.Pressed)
                {
                    info.ImageIndex = 2;
                }
                DrawSkinImage(cache, info);
                DrawText(cache);
                DrawImage(cache);
            }
        }
Пример #19
0
 private void RefreshBackColor()
 {
     BackColor = new SkinElementInfo(CommonSkins.GetSkin(LookAndFeel)[CommonSkins.SkinTextBorder]).Element.Border.Bottom;
     Padding = new Padding(BorderByState(_state), 1, 1, IsOfficeStyle ? BorderByState(_state) : 1);
 }
Пример #20
0
        protected Rectangle CalcGroupCaptionButtonBounds(GroupObjectInfoArgs info)
        {
            Rectangle result        = Rectangle.Empty;
            Rectangle captionClient = info.CaptionBounds;

            if (Painter is SkinGroupObjectPainter)
            {
                SkinElementInfo buttonInfo = new SkinElementInfo(Skin[CommonSkins.SkinGroupPanelExpandButton]);
                Size            buttonSize =
                    ObjectPainter.CalcObjectMinBounds(info.Graphics, SkinElementPainter.Default, buttonInfo).Size;
                if (buttonSize.IsEmpty)
                {
                    return(Rectangle.Empty);
                }
                if (!IsCaptionHorizontal)
                {
                    int saveWidth = captionClient.Width;
                    captionClient.Width  = captionClient.Height;
                    captionClient.Height = saveWidth;
                    saveWidth            = captionClient.X;
                    captionClient.X      = captionClient.Y;
                    captionClient.Y      = saveWidth;
                }
                captionClient.Width -= 4;
                result = Skin[CommonSkins.SkinGroupPanelExpandButton].Offset.GetBounds(captionClient, buttonSize, SkinOffsetKind.Far);
                if (!IsCaptionHorizontal)
                {
                    int saveX = result.X;
                    if (CaptionLocation == Locations.Left)
                    {
                        result.X = result.Y;
                        result.Y = captionClient.Width - saveX;
                    }
                    else
                    {
                        result.X = captionClient.Y;
                        result.Y = saveX;
                    }
                }
            }
            else
            {
                Size btnSize = new ExplorerBarOpenCloseButtonObjectPainter().CalcObjectMinBounds(new ExplorerBarOpenCloseButtonInfoArgs(info.Cache, Rectangle.Empty, info.Appearance, ObjectState.Normal, true)).Size;
                result      = captionClient;
                result.Size = btnSize;
                if (IsCaptionHorizontal)
                {
                    result.X  = (captionClient.Right - result.Width) - 4;
                    result.Y += (captionClient.Height - result.Height) / 2;
                }
                else if (CaptionLocation == Locations.Left)
                {
                    result.X  = (captionClient.Width - result.Width) / 2;
                    result.Y += captionClient.Top + 4;
                }
                else
                {
                    result.X  = captionClient.X + (captionClient.Width - result.Width) / 2;
                    result.Y += (captionClient.Bottom - result.Width) - 4;
                }
            }
            return(result);
        }
        static void DrawHoverBackground(PopupFormGraphicsInfoArgs args)
        {
            var info = (ItemSelectorPopupFormViewInfo)args.ViewInfo;

            if (info.HoveredIndex == null) return;

            SkinElementInfo elemInfo = new SkinElementInfo(info.HoverElement,
                new Rectangle(info.RowsArea.X, info.GetRowCoordinate(info.HoveredIndex.Value), info.RowsArea.Width, info.RowHeight)
            );

            elemInfo.Cache = args.Cache;
            elemInfo.State = info.HoveredItemState;
            elemInfo.ImageIndex = info.HoveredItemState == ObjectState.Pressed ? 2 : 1;

            SkinElementPainter.Default.DrawObject(elemInfo);
        }
Пример #22
0
 private void RefreshBackColor()
 {
     BackColor = new SkinElementInfo(CommonSkins.GetSkin(LookAndFeel)[CommonSkins.SkinTextBorder]).Element.Border.Bottom;
     Padding   = new Padding(BorderByState(_state), 1, 1, IsOfficeStyle ? BorderByState(_state) : 1);
 }
Пример #23
0
        void DrawRow(Graphics g, DataRow row, string[] words, int top, bool selected)
        {
            Font  TextFont  = (selected ? selResultFont : listFont);
            Brush TextBrush = (selected ? selResultBrush : resultBrush);

            if (selected)                                                                                                                                               //If this is the selected result, and an animation is not in progress, draw its background.
            {
                SkinElement skinElem = commonSkin[CommonSkins.SkinButton];

                SkinElementInfo elemInfo = new SkinElementInfo(skinElem, new Rectangle(0, Math.Max(0, top), popupCanvas.Width, lineHeight));
                elemInfo.Cache = new GraphicsCache(g);
                elemInfo.State = (sawMouseDown && MouseButtons == MouseButtons.Left)
                                                                        ? ObjectState.Hot | ObjectState.Pressed : ObjectState.Hot;
                new SkinButtonObjectPainter(UserLookAndFeel.Default).DrawObject(elemInfo);
            }
            if (words.Length == 0)                                                                                                              //If the user has not entered a search,
            {
                foreach (ColumnInfo cColumn in Columns)                                                                                         //For each column in the list of columns to draw,
                {
                    var cellText = String.Format(CultureInfo.CurrentCulture, cColumn.FormatString, row[cColumn.FieldName]);
                    g.DrawString(                                                                                                                                       //Draw each column using the correct brush and font.
                        cellText,
                        TextFont,
                        TextBrush,
                        new RectangleF(cColumn.Left, top, cColumn.Width, lineHeight),
                        resultFormat);
                }
            }
            else                                                                                                        //If the user has entered a search
            {
                using (LinearGradientBrush BoldBrush = new LinearGradientBrush(                                         //Create the brush used to highlight the matches.
                           new Rectangle(0, top, popupCanvas.Width, lineHeight), Color.Purple, Color.Red, LinearGradientMode.Vertical)) {
                    if (selected)                                                                                       //If this is the selected result, and an animation is not in progress,
                    {
                        BoldBrush.LinearColors = new Color[] { Color.Red, Color.DarkRed }
                    }
                    ;                                                                                                   //Change the color scheme of the highlight brush.

                    foreach (ColumnInfo cColumn in Columns)                                                             //For each column in the list of columns to draw,
                    {
                        var    cellText    = String.Format(CultureInfo.CurrentCulture, cColumn.FormatString, row[cColumn.FieldName]);
                        string MatchString = "";
                        float  MatchWidth  = 0;

                        foreach (string cWord in words)                                                                                                //For each word,
                        {
                            if (cWord.Length > MatchString.Length && cellText.Replace(' ', '-').StartsWith(cWord, StringComparison.OrdinalIgnoreCase)) //If this word matches the column, and is longer than the previous match,
                            {
                                MatchString = cellText.ToString().Substring(0, cWord.Length);                                                          //Get the match.
                            }
                        }

                        if (MatchString.Length > 0)                                                                             //If we found a match,
                        {
                            MatchWidth = g.MeasureStringWidth(MatchString, matchFont);                                          //Get its width in its special font.

                            g.DrawString(                                                                                       //Draw the match.
                                MatchString,
                                matchFont,
                                BoldBrush,
                                new RectangleF(cColumn.Left, top, cColumn.Width, lineHeight),
                                resultFormat);
                        }
                        g.DrawString(                                                                                                                                   //Draw the remainder (or, if it didn't match, all) of the column using the normal brush and font, offset to account for the width of the match.
                            cellText.Substring(MatchWidth == 0 ? 0 : MatchString.Length),
                            TextFont,
                            TextBrush,
                            new RectangleF(cColumn.Left + MatchWidth, top, cColumn.Width, lineHeight),
                            resultFormat);
                    }
                }
            }
        }

        #endregion
        #region Layout
        void UpdateDisplay()
        {
            if (results.Count * lineHeight >= MaxPopupHeight)
            {
                popupScroller.Visible = true;
                popupScroller.Maximum = results.Count * lineHeight;
                popupScroller.Value   = Math.Min(popupScroller.Value, MaxScroll);
            }
            else
            {
                popupScroller.Visible = false;
                popupScroller.Maximum = 0;
            }
            if (PopupOpen)
            {
                popupCanvas.ResizeRedraw = TargetPopupHeight > PopupHeight;
                popupCanvas.Invalidate();
                resizeAnimator.Start();
            }
        }
        protected override void DrawFrameCore(GraphicsCache cache, SkinElementInfo info, FrameKind kind)
        {
            var formBorderColor = GetFormBorderColor();

            cache.FillRectangle(formBorderColor, info.Bounds);
        }
Пример #25
0
 public void PublicForeground(SkinElementInfo ee)
 {
     base.DrawSkinForeground(ee);
 }
Пример #26
0
 protected override void DrawSkinImage(SkinElementInfo elementInfo, SkinImage skinImage)
 {
     base.DrawSkinImage(elementInfo, skinImage);
 }
 void DrawSkinImage(GraphicsCache cache, SkinElementInfo info)
 {
     ObjectPainter.DrawObject(cache, SkinElementPainter.Default, info);
 }
Пример #28
0
 protected virtual void UpdateSkinThumbState(SkinElementInfo info, TrackBarObjectInfoArgs e, int index)
 {
     info.State      = e.State;
     info.ImageIndex = -1;
 }