示例#1
0
 private void UpdatedNotify(object sender, CBCharacteristicEventArgs e)
 {
     if (e.Characteristic.UUID == _nativeCharacteristic.UUID)
     {
         ValueUpdated?.Invoke(this, new CharacteristicUpdatedEventArgs(this));
     }
 }
示例#2
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            if (ObservedProcess.Process.HasExited)
            {
                return;
            }
            byte[] result = TryReadProcessMemory(ObservedProcess.ProcessHandle, ObservedProcess.Process.MainModule.BaseAddress.ToInt64(), Convert.ToInt64(TargetAddress, 16));
            if (result == null)
            {
                return;
            }
            ulong oldValue = ReadValue;

            ReadValue = ((ReadValueType)ValueType).ToValue(result);
            if (ReadValue == oldValue)
            {
                return;
            }
            foreach (Notifier notifier in Notifiers)
            {
                if (notifier.CompareValue(oldValue, ReadValue))
                {
                    LogBuilder.AppendLine(string.Format("[{0}] : {1}", DateTime.Now.ToString(), notifier.GetCompareInfo(oldValue, ReadValue)));
                    if (NotifierPriorityEnabled)
                    {
                        break;
                    }
                }
            }
            ValueUpdated?.Invoke(this, oldValue, ReadValue);
        }
 private void OnCharacteristicValueChanged(object sender, CharacteristicReadCallbackEventArgs e)
 {
     if (e.Characteristic.Uuid == NativeCharacteristic.Uuid)
     {
         ValueUpdated?.Invoke(this, new CharacteristicUpdatedEventArgs(this));
     }
 }
示例#4
0
        public void Start()
        {
            Pause();

            _lastMilliseconds = 0;
            _timer            = Ticker.Default.Insert(step =>
            {
                long ms = step + _lastMilliseconds;

                Value = Math.Min(1.0f, ms / (double)Length);

                _lastMilliseconds = ms;

                ValueUpdated?.Invoke(this, EventArgs.Empty);

                if (Value >= 1.0f)
                {
                    if (Loop)
                    {
                        _lastMilliseconds = 0;
                        Value             = 0.0f;
                        return(true);
                    }

                    Finished?.Invoke(this, EventArgs.Empty);
                    Value  = 0.0f;
                    _timer = 0;
                    return(false);
                }
                return(true);
            });
        }
示例#5
0
 public void UpdateValue(object newValue)
 {
     if (!((IList)_node.Values[_index]).Contains(newValue))
     {
         ((IList)_node.Values[_index]).Add(newValue);
     }
     ValueUpdated?.Invoke(this, EventArgs.Empty);
 }
 public void SetValue(object value)
 {
     if (_value != value)
     {
         _value = value;
         ValueUpdated?.Invoke();
     }
 }
示例#7
0
        protected virtual void RaiseOnUpdatedValue(object sender, IRtValue value, DateTime?updated = null, bool status = true)
        {
            Value   = value ?? valueNull;
            Updated = updated ?? DateTime.Now;
            Status  = status;

            ValueUpdated?.Invoke(sender, this);
        }
示例#8
0
文件: Tweener.cs 项目: zhamppx97/maui
 void FinishImmediately()
 {
     Value = 1.0f;
     ValueUpdated?.Invoke(this, EventArgs.Empty);
     Finished?.Invoke(this, EventArgs.Empty);
     Value  = 0.0f;
     _timer = 0;
 }
