/// <summary> /// Recherche de la couche immédiatement en dessous /// </summary> /// <param name="layer">The layer.</param> /// <param name="potentialLayer">The potential layer.</param> /// <returns></returns> private static SoftwareLayer GetDownestLayer(SoftwareLayer layer, SoftwareLayer potentialLayer) { // Recherche du layerPackage en dessous if (layer is InterfaceLayer) { LayerPackage layerPackage = null; foreach (LayerPackage lp in layer.SoftwareComponent.LayerPackages) { if (lp.Level < ((InterfaceLayer)layer).Level) { if (layerPackage == null || layerPackage.Level < lp.Level) { layerPackage = lp; } } } if (layerPackage != null) { List <SoftwareLayer> layers = new List <SoftwareLayer>(); foreach (SoftwareLayer sl in layerPackage.Layers) { layers.Add(sl); } // TODO a voir - On retourne tjs le 1er layer if (layers.Count == 0) { return(null); } foreach (SoftwareLayer sl in layers) { if (sl == potentialLayer) { return(potentialLayer); } } return(layers[0]); } } else { // Recherche de la couche d'interface ISortedLayer theLayer = null; foreach (AbstractLayer al in layer.SoftwareComponent.Layers) { ISortedLayer sl = al as ISortedLayer; if (sl != null && sl.Level < ((Layer)layer).Level) { if (theLayer == null || theLayer.Level < sl.Level) { theLayer = sl; } } } return(theLayer as SoftwareLayer); } return(null); }
/// <summary> /// Determines whether this instance [can accept layer package and layer as source and target] the specified source layer package. /// </summary> /// <param name="sourceLayerPackage">The source layer package.</param> /// <param name="targetLayer">The target layer.</param> /// <returns> /// <c>true</c> if this instance [can accept layer package and layer as source and target] the specified source layer package; otherwise, <c>false</c>. /// </returns> private static bool CanAcceptLayerPackageAndLayerAsSourceAndTarget(LayerPackage sourceLayerPackage, Layer targetLayer) { ISortedLayer sl = targetLayer as ISortedLayer; if (sl == null) { return(false); } return(sourceLayerPackage.Level == sl.Level); }
/// <summary> /// </summary> /// <param name="e">Provides data for the ElementDeleted event.</param> public override void ElementDeleted(ElementDeletedEventArgs e) { LayerPackage layerPackage = e.ModelElement as LayerPackage; if (layerPackage == null) { return; } if (layerPackage.Store.InUndoRedoOrRollback) { return; } SoftwareComponent component = CandleModel.GetInstance(layerPackage.Store).SoftwareComponent; if (component != null) { // Suppression de la couche d'interface AbstractLayer interfaceLayer = null; foreach (AbstractLayer al in component.Layers) { ISortedLayer sl = al as ISortedLayer; if (sl != null && sl.Level == layerPackage.LayerLevel) { interfaceLayer = al; break; } } if (interfaceLayer != null) { interfaceLayer.Delete(); } IList <PresentationViewsSubject> shapes = PresentationViewsSubject.GetLinksToPresentation(component); foreach (PresentationViewsSubject link in shapes) { ((SoftwareComponentShape)link.Presentation).ArrangeShapes(); } } }