public void InsertDocument (int docIndex, DocumentReference dr)
{
if (docIndex < 0)
return;
// Watch out in case we already got notified of this insertion
var existing = docIndex < Docs.Count ? Docs [docIndex] : null;
if (existing != null && existing.File.Path == dr.File.Path)
return;
//
// Insert it nicely
//
Docs.Insert (docIndex, dr);
items.Insert (docIndex, new DocumentsViewItem (dr));
try {
docsView.InsertItems (new[] { docIndex });
} catch (Exception ex) {
Debug.WriteLine (ex);
}
}