コード例 #1
0
        public Color print_bg_color(OLVListItem item, text_part print)
        {
            match_item i      = item.RowObject as match_item;
            bool       is_sel = !ignore_selection?parent_sel.Contains(item.Index) : false;

            Color default_bg = i.bg(parent_);
            Color bg         = print.bg != util.transparent ? print.bg : default_bg;

            if (bg == util.transparent)
            {
                bg = app.inst.bg;
            }
            // selection needs a bit of dark
            if (is_sel)
            {
                bg = sel_bg_color(bg);
            }

            if (print.is_typed_search && !print.is_find_search)
            {
                // 1.7.22 - don't use the overridden background - we want to have the same background for all finds
                bg = util.darker_color(default_bg);
            }
            return(bg);
        }
コード例 #2
0
ファイル: search_renderer.cs プロジェクト: yg8868/logwizard
        public search_renderer(log_view parent, search_form search)
        {
            search_ = search;
            drawer_ = new log_view_item_draw_ui(parent);

            Color normal_fg_ = app.inst.fg, normal_bg_ = app.inst.bg;

            default_ = new text_part(0, 0)
            {
                fg = normal_fg_, bg = normal_bg_,
            };

            Color search_line_fg_ = app.inst.search_found_full_line_fg, search_line_bg_ = app.inst.bg;

            around_search_ = new text_part(0, 0)
            {
                fg = search_line_fg_, bg = search_line_bg_
            };

            Color search_fg_ = app.inst.search_found_fg, search_bg_ = util.darker_color(app.inst.bg);

            search_text_ = new text_part(0, 0)
            {
                text = "not important", fg = search_fg_, bg = search_bg_, bold = true, italic = false
            };
        }
コード例 #3
0
        public Font font(text_part print)
        {
            string font_name = print != null && print.font_name != "" ? print.font_name : default_font.FontFamily.Name;
            int    font_size = print != null && print.font_size > 0 ? print.font_size : (int)(default_font.Size + .5);
            Font   f         = fonts_.get_font(font_name, font_size, print != null && print.bold, print != null && print.italic, print != null && print.underline);

            return(f);
        }
コード例 #4
0
        // constructs a new object as a merge of this and other
        // other overrides everything from this
        //
        // note: start/len/text are taken from other (overridden)
        public text_part merge_copy(text_part other)
        {
            var copy = new text_part(other.start, other.len, this)
            {
                text = other.text
            };

            if (other.fg != util.transparent)
            {
                copy.fg = other.fg;
            }
            if (other.bg != util.transparent)
            {
                copy.bg = other.bg;
            }
            if (other.underline)
            {
                copy.underline = true;
            }
            if (other.bold)
            {
                copy.bold = true;
            }
            if (other.italic)
            {
                copy.italic = true;
            }

            if (other.font_name != "")
            {
                copy.font_name = other.font_name;
            }
            if (other.font_size > 0)
            {
                copy.font_size = other.font_size;
            }

            if (other.is_find_search)
            {
                copy.is_find_search = true;
            }
            if (other.is_typed_search)
            {
                copy.is_typed_search = true;
            }

            if (other.modify_fg != modify_color_type.same)
            {
                copy.modify_fg = other.modify_fg;
            }
            if (other.modify_bg != modify_color_type.same)
            {
                copy.modify_bg = other.modify_bg;
            }

            return(copy);
        }
コード例 #5
0
        public text_part(int start, int len, text_part src = null)
        {
            if (src != null)
            {
                copy_from(src);
            }

            start_ = start;
            len_   = len;
        }
コード例 #6
0
        public Color print_fg_color(OLVListItem item, text_part print)
        {
            match_item i        = item.RowObject as match_item;
            Color      fg       = i.fg(parent_);
            Color      print_fg = print.fg != util.transparent ? print.fg : fg;

            if (print_fg == util.transparent)
            {
                print_fg = app.inst.fg;
            }
            return(print_fg);
        }
