private void load_save(bool load, string prefix)
        {
            app.load_save(load, ref name, prefix + ".name", "Default");

            string settings_str = default_settings_.ToString();

            if (load)
            {
                app.load_save(load, ref settings_str, prefix + ".default_settings");
                default_settings_ = new settings_as_string(settings_str);

                if (settings_str == "")
                {
                    // ... 1.4.8- kept the old name for persistenting
                    app.load_save(load, ref settings_str, prefix + ".default_syntax");
                    if (settings_str != "")
                    {
                        default_settings_.set("syntax", settings_str);
                    }
                }
            }
            else
            {
                app.load_save(load, ref settings_str, prefix + ".default_settings");
            }

            int view_count = views.Count;

            app.load_save(load, ref view_count, prefix + ".view_count", 0);
            if (load)
            {
                views.Clear();
                while (views.Count < view_count)
                {
                    views.Add(new ui_view());
                }
            }

            for (int i = 0; i < view_count; ++i)
            {
                views[i].load_save(load, prefix + ".view" + i + ".");
            }

            if (load && views.Count == 0)
            {
                views.Add(new ui_view()
                {
                    is_default_name = true, name = "View_1"
                });
            }
        }
示例#2
0
        private void on_new_log() {
            string size = text_ is file_text_reader ? " (" + new FileInfo(text_.name).Length + " bytes)" : "";
            set_status_forever("Log: " + text_.name + size);
            dropHere.Visible = false;

            if (history_.Count < 1)
                history_select(text_.settings);

            var reader_settings_copy = new settings_as_string( text_.settings.ToString() );
            var context_settings_copy = new settings_as_string( settings_to_context(reader_settings_copy).default_settings.ToString());
            context_settings_copy.merge(reader_settings_copy.ToString());
            var file_text = text_ as file_text_reader;
            if (file_text != null) 
                if ( factory.guess_file_type(file_text.name) == "line-by-line")
                    if (reader_settings_copy.get("syntax") == "") {
                        // file reader doesn't know syntax
                        // by default - try to find the syntax by reading the header info; otherwise, try to parse it
                        string file_to_syntax = log_to.file_to_syntax(text_.name);
                        if (file_to_syntax != "") 
                            // note: file-to-syntax overrides the context syntax
                            context_settings_copy.set("syntax", file_to_syntax);                        
                        // note: if the context already knows syntax, use that
                        else if (context_settings_copy.get("syntax") == "") {
                            string found_syntax = file_text.try_to_find_log_syntax();
                            if (found_syntax != "" && found_syntax != file_text_reader.UNKNOWN_SYNTAX) 
                                context_settings_copy.set("syntax", found_syntax);
                        }
                    }            

            text_.merge_setings( context_settings_copy);

            // note: we recreate the log, so that cached filters know to rebuild
            log_parser_ = new log_parser(text_);
            log_parser_.on_aliases_changed = on_aliases_changed;
            if ( text_.settings.get("description_template") != "")
                description.set_layout( text_.settings.get("description_template"));

            ui_context log_ctx = settings_to_context( text_.settings );
            bool same_context = log_ctx == cur_context();
            if (!same_context) {
                ++ignore_change_;
                // set_aliases context based on log
                curContextCtrl.SelectedIndex = contexts_.IndexOf(log_ctx);
                --ignore_change_;

                remove_all_log_views();
                on_context_changed();
            }

            full_log_ctrl_.set_filter(new List<raw_filter_row>());
            on_new_log_parser();
            load();

            if (log_parser_.has_multi_line_columns) 
                if (!app.inst.has_shown_details_pane) {
                    app.inst.has_shown_details_pane = true;
                    show_details(global_ui.show_details = true);
                }

            add_reader_to_history();
            app.inst.set_log_file(selected_file_name());
            Text = reader_title() + " - Log Wizard " + version();

            logger.Info("new reader " + history_[logHistory.SelectedIndex].name);

            // at this point, some file has been dropped
            log_view_for_tab(0).Visible = true;

            notes.Enabled = text_ is file_text_reader;
            if (notes.Enabled) {
                notes.load(notes_keeper.inst.notes_file_for_file(text_.name));
                merge_notes();
            }

            util.postpone(update_list_view_edit, 250);
            util.postpone(check_are_settings_complete, 1500);
        }
示例#3
0
        public log_settings_string sub(string[] names)
        {
            settings_as_string sub_sett = settings_.sub(names);

            return(new log_settings_string(sub_sett.ToString()));
        }
示例#4
0
 public override string ToString()
 {
     return(settings_.ToString());
 }