示例#9
0
文件: Tweener.cs 项目: sung-su/maui
        public void Start()
        {
            Pause();

            _lastMilliseconds = 0;
            _frames           = 0;

            if (!animationManager.Ticker.SystemEnabled)
            {
                FinishImmediately();
                return;
            }

            _timer = animationManager.Insert(step =>
            {
                if (step == long.MaxValue)
                {
                    // We're being forced to finish
                    Value = 1.0;
                }
                else
                {
                    long ms = step + _lastMilliseconds;

                    Value = Math.Min(1.0f, ms / (double)Length);

                    _lastMilliseconds = ms;
                }

                long wantedFrames = (_lastMilliseconds / Rate) + 1;
                if (wantedFrames > _frames || Value >= 1.0f)
                {
                    ValueUpdated?.Invoke(this, EventArgs.Empty);
                }
                _frames = wantedFrames;

                if (Value >= 1.0f)
                {
                    if (Loop)
                    {
                        _lastMilliseconds = 0;
                        Value             = 0.0f;
                        return(true);
                    }

                    Finished?.Invoke(this, EventArgs.Empty);
                    Value  = 0.0f;
                    _timer = 0;
                    return(false);
                }
                return(true);
            });
            if (!animationManager.Ticker.IsRunning)
            {
                animationManager.Ticker.Start();
            }
        }
        private void OnUpdatedCharacteristicValue(object sender, CBCharacteristicEventArgs e)
        {
            var c   = e.Characteristic;
            var cId = c.UUID;
            var tId = _nativeCharacteristic.UUID;

            if (cId == tId)
            {
                ValueUpdated?.Invoke(this, new CharacteristicUpdateEventArgs(this));
            }
        }
示例#11
0
        //public static event TaskCompletedHandler TaskCompleted;

        public static void RaiseEvent(object sender, GameEventArgs e)
        {
            if (e is TaskProgressAdvancedEventArgs se)
            {
                se.TaskInfo = sender as Task;
                TaskProgressAdvenced?.Invoke(sender as Task, se);
            }
            else if (e is ValueUpdatedEventArgs ve)
            {
                ValueUpdated?.Invoke(sender as ValueComplex, ve);
            }
        }
        public Characteristic(GattCharacteristic charac)
        {
            NativeCharacteristic = charac;

            Id = NativeCharacteristic.Uuid;

            NativeCharacteristic.ValueChanged += (s, c) =>
            {
                var data = new byte[c.CharacteristicValue.Length];
                CryptographicBuffer.CopyToByteArray(c.CharacteristicValue, out data);
                ValueUpdated?.Invoke(this, data);
            };
        }
示例#13
0
 public void UpdateValue(object value)
 {
     if (_node == null)
     {
         throw new ArgumentNullException("Node is null");
     }
     if (_index < 0)
     {
         throw new IndexOutOfRangeException("Index < 0");
     }
     _node.Values[_index] = value;
     ValueUpdated?.Invoke(this, EventArgs.Empty);
 }
示例#14
0
        private void ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
        {
            var count = args.CharacteristicValue.Length;

            byte[] buffer = new byte[count];
            var    data   = String.Empty;

            DataReader.FromBuffer(args.CharacteristicValue).ReadBytes(buffer);
            gattCharacteristicWithValue.Value = buffer;
            ValueUpdated?.Invoke(this, new CharacteristicReadEventArgs()
            {
                Characteristic = this,
            });
        }
示例#15
0
        //Should go UP to receive vibrations
        protected virtual void OnLPUpdated(int oldValue, int newValue, int maxValue)
        {
            if (oldValue == newValue || oldValue > newValue)
            {
                return;
            }
            ValueUpdated?.Invoke(this, new Tuple <string, string>("OnLPUpdated", newValue.ToString()));
            var percentageHit = Math.Abs(oldValue - newValue) * 1d / maxValue;

            LPHitReceived?.Invoke(this, percentageHit);

            var percentageLP = (1d * newValue) / maxValue;

            LPUpdated?.Invoke(this, percentageLP);
        }
示例#16
0
        public void Start()
        {
            Pause();

            _lastMilliseconds = 0;
            _frames           = 0;

            _timer = Ticker.Default.Insert(step =>
            {
                if (step == long.MaxValue)
                {
                    // We're being forced to finish
                    Value = 1.0;
                }
                else
                {
                    long ms = step + _lastMilliseconds;

                    Value = Math.Min(1.0f, ms / (double)Length);

                    _lastMilliseconds = ms;
                }

                long wantedFrames = (_lastMilliseconds / Rate) + 1;
                if (wantedFrames > _frames || Value >= 1.0f)
                {
                    ValueUpdated?.Invoke(this, EventArgs.Empty);
                }
                _frames = wantedFrames;

                if (Value >= 1.0f)
                {
                    if (Loop)
                    {
                        _lastMilliseconds = 0;
                        Value             = 0.0f;
                        return(true);
                    }

                    Finished?.Invoke(this, EventArgs.Empty);
                    Value  = 0.0f;
                    _timer = 0;
                    return(false);
                }
                return(true);
            });
        }
