Esempio n. 1
0
        public blazorSessionService()
        {
            sessionNumber = ++sessionCounter;
            sessionTotal++;
            AnyUiDisplayContextHtml.addSession(sessionNumber);

            packages        = new PackageCentral();
            _packageCentral = packages;

            env = null;

            helper             = new DispEditHelperEntities();
            helper.levelColors = DispLevelColors.GetLevelColorsFromOptions(Options.Curr);
            // some functionality still uses repo != null to detect editMode!!
            repo            = new ModifyRepo();
            helper.editMode = editMode;
            helper.hintMode = hintMode;
            helper.repo     = repo;
            helper.context  = null;
            helper.packages = packages;

            stack17 = new AnyUiStackPanel()
            {
                Orientation = AnyUiOrientation.Vertical
            };

            if (env?.AasEnv?.AdministrationShells != null)
            {
                helper.DisplayOrEditAasEntityAas(packages, env.AasEnv,
                                                 env.AasEnv.AdministrationShells[0], editMode, stack17, hintMode: hintMode);
            }

            htmlDotnetThread = new Thread(AnyUiDisplayContextHtml.htmlDotnetLoop);
            htmlDotnetThread.Start();
        }
Esempio n. 2
0
        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;
                                }
                            }
                        }
Esempio n. 3
0
        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));
                        }
                    }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            //// env = new AdminShellPackageEnv("Example_AAS_ServoDCMotor_21.aasx");

            loadAasxFiles();
#if __test__PackageLogic
#else
            packages = new PackageCentral();
            // TODO (MIHO, 2021-06-07): how to initialize?
            packages.MainItem.TakeOver(env);

            helper             = new DispEditHelperEntities();
            helper.levelColors = DispLevelColors.GetLevelColorsFromOptions(Options.Curr);
            // some functionality still uses repo != null to detect editMode!!
            repo            = new ModifyRepo();
            helper.editMode = editMode;
            helper.hintMode = hintMode;
            helper.repo     = repo;
            helper.context  = null;
            helper.packages = packages;

            stack17             = new AnyUiStackPanel();
            stack17.Orientation = AnyUiOrientation.Vertical;

            helper.DisplayOrEditAasEntityAas(
                packages, env.AasEnv, env.AasEnv.AdministrationShells[0], editMode, stack17, hintMode: hintMode);

            AnyUi.AnyUiDisplayContextHtml.htmlDotnetThread.Start();
#endif

            //
            // Test for Blazor
            //

#if _not_enabled
            stack2 = JsonConvert.DeserializeObject <AnyUiStackPanel>(File.ReadAllText(@"c:\development\file.json"));
            var d = new JavaScriptSerializer();
            stack2 = d.Deserialize <AnyUiStackPanel>(File.ReadAllText(@"c:\development\file.json"));
            var parent = (Dictionary <string, object>)results["Parent"];
#endif

#if _not_enabled
            {
                string s = File.ReadAllText(@"c:\development\file.json");
                var    jsonSerializerSettings = new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.All
                };
                stack2 = JsonConvert.DeserializeObject <AnyUiStackPanel>(s, jsonSerializerSettings);
            }
#endif

            if (true)
            {
                stack.Orientation = AnyUiOrientation.Vertical;

                var lab1 = new AnyUiLabel();
                lab1.Content    = "Hallo1";
                lab1.Foreground = AnyUiBrushes.DarkBlue;
                stack.Children.Add(lab1);

                var stck2 = new AnyUiStackPanel();
                stck2.Orientation = AnyUiOrientation.Horizontal;
                stack.Children.Add(stck2);

                var lab2 = new AnyUiLabel();
                lab2.Content    = "Hallo2";
                lab2.Foreground = AnyUiBrushes.DarkBlue;
                stck2.Children.Add(lab2);

                var stck3 = new AnyUiStackPanel();
                stck3.Orientation = AnyUiOrientation.Horizontal;
                stck2.Children.Add(stck3);

                var lab3 = new AnyUiLabel();
                lab3.Content    = "Hallo3";
                lab3.Foreground = AnyUiBrushes.DarkBlue;
                stck3.Children.Add(lab3);

                if (editMode)
                {
                    var tb = new AnyUiTextBox();
                    tb.Foreground = AnyUiBrushes.Black;
                    tb.Text       = "Initial";
                    stck2.Children.Add(tb);

                    var btn = new AnyUiButton();
                    btn.Content     = "Click me!";
                    btn.DisplayData = new BlazorDisplayData(lambda: (o) =>
                    {
                        if (o == btn)
                        {
                            Program.LogLine = "Hallo, Match zwischen Button und callback!";
                        }
                    });
                    stck3.Children.Add(btn);
                }
            }

            CreateHostBuilder(args).Build().Run();
        }