コード例 #7
0
ファイル: search_renderer.cs プロジェクト: jtorjo/logwizard
        public search_renderer(log_view parent, search_form search) {
            search_ = search;
            drawer_ = new log_view_item_draw_ui(parent);

            Color normal_fg_ = app.inst.fg, normal_bg_ = app.inst.bg;
            default_ = new text_part(0,0) { fg = normal_fg_, bg = normal_bg_, };
            
            Color search_line_fg_ = app.inst.search_found_full_line_fg, search_line_bg_ = app.inst.bg;
            around_search_ = new text_part(0,0) { fg = search_line_fg_, bg = search_line_bg_ };

            Color search_fg_ = app.inst.search_found_fg, search_bg_ = util.darker_color(app.inst.bg);
            search_text_ = new text_part(0,0) { text = "not important", fg = search_fg_, bg = search_bg_, bold = true, italic = false };
        }
コード例 #8
0
ファイル: search_renderer.cs プロジェクト: jtorjo/logwizard
        private void draw_sub_string(int left, string sub, Graphics g, Brush b, Rectangle r, StringFormat fmt, text_part print) {
            int width = text_width(g, sub);
            if (print != default_) {
                Rectangle here = new Rectangle(r.Location, r.Size);
                here.X += left;
                here.Width = width + 1;
                g.FillRectangle( brush_.brush(print.bg), here);
            }

            Rectangle sub_r = new Rectangle(r.Location, r.Size);
            sub_r.X += left;
            sub_r.Width -= left;
            g.DrawString(sub, drawer_.font(print), brush_.brush( print.fg) , sub_r, fmt);
        }
コード例 #9
0
ファイル: log_view_render.cs プロジェクト: CaulyKan/logwizard
        private void draw_sub_string(int left, string sub, Graphics g, Brush b, Rectangle r, StringFormat fmt, text_part print) {
            int width = drawer_.text_width(g, sub, drawer_.font(print));
            Color print_bg = drawer_.print_bg_color(ListItem, print);
            if (print_bg.ToArgb() != bg_color_.ToArgb()) {
                Rectangle here = new Rectangle(r.Location, r.Size);
                here.X += left;
                here.Width = width + 1;
                g.FillRectangle( brush_.brush( print_bg) , here);
            }

            Rectangle sub_r = new Rectangle(r.Location, r.Size);
            sub_r.X += left;
            sub_r.Width -= left;
            g.DrawString(sub, drawer_.font(print), brush_.brush( drawer_.print_fg_color(ListItem, print)) , sub_r, fmt);
        }
コード例 #10
0
ファイル: text_part.cs プロジェクト: jtorjo/logwizard
        public void copy_from(text_part other) {
            start_ = other.start_;
            len_ = other.len_;

            fg = other.fg;
            bg = other.bg;
            underline = other.underline;
            bold = other.bold;
            italic = other.italic;
            font_name = other.font_name;
            text = other.text;
            is_typed_search = other.is_typed_search;
            is_find_search = other.is_find_search;
            font_size = other.font_size;
            modify_bg = other.modify_bg;
            modify_fg = other.modify_fg;
        }
コード例 #11
0
        public void copy_from(text_part other)
        {
            start_ = other.start_;
            len_   = other.len_;

            fg              = other.fg;
            bg              = other.bg;
            underline       = other.underline;
            bold            = other.bold;
            italic          = other.italic;
            font_name       = other.font_name;
            text            = other.text;
            is_typed_search = other.is_typed_search;
            is_find_search  = other.is_find_search;
            font_size       = other.font_size;
            modify_bg       = other.modify_bg;
            modify_fg       = other.modify_fg;
        }
コード例 #12
0
ファイル: log_view_render.cs プロジェクト: yg8868/logwizard
        private void draw_sub_string(int left, string sub, Graphics g, Brush b, Rectangle r, StringFormat fmt, text_part print)
        {
            int   width    = drawer_.text_width(g, sub, drawer_.font(print));
            Color print_bg = drawer_.print_bg_color(ListItem, print);

            if (print_bg.ToArgb() != bg_color_.ToArgb())
            {
                Rectangle here = new Rectangle(r.Location, r.Size);
                here.X    += left;
                here.Width = width + 1;
                g.FillRectangle(brush_.brush(print_bg), here);
            }

            Rectangle sub_r = new Rectangle(r.Location, r.Size);

            sub_r.X     += left;
            sub_r.Width -= left;
            g.DrawString(sub, drawer_.font(print), brush_.brush(drawer_.print_fg_color(ListItem, print)), sub_r, fmt);
        }
