public void AddImageDragDropListener(IActionListener listener)
 {
     pictureBoxSource.DragDrop += (sender, e) =>
     {
         if (e.Data.GetDataPresent(DataFormats.FileDrop))
         {
             var data = e.Data.GetData(DataFormats.FileDrop) as string[];
             if (data != null && data.Length > 0)
             {
                 listener.ActionPerformed(sender, new MyDragDropEventArgs<string[]>(data));
             }
         }
     };
     pictureBoxTarget.DragDrop += (sender, e) =>
     {
         if (e.Data.GetDataPresent(DataFormats.FileDrop))
         {
             var data = e.Data.GetData(DataFormats.FileDrop) as string[];
             if (data != null && data.Length > 0)
             {
                 listener.ActionPerformed(sender, new MyDragDropEventArgs<string[]>(data));
             }
         }
     };
 }
Пример #2
0
 private ToolTip GetToolTip(UIItem uiItem, IActionListener actionListener)
 {
     mouse.Click(uiItem.Bounds.Center());
     actionListener.ActionPerformed(Action.WindowMessage);
     Thread.Sleep(CoreAppXmlConfiguration.Instance.TooltipWaitTime);
     return ToolTip.GetFrom(uiItem.Bounds.Center());
 }
        protected virtual void Scroll(ScrollAmount amount)
        {
            if (!IsScrollable)
            {
                return;
            }
            switch (amount)
            {
            case ScrollAmount.LargeDecrement:
                ScrollPattern.SetScrollPercent(
                    ScrollPattern.Current.HorizontalScrollPercent,
                    ValidPercentage(ScrollPattern.Current.VerticalScrollPercent - ScrollPercentage));
                break;

            case ScrollAmount.SmallDecrement:
                ScrollPattern.SetScrollPercent(
                    ScrollPattern.Current.HorizontalScrollPercent,
                    ValidPercentage(ScrollPattern.Current.VerticalScrollPercent - SmallPercentage()));
                break;

            case ScrollAmount.LargeIncrement:
                ScrollPattern.SetScrollPercent(
                    ScrollPattern.Current.HorizontalScrollPercent,
                    ValidPercentage(ScrollPattern.Current.VerticalScrollPercent + ScrollPercentage));
                break;

            case ScrollAmount.SmallIncrement:
                ScrollPattern.SetScrollPercent(
                    ScrollPattern.Current.HorizontalScrollPercent,
                    ValidPercentage(ScrollPattern.Current.VerticalScrollPercent + SmallPercentage()));
                break;
            }
            actionListener.ActionPerformed(Action.Scroll);
        }
Пример #4
0
 private ToolTip GetToolTip(UIItem uiItem, IActionListener actionListener)
 {
     mouse.LeftClick(uiItem.Bounds.Center());
     actionListener.ActionPerformed(Action.WindowMessage);
     Thread.Sleep(CoreAppXmlConfiguration.Instance.TooltipWaitTime);
     return(ToolTip.GetFrom(uiItem.Bounds.Center()));
 }
Пример #5
0
        /// <summary>
        /// Implements <see cref="IUIItem.Enter"/>
        /// </summary>
        public virtual void Enter(string value)
        {
            var pattern = automationElement.Patterns.Value.PatternOrDefault;

            if (pattern != null)
            {
                pattern.SetValue(string.Empty);
            }
            if (string.IsNullOrEmpty(value))
            {
                return;
            }

            actionListener.ActionPerformed(Action.WindowMessage);
            EnterData(value);
        }
Пример #6
0
        /// <summary>
        /// Implements <see cref="IUIItem.Enter"/>
        /// </summary>
        public virtual void Enter(string value)
        {
            var pattern = Pattern(ValuePattern.Pattern) as ValuePattern;

            if (pattern != null)
            {
                pattern.SetValue(string.Empty);
            }
            if (string.IsNullOrEmpty(value))
            {
                return;
            }

            actionListener.ActionPerformed(Action.WindowMessage);
            EnterData(value);
        }
Пример #7
0
 public void Click(Point click)
 {
     if (Position.Contains(click))
     {
         mListener?.ActionPerformed();
         Background = Color.Aqua;
     }
 }
