Esempio n. 1
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) {
                var new_ = new history();
                new_.from_string(add.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();
            }
        }
Esempio n. 2
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();
        }
Esempio n. 3
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;
        }