public CopyPasteItemSME( AdminShell.AdministrationShellEnv env, AdminShell.Referable parentContainer, AdminShell.SubmodelElementWrapper wrapper, AdminShell.SubmodelElement sme) { this.env = env; this.parentContainer = parentContainer; this.wrapper = wrapper; this.sme = sme; }
public CopyPasteItemSME( AdminShell.AdministrationShellEnv env, AdminShell.Referable parentContainer, AdminShell.SubmodelElementWrapper wrapper, AdminShell.SubmodelElement sme, AdminShell.EnumerationPlacmentBase placement = null) { this.env = env; this.parentContainer = parentContainer; this.wrapper = wrapper; this.sme = sme; this.Placement = placement; }
public VisualElementSubmodelElement(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.Referable parentContainer, AdminShell.SubmodelElementWrapper wrap) : base() { this.Parent = parent; this.Cache = cache; this.theEnv = env; this.theContainer = parentContainer; this.theWrapper = wrap; this.Background = Brushes.White; this.Border = Brushes.White; this.TagString = "Elem"; if (wrap != null && wrap.submodelElement != null) { if (wrap.submodelElement is AdminShell.Property) { this.TagString = "Prop"; } if (wrap.submodelElement is AdminShell.File) { this.TagString = "File"; } if (wrap.submodelElement is AdminShell.Blob) { this.TagString = "Blob"; } if (wrap.submodelElement is AdminShell.ReferenceElement) { this.TagString = "Ref"; } if (wrap.submodelElement is AdminShell.RelationshipElement) { this.TagString = "Rel"; } if (wrap.submodelElement is AdminShell.SubmodelElementCollection) { this.TagString = "Coll"; } } this.TagBg = (SolidColorBrush)(new BrushConverter().ConvertFrom("#707070"));; this.TagFg = Brushes.White; RefreshFromMainData(); RestoreFromCache(); }
public VisualElementSubmodelElement( VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.Referable parentContainer, AdminShell.SubmodelElementWrapper wrap) : base() { this.Parent = parent; this.Cache = cache; this.theEnv = env; this.theContainer = parentContainer; this.theWrapper = wrap; this.Background = Brushes.White; this.Border = Brushes.White; this.TagBg = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"]; this.TagFg = Brushes.White; this.TagString = wrap.GetElementAbbreviation(); RefreshFromMainData(); RestoreFromCache(); }
public static CopyPasteItemSME ConvertFrom(AdminShell.Referable rf) { // access var sme = rf as AdminShell.SubmodelElement; if (sme == null) { return(null); } // new wrapper var wrapper = new AdminShell.SubmodelElementWrapper(); wrapper.submodelElement = sme; // create return(new CopyPasteItemSME() { sme = sme, wrapper = wrapper }); }
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 static void GenerateVisualElementsFromShellEnvAddElements( TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, VisualElementGeneric parent, AdminShell.Referable parentContainer, AdminShell.SubmodelElementWrapper el) { var ti = new VisualElementSubmodelElement(parent, cache, env, parentContainer, el); parent.Members.Add(ti); // Recurse: SMC if (el.submodelElement is AdminShell.SubmodelElementCollection elc && elc.value != null) { foreach (var elcc in elc.value) { GenerateVisualElementsFromShellEnvAddElements(cache, env, ti, elc, elcc); } } // Recurse: Entity // ReSharper disable ExpressionIsAlwaysNull if (el.submodelElement is AdminShell.Entity ele && ele.statements != null) { foreach (var eles in ele.statements) { GenerateVisualElementsFromShellEnvAddElements(cache, env, ti, ele, eles); } } // ReSharper enable ExpressionIsAlwaysNull // Recurse: Operation if (el.submodelElement is AdminShell.Operation elo) { if (elo.inputVariable != null) { foreach (var vin in elo.inputVariable) { ti.Members.Add( new VisualElementOperationVariable( ti, cache, env, el.submodelElement, vin, AdminShell.OperationVariable.Direction.In)); } } if (elo.outputVariable != null) { foreach (var vout in elo.outputVariable) { ti.Members.Add( new VisualElementOperationVariable( ti, cache, env, el.submodelElement, vout, AdminShell.OperationVariable.Direction.Out)); } } if (elo.inoutputVariable != null) { foreach (var vout in elo.inoutputVariable) { ti.Members.Add( new VisualElementOperationVariable( ti, cache, env, el.submodelElement, vout, AdminShell.OperationVariable.Direction.InOut)); } } } // Recurse: AnnotatedRelationshipElement if (el.submodelElement is AdminShell.AnnotatedRelationshipElement ela && ela.annotations != null) { foreach (var elaa in ela.annotations) { GenerateVisualElementsFromShellEnvAddElements(cache, env, ti, ela, elaa); } } }
public static void GenerateVisualElementsFromShellEnvAddElements(TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, VisualElementGeneric parent, AdminShell.Referable parentContainer, AdminShell.SubmodelElementWrapper el) { var ti = new VisualElementSubmodelElement(parent, cache, env, parentContainer, el); parent.Members.Add(ti); var elc = el.submodelElement as AdminShell.SubmodelElementCollection; if (elc != null) { foreach (var elcc in elc.value) { GenerateVisualElementsFromShellEnvAddElements(cache, env, ti, elc, elcc); } } }
// // Helper functions // public void DispSmeCutCopyPasteHelper( Panel stack, ModifyRepo repo, AdminShell.AdministrationShellEnv env, AdminShell.Referable parentContainer, CopyPasteBuffer cpb, AdminShell.SubmodelElementWrapper wrapper, AdminShell.SubmodelElement sme, string label = "Buffer:") { // access if (parentContainer == null || cpb == null || sme == null) { return; } // use an action this.AddAction( stack, label, new[] { "Cut", "Copy", "Paste above", "Paste below", "Paste into" }, repo, (buttonNdx) => { if (buttonNdx == 0 || buttonNdx == 1) { // store info cpb.valid = true; cpb.duplicate = buttonNdx == 1; cpb.item = new CopyPasteItemSME(env, parentContainer, wrapper, sme); // user feedback AasxPackageExplorer.Log.Singleton.Info( StoredPrint.Color.Blue, "Stored SubmodelElement '{0}'({1}) to internal buffer.{2}", "" + sme.idShort, "" + sme?.GetElementName(), cpb.duplicate ? " Paste will duplicate." : " Paste will cut at original position."); } if (buttonNdx == 2 || buttonNdx == 3 || buttonNdx == 4) { // present var item = cpb?.item as CopyPasteItemSME; if (!cpb.valid || item?.sme == null || item?.wrapper == null || item?.parentContainer == null) { if (this.flyoutProvider != null) { this.flyoutProvider.MessageBoxFlyoutShow( "No (valid) information for SubmodelElements in copy/paste buffer.", "Copy & Paste", MessageBoxButton.OK, MessageBoxImage.Information); } return(new ModifyRepo.LambdaActionNone()); } // user feedback AasxPackageExplorer.Log.Singleton.Info( "Pasting buffer with SubmodelElement '{0}'({1}) to internal buffer.", "" + item.sme.idShort, "" + item.sme.GetElementName()); // apply info var smw2 = new AdminShell.SubmodelElementWrapper(item.sme, shallowCopy: false); // 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 mssing here? }