Ejemplo n.º 1
0
        private void update_history(ComboBox box, List <history> history_, history old_sel)
        {
            box.Items.Clear();
            foreach (history hist in history_)
            {
                box.Items.Add(hist.ui_friendly_name);
            }

            box.SelectedIndex = old_sel != null?history_.IndexOf(old_sel) : -1;
        }
Ejemplo n.º 2
0
        public void add_history(history hist)
        {
            // ... just in case existed already
            static_history_.Remove(hist);

            static_history_.Add(hist);

            // force rebuilding
            lw_to_history_exists_.Clear();
        }
Ejemplo n.º 3
0
        private void add_reader_to_history() {
            int history_idx = history_.FindIndex(x => x.settings.get("guid") == text_.unique_id);

            ++ignore_change_;
            if (history_idx < 0) {
                history new_ = new history();
                new_.from_text_reader(text_);

                history_.Add(new_);
                logHistory.Items.Add(new_.ui_friendly_name);
            } else {
                // move to the end
                var existing = history_[history_idx];
                history_.RemoveAt(history_idx);
                logHistory.Items.RemoveAt(history_idx);

                history_.Add(existing);
                logHistory.Items.Add(existing.ui_friendly_name);
            }            
            logHistory.SelectedIndex = history_.Count - 1;
            --ignore_change_;
        }