Пример #8
0
 protected virtual void Scroll(ScrollAmount amount)
 {
     if (!IsScrollable)
     {
         return;
     }
     ScrollPattern.ScrollVertical(amount);
     actionListener.ActionPerformed(Action.Scroll);
 }
 protected virtual void Scroll(ScrollAmount amount)
 {
     if (!IsScrollable)
     {
         return;
     }
     ScrollPattern.ScrollHorizontal(amount);
     actionListener.ActionPerformed(Action.WindowMessage);
 }
Пример #10
0
 protected virtual void Scroll(ScrollAmount amount)
 {
     if (!IsScrollable)
     {
         return;
     }
     ScrollPattern.Scroll(0, amount);
     actionListener.ActionPerformed(Action.Scroll);
     throw new InvalidOperationException("Verifyu this (amount vs value)");
 }
Пример #11
0
 protected virtual void Scroll(ScrollAmount amount)
 {
     if (!IsScrollable)
     {
         return;
     }
     ScrollPattern.Scroll(amount, 0);
     actionListener.ActionPerformed(Action.WindowMessage);
     throw new InvalidOperationException("Verify the above, we scroll by enum value instead of actula value?");
 }
Пример #12
0
        public virtual void Send(string keysToType, IActionListener actionListener)
        {
            if (heldKeys.Count > 0)
            {
                keysToType = keysToType.ToLower();
            }

            CapsLockOn = false;
            foreach (char c in keysToType)
            {
                short key = VkKeyScan(c);
                if (c.Equals('\r'))
                {
                    continue;
                }

                if (ShiftKeyIsNeeded(key))
                {
                    SendKeyDown((short)KeyboardInput.SpecialKeys.SHIFT, false);
                }
                if (CtrlKeyIsNeeded(key))
                {
                    SendKeyDown((short)KeyboardInput.SpecialKeys.CONTROL, false);
                }
                if (AltKeyIsNeeded(key))
                {
                    SendKeyDown((short)KeyboardInput.SpecialKeys.ALT, false);
                }
                Press(key, false);
                if (ShiftKeyIsNeeded(key))
                {
                    SendKeyUp((short)KeyboardInput.SpecialKeys.SHIFT, false);
                }
                if (CtrlKeyIsNeeded(key))
                {
                    SendKeyUp((short)KeyboardInput.SpecialKeys.CONTROL, false);
                }
                if (AltKeyIsNeeded(key))
                {
                    SendKeyUp((short)KeyboardInput.SpecialKeys.ALT, false);
                }
            }

            actionListener.ActionPerformed(Action.WindowMessage);
        }
Пример #13
0
        /// <summary>
        /// Implements <see cref="IKeyboardWithActionListener.Send(string, IActionListener)"/>
        /// </summary>
        public virtual void Send(string keysToType, IActionListener actionListener)
        {
            if (HeldKeys.Count() > 0)
            {
                keysToType = keysToType.ToLower();
            }

            CapsLockOn = false;
            foreach (var key in from c in keysToType let key = KeyboardWin32.VkKeyScan(c) where !c.Equals('\r') select key)
            {
                if (KeyboardWin32.ShiftKeyIsNeeded(key))
                {
                    SendKeyDown((short)KeyboardInput.SpecialKeys.SHIFT, false);
                }
                if (KeyboardWin32.CtrlKeyIsNeeded(key))
                {
                    SendKeyDown((short)KeyboardInput.SpecialKeys.CONTROL, false);
                }
                if (KeyboardWin32.AltKeyIsNeeded(key))
                {
                    SendKeyDown((short)KeyboardInput.SpecialKeys.ALT, false);
                }
                Press(key, false);
                if (KeyboardWin32.ShiftKeyIsNeeded(key))
                {
                    SendKeyUp((short)KeyboardInput.SpecialKeys.SHIFT, false);
                }
                if (KeyboardWin32.CtrlKeyIsNeeded(key))
                {
                    SendKeyUp((short)KeyboardInput.SpecialKeys.CONTROL, false);
                }
                if (KeyboardWin32.AltKeyIsNeeded(key))
                {
                    SendKeyUp((short)KeyboardInput.SpecialKeys.ALT, false);
                }
            }

            actionListener.ActionPerformed(Action.WindowMessage);
        }
Пример #14
0
 /// <summary>
 /// Implements <see cref="IKeyboardWithActionListener.ActionPerformed(IActionListener)"/>
 /// </summary>
 /// <remarks>
 public virtual void ActionPerformed(IActionListener actionListener)
 {
     actionListener.ActionPerformed(new Action(ActionType.WindowMessage));
 }
