Exemple #1
0
 public void ResetItems()
 {
     ALog.Debug("");
     this.StopPlaying();
     this.StopRecording();
     this.Reset();
 }
Exemple #2
0
        private bool IsContinuePlaying()
        {
            ALog.Debug("");
            if (Preference.Instance.RepeatType == RepeatType.Infinite)
            {
                return(true);
            }

            if (Preference.Instance.RepeatType == RepeatType.Count)
            {
                bool isContinue = true;
                Preference.Instance.MainWindow.InvokeIfRequired(() =>
                {
                    if (Preference.Instance.RepeatCountControl.Value <= 0)
                    {
                        isContinue = false;
                    }

                    Preference.Instance.RepeatCountControl.Value--;
                });
                return(isContinue);
            }

            return(false);
        }
Exemple #3
0
        public void StartRecordingWithConfirm()
        {
            ALog.Debug("");

            bool isReset = true;

            if (this.Items.Count > 0)
            {
                MessageBoxResult result = MessageBox.Show("Do you want to reset all of recorder items?", "Question", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }

                if (result == MessageBoxResult.Yes)
                {
                    isReset = true;
                }
                else if (result == MessageBoxResult.No)
                {
                    isReset = false;
                }
            }

            if (isReset)
            {
                this.Reset();
            }

            StartRecording();
        }
    Reduce(IntervalEnvironment < Rational, Expression> left, WeakUpperBounds <Expression,  Rational> right)
    {
        ALog.BeginReduce("IntervalsWithSymbolicUpperBounds");

        foreach (Expression x in left.Keys)
        {
            foreach (Expression y in left.Keys)
            {
                if (x.Equals(y))
                {
                    continue;
                }

                FlatAbstractDomain <bool> b = left.CheckIfLessThan(x, y);

                if (b.IsTop || b.IsBottom)
                {
                    continue;
                }

                if (b.BoxedElement == true)
                {
                    ALog.Message("Adding " + ExpressionPrinter <Expression> .ToString(x, this.decoder) + " < " + ExpressionPrinter <Expression> .ToString(y, this.decoder)
                                 + " as " + left.BoundsFor(x) + " < " + left.BoundsFor(y));

                    right.TestTrueLessThan(x, y); // Add the constraint x < y
                }
            }
        }

        ALog.EndReduce();

        return(this.Factory(left, right));
    }
Exemple #5
0
 public void PauseRecording()
 {
     ALog.Debug("");
     this.State = ESRState.RecordingPause;
     this.WaitingRecorder.Stop();
     OnStopRecording();
 }
        public bool Start()
        {
            if (this.IsThreadEnable)
            {
                return(false);
            }

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

                this.IsThreadEnable   = true;
                const double waitTime = 0.02f; // 20 mesc
                while (!token.IsCancellationRequested)
                {
                    double startTime = Stopwatch.GetTimestamp();
                    if (this.CurrentWaitingTimeSec >= this.WaitingTimeSec)
                    {
                        AddWaitingRecorderItem(this.CurrentWaitingTimeSec);
                    }

                    Thread.Sleep((int)(waitTime * 1000));
                    this.CurrentWaitingTimeSec += (((double)Stopwatch.GetTimestamp() - startTime) / (double)Stopwatch.Frequency);
                }

                AddWaitingRecorderItem(this.CurrentWaitingTimeSec);
            }), this.CancelToken.Token);
            ALog.Debug("Start WaitingRecorder ThreadPool");
            return(true);
        }
Exemple #7
0
        public void AssignInParallel(IDictionary <Expression, Microsoft.Research.DataStructures.FList <Expression> > sourcesToTargets)
        {
            intv.AssignInParallel(sourcesToTargets);

            // Do the renamings
            foreach (Expression source in sourcesToTargets.Keys)
            {
                {
                    if (sourcesToTargets[source].Length() == 1)
                    { // we want to just follow the renamings, all the rest is not interesting and we discard it
                        Expression target = sourcesToTargets[source].Head;
                        // source -> target ,  i.e. the new name for "source" is "target"

                        ALog.Message(StringClosure.For("Renaming {0} to {1}", ExpressionPrinter.ToStringClosure(source, decoder), ExpressionPrinter.ToStringClosure(target, decoder)));

                        embedded = UnderlyingPolyhedra.Rename(embedded, Converter.BoxAsVariable(source, decoder), Converter.BoxAsVariable(target, decoder));
                    }
                }
            }
#if true || MOREPRECISE
            // else we want to keep track of constants

            foreach (Expression x in intv.Variables)
            {
                Interval value = intv.BoundsFor(x);
                {
                    this.AssignIntervalJustInPolyhedra(x, value);
                }
            }
#endif
        }
