Exemplo n.º 1
0
 /// <summary>Restores the snapshot.</summary>
 public void Restore(DiagramViewer view) {
    var appliedSettings = _restoreSettings(view);
    var appliedFilter = _restoreFilter(view.Shell);
    if (appliedSettings && !appliedFilter) {
       view.RecomputeLayout(true);
    }
    _restoreViewport(view);
    view.Shell.ViewName = Name;
 }
Exemplo n.º 2
0
 /// <summary>Gets a snapshot that captures the given diagram view.</summary>
 public static DiagramSnapshot Capture(DiagramViewer view, DiagramSnapshotScope scope) {
    var snapshot = new DiagramSnapshot(view.Shell.ViewName, scope);
    if (snapshot.Matches(DiagramSnapshotScope.Viewport)) {
       snapshot._captureViewport(view);
    }
    if (snapshot.Matches(DiagramSnapshotScope.Settings)) {
       snapshot._captureSettings(view);
    }
    if (snapshot.Matches(DiagramSnapshotScope.Filter)) {
       snapshot._captureFilter(view.Shell);
    }
    return snapshot;
 }
Exemplo n.º 3
0
 private bool _restoreSettings(DiagramViewer view) {
    if (Matches(DiagramSnapshotScope.Settings)) {
       var diagram = view.DiagramCanvas;
       diagram.DisplayOptions = _displayOptions;
       diagram.LayoutMethod = _layoutMethod;
       diagram.LayoutOrientation = _layoutOrientation;
       diagram.LayoutRatio = _layoutRatio;
       return true;
    } else {
       return false;
    }
 }
Exemplo n.º 4
0
 private void _captureSettings(DiagramViewer view) {
    var diagram = view.DiagramCanvas;
    _displayOptions = diagram.DisplayOptions;
    _layoutMethod = diagram.LayoutMethod;
    _layoutOrientation = diagram.LayoutOrientation;
    _layoutRatio = diagram.LayoutRatio;
 }
Exemplo n.º 5
0
 private bool _restoreViewport(DiagramViewer view) {
    if (Matches(DiagramSnapshotScope.Viewport)) {
       view.DiagramScroller.ScrollToHorizontalOffset(_origin.X);
       view.DiagramScroller.ScrollToVerticalOffset(_origin.Y);
       view.ZoomSlider.Value = _scale;
       return true;
    } else {
       return false;
    }
 }
Exemplo n.º 6
0
 private void _captureViewport(DiagramViewer view) {
    _scale = view.ZoomSlider.Value;
    _origin = new Point(view.DiagramScroller.HorizontalOffset, view.DiagramScroller.VerticalOffset);
 }
Exemplo n.º 7
0
 /// <summary>Creates a new <see cref="DiagramHistory"/> instance.</summary>
 public DiagramHistory(DiagramViewer viewer) {
    _viewer = viewer;
    _past = new Stack<DiagramSnapshot>();
    _future = new Stack<DiagramSnapshot>();
 }