コード例 #13
0
ファイル: text_part.cs プロジェクト: jtorjo/logwizard
        // constructs a new object as a merge of this and other
        // other overrides everything from this
        // 
        // note: start/len/text are taken from other (overridden)
        public text_part merge_copy(text_part other) {
            var copy = new text_part(other.start, other.len, this) { text = other.text };

            if (other.fg != util.transparent)
                copy.fg = other.fg;
            if (other.bg != util.transparent)
                copy.bg = other.bg;
            if (other.underline)
                copy.underline = true;
            if (other.bold)
                copy.bold = true;
            if (other.italic)
                copy.italic = true;

            if (other.font_name != "")
                copy.font_name = other.font_name;
            if (other.font_size > 0)
                copy.font_size = other.font_size;

            if (other.is_find_search)
                copy.is_find_search = true;
            if (other.is_typed_search)
                copy.is_typed_search = true;
            
            if (other.modify_fg != modify_color_type.same)
                copy.modify_fg = other.modify_fg;
            if (other.modify_bg != modify_color_type.same)
                copy.modify_bg = other.modify_bg;

            return copy;
        }
コード例 #14
0
ファイル: text_part.cs プロジェクト: jtorjo/logwizard
 protected bool Equals(text_part other) {
     return start_ == other.start_ && len_ == other.len_ && 
         fg.Equals(other.fg) && bg.Equals(other.bg) && bold == other.bold && italic == other.italic && String.Equals(font_name, other.font_name);
 }
コード例 #15
0
ファイル: text_part.cs プロジェクト: jtorjo/logwizard
 public text_part copy() {
     var new_ = new text_part(start, len, this);
     return new_;
 }
コード例 #16
0
ファイル: text_part.cs プロジェクト: jtorjo/logwizard
        public text_part(int start, int len, text_part src = null) {
            if ( src != null)
                copy_from(src);

            start_ = start;
            len_ = len;
        }
コード例 #17
0
 public Font font(text_part print) {
     string font_name = print != null && print.font_name != "" ? print.font_name : default_font.FontFamily.Name;
     int font_size = print != null && print.font_size > 0 ? print.font_size : (int)(default_font.Size + .5);
     Font f = fonts_.get_font(font_name, font_size, print != null && print.bold, print != null && print.italic, print != null && print.underline);
     return f;
 }
コード例 #18
0
        /*  string is internally separated by '/'
         *
         *  every entry can be any of:
         *  - font name, font size, foreground color, background color, bold, italic, underline
         *  The above is the precendence order as well
         *
         *  If you want to force having a background color without a foreground color, just prepend an extra #, like
         ##aabbcc
         */
        public static text_part from_friendly_string(string str)
        {
            text_part friendly = new text_part(0, 0);

            foreach (string word in str.Split('/').Select(x => x.ToLower()))
            {
                if (friendly.font_name == "")
                {
                    var possible_font = util.font_families().FirstOrDefault(x => x.ToLower() == word);
                    if (possible_font != null)
                    {
                        friendly.font_name = possible_font;
                        continue;
                    }
                }

                int possible_size = 0;
                if (int.TryParse(word, out possible_size))
                {
                    // don't allow too huge sizes
                    if (possible_size > 5 && possible_size < 24)
                    {
                        friendly.font_size = possible_size;
                        continue;
                    }
                }

                bool word_recognized = true;
                switch (word)
                {
                case "bold":
                    friendly.bold = true;
                    break;

                case "italic":
                    friendly.italic = true;
                    break;

                case "underline":
                    friendly.underline = true;
                    break;

                case "darker":
                    friendly.modify_fg = modify_color_type.darker;
                    break;

                case "lighter":
                    friendly.modify_fg = modify_color_type.lighter;
                    break;

                case "darker-bg":
                    friendly.modify_bg = modify_color_type.darker;
                    break;

                case "lighter-bg":
                    friendly.modify_bg = modify_color_type.lighter;
                    break;

                default:
                    word_recognized = false;
                    break;
                }
                if (word_recognized)
                {
                    continue;
                }

                bool  force_bg = word.StartsWith("##");
                Color col      = util.str_to_color(force_bg ? word.Substring(1) : word);
                if (col != util.transparent)
                {
                    bool is_bg = force_bg || friendly.fg != util.transparent;
                    if (is_bg)
                    {
                        friendly.bg = col;
                    }
                    else
                    {
                        friendly.fg = col;
                    }
                    continue;
                }
            }

            return(friendly);
        }
