コード例 #1
0
ファイル: color_time.cs プロジェクト: CaulyKan/logwizard
        internal override void format_after(format_cell cell) {
            if (formatting_ == null && light_color_ == "" && !show_diff_)
                // nothing to do
                return;
            if (cell.col_type != expected_type)
                return; // only color time column

            Color col = formatting_ != null ? formatting_.fg : util.transparent;
            if (col == util.transparent)
                col = cell.fg_color;

            var text = cell.format_text.text;
            if ( formatting_ != null)
                cell.format_text.add_part(new text_part(0, text.Length, formatting_) );

            bool needs_show_diff_now = show_diff_ && cell.row_index != cell.top_row_index;
            if (needs_show_diff_now) {
                int offset = util.datetime_difference_offset( prev_text(cell), text);
                Color lighter_col = light_color_ != "" ? parse_color(light_color_, cell.fg_color) : util.grayer_color(col);
                var parts = new List<text_part>() { new text_part(0, offset) { fg = lighter_col }, new text_part(offset, text.Length - offset) { fg = col } };
                cell.format_text.add_parts( parts);
            }
            else 
                cell.format_text.add_part( new text_part(0, text.Length) { fg = col });
        }
コード例 #2
0
ファイル: picture.cs プロジェクト: jtorjo/logwizard
 internal override void format_before_do_replace(format_cell cell) {
     string text = cell.format_text.text.ToLower();
     var exists = name_to_picture_.Keys.FirstOrDefault(x => text.StartsWith(x));
     picture_ = exists != null ? name_to_picture_[exists] : null;
     if ( picture_ != null)
         cell.format_text.replace_text(0, cell.format_text.text.Length, "");
 }
コード例 #3
0
ファイル: abbreviation.cs プロジェクト: yg8868/logwizard
        internal override void format_before_do_replace(format_cell cell)
        {
            if (find_ == "" || !is_on_)
            {
                return;
            }
            if (cell.location != format_cell.location_type.view && cell.location != format_cell.location_type.smart_edit)
            {
                return;
            }

            string txt = cell.format_text.text;

            txt = Regex.Replace(txt, find_, format_replace_string_, RegexOptions.IgnoreCase);
            if (txt != cell.format_text.text)
            {
                bool needs_formatting = replace_parts_.Count > 1;
                if (needs_formatting)
                {
                    var parts = formatted_parts(txt);
                    txt = util.concatenate(parts.Select(x => x.prefix), "");
                    cell.format_text.replace_text(0, cell.format_text.text.Length, txt);
                    // and now, apply the actual formatting
                    apply_format(cell, parts);
                }
                else
                {
                    // in this case, we don't have any formatting to do
                    cell.format_text.replace_text(0, cell.format_text.text.Length, txt);
                }
            }
        }
コード例 #4
0
ファイル: color_time.cs プロジェクト: CaulyKan/logwizard
        internal override void format_before(format_cell cell) {
            if (cell.col_type != expected_type)
                return; // only color time column

            var time = (cell.item as filter.match).line.time;
            if (format_time_ != "" && time != DateTime.MinValue)
                cell.format_text.replace_text(0, cell.format_text.text.Length, time.ToString(format_time_));
        }
コード例 #5
0
        internal override void format_before(format_cell cell)
        {
            var text = cell.format_text.text;

            if (formatting_ != null && formatting_.bg != util.transparent)
            {
                cell.format_text.bg = formatting_.bg;
            }
        }
コード例 #6
0
 internal override void format_after(format_cell cell) {
     if (row_count_ < 1)
         return;
     int per_row = cell.row_index / row_count_;
     if (per_row % 2 == 1) {
         Color dark = parse_color(alternate_color_, cell.bg_color); 
         cell.format_text.bg = dark;
     }
 }
コード例 #7
0
ファイル: color_time.cs プロジェクト: CaulyKan/logwizard
 private string prev_text(format_cell cell) {
     string prev = cell.prev_text;
     if (cell.row_index > 0 && format_time_ != "") {
         var prev_item = cell.parent.item_at(cell.row_index - 1);
         var time = (prev_item as filter.match).line.time;
         if (time != DateTime.MinValue)
             prev = time.ToString(format_time_);
     }
     return prev;
 }