示例#5
0
        private static void load_contexts(settings_file sett) {
            logger.Debug("loading contexts");

            int history_count = int.Parse( sett.get("history_count", "0"));
            for (int idx = 0; idx < history_count; ++idx) {
                history hist = new history();
                string guid = sett.get("history." + idx + ".guid");
                if (guid != "") {
                    // 1.5.6+ - guid points to the whole settings
                    string settings = sett.get("guid." + guid);
                    Debug.Assert(settings.Contains(guid));
                    hist.from_string(settings);
                } else {
                    // old code (pre 1.5.6)
                    string type_str = sett.get("history." + idx + "type", "file");
                    if (type_str == "0")
                        type_str = "file";
                    string name = sett.get("history." + idx + "name");
                    string friendly_name = sett.get("history." + idx + "friendly_name");

                    settings_as_string history_sett = new settings_as_string("");
                    history_sett.set("type", type_str);
                    history_sett.set("name", name);
                    history_sett.set("friendly_name", friendly_name);
                    // create a guid now
                    history_sett.set("guid", Guid.NewGuid().ToString());
                    hist.from_string(history_sett.ToString());
                }

                history_.Add( hist );
            }
            history_ = history_.Where(h => {
                if (h.type == history.entry_type.file)
                    if( File.Exists(h.name))
                        // 1.1.5+ - compute md5s for this
                        md5_log_keeper.inst.compute_default_md5s_for_file(h.name);
                    else
                        return false;
                return true;
            }).ToList();


            int count = int.Parse( sett.get("context_count", "1"));
            for ( int i = 0; i < count ; ++i) {
                ui_context ctx = new ui_context();
                ctx.load("context." + i);
                contexts_.Add(ctx);
            }
            // 1.1.25 - at application start - remove empty contexts (like, the user may have dragged a file, not what he wanted, dragged another)
            contexts_ = contexts_.Where(x => x.has_not_empty_views || x.name == "Default").ToList();
        }
示例#6
0
        private void on_new_log() {
            string size = text_ is file_text_reader ? " (" + new FileInfo(text_.name).Length + " bytes)" : "";
            set_status_forever("Log: " + text_.name + size);
            dropHere.Visible = false;

            if (history_.Count < 1)
                history_select(text_.unique_id);

            var reader_settings_copy = new settings_as_string( text_.settings.ToString() );
            var context_settings_copy = new settings_as_string( settings_to_context(reader_settings_copy).default_settings.ToString());
            context_settings_copy.merge(reader_settings_copy.ToString());
            var file_text = text_ as file_text_reader;
            if (file_text != null) 
                if ( factory.guess_file_type(file_text.name) == "line-by-line")
                    if (reader_settings_copy.get("syntax") == "") {
                        // file reader doesn't know syntax
                        // by default - try to find the syntax by reading the header info; otherwise, try to parse it
                        string file_to_syntax = log_to.file_to_syntax(text_.name);
                        if (file_to_syntax != "") {
                            // note: file-to-syntax overrides the context syntax
                            context_settings_copy.set("syntax", file_to_syntax);
                            context_settings_copy.set("syntax_type", "file_to_syntax");
                        }
                        // note: if the context already knows syntax, use that
                        else if (context_settings_copy.get("syntax") == "") {
                            string found_syntax = file_text.try_to_find_log_syntax();
                            if (found_syntax != "" && found_syntax != file_text_reader.UNKNOWN_SYNTAX) {
                                context_settings_copy.set("syntax", found_syntax);
                                context_settings_copy.set("syntax_type", "try_to_find_syntax");
                            }
                        }
                    }            

            text_.merge_setings( context_settings_copy.ToString());

            // note: we recreate the log, so that cached filters know to rebuild
            log_parser_ = new log_parser(text_);
            on_new_log_parser();

            full_log_ctrl_.set_filter(new List<raw_filter_row>());

            Text = reader_title() + " - Log Wizard " + version();
            add_reader_to_history();

            load_bookmarks();
            logger.Info("new reader " + history_[logHistory.SelectedIndex].name);

            // at this point, some file has been dropped
            log_view_for_tab(0).Visible = true;

            notes.Enabled = text_ is file_text_reader;
            if (notes.Enabled) {
                notes.load(notes_keeper.inst.notes_file_for_file(text_.name));
                merge_notes();
            }

            util.postpone(update_list_view_edit, 250);
            util.postpone(check_are_settings_complete, 1500);
        }
示例#7
0
        private int history_select(string unique_name, string friendly_name = "") {
            ++ignore_change_;
            bool needs_save = false;
            logHistory.SelectedIndex = -1;

            bool found = false;
            for (int i = 0; i < history_.Count && !found; ++i)
                if (history_[i].unique_name == unique_name) {
                    found = true;
                    bool is_sample = unique_name.ToLower().EndsWith("logwizardsetupsample.log");
                    // if not default form - don't move the selection to the end
                    bool is_default_form = toggled_to_custom_ui_ < 0;
                    if (is_sample || !is_default_form)
                        logHistory.SelectedIndex = i;
                    else {
                        // whatever the user selects, move it to the end
                        history h = history_[i];
                        history_.RemoveAt(i);
                        history_.Add(h);
                        logHistory.Items.RemoveAt(i);
                        logHistory.Items.Add(h.ui_friendly_name);
                        logHistory.SelectedIndex = logHistory.Items.Count - 1;
                        needs_save = true;
                    }
                }

            if (logHistory.SelectedIndex < 0) {
                // if we end up here, it can only be a file! - we don't allow selecting anything else that we don't already have in history
                Debug.Assert(File.Exists(unique_name));
                // FIXME (minor) if not on the default form -> i should not put it last (since that will be automatically loaded at restart)
                history new_ = new history();
                settings_as_string hist_sett = new settings_as_string("");
                hist_sett.set("type", "file");
                hist_sett.set("name", unique_name);
                hist_sett.set("friendly_name", friendly_name);
                // FIXME perhaps GUID as well?
                new_.from_string(hist_sett.ToString());
                history_.Add(new_);
                logHistory.Items.Add(history_.Last().ui_friendly_name);
                logHistory.SelectedIndex = logHistory.Items.Count - 1;
            }
            --ignore_change_;

            if (needs_save)
                save();
            return logHistory.SelectedIndex;
        }