コード例 #1
0
        public virtual void Draw(Surfaces.SurfaceBase surface, Rectangle area, object item, ControlStates itemState)
        {
            if (item is Color || item is Tuple <Color, Color, string> )
            {
                string value = new string(' ', area.Width - 2);

                Cell cellLook = GetStateAppearance(itemState).Clone();

                if (item is Color color)
                {
                    cellLook.Background = color;
                    surface.Print(area.Left + 1, area.Top, value, cellLook);
                }
                else
                {
                    cellLook.Foreground = ((Tuple <Color, Color, string>)item).Item2;
                    cellLook.Background = ((Tuple <Color, Color, string>)item).Item1;
                    value = ((Tuple <Color, Color, string>)item).Item3.Align(HorizontalAlignment.Left, area.Width - 2);
                    surface.Print(area.Left + 1, area.Top, value, cellLook);
                }

                surface.Print(area.Left, area.Top, " ", cellLook);
                surface.Print(area.Left + area.Width - 1, area.Top, " ", cellLook);

                if (itemState.HasFlag(ControlStates.Clicked))
                {
                    surface.SetGlyph(area.Left, area.Top, 16);
                    surface.SetGlyph(area.Left + area.Width - 1, area.Top, 17);
                }
            }
            else
            {
                base.Draw(surface, area, item, itemState);
            }
        }
コード例 #2
0
        /// <inheritdoc/>
        public override void Draw(ListBox control, Rectangle area, object item, ControlStates itemState)
        {
            ColoredGlyph appearance;
            string       displayString;

            if (item is System.IO.DirectoryInfo || item is FileDirectoryListbox.FauxDirectory)
            {
                if (item is System.IO.DirectoryInfo info)
                {
                    displayString = "<" + info.Name + ">";
                }
                else
                {
                    displayString = "<" + ((FileDirectoryListbox.FauxDirectory)item).Name + ">";
                }

                if (itemState.HasFlag(ControlStates.MouseOver) && itemState.HasFlag(ControlStates.Selected))
                {
                    appearance = DirectoryAppSelectedOver;
                }
                else if (itemState.HasFlag(ControlStates.MouseOver))
                {
                    appearance = DirectoryAppMouseOver;
                }
                else if (itemState.HasFlag(ControlStates.Selected))
                {
                    appearance = DirectoryAppSelected;
                }
                else
                {
                    appearance = DirectoryAppNormal;
                }
            }
            else if (item is System.IO.FileInfo info)
            {
                displayString = info.Name;

                if (itemState.HasFlag(ControlStates.MouseOver) && itemState.HasFlag(ControlStates.Selected))
                {
                    appearance = DirectoryAppSelectedOver;
                }
                else if (itemState.HasFlag(ControlStates.MouseOver))
                {
                    appearance = DirectoryAppMouseOver;
                }
                else if (itemState.HasFlag(ControlStates.Selected))
                {
                    appearance = DirectoryAppSelected;
                }
                else
                {
                    appearance = FileAppNormal;
                }
            }
            else if (item is FileDirectoryListbox.HighlightedExtFile extInfo)
            {
                displayString = extInfo.Name;

                if (itemState.HasFlag(ControlStates.MouseOver) && itemState.HasFlag(ControlStates.Selected))
                {
                    appearance = HighExtAppSelectedOver;
                }
                else if (itemState.HasFlag(ControlStates.MouseOver))
                {
                    appearance = HighExtAppMouseOver;
                }
                else if (itemState.HasFlag(ControlStates.Selected))
                {
                    appearance = HighExtAppSelected;
                }
                else
                {
                    appearance = HighExtAppNormal;
                }
            }
            else
            {
                appearance    = GetStateAppearance(itemState);
                displayString = item.ToString();
            }

            control.Surface.Print(area.X, area.Y, displayString.Align(SadConsole.HorizontalAlignment.Left, area.Width), appearance);
        }