public void AddDocumentWorkspace(DocumentWorkspace addMe) { this.documents.Add(addMe); ImageStrip.Item docButton = new ImageStrip.Item(); docButton.Image = null; docButton.Tag = addMe; AddItem(docButton); this.documentButtons.Add(docButton); addMe.CompositionUpdated += Workspace_CompositionUpdated; this.dw2button.Add(addMe, docButton); if (addMe.Document != null) { QueueThumbnailUpdate(addMe); docButton.Dirty = addMe.Document.Dirty; addMe.Document.DirtyChanged += Document_DirtyChanged; } addMe.DocumentChanging += Workspace_DocumentChanging; addMe.DocumentChanged += Workspace_DocumentChanged; OnDocumentListChanged(); }
private void Document_DirtyChanged(object sender, EventArgs e) { for (int i = 0; i < this.documents.Count; ++i) { if (object.ReferenceEquals(sender, this.documents[i].Document)) { ImageStrip.Item docButton = this.dw2button[this.documents[i]]; docButton.Dirty = ((Document)sender).Dirty; } } }
private void OnThumbnailUpdated(DocumentWorkspace dw) { // We must double check that the DW is still around, because there's a chance // that the DW was been removed while the thumbnail was being rendered. if (this.dw2button.ContainsKey(dw)) { ImageStrip.Item docButton = this.dw2button[dw]; RenderArgs docRA = this.thumbs[dw]; docButton.Image = docRA.Bitmap; docButton.Update(); } }
private void Workspace_DocumentChanged(object sender, EventArgs e) { DocumentWorkspace dw = (DocumentWorkspace)sender; ImageStrip.Item docButton = this.dw2button[dw]; if (dw.Document != null) { docButton.Dirty = dw.Document.Dirty; dw.Document.DirtyChanged += Document_DirtyChanged; } else { docButton.Dirty = false; } }
public void RemoveDocumentWorkspace(DocumentWorkspace removeMe) { removeMe.CompositionUpdated -= Workspace_CompositionUpdated; if (this.selectedDocument == removeMe) { this.selectedDocument = null; } removeMe.DocumentChanging -= Workspace_DocumentChanging; removeMe.DocumentChanged -= Workspace_DocumentChanged; if (removeMe.Document != null) { removeMe.Document.DirtyChanged -= Document_DirtyChanged; } this.documents.Remove(removeMe); this.thumbnailManager.RemoveFromQueue(removeMe); ImageStrip.Item docButton = this.dw2button[removeMe]; this.RemoveItem(docButton); this.dw2button.Remove(removeMe); this.documentButtons.Remove(docButton); if (this.thumbs.ContainsKey(removeMe)) { RenderArgs thumbRA = this.thumbs[removeMe]; Surface surface = thumbRA.Surface; thumbRA.Dispose(); this.thumbs.Remove(removeMe); surface.Dispose(); } OnDocumentListChanged(); }