public bool ShowModifyConfigWindow(IRecorderItem prevItem)
        {
            if (prevItem == null)
            {
                return(false);
            }

            IRecorderItemConfig config = CreateRecorderItemConfig(prevItem);

            config.RecorderItem = prevItem.Copy();
            Window window = config as Window;

            window.Owner = GM.Instance.MainWindow;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            if (window.ShowDialog() == false)
            {
                return(false);
            }

            IRecorderItem modifiedItem = config.RecorderItem.Copy();

            if (OnReplaceItem != null)
            {
                OnReplaceItem(prevItem, modifiedItem);
            }

            return(true);
        }
        private IRecorderItemConfig CreateRecorderItemConfig(IRecorderItem item)
        {
            IRecorderItemConfig recorderItemConfig = null;

            switch (item.Recorder)
            {
            case RecorderType.WaitSmart: recorderItemConfig = new WaitingTimeRecorderItemConfig(); break;

            case RecorderType.WaitTime: recorderItemConfig = new WaitingTimeRecorderItemConfig(); break;

            case RecorderType.MouseClick: recorderItemConfig = new MouseClickRecorderItemConfig(); break;

            case RecorderType.MouseUpDown: recorderItemConfig = new MouseUpDownRecorderItemConfig(); break;

            case RecorderType.MouseSmartClick: recorderItemConfig = new MouseUpDownRecorderItemConfig(); break;

            case RecorderType.MouseMove: recorderItemConfig = new MouseMoveRecorderItemConfig(); break;

            case RecorderType.MouseWheel: recorderItemConfig = new MouseWheelRecorderItemConfig(); break;

            case RecorderType.KeyUpDown: recorderItemConfig = new KeyUpDownRecorderItemConfig(); break;

            case RecorderType.KeyPress: recorderItemConfig = new KeyPressRecorderItemConfig(); break;
            }
            return(recorderItemConfig);
        }
Esempio n. 3
0
        public bool DeleteItem(IRecorderItem item)
        {
            if (item == null)
            {
                return(false);
            }

            //check is this last item
            if (!IsFirstItem(item))
            {
                int           removedItemIndex = this.Items.IndexOf(item);
                IRecorderItem prevItem         = this.Items[removedItemIndex - 1];
                TimeSpan      decreaseTime     = GetTimeSpan(item as AbsRecorderItem, prevItem as AbsRecorderItem);

                //Adjust a timestamp in remained items
                AdjustTimeSpanbyItem(item, decreaseTime);
            }

            this.Items.Remove(item);
            ResetCurrentRecorderbyLast();

            if (OnDeleteItem != null)
            {
                OnDeleteItem(item);
            }

            return(true);
        }
Esempio n. 4
0
        public double WaitingPlaying(IRecorderItem item)
        {
            if (this.LastItem == null)
            {
                this.LastItem = item;
            }

            double timeSec = (item.Time - this.LastItem.Time).TotalSeconds + this.LastItem.ResidualTimeSec;

            if (timeSec < 0)
            {
                timeSec = 0;
            }

            double startTime = Stopwatch.GetTimestamp();

            while (true)
            {
                if (timeSec <= (((double)Stopwatch.GetTimestamp() - startTime) / (double)Stopwatch.Frequency))
                {
                    break;
                }

                if (timeSec > AUtil.SimulatorMiniumSleepTimeSec)
                {
                    Thread.Sleep(1);
                }
            }
            this.LastItem = item;
            this.LastItem.ResidualTimeSec = timeSec - (((double)Stopwatch.GetTimestamp() - startTime) / (double)Stopwatch.Frequency);
            return(timeSec);
        }
        public void ShowModifyMemoWindow(IRecorderItem prevItem)
        {
            if (prevItem == null)
            {
                return;
            }

            IRecorderItemConfig config = new RecorderItemMemoConfig();

            config.RecorderItem = prevItem.Copy();
            Window window = config as Window;

            window.Owner = GM.Instance.MainWindow;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            if (window.ShowDialog() == false)
            {
                return;
            }

            IRecorderItem modifiedItem = config.RecorderItem.Copy();

            if (OnReplaceItem != null)
            {
                OnReplaceItem(prevItem, modifiedItem);
            }
        }