コード例 #8
0
ファイル: regex_color.cs プロジェクト: CaulyKan/logwizard
        internal override void format_after(format_cell cell) {
            if (expr_ == "" || regex_ == null)
                return;

            var text = cell.format_text.text;
            Color col = parse_color(color_, cell.fg_color);

            var found = util.regex_matches(regex_, text).OrderBy(x => x.Item1).ToList();
            // see if i need to replace with written in another base
            cell.format_text.add_parts( found.Select(x => new text_part(x.Item1, x.Item2) { fg = col }).ToList());
        }
コード例 #9
0
        internal override void format_before_do_replace(format_cell cell)
        {
            string text   = cell.format_text.text.ToLower();
            var    exists = name_to_picture_.Keys.FirstOrDefault(x => text.StartsWith(x));

            picture_ = exists != null ? name_to_picture_[exists] : null;
            if (picture_ != null)
            {
                cell.format_text.replace_text(0, cell.format_text.text.Length, "");
            }
        }
コード例 #10
0
        internal override void format_before(format_cell cell)
        {
            if (cell.col_type != expected_type)
            {
                return; // only color time column
            }
            var time = (cell.item as filter.match).line.time;

            if (format_time_ != "" && time != DateTime.MinValue)
            {
                cell.format_text.replace_text(0, cell.format_text.text.Length, time.ToString(format_time_));
            }
        }
コード例 #11
0
ファイル: cell.cs プロジェクト: jtorjo/logwizard
        internal override void format_after(format_cell cell) {
            var text = cell.format_text.text;
            if ( formatting_ != null)
                cell.format_text.add_part(new text_part(0, text.Length, formatting_) );

            bool is_sel = cell.row_index == cell.sel_index;
            if (is_sel && cell.is_bookmark && selection_and_bookmark_image_ != null)
                cell.format_text.image = selection_and_bookmark_image_;
            else if ( is_sel && selection_image_ != null)
                cell.format_text.image = selection_image_;
            else if (cell.is_bookmark && bookmark_image_ != null)
                cell.format_text.image = bookmark_image_;
        }
コード例 #12
0
        internal override void format_after(format_cell cell)
        {
            if (formatting_ == null && light_color_ == "" && !show_diff_)
            {
                // nothing to do
                return;
            }
            if (cell.col_type != expected_type)
            {
                return; // only color time column
            }
            Color col = formatting_ != null ? formatting_.fg : util.transparent;

            if (col == util.transparent)
            {
                col = cell.fg_color;
            }

            var text = cell.format_text.text;

            if (formatting_ != null)
            {
                cell.format_text.add_part(new text_part(0, text.Length, formatting_));
            }

            bool needs_show_diff_now = show_diff_ && cell.row_index != cell.top_row_index;

            if (needs_show_diff_now)
            {
                int   offset      = util.datetime_difference_offset(prev_text(cell), text);
                Color lighter_col = light_color_ != "" ? parse_color(light_color_, cell.fg_color) : util.grayer_color(col);
                var   parts       = new List <text_part>()
                {
                    new text_part(0, offset)
                    {
                        fg = lighter_col
                    }, new text_part(offset, text.Length - offset)
                    {
                        fg = col
                    }
                };
                cell.format_text.add_parts(parts);
            }
            else
            {
                cell.format_text.add_part(new text_part(0, text.Length)
                {
                    fg = col
                });
            }
        }
コード例 #13
0
        internal override void format_after(format_cell cell)
        {
            if (row_count_ < 1)
            {
                return;
            }
            int per_row = cell.row_index / row_count_;

            if (per_row % 2 == 1)
            {
                Color dark = parse_color(alternate_color_, cell.bg_color);
                cell.format_text.bg = dark;
            }
        }
コード例 #14
0
        private string prev_text(format_cell cell)
        {
            string prev = cell.prev_text;

            if (cell.row_index > 0 && format_time_ != "")
            {
                var prev_item = cell.parent.item_at(cell.row_index - 1);
                var time      = (prev_item as filter.match).line.time;
                if (time != DateTime.MinValue)
                {
                    prev = time.ToString(format_time_);
                }
            }
            return(prev);
        }
