lw_common.ui.note_ctrl.load C# (CSharp) Method

load() public method

public load ( string file_name ) : void
file_name string
return void
        public void load(string file_name) {
            // set the author color first!
            Debug.Assert(author_color_ != util.transparent);

            if (file_name == "")
                // maybe we could not access the original file...
                return;

            ++ignore_change_;
            if (file_name_ != "")
                // in this case, we're loading the notes from somewhere else, save_to existing first
                save();

            // we need to specify the full name!
            Debug.Assert(file_name == new FileInfo(file_name).FullName);
            file_name_ = file_name;

            notes_sorted_by_line_index_.Clear();
            notesCtrl.ClearObjects();
            cur_line.clear();

            var loaded = load_settings_file(this, file_name);
            lines_ = loaded.Item1;
            lines_.Add(cur_line_id_, new line());

            foreach (var n in loaded.Item2) {
                if (n.the_note != null) {
                    add_color_for_author(n.the_note.author_name, n.the_note.author_color);
                    add_note(lines_[n.line_id], n.the_note, n.note_id, n.reply_id, n.deleted, n.utc_last_edited);
                } else
                    add_note_header(n.line_id, n.note_id, n.deleted, n.utc_last_edited);
            }
        
            // set_aliases last_note_id and last_line_id
            dirty_ = false;
            --ignore_change_;

            refresh_notes();
            notesCtrl.Refresh();
        }