Exemplo n.º 1
0
    public override HIDInput ReadJson(JsonReader reader, Type objectType, HIDInput existingValue, bool hasExistingValue, JsonSerializer serializer)
    {
        HIDInput res = null;

        JObject jObject = JObject.Load(reader);


        if (string.IsNullOrEmpty(getValue(jObject, "PosX")))  //key
        {
            HIDKeyInput temp = new HIDKeyInput();
            temp.Key    = (Keys)int.Parse(getValue(jObject, "Key"));
            temp.Status = (KeyStatus)int.Parse(getValue(jObject, "Status"));
            res         = temp;
        }
        else    //mouse
        {
            HIDMouseInput temp = new HIDMouseInput();
            temp.PosX   = int.Parse(getValue(jObject, "PosX"));
            temp.PosY   = int.Parse(getValue(jObject, "PosY"));
            temp.Status = (MouseStatus)int.Parse(getValue(jObject, "Status"));
            res         = temp;
        }

        res.Time = int.Parse(getValue(jObject, "Time"));
        return(res);
    }
Exemplo n.º 2
0
        private void OnMouseInput(INativeWindow window, IInputDevice device, ref HIDMouseInput input)
        {
            var mouseDevice  = (MouseDevice)InputDevice.GetOrAddDevice(device);
            var coreWindow   = window == null ? null : CoreWindow.FindWindow(window);
            var rootVisual   = coreWindow?.RootVisual;
            var hitUIElement = rootVisual?.InputHitTest(new Point(input.CursorX, input.CursorY));

            if (hitUIElement != null)
            {
                if (input.ChangedButton == 0)
                {
                    UIElement.RaiseEvent(new PointerRoutedEventArgs(UIElement.PointerMoveEvent, hitUIElement, mouseDevice));
                }
                else if (input.ChangedButton == 6)
                {
                    ;
                }
                else
                {
                    if (input.ChangedButtonState == PointerButtonState.Pressed)
                    {
                        UIElement.RaiseEvent(new PointerButtonRoutedEventArgs(UIElement.PointerPressedEvent, hitUIElement, mouseDevice,
                                                                              input.ChangedButton, input.ChangedButtonState));
                    }
                    else if (input.ChangedButtonState == PointerButtonState.Released)
                    {
                        UIElement.RaiseEvent(new PointerButtonRoutedEventArgs(UIElement.PointerReleasedEvent, hitUIElement, mouseDevice,
                                                                              input.ChangedButton, input.ChangedButtonState));
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static HIDInput dataGridRow_to_HIDInput(DataGridView dv, int row)
        {
            if (dv.Rows[row].Cells["posx"].Value == null)
            {
                return(null);
            }

            string   posy = (string)dv.Rows[row].Cells["posy"].Value;
            HIDInput temp = null;

            if (string.IsNullOrEmpty(posy))  //keyboard
            {
                HIDKeyInput k = new HIDKeyInput();
                k.Key    = (Keys)dv.Rows[row].Cells["posx"].Value;
                k.Status = (KeyStatus)dv.Rows[row].Cells["status"].Value;
                temp     = k;
            }
            else    //mouse
            {
                HIDMouseInput m = new HIDMouseInput();
                m.PosX   = int.Parse((string)dv.Rows[row].Cells["posx"].Value);
                m.PosY   = int.Parse((string)dv.Rows[row].Cells["posy"].Value);
                m.Status = (MouseStatus)dv.Rows[row].Cells["status"].Value;
                temp     = m;
            }
            temp.Time = int.Parse(dv.Rows[row].Cells["time"].Value.ToString());
            return(temp);
        }
Exemplo n.º 4
0
        public void settings_to_UI(settings res)
        {
            //sleep

            checkBox2.Checked    = res.Launch.Sleep.Enable;
            numericUpDown1.Value = res.Launch.Sleep.Minutes;
            //time

            checkBox1.Checked    = res.Launch.Timing.Enable;
            numericUpDown4.Value = res.Launch.Timing.Hour;
            numericUpDown3.Value = res.Launch.Timing.Minute;
            numericUpDown2.Value = res.Launch.Timing.Second;
            //http

            checkBox3.Checked       = res.httpGet.Enable;
            textBox1.Text           = res.httpGet.URL;
            comboBox1.SelectedIndex = (int)res.httpGet.Operator;
            textBox2.Text           = res.httpGet.value;
            //proccess
            textBox4.Text     = res.Proccess.Close;
            checkBox4.Checked = res.Proccess.Enable;

            dataGridView1.Rows.Clear();



            for (int i = 0; i < res.HID.Count; i++)
            {
                if (res.HID[i].GetType() == typeof(HIDMouseInput))
                {
                    HIDMouseInput m = (HIDMouseInput)res.HID[i];
                    this.dataGridView1.Rows.Add(this.dataGridView1.Rows.Count, m.Status, m.PosX.ToString(), m.PosY.ToString(), m.Time);
                }
                else if (res.HID[i].GetType() == typeof(HIDKeyInput))
                {
                    HIDKeyInput k = (HIDKeyInput)res.HID[i];
                    this.dataGridView1.Rows.Add(this.dataGridView1.Rows.Count, k.Status, k.Key, string.Empty, k.Time);
                }
            }
        }
Exemplo n.º 5
0
 public MouseEventArgs(HIDMouseInput input)
 {
     MouseInput = input;
 }
Exemplo n.º 6
0
 public void OnMouseInput([In] INativeWindow window, [In] IInputDevice device, [In] ref HIDMouseInput input)
 {
     GetTarget()?.OnMouseInput(window, device, ref input);
 }