public ScriptColumn(string label,
                            ScriptBlock script,
                            ColumnAlignment alignment,
                            int width,
                            string tag,
                            TrimLocation trimLocation,
                            bool captureContext)
            : base(alignment, width, tag, trimLocation)
        {
            if (String.IsNullOrEmpty(label))
            {
                throw new ArgumentException("You must supply a column label.", "label");
            }

            if (null == script)
            {
                throw new ArgumentNullException("script");
            }

            m_label = label;
            Script  = script;
            if (captureContext)
            {
                Context = DbgProvider.CapturePsContext();
            }
        } // end constructor
 TextSelectWholeBoundedWordDialog(bool wholeWord)
 {
     InitializeComponent();
     Title = $"Select {(wholeWord ? "Whole" : "Bounded")} Word";
     chars.CompletionTag = wholeWord ? WHOLEWORDCOMPLETIONTAG : BOUNDEDWORDCOMPLETIONTAG;
     Chars    = wholeWord ? ALPHANUMERIC : STRING;
     Location = TrimLocation.Both;
 }
 public ScriptColumn(string label,
                     ScriptBlock script,
                     ColumnAlignment alignment,
                     int width,
                     string tag,
                     TrimLocation trimLocation)
     : this(label, script, alignment, width, tag, trimLocation, false)
 {
 }
示例#4
0
        } // end Truncate()

        /// <summary>
        ///    Creates a new ColorString object if truncation is necessary.
        /// </summary>
        public static ColorString Truncate(ColorString cs,
                                           int maxApparentWidth,
                                           bool useEllipsis,
                                           TrimLocation trimLocation)
        {
            if (cs.Length <= maxApparentWidth)
            {
                return(cs);
            }

            // Would it be better to go through all the elements?
            return(CaStringUtil.Truncate(cs.ToString(true),
                                         maxApparentWidth,
                                         useEllipsis,
                                         trimLocation));
        } // end Truncate()
        public ScriptColumn(string label,
                            ScriptBlock script,
                            ColumnAlignment alignment,
                            int width,
                            string tag,
                            TrimLocation trimLocation)
            : base(alignment, width, tag, trimLocation)
        {
            if (String.IsNullOrEmpty(label))
            {
                throw new ArgumentException("You must supply a column label.", nameof(label));
            }

            Label  = label;
            Script = script ?? throw new ArgumentNullException(nameof(script));
        } // end constructor
        public PropertyColumn(string propertyName,
                              ColorString formatString,
                              string label,
                              ColumnAlignment alignment,
                              int width,
                              string tag,
                              TrimLocation trimLocation)
            : base(alignment, width, tag, trimLocation)
        {
            if (String.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentException("You must supply a property name.", "propertyname");
            }

            PropertyName = propertyName;
            FormatString = formatString;
            m_label      = label;
        } // end constructor
示例#7
0
        protected static string PadAndAlign(string s,
                                            int width,
                                            ColumnAlignment alignment,
                                            TrimLocation trimLocation)
        {
            Util.Assert(ColumnAlignment.Default != alignment);

            int len = CaStringUtil.Length(s);
            int pad = width - len;

            if (0 == pad)
            {
                return(s);
            }

            if (pad < 0)
            {
                // Oh dear... too big to fit.
                return(CaStringUtil.Truncate(s, width, true, trimLocation));
            }

            switch (alignment)
            {
            case ColumnAlignment.Left:
                return(s + new String(' ', pad));

            case ColumnAlignment.Center:
                int leftpad  = pad / 2;
                int rightpad = pad - leftpad;
                return(new String(' ', leftpad) + s + new String(' ', rightpad));

            case ColumnAlignment.Right:
                return(new String(' ', pad) + s);

            default:
                throw new ArgumentException(Util.Sprintf("Invalid ColumnAlignment value: {0}",
                                                         alignment),
                                            "alignment");
            }
        } // end PadAndAlign()
示例#8
0
        /// <summary>
        ///    Creates a new ColorString object if any change is necessary.
        ///    TODO: Perhaps it should /always/ create a new object?
        /// </summary>
        /// <remarks>
        ///    Note that not all combinations of useEllipsis, contentAlignment, and
        ///    trimLocation are valid.
        /// </remarks>
        public static ColorString MakeFixedWidth(ColorString cs,
                                                 int maxApparentWidth,
                                                 bool useEllipsis,
                                                 Alignment contentAlignment,
                                                 TrimLocation trimLocation)
        {
            if (cs.Length > maxApparentWidth)
            {
                return(Truncate(cs, maxApparentWidth, useEllipsis, trimLocation));
            }
            else if (cs.Length == maxApparentWidth)
            {
                return(cs);
            }

            int diff = maxApparentWidth - cs.Length;

            switch (contentAlignment)
            {
            case Alignment.Undefined:
            case Alignment.Left:
                // Pad right:
                return(new ColorString(cs).Append(new String(' ', diff)));

            case Alignment.Right:
                // Pad left:
                return(new ColorString(new String(' ', diff)).Append(cs));

            case Alignment.Center:
                int diff2 = diff / 2;
                diff = diff - diff2;
                return(new ColorString(new String(' ', diff2))
                       .Append(cs)
                       .Append(new String(' ', diff)));

            default:
                throw new Exception("Unexpected alignment value.");
            }
        } // end MakeFixedWidth()
        protected Column(ColumnAlignment alignment, int width, string tag, TrimLocation trimLocation)
        {
            // We used to make sure that your specified column width was big enough to
            // handle truncation. But that precluded having very narrow colums, which is
            // occasionally handy for squishing in lots of small, flag-type data.
            //
            // The trick is that if you pass a width of less than 4, you'd better be sure
            // that your data won't ever get truncated, because the truncation code will
            // have a fit if it can't indicate truncation by sticking an ellipsis onto at
            // least one character.
            //
            // If we ever want to go back to enforcing column width of at least 4, then
            // the workaround for narrow columns would be to combine columns (the header
            // would be the original column headers separated by a space, and manually
            // format the column value to include both "virtual" columns).
            // if( (width < 4) && (width > 0) )
            //     throw new ArgumentOutOfRangeException( "width" );

            Alignment    = alignment;
            Width        = width;
            Tag          = tag;
            TrimLocation = trimLocation;
        } // end constructor