Exemple #8
0
        private void buttonPlay_Click(object sender, RoutedEventArgs e)
        {
            ALog.Debug("");
            bool isReset = this.Recorder.State != ESRState.PlayingPause;

            this.Recorder.StartPlaying(isReset);
        }
Exemple #9
0
        public void MouseInput(EventHook.MouseEventArgs e)
        {
            if (e.Message == GetMouseMessages())
            {
                if (this.IsIgnoreMouseRecorder)
                {
                    this.RemainedIgnoreMouseButtonDownCount--;
                    if (this.RemainedIgnoreMouseButtonDownCount >= 0)
                    {
                        ALog.Debug("MouseWatcher::IsIgnoreMouseRecorder is true!");
                        return;
                    }
                }

                this.IsIgnoreMouseRecorder = true;
                this.RemainedIgnoreMouseButtonDownCount = Preference.Instance.DragClickNumberOfClicks;
                new Thread(() => {
                    for (int i = 0; i < Preference.Instance.DragClickNumberOfClicks; i++)
                    {
                        GM.Instance.InputSimulator.Mouse.RightButtonClick();
                        Thread.Sleep(Preference.Instance.DragClickClickTimeIntervalMsec);
                    }
                }).Start();
            }
        }
Exemple #10
0
 private void OnPushKey(VirtualKeyCode key)
 {
     ALog.Debug("VirtualKeyCode={0}", key.ToString());
     if (key == VirtualKeyCode.DELETE && AUtil.IsStop(this.Recorder.State))
     {
         DeleteKey();
     }
 }
Exemple #11
0
 public void StartPlaying(bool isReset)
 {
     ALog.Debug("IsReset={0}", isReset);
     if (isReset)
     {
         ResetToStart();
     }
     StartPlaying();
 }
Exemple #12
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);
        }
Exemple #13
0
        public void ResetToStart()
        {
            ALog.Debug("");
            if (!AUtil.IsStopPause(this.State))
            {
                return;
            }

            this.Player.ResetToStart();
        }
Exemple #14
0
        public bool StartPlaying(List <IRecorderItem> items)
        {
            if (items.Count <= 0)
            {
                ALog.Debug("ESRRecorder::StartPlaying::Item's count is 0.");
                return(false);
            }

            ALog.Debug("");
            this.State = ESRState.Playing;
            this.Player.Start(items);
            return(true);
        }
Exemple #15
0
 private void OnRecording()
 {
     ALog.Debug("State={0}", this.Recorder.State);
     if (AUtil.IsStopPause(this.Recorder.State))
     {
         bool isReset = this.Recorder.State != ESRState.RecordingPause;
         this.Recorder.StartRecording();
     }
     else
     {
         this.Recorder.PauseAll();
     }
 }
Exemple #16
0
        public void Initialize(ESRRecorder recorder)
        {
            ALog.Debug("");
            this.Recorder = recorder;

            this.Recorder.OnChangedState += (state) =>
            {
                this.InvokeIfRequired(() =>
                {
                    EnableToolbarButton(state);
                });
            };
        }
Exemple #17
0
        public static Task.BaseInfo Get(int id, int childid)
        {
            DailyTaskData data = Get(id);

            if (data != null && data.taskList.Count >= childid)
            {
                return(data.taskList[childid - 1]);
            }
            else
            {
                ALog.logError(string.Format("Daily Task Error: doesnt has ID:{0},childID:{1}!", id, childid));
            }
            return(null);
        }
Exemple #18
0
    public void UpdateItem(t_ObjectProto item)
    {
        int index = mItemList.FindIndex((t_ObjectProto si) => { return(si.qwThisID == item.qwThisID); });

        if (index != -1)
        {
            mItemList.RemoveAt(index);
            mItemList.Add(item);
        }
        else
        {
            string error = "道具不存在: " + item.dwObjectID.ToString() + " X:" + item.pos.x.ToString();
            ALog.logWarning(error);
        }
    }