Esempio n. 6
0
 public void UpdateItem(IRecorderItem item)
 {
     //Do not call ResetWaitingTime()
     if (OnUpdateItem != null)
     {
         OnUpdateItem(item);
     }
 }
Esempio n. 7
0
        public bool Start(List <IRecorderItem> items)
        {
            if (items.Count <= 0)
            {
                ALog.Debug("Playing item is 0.");
                return(false);
            }

            Stop();

            ResetLastItem();

            this.CancelToken = new CancellationTokenSource();
            ThreadPool.QueueUserWorkItem(new WaitCallback((obj) =>
            {
                CancellationToken token = (CancellationToken)obj;

                this.IsThreadEnable = true;
                bool isLastStep     = false;
                if (OnStartPlaying != null)
                {
                    OnStartPlaying();
                }

                this.CurrentRecorder = items.First();
                while (!token.IsCancellationRequested)
                {
                    if (!this.CurrentRecorder.Play(this))
                    {
                        break;
                    }

                    if (IsLastStep(items))
                    {
                        if (IsContinuePlaying())
                        {
                            this.CurrentRecorder = items.First();
                            continue;
                        }
                        isLastStep = true;
                        break;
                    }

                    if (!NextStep(items))
                    {
                        break;
                    }
                }

                if (OnStopPlaying != null)
                {
                    OnStopPlaying(isLastStep);
                }
            }), this.CancelToken.Token);
            ALog.Debug("Start Playing ThreadPool");
            return(true);
        }
Esempio n. 8
0
        public void AddKeyItem(IRecorderItem item)
        {
            if (item == null)
            {
                return;
            }

            this.CurrentKeyRecorder = item;
            AddItem(item);
        }
Esempio n. 9
0
        public void AddMouseItem(IRecorderItem item)
        {
            if (item == null)
            {
                return;
            }

            this.CurrentMouseRecorder = item;
            AddItem(item);
        }