示例#17
0
        public void Start()
        {
            Pause();

            _lastMilliseconds = 0;

            if (!BaseTicker.Default.SystemEnabled)
            {
                FinishImmediately();
                return;
            }

            _timer = BaseTicker.Default.Insert(step =>
            {
                if (step == long.MaxValue)
                {
                    // We're being forced to finish
                    Value = 1.0;
                }
                else
                {
                    long ms = step + _lastMilliseconds;

                    Value = Math.Min(1.0f, ms / (double)Length);

                    _lastMilliseconds = ms;
                }

                ValueUpdated?.Invoke(this, EventArgs.Empty);

                if (Value >= 1.0f)
                {
                    if (Loop)
                    {
                        _lastMilliseconds = 0;
                        Value             = 0.0f;
                        return(true);
                    }

                    Finished?.Invoke(this, EventArgs.Empty);
                    Value  = 0.0f;
                    _timer = 0;
                    return(false);
                }
                return(true);
            });
        }
示例#18
0
        //Should go UP to receive vibrations
        protected virtual void OnHumHPUpdated(int oldValue, int newValue, int maxValue)
        {
            if (oldValue == newValue)
            {
                return;
            }
            if (newValue > oldValue)
            {
                HumLifeRefilled?.Invoke(this, null); return;
            }
            ValueUpdated?.Invoke(this, new Tuple <string, string>("OnHumHPUpdated", newValue.ToString()));
            var percentageHit = Math.Abs(oldValue - newValue) * 1d / maxValue;

            HumiliationHPHitReceived?.Invoke(this, percentageHit);

            var percentageLP = 1d * newValue / maxValue;

            HumiliationHPUpdated?.Invoke(this, percentageLP);
        }
        private void ValidateAndSet(string enteredValue)
        {
            if (enteredValue.Length < 1)
            {
                SetValue(_value);
            }
            else
            {
                var oldValue = _value;

                if (enteredValue[0] == '$')
                {
                    if (int.TryParse(enteredValue.TrimStart('$'), System.Globalization.NumberStyles.HexNumber, null, out int newValue))
                    {
                        SetValue(newValue);
                        if (newValue != oldValue)
                        {
                            ValueUpdated?.Invoke(this, EventArgs.Empty);
                        }
                    }
                    else
                    {
                        SetValue(_value);
                    }
                }
                else
                {
                    if (int.TryParse(enteredValue, out int newValue))
                    {
                        SetValue(newValue);
                        if (newValue != oldValue)
                        {
                            ValueUpdated?.Invoke(this, EventArgs.Empty);
                        }
                    }
                    else
                    {
                        SetValue(_value);
                    }
                }
            }
        }
示例#20
0
        //Should go DOWN to receive vibrations
        protected virtual void OnHPUpdated(int oldValue, int newValue, int maxValue)
        {
            if (oldValue == newValue)
            {
                return;
            }
            if (newValue > oldValue)
            {
                LifeRefilled?.Invoke(this, null); return;
            }
            if (newValue < oldValue && newValue <= 0 && oldValue > 0)
            {
                RoundEndedLoss?.Invoke(this, null); return;
            }
            ValueUpdated?.Invoke(this, new Tuple <string, string>("OnHPUpdated", newValue.ToString()));
            var percentageHit = Math.Abs(oldValue - newValue) * 1d / maxValue;

            HPHitReceived?.Invoke(this, percentageHit);

            var percentageHP = 1d * newValue / maxValue;

            HPUpdated?.Invoke(this, percentageHP);
        }
示例#21
0
 public void UpdateValue(object value)
 {
     _node.Values[_index] = value;
     ValueUpdated?.Invoke(this, EventArgs.Empty);
 }
