/// <summary> /// Adds a "feature" field of type "checkbox" or "text" to the matching domain/type modules. This field will be showing in the module options popup and it will be bound to the given module parameter. /// This command should only appear inside a Program.Setup delegate. /// </summary> /// <returns> /// ProgramHelper. /// </returns> /// <param name='forDomains'> /// A string with comma separated list of domains of modules that will showing this input field. Use an empty string for all domains. /// </param> /// <param name='forModuleTypes'> /// A string with comma separated list of types of modules that will showing this input field. /// </param> /// <param name='parameterName'> /// Name of the module parameter associated to this input field. /// </param> /// <param name='description'> /// Description for this input field. /// </param> public ProgramHelper AddFeature( string forDomains, string forModuleTypes, string parameterName, string description, string type ) { var program = homegenie.ProgramEngine.Programs.Find(p => p.Address.ToString() == myProgramId.ToString()); ProgramFeature feature = null; // try { feature = program.Features.Find(f => f.Property == parameterName); } catch (Exception ex) { HomeGenieService.LogEvent( myProgramDomain, myProgramId.ToString(), ex.Message, "Exception.StackTrace", ex.StackTrace ); } // if (feature == null) { feature = new ProgramFeature(); program.Features.Add(feature); } feature.FieldType = type; feature.Property = parameterName; feature.Description = description; feature.ForDomains = forDomains; feature.ForTypes = forModuleTypes; return(this); }
/// <summary> /// Return the ProgramFeature object associated to the specified module parameter. /// </summary> /// <param name="propertyName">Parameter name.</param> public ProgramFeature Feature(string parameterName) { var program = homegenie.ProgramEngine.Programs.Find(p => p.Address.ToString() == myProgramId.ToString()); ProgramFeature feature = null; // try { feature = program.Features.Find(f => f.Property == parameterName); } catch (Exception ex) { HomeGenieService.LogEvent( myProgramDomain, myProgramId.ToString(), ex.Message, "Exception.StackTrace", ex.StackTrace ); } // return(feature); }
/// <summary> /// Return the feature field associated to the specified module parameter. /// </summary> /// <param name="parameterName">Parameter name.</param> public ProgramFeature Feature(string parameterName) { var program = GetProgramBlock(); ProgramFeature feature = null; // try { feature = program.Features.Find(f => f.Property == parameterName); } catch (Exception ex) { HomeGenieService.LogError( myProgramDomain, myProgramId.ToString(), ex.Message, "Exception.StackTrace", ex.StackTrace ); } // return(feature); }
/// <summary> /// Adds a "feature" field to modules matching the specified domain/type. /// Feature fields are used by automation programs to create own handled module parameters. /// This command should only appear inside a Program.Setup delegate. /// </summary> /// <returns> /// ProgramHelper. /// </returns> /// <param name='forDomains'> /// A string with comma separated list of domains of modules that will showing this input field. Use an empty string for all domains. /// </param> /// <param name='forModuleTypes'> /// A string with comma separated list of types of modules that will showing this input field. /// </param> /// <param name='parameterName'> /// Name of the module parameter bound to this feature field. /// </param> /// <param name='description'> /// Description for this input field. /// </param> /// <param name='type'> /// The type of this feature field (eg. "text", "password", "cron.text", ...). Each type can have different initialization options /// that are specified as ":" separated items. See html/ui/widgets folder for a list of possible types/options. /// </param> public ProgramHelper AddFeature( string forDomains, string forModuleTypes, string parameterName, string description, string type ) { var program = homegenie.ProgramManager.Programs.Find(p => p.Address.ToString() == myProgramId.ToString()); ProgramFeature feature = null; // try { feature = program.Features.Find(f => f.Property == parameterName); } catch (Exception ex) { HomeGenieService.LogError( myProgramDomain, myProgramId.ToString(), ex.Message, "Exception.StackTrace", ex.StackTrace ); } // if (feature == null) { feature = new ProgramFeature(); program.Features.Add(feature); } feature.FieldType = type; feature.Property = parameterName; feature.Description = description; feature.ForDomains = forDomains; feature.ForTypes = forModuleTypes; return this; }