Esempio n. 10
0
        private bool IsCurrentMouseWheelDir(IRecorderItem newRecorderItem)
        {
            if (this.CurrentRecorder?.Recorder == RecorderType.MouseWheel &&
                this.CurrentRecorder.Dir == newRecorderItem.Dir)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 11
0
        private bool IsSameKeyCodeAndWithInIntervalTime(IRecorderItem item, KeyInputEventArgs e)
        {
            IKeyRecorderItem keyItem = item as IKeyRecorderItem;

            if (keyItem.VkCode == e.KeyData.VkCode &&
                (DateTime.Now - item.Time).TotalSeconds < this.KeyPressIntervalTimeSec)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
        public void Add(ApplicationEventArgs e)
        {
            IRecorderItem newRecorder = null;

            newRecorder = new ApplicationRecorderItem()
            {
                ApplicationData = e.ApplicationData,
                Event           = e.Event,
            };

            this.ESRRecorder.AddItem(newRecorder);
            this.ESRRecorder.CurrentRecorder = newRecorder;
        }
Esempio n. 13
0
        private void MenuItem_NewKeyPressItem_Click(object sender, RoutedEventArgs e)
        {
            IRecorderItem newItem = this.RecorderItemConfigManager.ShowNewConfigWindow(new KeyPressRecorderItem()
            {
                Time = GetNewItemTime() + TimeSpan.FromSeconds(ESRRecorder.MinimumTimeSpan)
            });

            if (newItem == null)
            {
                return;
            }

            this.Recorder.InsertItem(this.RecorderListView.SelectedItem as IRecorderItem, newItem);
        }
Esempio n. 14
0
        private bool IsCurrentSingleMouseMove(IRecorderItem newItem)
        {
            if (newItem.Recorder == RecorderType.MouseMove)
            {
                return(false);
            }

            if (this.CurrentRecorder?.Recorder == RecorderType.MouseMove &&
                this.CurrentRecorder.ChildItems.Count <= 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 15
0
        private void ReplaceKeyDownToKeyPress(IRecorderItem item)
        {
            IKeyRecorderItem keyItem = item as IKeyRecorderItem;
            IRecorderItem    newItem = new KeyPressRecorderItem()
            {
                Dir              = Dir.Press,
                VkCode           = keyItem.VkCode,
                Keyname          = keyItem.Keyname,
                UnicodeCharacter = keyItem.UnicodeCharacter,
                ModifierKeys     = keyItem.ModifierKeys
            };

            this.ESRRecorder.ReplaceItem(item, newItem);
        }
Esempio n. 16
0
        public void AddItem(IRecorderItem item)
        {
            if (item == null)
            {
                return;
            }

            ResetWaitingTime();
            this.CurrentRecorder = item;
            this.Items.Add(item);
            if (OnAddItem != null)
            {
                OnAddItem(item);
            }
        }
Esempio n. 17
0
        private bool IsIgnoreMouseMove(IRecorderItem item)
        {
            MouseMoveRecorderItem mouseItem = item as MouseMoveRecorderItem;

            Trace.Assert(mouseItem != null, "IsIgnoreMouseMove::mouseItem is null");
            if (this.CurrentRecorder?.Recorder == RecorderType.MouseWheel ||
                this.CurrentRecorder?.Recorder == RecorderType.MouseMove ||
                this.CurrentRecorder?.Recorder == RecorderType.MouseClick)
            {
                if (mouseItem.Point == this.CurrentRecorder?.Point)
                {
                    return(true);
                }
            }
            return(false);
        }
        public IRecorderItem ShowNewConfigWindow(IRecorderItem item)
        {
            IRecorderItemConfig config = CreateRecorderItemConfig(item);

            config.RecorderItem = item.Copy();
            Window window = config as Window;

            window.Owner = GM.Instance.MainWindow;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            if (window.ShowDialog() == false)
            {
                return(null);
            }

            return(config.RecorderItem.Copy());
        }
Esempio n. 19
0
        private void AdjustTimeSpanbyItem(IRecorderItem item, TimeSpan decreaseTime)
        {
            if (IsLastItem(item) || decreaseTime.TotalSeconds == 0)
            {
                return;
            }

            int startIndex = this.Items.IndexOf(item);

            //Adjust a timestamp in remained items
            for (int i = startIndex + 1; i < this.Items.Count; i++)
            {
                AbsRecorderItem recorderItem = this.Items[i] as AbsRecorderItem;
                recorderItem.AdjustTimeSpan(decreaseTime);
            }
        }
Esempio n. 20
0
        public void DeleteSelectedItems()
        {
            if (this.RecorderListView.SelectedItems == null || this.RecorderListView.SelectedItems.Count <= 0)
            {
                return;
            }

            this.Recorder.Player.ResetLastItem();

            List <IRecorderItem> deleteItems = new List <IRecorderItem>();

            foreach (var i in this.RecorderListView.SelectedItems)
            {
                IRecorderItem item = i as IRecorderItem;
                deleteItems.Add(item);
            }
            this.Recorder.DeleteItem(deleteItems);
        }
Esempio n. 21
0
        private void AddWaitingRecorderItem(double waitingTimeSec)
        {
            IRecorderItem newRecorder = null;

            newRecorder = new WaitTimeRecorderItem()
            {
                WaitingTimeSec = waitingTimeSec,
            };

            if (this.CurrentRecorder?.IsEqualType(newRecorder) == true)
            {
                this.CurrentRecorder.ChildItems.Add(newRecorder);
                this.ESRRecorder.UpdateItem(this.CurrentRecorder);
                return;
            }

            this.ESRRecorder.AddItem(newRecorder);
            ALog.Debug("Add Waiting Event!");
        }
Esempio n. 22
0
        public bool ReplaceItem(IRecorderItem oldItem, IRecorderItem newItem)
        {
            int index = this.Items.IndexOf(oldItem);

            if (index < 0 || index >= this.Items.Count)
            {
                ALog.Debug("ReplaceItem::Index is invalide!(Index={0})", index);
                return(false);
            }

            ResetWaitingTime();
            this.CurrentRecorder = newItem;
            this.Items[index]    = newItem;
            if (OnReplaceItem != null)
            {
                OnReplaceItem(oldItem, newItem);
            }

            return(true);
        }
Esempio n. 23
0
        private bool NextStep(List <IRecorderItem> items)
        {
            int index = items.IndexOf(this.CurrentRecorder);

            if (index == -1)
            {
                ALog.Debug("ESRPlayer::index not found.");
                return(false);
            }

            if (index >= items.Count - 1)
            {
                ALog.Debug("ESRPlayer::Current index is last index");
                return(false);
            }

            index++;
            ALog.Debug($"ESRPlayer::Current index is {index}");
            this.CurrentRecorder = items[index];
            return(true);
        }
Esempio n. 24
0
        public bool InsertItem(IRecorderItem prevItem, IRecorderItem newItem)
        {
            int startIndex = -1;

            if (prevItem != null)
            {
                startIndex = this.Items.IndexOf(prevItem);
            }

            this.Items.Insert(startIndex + 1, newItem);
            if (OnInsertItem != null)
            {
                OnInsertItem(prevItem, newItem);
            }

            TimeSpan increaseTimeSec = TimeSpan.FromSeconds(newItem.TotalTimeDurationSec);

            for (int i = startIndex + 1; i < this.Items.Count; i++)
            {
                AbsRecorderItem recorderItem = this.Items[i] as AbsRecorderItem;
                recorderItem.AdjustTimeSpan(increaseTimeSec);
            }
            return(true);
        }
Esempio n. 25
0
 public void ResetToStart()
 {
     this.CurrentRecorder = this.ESRRecorder.Items.First();
 }
Esempio n. 26
0
 public bool IsEqualType(IRecorderItem item)
 {
     return(this.Recorder == item?.Recorder);
 }
Esempio n. 27
0
 public bool IsSameRecorderType(IRecorderItem item)
 {
     return(this.Recorder == item.Recorder);
 }
Esempio n. 28
0
        public void Add(KeyInputEventArgs e)
        {
            IRecorderItem newRecorder = null;

            if (e.KeyData.EventType == KeyEvent.up)
            {
                if (IsIncludedKeyItem(e))
                {
                    ALog.Debug("KeyEvent.Up.IsIncludedKeyItem == true");
                    return;
                }

                IRecorderItem prevRecorder = GetPrviousKeyDownItem(e);
                if (prevRecorder != null)
                {
                    //Delete Previous Key up Items
                    ALog.Debug("Delete Items::Recorder={0}, VkCode={1}", prevRecorder.Recorder, AUtil.ToVKeyToString((prevRecorder as IKeyRecorderItem).VkCode));
                    this.ESRRecorder.DeleteItem(prevRecorder);

                    //New Key Press
                    this.ESRRecorder.ResetCurrentRecorderbyLast();
                    newRecorder = new KeyPressRecorderItem()
                    {
                        Dir              = Dir.Press,
                        VkCode           = e.KeyData.VkCode,
                        Keyname          = e.KeyData.Keyname,
                        UnicodeCharacter = e.KeyData.UnicodeCharacter,
                        ModifierKeys     = Control.ModifierKeys
                    };

                    //If Current Is KeyPress, this KeyPress add into ChildItem
                    if (this.CurrentRecorder?.Recorder == RecorderType.KeyPress)
                    {
                        ALog.Debug("Add KeyPress into KeyPress.ChildItem");
                        this.ESRRecorder.ResetWaitingTime();
                        this.CurrentRecorder.ChildItems.Add(newRecorder);
                        this.ESRRecorder.UpdateItem(this.CurrentRecorder);
                        return;
                    }
                }
                else
                {
                    ALog.Debug("KeyUp Item");
                    newRecorder = new KeyUpDownRecorderItem()
                    {
                        Dir              = Dir.Up,
                        VkCode           = e.KeyData.VkCode,
                        Keyname          = e.KeyData.Keyname,
                        UnicodeCharacter = e.KeyData.UnicodeCharacter,
                        ModifierKeys     = Control.ModifierKeys
                    };
                }
            }
            else
            {
                //it's state on pressing key
                if (IsLastSameKeyDown(e.KeyData.VkCode))
                {
                    ALog.Debug("KeyEvent.Down, IsLastKeyDown: True");
                    return;
                }

                //If current is KeyPress, Add a item into ChildItem
                if (IsCurrentKeyPress() && !IsCtrlAltShift(e.KeyData.VkCode) && !IsCtrlAltShift(Control.ModifierKeys))
                {
                    //New Key Press
                    this.ESRRecorder.ResetCurrentRecorderbyLast();
                    newRecorder = new KeyPressRecorderItem()
                    {
                        Dir              = Dir.Press,
                        VkCode           = e.KeyData.VkCode,
                        Keyname          = e.KeyData.Keyname,
                        UnicodeCharacter = e.KeyData.UnicodeCharacter,
                        ModifierKeys     = Control.ModifierKeys
                    };

                    this.ESRRecorder.ResetWaitingTime();
                    this.CurrentRecorder.ChildItems.Add(newRecorder);
                    this.ESRRecorder.UpdateItem(this.CurrentRecorder);
                    return;
                }

                //If Current is Key Down, It means continuosly 2 item's Type is KeyDown.
                //So that, 1) Replace Previous KeyDown item to KeyPress
                //         2) Add a this time KeyDown item into Child Item
                if (IsCurrentKeyDown() && !IsCtrlAltShift(e.KeyData.VkCode) && !IsCtrlAltShift(Control.ModifierKeys))
                {
                    ReplaceKeyDownToKeyPress(this.CurrentRecorder);

                    //New Key Press
                    this.ESRRecorder.ResetCurrentRecorderbyLast();
                    newRecorder = new KeyPressRecorderItem()
                    {
                        Dir              = Dir.Press,
                        VkCode           = e.KeyData.VkCode,
                        Keyname          = e.KeyData.Keyname,
                        UnicodeCharacter = e.KeyData.UnicodeCharacter,
                        ModifierKeys     = Control.ModifierKeys
                    };

                    this.ESRRecorder.ResetWaitingTime();
                    this.CurrentRecorder.ChildItems.Add(newRecorder);
                    this.ESRRecorder.UpdateItem(this.CurrentRecorder);
                    return;
                }

                //New Key Down
                newRecorder = new KeyUpDownRecorderItem()
                {
                    Dir              = Dir.Down,
                    VkCode           = e.KeyData.VkCode,
                    Keyname          = e.KeyData.Keyname,
                    UnicodeCharacter = e.KeyData.UnicodeCharacter,
                    ModifierKeys     = Control.ModifierKeys
                };
            }

            this.ESRRecorder.AddKeyItem(newRecorder);
        }
Esempio n. 29
0
        public void Add(MouseEventArgs e)
        {
            IRecorderItem newRecorder = null;

            if (e.Message == MouseMessages.WM_MOUSEWHEEL)
            {
                newRecorder = new MouseWheelRecorderItem()
                {
                    Dir       = ((int)e.MouseData) > 0 ? Dir.Up : Dir.Down,
                    Point     = new System.Windows.Point(e.Point.x, e.Point.y),
                    MouseData = (int)e.MouseData,
                };

                if (IsCurrentMouseWheelDir(newRecorder))
                {
                    this.WaitingRecorder.ResetWaitingTime();
                    this.CurrentRecorder.ChildItems.Add(newRecorder);
                    this.ESRRecorder.UpdateItem(this.CurrentRecorder);
                    return;
                }
            }
            else if (e.Message == MouseMessages.WM_LBUTTONDOWN ||
                     e.Message == MouseMessages.WM_RBUTTONDOWN ||
                     e.Message == MouseMessages.WM_WHEELBUTTONDOWN)
            {
                if (IsLastMouseDown())
                {
                    return;
                }

                if (IsMouseButtonPress())
                {
                    newRecorder = new MouseClickRecorderItem()
                    {
                        Button    = ToButtonType(e.Message),
                        Point     = new System.Windows.Point(e.Point.x, e.Point.y),
                        MouseData = (int)e.MouseData,
                    };

                    this.ESRRecorder.ResetWaitingTime();
                    this.CurrentMouseRecorder.ChildItems.Add(newRecorder);
                    this.ESRRecorder.UpdateItem(this.CurrentMouseRecorder);
                    return;
                }

                newRecorder = new MouseUpDownRecorderItem()
                {
                    Dir       = Dir.Down,
                    Button    = ToButtonType(e.Message),
                    Point     = new System.Windows.Point(e.Point.x, e.Point.y),
                    MouseData = (int)e.MouseData,
                };
            }
            else if (e.Message == MouseMessages.WM_LBUTTONUP ||
                     e.Message == MouseMessages.WM_RBUTTONUP ||
                     e.Message == MouseMessages.WM_WHEELBUTTONUP)
            {
                if (IsMouseButtonPress())
                {
                    ALog.Debug("MouseEvent.Up, IsMouseButtonPress: True");
                    if (IsCurrentMouseClick())
                    {
                        return;
                    }

                    //Remove MouseDown item
                    this.ESRRecorder.DeleteItem(this.CurrentMouseRecorder);
                    this.ESRRecorder.ResetCurrentRecorderbyLast();

                    newRecorder = new MouseClickRecorderItem()
                    {
                        Button    = ToButtonType(e.Message),
                        Point     = new System.Windows.Point(e.Point.x, e.Point.y),
                        MouseData = (int)e.MouseData,
                    };
                }
                else
                {
                    newRecorder = new MouseUpDownRecorderItem()
                    {
                        Dir       = Dir.Up,
                        Button    = ToButtonType(e.Message),
                        Point     = new System.Windows.Point(e.Point.x, e.Point.y),
                        MouseData = (int)e.MouseData,
                    };
                }
            }
            else if (e.Message == MouseMessages.WM_MOUSEMOVE)
            {
                newRecorder = new MouseMoveRecorderItem()
                {
                    Point     = new System.Windows.Point(e.Point.x, e.Point.y),
                    MouseData = (int)e.MouseData,
                };

                if (IsIgnoreMouseMove(newRecorder))
                {
                    ALog.Debug("ESRMouseRecorder::Add(MouseEvent)::IsIgnoreMouseMove");
                    return;
                }

                if (IsCurrentMouseMove())
                {
                    this.WaitingRecorder.ResetWaitingTime();
                    this.CurrentMouseRecorder.ChildItems.Add(newRecorder);
                    this.ESRRecorder.UpdateItem(this.CurrentMouseRecorder);
                    return;
                }
            }

            //Need to delete Unnecessary a mouse move item
            if (IsCurrentSingleMouseMove(newRecorder))
            {
                this.ESRRecorder.DeleteItem(this.CurrentRecorder);
            }

            this.ESRRecorder.AddMouseItem(newRecorder);
        }
Esempio n. 30
0
        private bool IsCtrlAltShift(IRecorderItem item)
        {
            IKeyRecorderItem keyItem = item as IKeyRecorderItem;

            return(IsCtrlAltShift(keyItem.VkCode));
        }