コード例 #15
0
ファイル: abbreviation.cs プロジェクト: yg8868/logwizard
        private void apply_format(format_cell cell, List <format_part> format)
        {
            int cur_idx     = 0;
            var apply_parts = new List <text_part>();

            foreach (var part in format)
            {
                cur_idx += part.prefix.Length;
                if (part.format != null)
                {
                    apply_parts.Add(new text_part(cur_idx, part.len, part.format));
                }
            }
            cell.format_text.add_parts(apply_parts);
        }
コード例 #16
0
ファイル: regex_color.cs プロジェクト: yg8868/logwizard
        internal override void format_after(format_cell cell)
        {
            if (expr_ == "" || regex_ == null)
            {
                return;
            }

            var   text = cell.format_text.text;
            Color col  = parse_color(color_, cell.fg_color);

            var found = util.regex_matches(regex_, text).OrderBy(x => x.Item1).ToList();

            // see if i need to replace with written in another base
            cell.format_text.add_parts(found.Select(x => new text_part(x.Item1, x.Item2)
            {
                fg = col
            }).ToList());
        }
コード例 #17
0
        private bool already_formatted(format_cell cell, int start, int len)
        {
            var text = cell.format_text.text;

            for (int idx = start; idx < start + len; ++idx)
            {
                var part = cell.format_text.part_at_index(idx);
                if (part != null)
                {
                    // in this case, we consider "formatted" only if the part found is less than then whole text
                    if (part.len < text.Length)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #18
0
        internal override void get_tooltip(format_cell cell, int char_index, ref string tooltip)
        {
            if (!is_cell_type_ok(cell.col_type))
            {
                return;
            }
            var text = cell.format_text.text;

            if (text == "")
            {
                return;
            }

            int start = char_index, end = char_index;

            while (start >= 0 && is_number_char(text[start]))
            {
                --start;
            }
            if (start < 0)
            {
                start = 0;
            }
            if (!is_number_char(text[start]))
            {
                ++start;
            }
            while (end < text.Length && is_number_char(text[end]))
            {
                ++end;
            }

            if (end > start)
            {
                string number = text.Substring(start, end - start);
                try {
                    long n = to_number(number);
                    tooltip = String.Format("D {0}\r\nH {1}\r\nO {2}\r\nB {3}",
                                            Convert.ToString(n, 10), Convert.ToString(n, 16), Convert.ToString(n, 8), Convert.ToString(n, 2));
                } catch {
                    // invalid number
                }
            }
        }
コード例 #19
0
ファイル: multiline.cs プロジェクト: jtorjo/logwizard
        internal override void format_before_do_replace(format_cell cell) {
            // see if on view
            if (cell.location != format_cell.location_type.view)
                return;
            if (!show_multi_into_single_line_)
                return;

            // ... make sure we catch all lines
            var lines = cell.format_text.text.Replace("\r\n", "\r").Replace("\n", "\r").Split(new[] {"\r"}, StringSplitOptions.None);
            if (lines.Length <= 1)
                return; // single line

            var new_text = util.concatenate(lines, separator_);
            cell.format_text.replace_text(0, cell.format_text.text.Length, new_text);

            if (alternate_format_ != null || separator_format_ != null) {
                if ( alternate_format_ != null)
                    alternate_format_.update_colors(cell);
                if ( separator_format_ != null)
                    separator_format_.update_colors(cell);

                int cur_idx = 0;
                var line_indexes = new List<int>();
                foreach (var line in lines) {
                    line_indexes.Add(cur_idx);
                    cur_idx += line.Length + separator_.Length;
                }
                List<text_part> parts = new List<text_part>();
                for (int i = 0; i < line_indexes.Count; i++) {
                    bool even = i % 2 == 0;
                    if ( separator_format_ != null && i < line_indexes.Count - 1)
                        parts.Add( new text_part(line_indexes[i] + lines[i].Length, separator_.Length, separator_format_) );
                    if (!even) {
                        // odd - show in alternate
                        if ( alternate_format_ != null)
                            parts.Add( new text_part( line_indexes[i], lines[i].Length, alternate_format_));
                    }
                }
                cell.format_text.add_parts(parts);
            }
        }
コード例 #20
0
ファイル: abbreviation.cs プロジェクト: jtorjo/logwizard
        internal override void format_before_do_replace(format_cell cell) {
            if (find_ == "" || !is_on_)
                return;
            if (cell.location != format_cell.location_type.view && cell.location != format_cell.location_type.smart_edit)
                return;

            string txt = cell.format_text.text;
            txt = Regex.Replace(txt, find_, format_replace_string_, RegexOptions.IgnoreCase);
            if (txt != cell.format_text.text) {
                bool needs_formatting = replace_parts_.Count > 1;
                if ( needs_formatting) {
                    var parts = formatted_parts(txt);
                    txt = util.concatenate(parts.Select(x => x.prefix), "");
                    cell.format_text.replace_text(0, cell.format_text.text.Length, txt);
                    // and now, apply the actual formatting
                    apply_format(cell, parts);
                }
                else 
                    // in this case, we don't have any formatting to do
                    cell.format_text.replace_text(0, cell.format_text.text.Length, txt);
            }
        }
コード例 #21
0
        internal override void format_after(format_cell cell)
        {
            var text = cell.format_text.text;

            if (formatting_ != null)
            {
                cell.format_text.add_part(new text_part(0, text.Length, formatting_));
            }

            bool is_sel = cell.row_index == cell.sel_index;

            if (is_sel && cell.is_bookmark && selection_and_bookmark_image_ != null)
            {
                cell.format_text.image = selection_and_bookmark_image_;
            }
            else if (is_sel && selection_image_ != null)
            {
                cell.format_text.image = selection_image_;
            }
            else if (cell.is_bookmark && bookmark_image_ != null)
            {
                cell.format_text.image = bookmark_image_;
            }
        }
コード例 #22
0
        internal override void format_after(format_cell cell)
        {
            if (compare_.Count < 1)
            {
                return; // nothing to compare
            }
            var text = cell.format_text.text;

            int before_idx = before_ != "" ? text.IndexOf(before_) : 0;

            if (before_idx >= 0)
            {
                before_idx += before_.Length;
                int after_idx = after_ != "" ? text.IndexOf(after_, before_idx) : text.Length;
                if (after_idx >= 0)
                {
                    var    number = text.Substring(before_idx, after_idx - before_idx).Trim();
                    double val;
                    if (double.TryParse(number, out val))
                    {
                        // found the number - at this point, do all comparisons
                        text_part format_number = new text_part(0, 0);
                        foreach (var comp in compare_)
                        {
                            bool equal = false, less = false, greater = false;
                            try {
                                if (is_int_)
                                {
                                    equal   = (long)val == comp.compare_int;
                                    less    = (long)val < comp.compare_int;
                                    greater = (long)val > comp.compare_int;
                                }
                                else
                                {
                                    equal   = val == comp.compare_double;
                                    less    = val < comp.compare_double;
                                    greater = val > comp.compare_double;
                                }
                            } catch {
                                // this can happen only if number is longer than 'long'
                                equal = less = greater = false;
                            }

                            if (equal && comp.equal != null)
                            {
                                format_number = format_number.merge_copy(comp.equal);
                            }
                            else if (less && comp.less != null)
                            {
                                format_number = format_number.merge_copy(comp.less);
                            }
                            else if (greater && comp.greater != null)
                            {
                                format_number = format_number.merge_copy(comp.greater);
                            }
                        }

                        cell.format_text.add_part(new text_part(before_idx, after_idx - before_idx, format_number));
                    }
                }
            }
        }
コード例 #23
0
ファイル: cell.cs プロジェクト: jtorjo/logwizard
 internal override void format_before(format_cell cell) {
     var text = cell.format_text.text;
     if (formatting_ != null && formatting_.bg != util.transparent)
         cell.format_text.bg = formatting_.bg;
 }
コード例 #24
0
        internal override void format_before(format_cell cell)
        {
            if (!is_cell_type_ok(cell.col_type))
            {
                return;
            }
            if (color_ == "" && number_base == 10 && pad_ == "" && !look_for_hex_)
            {
                // we don't need to do anything
                return;
            }

            // if number too big, don't do anything
            // also, doubles -> don't care about base
            var text = cell.format_text.text;

            Color col = parse_color(color_, cell.fg_color);

            if (look_for_hex_)
            {
                // ... note: we don't want the delimeters included
                var hex_numbers = util.regex_matches(regex_hex_, text).Where(
                    // note: if the number is already formatted in some way, don't format it again
                    x => double_check_is_hex(text.Substring(x.Item1, x.Item2)) && !already_formatted(cell, x.Item1, x.Item2))
                                  .ToList();
                cell.format_text.add_parts(hex_numbers.Select(x => new text_part(x.Item1, x.Item2)
                {
                    fg = col
                }).ToList());
            }

            /* IMPORTANT: we have the following assumption: the hexa numbers NEVER interfere with the decimal numbers.
             *
             *  Here's the rationale: the decimal numbers can be transformed, while the hex numbers will NEVER be transformed. In other words, we can transform
             *  something like "Number 255 is awesome." into "Number FF is awesome". Thus, we're replacing sub-text in a a text that also has formatting.
             *
             *  Normally, that should work ok (formatted_text.replace_text), but if texts got to be imbricated one another, things could get ugly
             *
             */
            var dec_numbers = util.regex_matches(regex_decimal_, text)
                              // note: if the number is already formatted in some way, don't format it again
                              .Where(x => !already_formatted(cell, x.Item1, x.Item2)).OrderBy(x => x.Item1).ToList();

            // see if i need to replace with written in another base
            cell.format_text.add_parts(dec_numbers.Select(x => new text_part(x.Item1, x.Item2)
            {
                fg = col
            }).ToList());

            int start_offset = 0;

            foreach (var cur_number_offset in dec_numbers)
            {
                int start = cur_number_offset.Item1 + start_offset, len = cur_number_offset.Item2;
                var new_number = convert_number(cell.format_text.text.Substring(start, len));
                if (new_number != "")
                {
                    cell.format_text.replace_text(start, len, new_number);
                    int diff = new_number.Length - len;
                    start_offset += diff;
                }
            }
        }
コード例 #25
0
ファイル: regex_color.cs プロジェクト: CaulyKan/logwizard
        internal override void format_before(format_cell cell) {

        }
コード例 #26
0
ファイル: multiline.cs プロジェクト: yg8868/logwizard
        internal override void format_before_do_replace(format_cell cell)
        {
            // see if on view
            if (cell.location != format_cell.location_type.view)
            {
                return;
            }
            if (!show_multi_into_single_line_)
            {
                return;
            }

            // ... make sure we catch all lines
            var lines = cell.format_text.text.Replace("\r\n", "\r").Replace("\n", "\r").Split(new[] { "\r" }, StringSplitOptions.None);

            if (lines.Length <= 1)
            {
                return; // single line
            }
            var new_text = util.concatenate(lines, separator_);

            cell.format_text.replace_text(0, cell.format_text.text.Length, new_text);

            if (alternate_format_ != null || separator_format_ != null)
            {
                if (alternate_format_ != null)
                {
                    alternate_format_.update_colors(cell);
                }
                if (separator_format_ != null)
                {
                    separator_format_.update_colors(cell);
                }

                int cur_idx      = 0;
                var line_indexes = new List <int>();
                foreach (var line in lines)
                {
                    line_indexes.Add(cur_idx);
                    cur_idx += line.Length + separator_.Length;
                }
                List <text_part> parts = new List <text_part>();
                for (int i = 0; i < line_indexes.Count; i++)
                {
                    bool even = i % 2 == 0;
                    if (separator_format_ != null && i < line_indexes.Count - 1)
                    {
                        parts.Add(new text_part(line_indexes[i] + lines[i].Length, separator_.Length, separator_format_));
                    }
                    if (!even)
                    {
                        // odd - show in alternate
                        if (alternate_format_ != null)
                        {
                            parts.Add(new text_part(line_indexes[i], lines[i].Length, alternate_format_));
                        }
                    }
                }
                cell.format_text.add_parts(parts);
            }
        }
コード例 #27
0
ファイル: format.cs プロジェクト: yg8868/logwizard
 internal override void get_tooltip(format_cell cell, int char_index, ref string tooltip) {
     foreach ( var formatter in sub_)
         formatter.get_tooltip(cell, char_index, ref tooltip);
 }
コード例 #28
0
ファイル: format_number.cs プロジェクト: CaulyKan/logwizard
        internal override void format_before(format_cell cell) {
            if (!is_cell_type_ok(cell.col_type))
                return;
            if (color_ == "" && number_base == 10 && pad_ == "" && !look_for_hex_)
                // we don't need to do anything
                return;

            // if number too big, don't do anything
            // also, doubles -> don't care about base
            var text = cell.format_text.text;

            Color col = parse_color(color_, cell.fg_color);
            if (look_for_hex_) {
                // ... note: we don't want the delimeters included
                var hex_numbers = util.regex_matches(regex_hex_, text).Where(
                    // note: if the number is already formatted in some way, don't format it again
                    x => double_check_is_hex(text.Substring(x.Item1, x.Item2)) && !already_formatted(cell, x.Item1, x.Item2) )
                    .ToList();
                cell.format_text.add_parts(hex_numbers.Select(x => new text_part(x.Item1, x.Item2) {fg = col}).ToList());
            }

            /* IMPORTANT: we have the following assumption: the hexa numbers NEVER interfere with the decimal numbers.

                Here's the rationale: the decimal numbers can be transformed, while the hex numbers will NEVER be transformed. In other words, we can transform
                something like "Number 255 is awesome." into "Number FF is awesome". Thus, we're replacing sub-text in a a text that also has formatting.

                Normally, that should work ok (formatted_text.replace_text), but if texts got to be imbricated one another, things could get ugly 
            */
            var dec_numbers = util.regex_matches(regex_decimal_, text)
                // note: if the number is already formatted in some way, don't format it again
                .Where(x => !already_formatted(cell, x.Item1, x.Item2)) .OrderBy(x => x.Item1).ToList();
            // see if i need to replace with written in another base
            cell.format_text.add_parts(dec_numbers.Select(x => new text_part(x.Item1, x.Item2) {fg = col}).ToList());

            int start_offset = 0;
            foreach (var cur_number_offset in dec_numbers) {
                int start = cur_number_offset.Item1 + start_offset, len = cur_number_offset.Item2;
                var new_number = convert_number(cell.format_text.text.Substring(start, len));
                if (new_number != "") {
                    cell.format_text.replace_text(start, len, new_number);
                    int diff = new_number.Length - len;
                    start_offset += diff;
                }
            }
        }
コード例 #29
0
ファイル: format.cs プロジェクト: yg8868/logwizard
 internal override void format_before_do_replace(format_cell cell) {
     foreach ( var formatter in sub_)
         formatter.format_before_do_replace(cell);
 }
コード例 #30
0
 internal virtual void format_after(format_cell cell) {            
 }
コード例 #31
0
ファイル: abbreviation.cs プロジェクト: jtorjo/logwizard
 private void apply_format(format_cell cell, List<format_part> format) {
     int cur_idx = 0;
     var apply_parts = new List<text_part>();
     foreach (var part in format) {
         cur_idx += part.prefix.Length;
         if ( part.format != null)
             apply_parts.Add( new text_part(cur_idx, part.len, part.format));
     }
     cell.format_text.add_parts(apply_parts);
 }
コード例 #32
0
 internal override void format_before(format_cell cell)
 {
 }
コード例 #33
0
 internal virtual void format_before(format_cell cell) { 
 }
コード例 #34
0
ファイル: format_number.cs プロジェクト: CaulyKan/logwizard
        internal override void get_tooltip(format_cell cell, int char_index, ref string tooltip) {
            if (!is_cell_type_ok(cell.col_type))
                return;
            var text = cell.format_text.text;
            if (text == "")
                return;

            int start = char_index, end = char_index;
            while (start >= 0 && is_number_char(text[start]))
                --start;
            if (start < 0)
                start = 0;
            if (!is_number_char(text[start]))
                ++start;
            while (end < text.Length && is_number_char(text[end]))
                ++end;

            if (end > start) {
                string number = text.Substring(start, end - start);
                try {
                    long n = to_number(number);
                    tooltip = String.Format("D {0}\r\nH {1}\r\nO {2}\r\nB {3}",
                        Convert.ToString(n, 10), Convert.ToString(n, 16), Convert.ToString(n, 8), Convert.ToString(n, 2));
                } catch {
                    // invalid number
                }
            }
        }
コード例 #35
0
ファイル: format.cs プロジェクト: yg8868/logwizard
 internal override void format_after(format_cell cell) {
     foreach ( var formatter in sub_)
         formatter.format_after(cell);
 }
コード例 #36
0
ファイル: format_number.cs プロジェクト: CaulyKan/logwizard
        private bool already_formatted(format_cell cell, int start, int len) {
            var text = cell.format_text.text;
            for (int idx = start; idx < start + len; ++idx) {
                var part = cell.format_text.part_at_index(idx);
                if ( part != null)
                    // in this case, we consider "formatted" only if the part found is less than then whole text
                    if (part.len < text.Length)
                        return true;

            }
            return false;
        }
コード例 #37
0
ファイル: compare_number.cs プロジェクト: jtorjo/logwizard
        internal override void format_after(format_cell cell) {
            if (compare_.Count < 1)
                return; // nothing to compare

            var text = cell.format_text.text;

            int before_idx = before_ != "" ? text.IndexOf(before_) : 0;
            if (before_idx >= 0) {
                before_idx += before_.Length;
                int after_idx = after_ != "" ? text.IndexOf(after_, before_idx) : text.Length;
                if (after_idx >= 0) {
                    var number = text.Substring(before_idx, after_idx - before_idx).Trim();
                    double val;
                    if (double.TryParse(number, out val)) {
                        // found the number - at this point, do all comparisons
                        text_part format_number = new text_part(0,0);
                        foreach (var comp in compare_) {
                            bool equal = false, less = false, greater = false;
                            try {
                                if (is_int_) {
                                    equal = (long) val == comp.compare_int;
                                    less = (long) val < comp.compare_int;
                                    greater = (long) val > comp.compare_int;
                                } else {
                                    equal = val == comp.compare_double;
                                    less = val < comp.compare_double;
                                    greater = val > comp.compare_double;
                                }
                            } catch {
                                // this can happen only if number is longer than 'long'
                                equal = less = greater = false;
                            }

                            if (equal && comp.equal != null)
                                format_number = format_number.merge_copy(comp.equal);
                            else if (less && comp.less != null)
                                format_number = format_number.merge_copy(comp.less);
                            else if (greater && comp.greater != null)
                                format_number = format_number.merge_copy(comp.greater);
                        }

                        cell.format_text.add_part( new text_part(before_idx, after_idx - before_idx, format_number));
                    }
                }
            }
        }
コード例 #38
0
 internal virtual void format_after(format_cell cell)
 {
 }
コード例 #39
0
 internal virtual void get_tooltip(format_cell cell, int char_index, ref string tooltip) {
 }
コード例 #40
0
 internal override void format_after(format_cell cell)
 {
 }
コード例 #41
0
 internal virtual void get_tooltip(format_cell cell, int char_index, ref string tooltip)
 {
 }
コード例 #42
0
ファイル: picture.cs プロジェクト: jtorjo/logwizard
 internal override void format_after(format_cell cell) {
 }
コード例 #43
0
 /*  You should override this is you're replacing large parts of the text. The idea is to do this first,
  *  because replacing large text (thtat internally contains formatted parts) can go wrong. Namely, the formatted parts might point to the wrong location.
  *
  *  Example:
  *  say I'm replacig "I have 23 lines of awesome text." with "I have plenty of awesome text".
  *  Say the "23" part is formatted to show in red. What shall I do with this part in the replaced text?
  *  I would end up showing "pl" characters in red - which makes no sense.
  */
 internal virtual void format_before_do_replace(format_cell cell)
 {
 }
コード例 #44
0
 internal virtual void format_before(format_cell cell)
 {
 }
コード例 #45
0
        /*  You should override this is you're replacing large parts of the text. The idea is to do this first,
            because replacing large text (thtat internally contains formatted parts) can go wrong. Namely, the formatted parts might point to the wrong location.

            Example: 
            say I'm replacig "I have 23 lines of awesome text." with "I have plenty of awesome text".
            Say the "23" part is formatted to show in red. What shall I do with this part in the replaced text? 
            I would end up showing "pl" characters in red - which makes no sense.
        */
        internal virtual void format_before_do_replace(format_cell cell) { 
        }