public void InitPlugin(string[] args) { // start .. Log.Info("InitPlugin() called with args = {0}", (args == null) ? "" : string.Join(", ", args)); // .. with built-in options options = AasxPluginGenericForms.GenericFormOptions.CreateDefault(); // try load defaults options from assy directory try { // need special settings var settings = AasxPluginOptionSerialization.GetDefaultJsonSettings( new[] { typeof(AasxPluginGenericForms.GenericFormOptions), typeof(AasForms.FormDescBase) }); // base options var newOpt = AasxPluginOptionsBase.LoadDefaultOptionsFromAssemblyDir <AasxPluginGenericForms.GenericFormOptions>( this.GetPluginName(), Assembly.GetExecutingAssembly(), settings); if (newOpt != null) { this.options = newOpt; } // try find additional options this.options.TryLoadAdditionalOptionsFromAssemblyDir <AasxPluginGenericForms.GenericFormOptions>( this.GetPluginName(), Assembly.GetExecutingAssembly(), settings, this.Log); } catch (Exception ex) { Log.Error(ex, "Exception when reading default options {1}"); } }
public static GenericFormsControl FillWithWpfControls( LogInstance log, object opackage, object osm, AasxPluginGenericForms.GenericFormOptions options, PluginEventStack eventStack, object masterDockPanel) { // access var package = opackage as AdminShellPackageEnv; var sm = osm as AdminShell.Submodel; var master = masterDockPanel as DockPanel; if (package == null || sm == null || master == null) { return(null); } // the Submodel elements need to have parents sm.SetAllParents(); // create TOP control var shelfCntl = new GenericFormsControl(); shelfCntl.Start(log, package, sm, options, eventStack); master.Children.Add(shelfCntl); // return shelf return(shelfCntl); }
public void Start( LogInstance log, AdminShellPackageEnv thePackage, AdminShell.Submodel theSubmodel, AasxPluginGenericForms.GenericFormOptions theOptions, PluginEventStack eventStack) { this.Log = log; this.thePackage = thePackage; this.theSubmodel = theSubmodel; this.theOptions = theOptions; this.theEventStack = eventStack; }
public AasxPluginResultBase ActivateAction(string action, params object[] args) { try { // for speed reasons, have the most often used at top! if (action == "call-check-visual-extension") { // arguments if (args.Length < 1) { return(null); } // looking only for Submodels var sm = args[0] as AdminShell.Submodel; if (sm == null) { return(null); } // check for a record in options, that matches Submodel var found = this.options?.MatchRecordsForSemanticId(sm.semanticId); if (found == null) { return(null); } // success prepare record var cve = new AasxPluginResultVisualExtension(found.FormTag, found.FormTitle); // ok return(cve); } // rest follows if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string) { var settings = AasxPluginOptionSerialization.GetDefaultJsonSettings( new[] { typeof(AasxPluginGenericForms.GenericFormOptions), typeof(AasForms.FormDescBase) }); var newOpt = Newtonsoft.Json.JsonConvert.DeserializeObject <AasxPluginGenericForms.GenericFormOptions>( (args[0] as string), settings); if (newOpt != null) { this.options = newOpt; } } if (action == "get-json-options") { var settings = AasxPluginOptionSerialization.GetDefaultJsonSettings( new[] { typeof(AasxPluginGenericForms.GenericFormOptions), typeof(AasForms.FormDescBase) }); var json = Newtonsoft.Json.JsonConvert.SerializeObject( this.options, typeof(AasxPluginGenericForms.GenericFormOptions), settings); return(new AasxPluginResultBaseObject("OK", json)); } if (action == "get-licenses") { var lic = new AasxPluginResultLicense(); lic.shortLicense = ""; lic.isStandardLicense = true; lic.longLicense = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir( "LICENSE.txt", Assembly.GetExecutingAssembly()); return(lic); } if (action == "get-events" && this.eventStack != null) { // try access return(this.eventStack.PopEvent()); } if (action == "event-return" && args != null && args.Length >= 1 && args[0] is AasxPluginEventReturnBase && this.formsControl != null) { this.formsControl.HandleEventReturn(args[0] as AasxPluginEventReturnBase); } if (action == "get-check-visual-extension") { var cve = new AasxPluginResultBaseObject(); cve.strType = "True"; cve.obj = true; return(cve); } if (action == "fill-panel-visual-extension") { // arguments if (args == null || args.Length < 3) { return(null); } // call this.formsControl = AasxPluginGenericForms.GenericFormsControl.FillWithWpfControls( Log, args[0], args[1], this.options, this.eventStack, args[2]); // give object back var res = new AasxPluginResultBaseObject(); res.obj = this.formsControl; return(res); } if (action == "get-list-new-submodel") { // prepare list var list = new List <string>(); // check if (options != null && options.Records != null) { foreach (var rec in options.Records) { if (rec.FormTitle != null) { list.Add("" + rec.FormTitle); } } } // make result var res = new AasxPluginResultBaseObject(); res.strType = "OK"; res.obj = list; return(res); } if (action == "generate-submodel" && args != null && args.Length >= 1 && args[0] is string) { // get arguments var smName = args[0] as string; if (smName == null) { return(null); } // identify record AasxPluginGenericForms.GenericFormsOptionsRecord foundRec = null; if (options != null && options.Records != null) { foreach (var rec in options.Records) { if (rec.FormTitle != null && rec.FormTitle == smName) { foundRec = rec; } } } if (foundRec == null || foundRec.FormSubmodel == null) { return(null); } // generate var sm = foundRec.FormSubmodel.GenerateDefault(); // make result var res = new AasxPluginResultGenerateSubmodel(); res.sm = sm; res.cds = foundRec.ConceptDescriptions; return(res); } } catch (Exception ex) { Log.Error(ex, ""); } // default return(null); }