Exemple #19
0
    public GeneralInfo GetGeneralInfo(int idx)
    {
        int         index = generals.FindIndex((info) => info.id == idx);
        GeneralInfo inf   = null;

        try
        {
            inf = generals[index];
        }
        catch (Exception)
        {
            ALog.logWarning("DungeonMgr=> Error General ID: " + idx.ToString());
        }
        return(inf);
    }
                /// <summary>
                /// Hypothesis: Bound Analysis assumed that <code>0 &le; len </code> and
                /// </summary>
                /// <param name="dest"></param>
                private SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> HandleAllocations(APC pc, Variable dest, Variable len, SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> data)
                {
                    var lenAsExp = BoxedExpression.For(this.Context.Refine(pc, len), this.Decoder.Outdecoder);

                    lenAsExp = this.Decoder.Stripped(lenAsExp);
                    var destAsExp = BoxedExpression.For(this.Context.Refine(pc, dest), this.Decoder.Outdecoder);

                    ALog.BeginTransferFunction(StringClosure.For("[P]Allocation"),
                                               ExpressionPrinter.ToStringClosure(lenAsExp, this.Decoder), PrettyPrintPC(pc), StringClosure.For(data));

                    var refinedDomain = data.Allocation(new BoxedVariable <Variable>(dest), lenAsExp);

                    ALog.EndTransferFunction(StringClosure.For(data));

                    return(refinedDomain);
                }
        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!");
        }
Exemple #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);
        }
Exemple #23
0
        public static DungeonWar Get(int id)
        {
            DungeonWar war = null;

            if (!dataMap.TryGetValue(id, out war))
            {
                string filepath = "data/xml/dugeonWar/section_" + id.ToString();
                war = AResource.LoadXML <DungeonWar>(filepath);
                if (war != null)
                {
                    dataMap.Add(id, war);
                }
                else
                {
                    ALog.logError(filepath + " doesnot exist!");
                }
            }

            return(war);
        }
Exemple #24
0
        public static Property GetProperty(int type, int star, int lv)
        {
            try
            {
                SoldierPropertyData d = Get(type);
                if (d != null)
                {
                    StarProperty sp = d.props[star - 1];
                    if (sp != null)
                    {
                        return(sp.lvPropertys[lv - 1]);
                    }
                }
            }
            catch (Exception exc)
            {
                ALog.error(exc.Message);
            }

            return(null);
        }
Exemple #25
0
    public override void unserialize(MemoryStream stream)
    {
        base.unserialize(stream);

        byte[] bmessageid = new byte[4];
        stream.Read(bmessageid, 0, 4);
        messageid = BitConverter.ToUInt32(bmessageid, 0);

        byte[] bsize = new byte[4];
        stream.Read(bsize, 0, 4);
        size = BitConverter.ToUInt32(bsize, 0);
        try
        {
            data = new byte[size];
            stream.Read(data, 0, (int)size);
        }
        catch (Exception ex)
        {
            ALog.logError(ex.Message);
        }
    }
Exemple #26
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);
        }
                /// <summary>
                /// Here we catch the calls to methods of String, so that we can apply operations on string, as concatenations. etc.
                /// </summary>
                public override SimpleStringAbstractDomain <BoxedExpression> Call <TypeList, ArgList>(APC pc, Method method, bool tail, bool virt, TypeList extraVarargs, Variable dest, ArgList args, SimpleStringAbstractDomain <BoxedExpression> data)
                // where ArgList : IIndexable<int>
                {
                    string methodName = this.DecoderForMetaData.FullName(method);

                    ALog.BeginTransferFunction(StringClosure.For("call"), StringClosure.For(methodName),
                                               StringClosure.For(pc), StringClosure.For(data));

                    SimpleStringAbstractDomain <BoxedExpression> result;
                    SimpleStringAbstractDomain <BoxedExpression> baseResult = base.Call <TypeList, ArgList>(pc, method, tail, virt, extraVarargs, dest, args, data);

                    if (IsACallToString(methodName))
                    {
                        result = HandleCallToString(pc, methodName, dest, args, baseResult);
                    }
                    else
                    {
                        result = baseResult;
                    }

                    ALog.EndTransferFunction(StringClosure.For(result));

                    return(result);
                }
Exemple #28
0
 private void OnDragClickStart()
 {
     ALog.Debug("OnDragClickStart={0}", this.Recorder.State);
     this.Recorder.StartDragClick();
 }
 internal static LogInformation ToLogInfo(ALog log)
 {
     return new LogInformation
     {
         Desc = log.Desc,
         OperTime = log.OperTime,
         UType = (UserTypeInfo)log.UType,
         Account = log.Account,
     };
 }
Exemple #30
0
 public void Initialize(ESRRecorder recorder)
 {
     ALog.Debug("");
     this.Recorder = recorder;
 }
        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);
        }