Exemple #1
0
        public ItemSelectorPopupForm(ItemSelector owner)
            : base(owner)
        {
            base.fCloseButtonStyle = BlobCloseButtonStyle.None;

            ScrollBar = new DevExpress.XtraEditors.VScrollBar();
            ScrollBar.ScrollBarAutoSize = true;
            ScrollBar.Scroll           += ScrollBar_Scroll;
            ScrollBar.LookAndFeel.Assign(Properties.LookAndFeel);
            Controls.Add(ScrollBar);

            dragScrollTimer       = new Timer();
            dragScrollTimer.Tick += DragScrollTimer_Tick;
        }
Exemple #2
0
        static void DrawCell(PopupFormGraphicsInfoArgs args, int rowIndex, ResultColumn column, int x)
        {
            var info = (ItemSelectorPopupFormViewInfo)args.ViewInfo;

            //Subtract the padding from the left edge and the width.  (To preserve the right edge)
            x += info.CellPaddingLeft;
            var location   = new Point(x, info.GetRowCoordinate(rowIndex));
            var cellWidth  = Math.Min(column.Width - info.CellPaddingLeft, info.RowsArea.Right - info.HoverElement.ContentMargins.Right - x);
            var cellBounds = new Rectangle(location, new Size(cellWidth, info.RowHeight));

            var text = column.GetValue(info.Rows[rowIndex]);

            //If this cell matched the filter, find the matching prefix.
            //I take the prefix from the cell value instead of the actual
            //word to allow for variations in case and hyphens.
            string matchedPart = null;

            if (column.ShouldFilter && info.FilterWords.Any())
            {
                var match = info.FilterWords.FirstOrDefault(fw => ItemSelector.ValueMatches(filterWord: fw, columnValue: text));
                if (match != null)
                {
                    matchedPart = text.Substring(0, match.Length);                      //The match might be the entire value
                }
            }

            Brush colorOverride = null;

            if (rowIndex == info.HoveredIndex &&
                info.HoverElement.Color.ForeColor != info.AppearanceResults.GetForeColor())
            {
                colorOverride = args.Cache.GetSolidBrush(info.HoverElement.Color.ForeColor);
            }

            if (String.IsNullOrEmpty(matchedPart))
            {
                info.AppearanceResults.DrawStringDefaultColor(args.Cache, text, cellBounds, colorOverride);
            }
            else
            {
                info.AppearanceMatch.DrawStringDefaultColor(args.Cache, matchedPart, cellBounds, colorOverride);

                var matchSize = Size.Ceiling(info.AppearanceMatch.CalcTextSize(args.Cache, matchedPart, cellWidth));
                matchSize.Width++;                      //DevExpress measures very aggressively
                cellBounds.X     += matchSize.Width;
                cellBounds.Width -= matchSize.Width;

                info.AppearanceResults.DrawStringDefaultColor(args.Cache, text.Substring(matchedPart.Length), cellBounds, colorOverride);
            }
        }