示例#1
0
 internal ChartSettings(MainChartSettings settings)
 {
     InitializeComponent();
     Settings          = settings;
     Previous          = new PreviousValue();
     IsFormInitialized = false;
     LocalizeWindow();
     UpdateUiBySettings();
     IsFormInitialized = true;
     UiControls.TrySetSelectedIndex(uiTop_ApplyTo_ComBx, (int)CurveApply.Average);
 }
示例#2
0
        private void Button_Div_Clicked(object sender, EventArgs e)
        {
            if (PreviousOperation == Operations.Divided)
            {
                PreviousValue   = PreviousValue / Convert.ToDecimal(LedDisplay.Text);
                LedDisplay.Text = PreviousValue.ToString();
                return;
            }

            PreviousValue     = Convert.ToDecimal(LedDisplay.Text);
            PreviousOperation = Operations.Divided;

            LedDisplay.Text = "0";
        }
 private void _tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     lock (_tmr)
     {
         var newValue = Selector(Object);
         if (PreviousValue.EqualsWithNullHandling(newValue))
         {
             return;
         }
         if (Changed != null)
         {
             var changedEventArgs = new ChangedEventArgs <TSelectedValue>(PreviousValue, newValue);
             Changed(this, changedEventArgs);
         }
         PreviousValue = newValue;
     }
 }
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            bool needUpdating;

            if (firstRender)
            {
                JsModule = await JsRuntime.InvokeAsync <IJSObjectReference>("import", "./_content/BlazorNumericTextBox/numerictextbox.js");

                string toDecimalSeparator = "";
                if (DecimalSeparator != ".")
                {
                    toDecimalSeparator = DecimalSeparator;
                }

                await JsModule.InvokeVoidAsync("ConfigureNumericTextBox",
                                               new string[] {
                    "#" + Id,
                    ".",
                    toDecimalSeparator,
                    SelectOnEntry ? "true" : "",
                    MaxLength.ToString(),
                    KeyPressCustomFunction
                });

                await SetVisibleValue(Value);

                needUpdating = true;
            }
            else
            {
                needUpdating = !PreviousValue.Equals(Value);
            }

            if (needUpdating)
            {
                await SetVisibleValue(Value);

                PreviousValue = Value;
            }
        }
        internal void InitEventGeneration()
        {
            Core.Config.GpioConfiguration.InputModePins.ForEach((pin) => {
                Pin pinConfig                = Driver.GetPinConfig(pin);
                CurrentValue currentValue    = new CurrentValue(pinConfig.PinState, pinConfig.IsPinOn, pinConfig.Mode, PinEventState.Both);
                PreviousValue previousValue  = new PreviousValue(pinConfig.PinState, pinConfig.IsPinOn, pinConfig.Mode, PinEventState.Both);
                PinEventConfiguration config = new PinEventConfiguration(pin, PinEventState.Both, currentValue, previousValue, new CancellationTokenSource());
                Helpers.InBackgroundThread(() => Generate(ref config), longRunning: true);
                EventConfigurations.Add(config);
            });

            Core.Config.GpioConfiguration.OutputModePins.ForEach((pin) => {
                Pin pinConfig                = Driver.GetPinConfig(pin);
                CurrentValue currentValue    = new CurrentValue(pinConfig.PinState, pinConfig.IsPinOn, pinConfig.Mode, PinEventState.Both);
                PreviousValue previousValue  = new PreviousValue(pinConfig.PinState, pinConfig.IsPinOn, pinConfig.Mode, PinEventState.Both);
                PinEventConfiguration config = new PinEventConfiguration(pin, PinEventState.Both, currentValue, previousValue, new CancellationTokenSource());
                Helpers.InBackgroundThread(() => Generate(ref config), longRunning: true);
                EventConfigurations.Add(config);
            });

            Logger.Info($"'{EventConfigurations.Count}' pin configurations with events initiated.");
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") static <Key> void applyUpdate(ReadableState<Key> store, java.util.concurrent.ConcurrentMap<Key, ChangeEntry> changes, Key key, ValueUpdate update, boolean reset, long version) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal static void ApplyUpdate <Key>(ReadableState <Key> store, ConcurrentMap <Key, ChangeEntry> changes, Key key, ValueUpdate update, bool reset, long version)
        {
            ChangeEntry value = changes.get(key);

            if (value == null)
            {
                ChangeEntry newEntry = ChangeEntry.Of(new sbyte[store.KeyFormat().valueSize()], version);
                lock ( newEntry )
                {
                    value = changes.putIfAbsent(key, newEntry);
                    if (value == null)
                    {
                        BigEndianByteArrayBuffer buffer = new BigEndianByteArrayBuffer(newEntry.Data);
                        if (!reset)
                        {
                            PreviousValue lookup = new PreviousValue(newEntry.Data);
                            if (!store.Lookup(key, lookup))
                            {
                                buffer.Clear();
                            }
                        }
                        update.Update(buffer);
                        return;
                    }
                }
            }
            lock ( value )
            {
                BigEndianByteArrayBuffer target = new BigEndianByteArrayBuffer(value.Data);
                value.Version = version;
                if (reset)
                {
                    target.Clear();
                }
                update.Update(target);
            }
        }
示例#7
0
        private static PreviousValue ConvertPreviousValue(PreviousValueData pv)
        {
            PreviousValue prevValue = null;

            try
            {
                if (pv != null)
                {
                    prevValue = new PreviousValue
                    {
                        EndDate   = pv.EndDate,
                        Source    = pv.Source,
                        StartDate = pv.StartDate,
                        Unit      = pv.Unit,
                        Value     = pv.Value
                    };
                }
                return(prevValue);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:ConvertPreviousValue()::" + ex.Message, ex.InnerException);
            }
        }
示例#8
0
 private void Awake()
 {
     p_animatorStateInfo = new PreviousValue <AnimatorStateInfo>();
 }
 private void Awake()
 {
     _rigidbody       = GetComponent <Rigidbody>();
     p_inputMagnitude = new PreviousValue <float>();
 }
示例#10
0
 private void Awake()
 {
     _rigidbody  = GetComponent <Rigidbody>();
     _animator   = GetComponent <Animator>();
     p_isJumping = new PreviousValue <bool>();
 }
示例#11
0
 internal PinEventConfiguration(int gpioPin, PinEventState eventState, CurrentValue currentValue, PreviousValue previousValue, CancellationTokenSource?token = default)
 {
     GpioPin    = gpioPin;
     EventState = eventState;
     EventToken = token == null ? new CancellationTokenSource() : token;
     Current    = currentValue;
     Previous   = previousValue;
 }
        private async Task HasLostFocus()
        {
            var data = await JsModule.InvokeAsync <string>("GetNumericTextBoxValue", new string[] { "#" + Id });

            var cleaned = string.Join("",
                                      data.Replace("(", "-").Where(x => char.IsDigit(x) ||
                                                                   x == '-' ||
                                                                   x.ToString() == DecimalSeparator).ToArray());
            var parsed = decimal.TryParse(cleaned, NumberStyles.Any, Culture.NumberFormat, out var valueAsDecimal);

            if (!parsed)
            {
                if (string.IsNullOrEmpty(Format))
                {
                    VisibleValue = "";
                }
                else
                {
                    VisibleValue = 0.ToString(Format);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(Format))
                {
                    VisibleValue = cleaned;
                }
                else
                {
                    VisibleValue = valueAsDecimal.ToString(Format);
                }
            }

            // Negative monetary values a represented with parenthesis
            cleaned = string.Join("",
                                  VisibleValue.Replace("(", "-")
                                  .Where(x => char.IsDigit(x) ||
                                         x == '-' ||
                                         x.ToString() == DecimalSeparator).ToArray());

            parsed = decimal.TryParse(cleaned, NumberStyles.Any, Culture.NumberFormat, out var roundedValue);

            if (parsed)
            {
                Value = (TItem)Convert.ChangeType(roundedValue, typeof(TItem));
            }
            else
            {
                Value = (TItem)Convert.ChangeType(valueAsDecimal, typeof(TItem));
            }

            // Do not remove. Problems in browser events and Blazor changes the value of the Value property
            var value = Value;

            await SetVisibleValue(Value);

            Value = value;
            await ValueChanged.InvokeAsync(Value);

            if (!PreviousValue.Equals(Value))
            {
                if (!string.IsNullOrEmpty(FieldIdentifier.FieldName))
                {
                    EditContext.NotifyFieldChanged(FieldIdentifier);
                }
                await NumberChanged.InvokeAsync(Value);
            }

            AdditionalStyles = AlignToRight;

            if (OnBlur != null)
            {
                await OnBlur.Invoke();
            }
        }