Beispiel #1
0
 public void Update(double newValue)
 {
     if (ActiveDirection == SignalDirection.Rising)
     {
         if (newValue > Threshold && !Active)
         {
             Active = true;
             ActiveChanged.Fire(Active);
         }
         else if (newValue <= (Threshold - CoolDownAmount) && Active)
         {
             Active = false;
             ActiveChanged.Fire(Active);
         }
     }
     else if (ActiveDirection == SignalDirection.Falling)
     {
         if (newValue < Threshold && !Active)
         {
             Active = true;
             ActiveChanged.Fire(Active);
         }
         else if (newValue >= (Threshold + CoolDownAmount) && Active)
         {
             Active = false;
             ActiveChanged.Fire(Active);
         }
     }
 }
Beispiel #2
0
 private void Changes(bool hadAny, bool hasAny)
 {
     if ((hadAny && !hasAny) || (!hadAny && hasAny))
     {
         ActiveChanged?.Invoke();
     }
 }
Beispiel #3
0
        private async Task ToogleActive(MouseEventArgs e)
        {
            isActive = !isActive;
            await ActiveChanged.InvokeAsync(isActive);

            await OnClick.InvokeAsync(e);
        }
Beispiel #4
0
 /// <summary>
 ///     Raises the <see cref="ActiveChanged" /> event.
 /// </summary>
 /// <seealso cref="EventArgs" />
 protected virtual void OnActiveChanged()
 {
     ActiveChanged?.Invoke(this, EventArgs.Empty);
 }
 private void Changes()
 {
     ActiveChanged?.Invoke();
 }
        /// <summary>
        /// Initializes static members of the <see cref="ConfigurationSection{T}" /> class.
        /// </summary>
        static ConfigurationSection()
        {
            _activeChangeAction =
                new BufferedAction <string>(
                    // ReSharper disable EventExceptionNotDocumented, AssignNullToNotNullAttribute
                    changes =>
            {
                try
                {
                    T active = Active;
                    ActiveChanged?.Invoke(active, new ConfigurationChangedEventArgs(active, changes));
                }
                // ReSharper disable once CatchAllClause
                catch
                {
                    // ignored
                }
            },
                    // ReSharper restore EventExceptionNotDocumented, AssignNullToNotNullAttribute
                    ConfigurationExtensions.EventBufferMs);

            // Try to find attribute
            ConfigurationSectionAttribute attribute =
                (ConfigurationSectionAttribute)
                typeof(T).GetCustomAttributes(typeof(ConfigurationSectionAttribute), false).
                FirstOrDefault();

            string sectionName = attribute?.Name;

            if (string.IsNullOrEmpty(sectionName))
            {
                sectionName = typeof(T).Name;

                int len = sectionName.Length;

                // If it ends with 'configuration' strip it.
                if (len > 20 &&
                    sectionName.EndsWith(
                        "configurationsection",
                        StringComparison.CurrentCultureIgnoreCase))
                {
                    sectionName = sectionName.Substring(0, len -= 20);
                }
                else if (len > 13 &&
                         sectionName.EndsWith(
                             "configuration",
                             StringComparison.CurrentCultureIgnoreCase))
                {
                    sectionName = sectionName.Substring(0, len -= 13);
                }
                else if (len > 7 &&
                         sectionName.EndsWith(
                             "section",
                             StringComparison.CurrentCultureIgnoreCase))
                {
                    sectionName = sectionName.Substring(0, len -= 7);
                }
                else if (len > 6 &&
                         sectionName.EndsWith(
                             "config",
                             StringComparison.CurrentCultureIgnoreCase))
                {
                    sectionName = sectionName.Substring(0, len -= 6);
                }

                // Convert to lower camel case
                sectionName = sectionName.Substring(0, 1).ToLower() + (len > 1
                    ? sectionName.
                                                                       Substring(1)
                    : string.Empty);
            }

            SectionName = sectionName;
        }
Beispiel #7
0
 private void RaiseActiveChanged()
 {
     ActiveChanged?.Invoke(this, GetKey());
 }