/// <summary> /// Creates a new editing context layer. Editing context layers can be used to /// create editing modes. For example, you may create a layer before starting a /// drag operation on the designer. Any new context items you add to the layer /// hide context items underneath it. When the layer is removed, all context /// items under the layer are re-surfaced. This allows you to create a layer /// and set overrides for context items during operations such as drag and drop. /// </summary> internal override ContextLayer CreateLayer() { _currentLayer = new DefaultContextLayer(this, _currentLayer); return(_currentLayer); }
internal DefaultContextLayer(DefaultContextItemCollection collection, DefaultContextLayer parentLayer) { _collection = collection; _parentLayer = parentLayer; // can be null }
internal override void Remove() { // Only remove the layer if we have a parent layer. // Also, once we remove the layer make sure we don't // try to remove it if someone else calls Remove. if (_parentLayer != null) { _collection.OnLayerRemoved(this); _parentLayer = null; } }
internal DefaultContextItemCollection(EditingContext context) { _context = context; _currentLayer = new DefaultContextLayer(this, null); }
/// <summary> /// Called when the user removes a layer. /// </summary> private void OnLayerRemoved(DefaultContextLayer layer) { if (_currentLayer == layer) { _currentLayer = layer.ParentLayer; } else { var childLayer = FindChildLayer(layer); childLayer.ParentLayer = layer.ParentLayer; } Debug.Assert(_currentLayer != null, "DefaultContextLayer should not call OnLayerRemoved for top most layer"); // For each item that was in the layer, raise a changed event for it if (_subscriptions != null) { foreach (var oldItem in layer.Items.Values) { OnItemChanged(GetValue(oldItem.ItemType)); } } }
/// <summary> /// This helper function returns the childLayer for the layer that is passed in. /// This function is used in the OnLayerRemoved to link the layers when /// a layer (in the middle) is removed. /// </summary> /// <param name="layer"></param> /// <returns></returns> private DefaultContextLayer FindChildLayer(DefaultContextLayer layer) { var startLayer = _currentLayer; while (startLayer.ParentLayer != layer) { startLayer = startLayer.ParentLayer; } return startLayer; }
/// <summary> /// Creates a new editing context layer. Editing context layers can be used to /// create editing modes. For example, you may create a layer before starting a /// drag operation on the designer. Any new context items you add to the layer /// hide context items underneath it. When the layer is removed, all context /// items under the layer are re-surfaced. This allows you to create a layer /// and set overrides for context items during operations such as drag and drop. /// </summary> internal override ContextLayer CreateLayer() { _currentLayer = new DefaultContextLayer(this, _currentLayer); return _currentLayer; }
internal DefaultContextLayer(DefaultContextLayer parentLayer) { _parentLayer = parentLayer; // can be null }
internal DefaultContextItemManager(EditingContext context) { _context = context; _currentLayer = new DefaultContextLayer(null); }
public override void Remove(bool disposing = false) { // Only remove the layer if we have a parent layer or if being disposed. // Also, once we remove the layer make sure we don't // try to remove it if someone else calls Remove. if (_parentLayer != null || disposing) { foreach (var item in _items.Values) { var d = item as IDisposable; if (d != null) { d.Dispose(); } } _items.Clear(); _collection.OnLayerRemoved(this); _parentLayer = null; } }
/// <summary> /// Called when the user removes a layer. /// </summary> /// <param name="layer"></param> private void OnLayerRemoved(DefaultContextLayer layer) { if (_currentLayer == layer) { _currentLayer = layer.ParentLayer; } else { var childLayer = FindChildLayer(layer); if (childLayer != null) { childLayer.ParentLayer = layer.ParentLayer; } } }