Beispiel #1
0
        internal void OnCanvasTouchStart(int id, float x, float y)
        {
            if (_activeTouchpoints.ContainsKey(id))
            {
                throw new InvalidOperationException($"HTML Touch id {id} is already tracked. Cannot track another touchpoint using this id.");
            }

            var inx = NextFreeTouchIndex;

            if (inx < 0)
            {
                return;
            }

            _activeTouchpoints[id] = inx;
            ButtonValueChanged?.Invoke(this, new ButtonValueChangedArgs {
                Button = _tpButtonDescs[(int)TouchPoints.Touchpoint_0 + inx].ButtonDesc, Pressed = true
            });
            AxisValueChanged?.Invoke(this, new AxisValueChangedArgs {
                Axis = _tpAxisDescs[(int)TouchAxes.Touchpoint_0_X + 2 * inx].AxisDesc, Value = x
            });
            AxisValueChanged?.Invoke(this, new AxisValueChangedArgs {
                Axis = _tpAxisDescs[(int)TouchAxes.Touchpoint_0_Y + 2 * inx].AxisDesc, Value = y
            });
        }
Beispiel #2
0
        internal void OnViewTouchEnd(int id, float x, float y)
        {
            // Diagnostics.Log($"TouchEnd {id}");
            int inx;

            if (!_activeTouchpoints.TryGetValue(id, out inx))
            {
                return;
            }

            AxisValueChanged?.Invoke(this,
                                     new AxisValueChangedArgs
            {
                Axis  = _tpAxisDescs[(int)TouchAxes.Touchpoint_0_X + 2 * inx].AxisDesc,
                Value = x
            });
            AxisValueChanged?.Invoke(this,
                                     new AxisValueChangedArgs
            {
                Axis  = _tpAxisDescs[(int)TouchAxes.Touchpoint_0_Y + 2 * inx].AxisDesc,
                Value = y
            });
            ButtonValueChanged?.Invoke(this,
                                       new ButtonValueChangedArgs
            {
                Button  = _tpButtonDescs[(int)TouchPoints.Touchpoint_0 + inx].ButtonDesc,
                Pressed = false
            });
            _activeTouchpoints.Remove(id);
        }
 /// <summary>
 /// Установка нового значения оси. Предназначен для вызоыва из контроллера.
 /// </summary>
 /// <param name="parNewAxisValue"></param>
 public void SetAxisValue(double parNewAxisValue)
 {
     Delta = 0.0;
     if (Math.Abs(parNewAxisValue - Value) > GlobalDefinitionsConsts.FloatingPointCompTolerance)
     {
         Delta = parNewAxisValue - Value;
         Value = parNewAxisValue;
         AxisValueChanged?.Invoke(Value, Delta);
     }
 }
Beispiel #4
0
        private void OnImpAxisValueChanged(object sender, AxisValueChangedArgs args)
        {
            if (!_axesToListen.ContainsKey(args.Axis.Id))
            {
                throw new InvalidOperationException($"Unknown Axis {args.Axis.Name} ({args.Axis.Id})");
            }

            _axesToListen[args.Axis.Id] = args.Value;
            AxisValueChanged?.Invoke(this, args);
        }
Beispiel #5
0
        internal void OnCanvasTouchMove(int id, float x, float y)
        {
            int inx;

            if (!_activeTouchpoints.TryGetValue(id, out inx))
            {
                return;
            }

            AxisValueChanged?.Invoke(this, new AxisValueChangedArgs {
                Axis = _tpAxisDescs[(int)TouchAxes.Touchpoint_0_X + 2 * inx].AxisDesc, Value = x
            });
            AxisValueChanged?.Invoke(this, new AxisValueChangedArgs {
                Axis = _tpAxisDescs[(int)TouchAxes.Touchpoint_0_Y + 2 * inx].AxisDesc, Value = y
            });
        }
        internal void OnWindowsTouchMove(int id, float x, float y)
        {
            // Diagnostics.Log($"TouchMove {id}");
            int inx;

            if (!_activeTouchpoints.TryGetValue(id, out inx))
            {
                return;
            }

            AxisValueChanged?.Invoke(this, new AxisValueChangedArgs {
                Axis = _tpAxisDescs[(int)TouchAxes.Touchpoint_0_X + 2 * inx].AxisDesc, Value = x
            });
            AxisValueChanged?.Invoke(this, new AxisValueChangedArgs {
                Axis = _tpAxisDescs[(int)TouchAxes.Touchpoint_0_Y + 2 * inx].AxisDesc, Value = y
            });
        }
Beispiel #7
0
 protected virtual void OnChangedValue()
 {
     AxisValueChanged?.Invoke(_axisValue);
 }