コード例 #19
0
 public Color print_fg_color(OLVListItem item, text_part print) {
     match_item i = item.RowObject as match_item;            
     Color fg = i.fg(parent_);
     Color print_fg = print.fg != util.transparent ? print.fg : fg;
     if (print_fg == util.transparent)
         print_fg = app.inst.fg;
     return print_fg;
 }
コード例 #20
0
ファイル: rich_label_ctrl.cs プロジェクト: yg8868/logwizard
        private void parse_format(string format, ref text_part print, ref string link)
        {
            switch (format)
            {
            case "b":
                print.bold = true;
                return;

            case "/b":
                print.bold = false;
                return;

            case "i":
                print.italic = true;
                return;

            case "/i":
                print.italic = false;
                return;

            case "/a":
                link            = "";
                print.underline = false;
                return;

            case "/fg":
                print.fg = util.transparent;
                return;

            case "/bg":
                print.bg = util.transparent;
                return;

            case "/font":
                print.font_name = "";
                break;
            }

            if (format.StartsWith("a "))
            {
                format          = format.Substring(2).Trim();
                print.underline = true;
                link            = format;
            }
            else if (format.StartsWith("fg "))
            {
                format   = format.Substring(3).Trim();
                print.fg = util.str_to_color(format);
            }
            else if (format.StartsWith("bg "))
            {
                format   = format.Substring(3).Trim();
                print.bg = util.str_to_color(format);
            }
            else if (format.StartsWith("font "))
            {
                format          = format.Substring(5).Trim();
                print.font_name = format;
            }
            else
            {
                Debug.Assert(false);
            }
        }
コード例 #21
0
ファイル: rich_label_ctrl.cs プロジェクト: yg8868/logwizard
        // <a link> ... </a>
        // <b> ... </b>
        // <i> ... </i>
        // <fg #col>.... </fg>
        // <bg #col>.... </bg>
        // <font name>... </font>
        public void set_text(string text)
        {
            text_part cur_print = new text_part(0, 0);
            string    cur_link  = "";

            parts_.Clear();
            while (text != "")
            {
                int delimeter = text.IndexOf("<");
                if (delimeter > 0)
                {
                    var new_ = new part {
                        text = text.Substring(0, delimeter), link = cur_link
                    };
                    cur_link = "";
                    new_.print.copy_from(cur_print);
                    if (new_.link != "")
                    {
                        new_.print.fg = Color.DodgerBlue;
                    }
                    parts_.Add(new_);
                    int    end_delimeter = text.IndexOf(">", delimeter);
                    string format        = text.Substring(delimeter + 1, end_delimeter - delimeter - 1);
                    parse_format(format, ref cur_print, ref cur_link);
                    text = text.Substring(end_delimeter + 1);
                }
                else
                {
                    // it was the last part
                    var last = new part {
                        text = text
                    };
                    last.print.copy_from(cur_print);
                    parts_.Add(last);
                    text = "";
                }
            }

            // also, it must allow for multiline (if so, print one line, and scroll at a give time)
            for (int i = 0; i < parts_.Count; ++i)
            {
                int enter = parts_[i].text.IndexOf("\r\n");
                if (enter >= 0)
                {
                    string before = parts_[i].text.Substring(0, enter);
                    string after  = parts_[i].text.Substring(enter + 2);
                    parts_[i].text      = before;
                    parts_[i].ends_line = true;
                    if (after != "")
                    {
                        var new_ = new part()
                        {
                            text = after, link = parts_[i].link
                        };
                        new_.print.copy_from(parts_[i].print);
                        parts_.Insert(i + 1, new_);
                    }
                }
            }

            cur_line_idx_ = 0;
            Invalidate();
            Update();
            update_tip();
        }