Ejemplo n.º 4
0
        private void history_select(settings_as_string_readonly settings) {
            ++ignore_change_;
            bool needs_save = false;
            logHistory.SelectedIndex = -1;
            string unique_id = settings.get("guid");

            bool found = false;
            for (int i = 0; i < history_.Count && !found; ++i)
                if (history_[i].unique_id == unique_id) {
                    found = true;
                    bool is_sample = settings.get("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) {
                // 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();
                new_.from_settings(settings);
                history_.Add(new_);
                logHistory.Items.Add(history_.Last().ui_friendly_name);
                logHistory.SelectedIndex = logHistory.Items.Count - 1;
            }
            --ignore_change_;

            if (needs_save)
                save();
            return;
        }
Ejemplo n.º 5
0
        private void do_open_log(string initial_settings_str, string config_file) {
            var add = new edit_log_settings_form(initial_settings_str, edit_log_settings_form.edit_type.add);
            if (config_file != "")
                add.load_config(config_file);
            if (add.ShowDialog(this) == DialogResult.OK) {
                log_settings_string settings = new log_settings_string(add.settings);
                if (is_log_in_history(ref settings)) {
                    // we already have this in history
                    create_text_reader(settings);
                    return;
                }
                
                var new_ = new history();
                new_.from_settings(settings);
                history_list_.add_history(new_);
                global_ui.last_log_guid = new_.guid;

                Text = reader_title();
                create_text_reader(new_.write_settings);
                save();
            }            
        }
Ejemplo n.º 6
0
        private void add_reader_to_history() {
            var existing = history_.FirstOrDefault(x => x.settings.guid == text_.guid);

            if (existing == null) {
                history new_ = new history();
                new_.from_text_reader(text_);
                history_list_.add_history(new_);
                existing = new_;
            } 
            else 
                // 1.8.4
                existing.from_text_reader(text_);

            // move to the end
            global_ui.last_log_guid = existing.guid;            
            recreate_history_combo();

            // select last item
            ++ignore_change_;
            logHistory.SelectedIndex = logHistory.Items.Count - 1;
            --ignore_change_;
        }
Ejemplo n.º 7
0
        public void load()
        {
            var sett = app.inst.sett;

            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);
                    if (settings == "")
                    {
                        logger.Debug("history guid removed " + guid);
                        continue; // entry removed
                    }
                    Debug.Assert(settings.Contains(guid));
                    hist.from_settings(new log_settings_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");

                    var history_sett = new log_settings_string("");
                    history_sett.type.set((log_type)Enum.Parse(typeof(log_type), type_str));
                    history_sett.name.set(name);
                    history_sett.friendly_name.set(friendly_name);
                    // create a guid now
                    history_sett.guid.set(Guid.NewGuid().ToString());
                    hist.from_settings(history_sett);
                }

                static_history_.Add(hist);
            }
            static_history_ = static_history_.Where(h => {
                if (h.type == log_type.file)
                {
                    // 1.5.11 - don't include this into the list next time the user opens the app
                    //          (so that he'll see the "Drop me like it's hot" huge message)
                    if (h.name.ToLower().EndsWith("logwizardsetup.sample.log"))
                    {
                        return(false);
                    }
                    // old name of this sample file
                    if (h.name.ToLower().EndsWith("logwizardsetupsample.log"))
                    {
                        return(false);
                    }

                    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();
        }
Ejemplo n.º 8
0
        private void add_reader_to_history() {

            int history_idx = history_.FindIndex(x => x.settings.get("guid") == text_.unique_id);
            if (history_idx < 0) {
                history new_ = new history();
                new_.from_text_reader( text_);

                history_.Add(new_);
                history_idx = history_.Count - 1;
                logHistory.Items.Add(new_.ui_friendly_name);                
            }

            ++ignore_change_;
            logHistory.SelectedIndex = history_idx;
            --ignore_change_;
            update_history();
        }
Ejemplo n.º 9
0
        private void whatsupOpen_Click(object sender, EventArgs e) {
            var add = new edit_log_settings_form("", edit_log_settings_form.edit_type.add);
            if (add.ShowDialog(this) == DialogResult.OK) {
                log_settings_string settings = new log_settings_string(add.settings);
                if (is_log_in_history(ref settings)) {
                    // we already have this in history
                    create_text_reader(settings);
                    return;
                }
                
                var new_ = new history();
                new_.from_settings(settings);
                history_list_.add_history(new_);
                global_ui.last_log_guid = new_.guid;

                // should not be needed
#if old_code
                recreate_history_combo();
                ++ignore_change_;
                logHistory.SelectedIndex = logHistory.Items.Count - 1;
                --ignore_change_;
#endif

                Text = reader_title();
                create_text_reader(new_.write_settings);
                save();
            }
        }
Ejemplo n.º 10
0
        private void add_reader_to_history()
        {
            if ( text_ is debug_text_reader)
                return;
            history new_ = new history();
            if ( text_ is file_text_reader) {
                new_.name = ((file_text_reader)text_).name;
                new_.type = 0;
            }
            else if ( text_ is shared_memory_text_reader) {
                new_.name = ((shared_memory_text_reader)text_).name;
                new_.type = 1;
            }
            else
                Debug.Assert(false);

            int history_idx = -1;
            for ( int i = 0; i < history_.Count && history_idx < 0; ++i)
                if ( new_.name == history_[i].name && new_.type == history_[i].type)
                    history_idx = i;
            if ( history_idx < 0) {
                history_.Add(new_);
                history_idx = history_.Count - 1;
                logHistory.Items.Add(new_.combo_name);
            }
            else {
                ignore_change = true;
                friendlyNameCtrl.Text = history_[ history_idx].friendly_name;
                logSyntaxCtrl.Text = history_[ history_idx].log_syntax;
                ignore_change = false;
            }

            ignore_change = true;
            logHistory.SelectedIndex = history_idx;
            ignore_change = false;
            update_history();
        }
Ejemplo n.º 11
0
        private void load_contexts()
        {
            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();
                hist.type = int.Parse( sett.get("history." + idx + "type", "0"));
                hist.name = sett.get("history." + idx + "name");
                hist.friendly_name = sett.get("history." + idx + "friendly_name");
                hist.log_syntax = sett.get("history." + idx + "log_syntax");
                history_.Add( hist );
            }

            int count = int.Parse( sett.get("context_count", "1"));
            for ( int i = 0; i < count ; ++i) {
                ui_context ctx = new ui_context();
                ctx.name = sett.get("context." + i + ".name", "Default");
                ctx.auto_match = sett.get("context." + i + ".auto_match");

                ctx.show_filter = sett.get("context." + i + ".show_filter", "1") != "0";
                ctx.show_source = sett.get("context." + i + ".show_source", "1") != "0";
                ctx.show_fulllog = sett.get("context." + i + ".show_fulllog", "0") != "0";

                int view_count = int.Parse( sett.get("context." + i + ".view_count", "1"));
                for ( int v = 0; v < view_count; ++v) {
                    ui_view lv = new ui_view();
                    lv.name = sett.get("context." + i + ".view" + v + ".name");
                    int filter_count = int.Parse( sett.get("context." + i  + ".view" + v + ".filter_count", "0"));
                    for ( int f = 0; f < filter_count; ++f) {
                        string prefix = "context." + i + ".view" + v + ".filt" + f + ".";
                        bool enabled = int.Parse( sett.get(prefix + "enabled", "1")) != 0;
                        bool dimmed = int.Parse( sett.get(prefix + "dimmed", "0")) != 0;
                        string text = sett.get(prefix + "text");
                        lv.filters.Add( new ui_filter { enabled = enabled, dimmed = dimmed, text = text } );
                    }
                    ctx.views.Add(lv);
                }
                contexts_.Add(ctx);
            }
        }
Ejemplo n.º 12
0
        public void load() {
            var sett = app.inst.sett;

            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);
                    if (settings == "") {
                        logger.Debug("history guid removed " + guid);
                        continue; // entry removed
                    }
                    Debug.Assert(settings.Contains(guid));
                    hist.from_settings(new log_settings_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");

                    var history_sett = new log_settings_string("");
                    history_sett.type.set( (log_type) Enum.Parse(typeof (log_type), type_str));
                    history_sett.name.set(name);
                    history_sett.friendly_name.set(friendly_name);
                    // create a guid now
                    history_sett.guid.set(Guid.NewGuid().ToString());
                    hist.from_settings(history_sett);
                }

                static_history_ .Add( hist );
            }
            static_history_ = static_history_ .Where(h => {
                if (h.type == log_type.file) {
                    // 1.5.11 - don't include this into the list next time the user opens the app
                    //          (so that he'll see the "Drop me like it's hot" huge message)
                    if (h.name.ToLower().EndsWith("logwizardsetup.sample.log"))
                        return false;
                    // old name of this sample file
                    if (h.name.ToLower().EndsWith("logwizardsetupsample.log"))
                        return false;

                    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();            
        }
Ejemplo n.º 13
0
        private void update_history(ComboBox box, List<history> history_, history old_sel ) {
            box.Items.Clear();
            foreach (history hist in history_)
                box.Items.Add(hist.ui_friendly_name);

            box.SelectedIndex = old_sel != null ? history_.IndexOf(old_sel) : -1;
        }
Ejemplo n.º 14
0
        public void add_history(history hist) {
            // ... just in case existed already
            static_history_.Remove(hist);

            static_history_.Add(hist);
            
            // force rebuilding
            lw_to_history_exists_.Clear();
        }
Ejemplo n.º 15
0
        private void whatsupOpen_Click(object sender, EventArgs e) {
            var add = new edit_log_settings_form("", edit_log_settings_form.edit_type.add);
            if (add.ShowDialog(this) == DialogResult.OK) {
                settings_as_string_readonly settings = new settings_as_string(add.settings);
                if (is_log_in_history(ref settings)) {
                    // we already have this in history
                    create_text_reader(settings);
                    return;
                }
                var new_ = new history();
                new_.from_settings(settings);

                history_.Add(new_);
                ++ignore_change_;
                logHistory.Items.Add(history_.Last().ui_friendly_name);
                logHistory.SelectedIndex = logHistory.Items.Count - 1;
                --ignore_change_;

                Text = reader_title() + " - Log Wizard " + version();
                create_text_reader(new_.settings);
                save();
            }
        }
Ejemplo n.º 16
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);
                    if (settings == "") {
                        logger.Debug("history guid removed " + guid);
                        continue; // entry removed
                    }
                    Debug.Assert(settings.Contains(guid));
                    hist.from_settings(new settings_as_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_settings(history_sett);
                }

                history_.Add( hist );
            }
            history_ = history_.Where(h => {
                if (h.type == history.entry_type.file) {
                    // 1.5.11 - don't include this into the list next time the user opens the app
                    //          (so that he'll see the "Drop me like it's hot" huge message)
                    if (h.name.EndsWith("LogWizardSetupSample.log"))
                        return false;

                    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();
        }
Ejemplo n.º 17
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;
        }