Exemplo n.º 1
0
        /// <summary>Trims a block of text at the given length and appends an ellipsis if more characters exist.</summary>
        /// <param name="text">The text to trim.</param>
        /// <param name="length">The length of the text.</param>
        /// <param name="breakOnWholeWord">Whether or not to break on the next space instead of in the middle of a word.</param>
        /// <param name="moreLinkDelegate">A delegate which returns a link to more information.</param>
        /// <returns>The trimmed text.</returns>
        public static string TrimTextBlock(this string text, int length, bool breakOnWholeWord, GetStringValueDelegate moreLinkDelegate)
        {
            if (string.IsNullOrEmpty(text) || text.Length <= length)
            {
                return(text);
            }
            else
            {
                int    trimLength  = (breakOnWholeWord ? text.IndexOf(" ", length) : length);
                string trimmedText = null;

                if (trimLength < 0 || trimLength > text.Length)
                {
                    trimmedText = text;
                }
                else
                {
                    trimmedText = text.Substring(0, trimLength);
                }

                return("{0}...{1}".FormatString(trimmedText, (moreLinkDelegate == null ? "" : moreLinkDelegate())));
            }
        }
Exemplo n.º 2
0
 public RegisterString(DeviceBlock deviceBlock, RegisterSettings settings,
     SetStringValueDelegate setValue, GetStringValueDelegate getValue = null)
     : base(deviceBlock, settings)
 {
     String defaultValue = Settings.RegisterValue;
     if (defaultValue != null)
         RegisterValueString = new RegisterValueString(this, defaultValue);
     if (RegisterValueString != null)
     {
         HasFixedValue = true;
         MappedToRegisterData &= (Device.Params.Protocol.Type == ProtocolSettings.ProtocolType.Modbus);
         _Value = RegisterValueString.ValueString;
     }
     else
         HasFixedValue = false;
     SetStringValueInternal = setValue;
     GetStringValueInternal = getValue;
     LoadExtractor(settings.Extractor);
     LoadInserter(settings.Inserter);
 }
Exemplo n.º 3
0
 public VariableEntry_String(String name, SetStringValueDelegate setValueDelegate, GetStringValueDelegate getValueDelegate = null)
     : base(name)
 {
     SetValueDelegate = setValueDelegate;
     GetValueDelegate = getValueDelegate;
 }