コード例 #22
0
 protected bool Equals(text_part other)
 {
     return(start_ == other.start_ && len_ == other.len_ &&
            fg.Equals(other.fg) && bg.Equals(other.bg) && bold == other.bold && italic == other.italic && String.Equals(font_name, other.font_name));
 }
コード例 #23
0
        public text_part copy()
        {
            var new_ = new text_part(start, len, this);

            return(new_);
        }
コード例 #24
0
ファイル: text_part.cs プロジェクト: jtorjo/logwizard
        /*  string is internally separated by '/'

            every entry can be any of: 
            - font name, font size, foreground color, background color, bold, italic, underline
            The above is the precendence order as well

            If you want to force having a background color without a foreground color, just prepend an extra #, like
            ##aabbcc
        */
        public static text_part from_friendly_string(string str) {
            text_part friendly = new text_part(0,0);

            foreach (string word in str.Split('/').Select(x => x.ToLower())) {
                if (friendly.font_name == "") {
                    var possible_font = util.font_families().FirstOrDefault(x => x.ToLower() == word);
                    if (possible_font != null) {
                        friendly.font_name = possible_font;
                        continue;
                    }
                }

                int possible_size = 0;
                if ( int.TryParse(word, out possible_size))
                    // don't allow too huge sizes
                    if (possible_size > 5 && possible_size < 24) {
                        friendly.font_size = possible_size;
                        continue;
                    }

                bool word_recognized = true;
                switch (word) {
                case "bold":
                    friendly.bold = true;
                    break;
                case "italic":
                    friendly.italic = true;
                    break;
                case "underline":
                    friendly.underline = true;
                    break;
                case "darker":
                    friendly.modify_fg = modify_color_type.darker;
                    break;
                case "lighter":
                    friendly.modify_fg = modify_color_type.lighter;
                    break;
                case "darker-bg":
                    friendly.modify_bg = modify_color_type.darker;
                    break;
                case "lighter-bg":
                    friendly.modify_bg = modify_color_type.lighter;
                    break;
                default:
                    word_recognized = false;
                    break;
                }
                if (word_recognized)
                    continue;

                bool force_bg = word.StartsWith("##");
                Color col = util.str_to_color(force_bg ? word.Substring(1) : word);
                if (col != util.transparent) {
                    bool is_bg = force_bg || friendly.fg != util.transparent;
                    if (is_bg)
                        friendly.bg = col;
                    else
                        friendly.fg = col;
                    continue;
                }

            }

            return friendly;
        }
コード例 #25
0
        public Color print_bg_color(OLVListItem item, text_part print) {
            match_item i = item.RowObject as match_item;            
            bool is_sel = !ignore_selection ? parent_sel.Contains(item.Index) : false;

            Color default_bg = i.bg(parent_);
            Color bg = print.bg != util.transparent ? print.bg : default_bg;
            if (bg == util.transparent)
                bg = app.inst.bg;
            // selection needs a bit of dark
            if (is_sel)
                bg = sel_bg_color(bg);

            if (print.is_typed_search && !print.is_find_search)
                // 1.7.22 - don't use the overridden background - we want to have the same background for all finds
                bg = util.darker_color(default_bg);
            return bg;
        }
コード例 #26
0
ファイル: search_renderer.cs プロジェクト: yg8868/logwizard
        private void draw_sub_string(int left, string sub, Graphics g, Brush b, Rectangle r, StringFormat fmt, text_part print)
        {
            int width = text_width(g, sub);

            if (print != default_)
            {
                Rectangle here = new Rectangle(r.Location, r.Size);
                here.X    += left;
                here.Width = width + 1;
                g.FillRectangle(brush_.brush(print.bg), here);
            }

            Rectangle sub_r = new Rectangle(r.Location, r.Size);

            sub_r.X     += left;
            sub_r.Width -= left;
            g.DrawString(sub, drawer_.font(print), brush_.brush(print.fg), sub_r, fmt);
        }