示例#22
0
 public void ValueUpdatedEventInvoke()
 {
     ValueUpdated?.Invoke();
 }
示例#23
0
 protected virtual void RaiseOnUpdatedValue(IRtTag tag)
 {
     ValueUpdated?.Invoke(this, tag);
 }
示例#24
0
 public BleCharacteristic(ICharacteristic characteristic)
 {
     _characteristic = characteristic;
     _characteristic.ValueUpdated += (sender, args) => ValueUpdated?.Invoke(sender, Wrap(args.Characteristic));
 }
示例#25
0
 /// <summary>
 /// Handles DataUpdated event callback.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="e">Event arguments.</param>
 private void PressureSensorUpdated(object sender, PressureSensorDataUpdatedEventArgs e)
 {
     ValueUpdated?.Invoke(this, e.Pressure);
 }
示例#26
0
 /// <summary>
 /// Handler for when the characteristic value is changed. Updates the
 /// stored value
 /// </summary>
 private void OnCharacteristicValueChanged(object sender, GattValueChangedEventArgs e)
 {
     _value = e.CharacteristicValue.ToArray();  //add value to array
     ValueUpdated?.Invoke(this, new CharacteristicUpdatedEventArgs(this));
 }
示例#27
0
 private void CharacteristicValueChanged(object sender, CharacteristicUpdatedEventArgs e)
 {
     ValueUpdated?.Invoke(this, e.Characteristic.Value);
 }
示例#28
0
        private void updateEvaluation(string value, bool isDependenciesToBeUpdated)
        {
            bool isEvaluationSuccess = evaluate(value, out string evaluatedResult, out string evaluationFailureMessage, out List <SimpleVar> dependencyVariables);

            if (isEvaluationSuccess)
            {
                _tempCachePerformanceBooster[Name] = evaluatedResult;
            }
            else
            {
                _tempCachePerformanceBooster.Remove(Name);
            }
            if (isDependenciesToBeUpdated)
            {
                clearDependencyVariables();
                addDependencyVariables(dependencyVariables);

                _dependencyTreeGraph.DeleteAllEdgesTo(this);
                foreach (var depVar in dependencyVariables)
                {
                    _dependencyTreeGraph.AddEdge(depVar, this);
                }
            }

            if (_isDependencyTreeMode)
            {
                if (!_isDependencyTreeUpdationOnProgress)
                {
                    Stack <SimpleVar> evaluationStack = _dependencyTreeGraph.TopologicalSort(this, out bool isCyclic);
                    if (isCyclic)
                    {
                        isEvaluationSuccess      = false;
                        evaluationFailureMessage = "Cyclic referencing found by one of the dependencies";
                        _dependencyTreeGraph.DeleteAllEdgesTo(this);
                    }
                    else
                    {
                        _isDependencyTreeUpdationOnProgress = true;
                        while (evaluationStack.Count > 0)
                        {
                            var topVar = evaluationStack.Pop();
                            topVar.updateEvaluation(topVar.StrValue, false);
                        }
                        _isDependencyTreeUpdationOnProgress = false;
                    }
                    _tempCachePerformanceBooster.Clear();//This is essential because the purpose of _cachedVars is only for boosting performance during dependencies re-evaluation
                }
            }

            if (isEvaluationSuccess)
            {
                EvaluatedValue           = evaluatedResult;
                EvaluationFailureMessage = string.Empty;
                IsErrorHighlighted       = false;
            }
            else
            {
                EvaluatedValue           = string.Empty;
                EvaluationFailureMessage = evaluationFailureMessage;
                IsErrorHighlighted       = true;
            }
            LastUpdatedDateTime = DateTime.Now;

            if (!_isDependencyTreeMode)
            {
                ValueUpdated?.Invoke(this, EventArgs.Empty);
            }
        }
示例#29
0
 public void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
 {
     ValueUpdated?.Invoke(outLine.Data);
     //Debug.WriteLine(outLine.Data);
 }
示例#30
0
 private void UpdateEvent()
 {
     ValueUpdated?.Invoke();
 }