public void Push(AnyUiPanel panel, int iChild) { recursionStack[iRecursionStack] = new Program.AnyUiPanelEntry(); recursionStack[iRecursionStack].panel = panel; recursionStack[iRecursionStack].iChild = iChild + 1; iRecursionStack++; }
public void Pop(out AnyUiPanel panel, out int iChild) { panel = null; iChild = 0; if (iRecursionStack > 0) { iRecursionStack--; panel = recursionStack[iRecursionStack].panel; iChild = recursionStack[iRecursionStack].iChild; recursionStack[iRecursionStack] = null; } }
public void DispSmeCutCopyPasteHelper( AnyUiPanel stack, ModifyRepo repo, AdminShell.AdministrationShellEnv env, AdminShell.Referable parentContainer, CopyPasteBuffer cpbInternal, AdminShell.SubmodelElementWrapper wrapper, AdminShell.SubmodelElement sme, string label = "Buffer:") { // access if (parentContainer == null || cpbInternal == null || sme == null) { return; } // use an action this.AddAction( stack, label, new[] { "Cut", "Copy", "Paste above", "Paste below", "Paste into" }, repo, actionTags: new[] { "aas-elem-cut", "aas-elem-copy", "aas-elem-paste-above", "aas-elem-paste-below", "aas-elem-paste-into" }, action: (buttonNdx) => { if (buttonNdx == 0 || buttonNdx == 1) { // store info cpbInternal.Clear(); cpbInternal.Valid = true; cpbInternal.Duplicate = buttonNdx == 1; AdminShell.EnumerationPlacmentBase placement = null; if (parentContainer is AdminShell.IEnumerateChildren enc) { placement = enc.GetChildrenPlacement(sme); } cpbInternal.Items = new ListOfCopyPasteItem( new CopyPasteItemSME(env, parentContainer, wrapper, sme, placement)); cpbInternal.CopyToClipboard(context, cpbInternal.Watermark); // special case? // user feedback Log.Singleton.Info( StoredPrint.Color.Blue, "Stored SubmodelElement '{0}'({1}) to internal buffer.{2}", "" + sme.idShort, "" + sme?.GetElementName(), cpbInternal.Duplicate ? " Paste will duplicate." : " Paste will cut at original position."); } if (buttonNdx == 2 || buttonNdx == 3 || buttonNdx == 4) { // which buffer? var cbdata = context?.ClipboardGet(); var cpb = cpbInternal.CheckIfUseExternalCopyPasteBuffer(cbdata); // content? if (!cpb.ContentAvailable) { this.context?.MessageBoxFlyoutShow( "No sufficient infomation in internal paste buffer or external clipboard.", "Copy & Paste", AnyUiMessageBoxButton.OK, AnyUiMessageBoxImage.Error); return(new AnyUiLambdaActionNone()); } // uniform? if (!cpb.Items.AllOfElementType <CopyPasteItemSME>()) { this.context?.MessageBoxFlyoutShow( "No (valid) information for SubmodelElements in copy/paste buffer.", "Copy & Paste", AnyUiMessageBoxButton.OK, AnyUiMessageBoxImage.Information); return(new AnyUiLambdaActionNone()); } // user feedback Log.Singleton.Info($"Pasting {cpb.Items.Count} SubmodelElements from paste buffer"); // loop over items object nextBusObj = null; foreach (var it in cpb.Items) { // access var item = it as CopyPasteItemSME; if (item?.sme == null || item.wrapper == null || (!cpb.Duplicate && item?.parentContainer == null)) { Log.Singleton.Error("When pasting SME, an element was invalid."); continue; } // apply info var smw2 = new AdminShell.SubmodelElementWrapper(item.sme, shallowCopy: false); nextBusObj = smw2.submodelElement; // insertation depends on parent container if (buttonNdx == 2) { if (parentContainer is AdminShell.Submodel pcsm && wrapper != null) { this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>( pcsm.submodelElements, smw2, wrapper); } if (parentContainer is AdminShell.SubmodelElementCollection pcsmc && wrapper != null) { this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>( pcsmc.value, smw2, wrapper); } if (parentContainer is AdminShell.Entity pcent && wrapper != null) { this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>( pcent.statements, smw2, wrapper); } if (parentContainer is AdminShell.AnnotatedRelationshipElement pcarel && wrapper != null) { this.AddElementInListBefore <AdminShell.SubmodelElementWrapper>( pcarel.annotations, smw2, wrapper); } // TODO (Michael Hoffmeister, 2020-08-01): Operation complete? if (parentContainer is AdminShell.Operation pcop && wrapper?.submodelElement != null) { var place = pcop.GetChildrenPlacement(wrapper.submodelElement) as AdminShell.Operation.EnumerationPlacmentOperationVariable; if (place?.OperationVariable != null) { var op = new AdminShell.OperationVariable(); op.value = smw2; this.AddElementInListBefore <AdminShell.OperationVariable>( pcop[place.Direction], op, place.OperationVariable); nextBusObj = op; } } }
public void DispMultiElementCutCopyPasteHelper( AnyUiPanel stack, ModifyRepo repo, AdminShell.AdministrationShellEnv env, AdminShell.IAasElement parentContainer, CopyPasteBuffer cpb, ListOfVisualElementBasic entities, string label = "Buffer:") { // access if (parentContainer == null || cpb == null || entities == null) { return; } // use an action this.AddAction( stack, label, new[] { "Cut", "Copy" }, repo, actionTags: new[] { "aas-multi-elem-cut", "aas-multi-elem-copy" }, action: (buttonNdx) => { if (buttonNdx == 0 || buttonNdx == 1) { // store info cpb.Clear(); cpb.Valid = true; cpb.Duplicate = buttonNdx == 1; cpb.Items = new ListOfCopyPasteItem(); foreach (var el in entities) { if (el is VisualElementSubmodelElement vesme && parentContainer is AdminShell.Referable pcref) { var sme = vesme.theWrapper?.submodelElement; AdminShell.EnumerationPlacmentBase placement = null; if (parentContainer is AdminShell.IEnumerateChildren enc) { placement = enc.GetChildrenPlacement(sme); } cpb.Items.Add(new CopyPasteItemSME(env, pcref, vesme.theWrapper, sme, placement)); } if (el is VisualElementSubmodelRef vesmr) { cpb.Items.Add(new CopyPasteItemSubmodel(parentContainer, vesmr.theSubmodelRef, vesmr.theSubmodelRef, vesmr.theSubmodel)); } if (el is VisualElementSubmodel vesm) { cpb.Items.Add(new CopyPasteItemSubmodel(parentContainer, vesm.theSubmodel, null, vesm.theSubmodel)); } if (el is VisualElementOperationVariable veopv && parentContainer is AdminShell.Referable pcref2) { if (veopv.theOpVar?.value != null) { cpb.Items.Add(new CopyPasteItemSME(env, pcref2, veopv.theOpVar.value, veopv.theOpVar.value?.submodelElement)); } } if (el is VisualElementConceptDescription vecd) { cpb.Items.Add(new CopyPasteItemIdentifiable(parentContainer, vecd.theCD)); } if (el is VisualElementAsset veass) { cpb.Items.Add(new CopyPasteItemIdentifiable(parentContainer, veass.theAsset)); } if (el is VisualElementAdminShell veaas) { cpb.Items.Add(new CopyPasteItemIdentifiable(parentContainer, veaas.theAas)); } }