public void SetLayerOverlay(Layer layer, DocumentLayerOverlay overlay) { if (!this.overlays.TryAdd(layer, overlay)) { throw new InvalidOperationException(); } }
public void SetLayerOverlay(Layer layer, DocumentLayerOverlay overlay, RectInt32?invalidateRect) { Validate.Begin().IsNotNull <Layer>(layer, "layer").IsNotNull <DocumentLayerOverlay>(overlay, "overlay").Check(); base.VerifyAccess(); if (overlay.IsCancellationRequested) { throw new InvalidOperationException("Cannot set a layer overlay if it's already been cancelled"); } if (this.document == null) { throw new InvalidOperationException("Cannot set a layer if there's no document"); } if (!this.document.Layers.Contains(layer)) { throw new InvalidOperationException("Cannot set a layer overlay for a layer that doesn't exist in this Document"); } if (this.overlays.ContainsKey(layer)) { throw new InvalidOperationException("that layer already has an overlay"); } this.overlays.Add(layer, overlay); this.documentRenderer.SetLayerOverlay(layer, overlay); if (invalidateRect.HasValue) { if (invalidateRect.Value.HasPositiveArea) { layer.Invalidate(invalidateRect.Value); } } else { layer.Invalidate(overlay.AffectedBounds); } }
public void RemoveLayerOverlay(Layer layer, DocumentLayerOverlay overlay, RectInt32?invalidateRect) { DocumentLayerOverlay overlay2; Validate.Begin().IsNotNull <Layer>(layer, "layer").IsNotNull <DocumentLayerOverlay>(overlay, "overlay").Check(); base.VerifyAccess(); if (!this.overlays.TryGetValue(layer, out overlay2)) { throw new KeyNotFoundException(); } if (overlay2 != overlay) { throw new InvalidOperationException(); } this.overlays.Remove(layer); this.documentRenderer.RemoveLayerOverlay(layer); overlay.Cancel(); if (invalidateRect.HasValue) { if (invalidateRect.Value.HasPositiveArea) { layer.Invalidate(invalidateRect.Value); } } else { layer.Invalidate(overlay.AffectedBounds); } }
public void ReplaceLayerOverlay(Layer layer, DocumentLayerOverlay oldOverlay, DocumentLayerOverlay newOverlay, RectInt32?invalidateRect) { DocumentLayerOverlay overlay; base.VerifyAccess(); if ((oldOverlay == null) && (newOverlay == null)) { throw new ArgumentNullException(); } this.overlays.TryGetValue(layer, out overlay); if (overlay != oldOverlay) { throw new InvalidOperationException(); } if ((oldOverlay == null) && (newOverlay != null)) { this.SetLayerOverlay(layer, newOverlay, invalidateRect); } else if (newOverlay == null) { this.RemoveLayerOverlay(layer, overlay, invalidateRect); } else { if (newOverlay.IsCancellationRequested) { throw new InvalidOperationException("Cannot set an overlay which is already cancelled"); } this.overlays[layer] = newOverlay; this.documentRenderer.ReplaceLayerOverlay(layer, newOverlay); oldOverlay.Cancel(); if (invalidateRect.HasValue) { if (invalidateRect.Value.HasPositiveArea) { layer.Invalidate(invalidateRect.Value); } } else { RectInt32?nullable = (oldOverlay == null) ? null : new RectInt32?(oldOverlay.AffectedBounds); RectInt32?nullable2 = (newOverlay == null) ? null : new RectInt32?(newOverlay.AffectedBounds); RectInt32?nullable3 = RectInt32Util.Union(nullable, nullable2); if (nullable3.HasValue && nullable3.Value.HasPositiveArea) { layer.Invalidate(nullable3.Value); } } } }
public void ReplaceLayerOverlay(Layer layer, DocumentLayerOverlay overlay) { this.overlays[layer] = overlay; }
public void SetLayerOverlay(Layer layer, DocumentLayerOverlay overlay, RectInt32?invalidateRect = new RectInt32?()) { this.documentCanvasLayer.SetLayerOverlay(layer, overlay, invalidateRect); }
public void ReplaceLayerOverlay(Layer layer, DocumentLayerOverlay oldOverlay, DocumentLayerOverlay newOverlay, RectInt32?invalidateRect = new RectInt32?()) { this.documentCanvasLayer.ReplaceLayerOverlay(layer, oldOverlay, newOverlay, invalidateRect); }