Пример #15
0
 /// <summary>
 /// Implements <see cref="IKeyboardWithActionListener.LeaveKey(KeyboardInput.SpecialKeys, IActionListener)"/>
 /// </summary>
 public virtual void LeaveKey(KeyboardInput.SpecialKeys key, IActionListener actionListener)
 {
     SendKeyUp((short)key, true);
     RemoveUsedKey(key);
     actionListener.ActionPerformed(Action.WindowMessage);
 }
Пример #16
0
 /// <summary>
 /// Implements <see cref="IKeyboardWithActionListener.HoldKey(KeyboardInput.SpecialKeys, IActionListener)"/>
 /// </summary>
 public virtual void HoldKey(KeyboardInput.SpecialKeys key, IActionListener actionListener)
 {
     SendKeyDown((short)key, true);
     AddUsedKey(key);
     actionListener.ActionPerformed(Action.WindowMessage);
 }
Пример #17
0
 public virtual void PressSpecialKey(KeyboardInput.SpecialKeys key, IActionListener actionListener)
 {
     Send(key, true);
     actionListener.ActionPerformed(Action.WindowMessage);
 }
Пример #18
0
        public virtual void Send(string keysToType, IActionListener actionListener)
        {
            if (heldKeys.Count > 0) keysToType = keysToType.ToLower();

            CapsLockOn = false;
            foreach (char c in keysToType)
            {
                short key = VkKeyScan(c);
                if (c.Equals('\r')) continue;

                if (ShiftKeyIsNeeded(key)) SendKeyDown((short) KeyboardInput.SpecialKeys.SHIFT, false);
                if (CtrlKeyIsNeeded(key)) SendKeyDown((short) KeyboardInput.SpecialKeys.CONTROL, false);
                if (AltKeyIsNeeded(key)) SendKeyDown((short) KeyboardInput.SpecialKeys.ALT, false);
                Press(key, false);
                if (ShiftKeyIsNeeded(key)) SendKeyUp((short) KeyboardInput.SpecialKeys.SHIFT, false);
                if (CtrlKeyIsNeeded(key)) SendKeyUp((short) KeyboardInput.SpecialKeys.CONTROL, false);
                if (AltKeyIsNeeded(key)) SendKeyUp((short) KeyboardInput.SpecialKeys.ALT, false);
            }

            actionListener.ActionPerformed(Action.WindowMessage);
        }
Пример #19
0
 internal virtual void HoldKey(KeyboardInput.SpecialKeys key, IActionListener actionListener)
 {
     SendKeyDown((short) key, true);
     heldKeys.Add(key);
     actionListener.ActionPerformed(Action.WindowMessage);
 }
Пример #20
0
 public virtual void LeaveKey(KeyboardInput.SpecialKeys key, IActionListener actionListener)
 {
     SendKeyUp((short) key, true);
     heldKeys.Remove(key);
     actionListener.ActionPerformed(Action.WindowMessage);
 }
 private void ActionPerformed()
 {
     actionListener.ActionPerformed(Action.WindowMessage);
 }
Пример #22
0
 private static void ActionPerformed(IActionListener actionListener)
 {
     actionListener.ActionPerformed(new Action(ActionType.WindowMessage));
 }
Пример #23
0
 public void AddLoadSourceListener(IActionListener listener)
 {
     btnLoadSource.Click += (sender, e) =>
     {
         using (var fileDialog = new OpenFileDialog())
         {
             if (fileDialog.ShowDialog() != DialogResult.OK) return;
             listener.ActionPerformed(pictureBoxFilterInput, new MyFileEventArgs(fileDialog.FileName));
         }
     };
 }
Пример #24
0
 /// <summary>
 /// Implements <see cref="IKeyboardWithActionListener.PressSpecialKey(KeyboardInput.SpecialKeys, IActionListener)"/>
 /// </summary>
 public virtual void PressSpecialKey(KeyboardInput.SpecialKeys key, IActionListener actionListener)
 {
     Send(key, true);
     actionListener.ActionPerformed(Action.WindowMessage);
 }
Пример #25
0
 private static void ActionPerformed(IActionListener actionListener)
 {
     actionListener.ActionPerformed(new Action(ActionType.WindowMessage));
 }