private void LlenarComboBoxs()
 {
     DelayComboBox.ItemsSource            = Delays;
     DelayComboBox.SelectedValue          = Delays.FirstOrDefault();
     ModoRepeticionComboBox.ItemsSource   = ModoRepeticion;
     ModoRepeticionComboBox.SelectedValue = ModoRepeticion.FirstOrDefault();
 }
        protected override void DialogOkClicked(object o)
        {
            if (settingsService.SkillCastSettings.SkillCastConfigurations.Any(x => x.Name == Name && x != CurrentConfiguration))
            {
                messageBoxService.ShowOK(this, "Profile with name exists", $"There already is a profile named {Name}. Pick a different name.");

                return;
            }

            CurrentConfiguration.Name         = Name;
            CurrentConfiguration.Delays       = new Dictionary <int, int>();
            CurrentConfiguration.SkillIndices = new List <int>();

            var arr = Delays.ToArray();

            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] > 0)
                {
                    CurrentConfiguration.Delays[i] = arr[i];
                    CurrentConfiguration.SkillIndices.Add(i);
                }
            }

            DialogResult = true;
        }
Пример #3
0
 /// <exception cref="NumberFormatException"></exception>
 private void ProcessResultsFiles(string resultsFile1, string resultsFile2)
 {
     Sysout("Delaying:");
     try
     {
         DelayCalculation calculation = new DelayCalculation(resultsFile1, resultsFile2);
         calculation.ValidateData();
         if (!calculation.IsValidData())
         {
             ExitWithError("> Result files are invalid for delaying!");
         }
         _delays = calculation.CalculatedDelays();
         Sysout("> Required delays:");
         Sysout("> " + _delays);
         Sysout("> Adjusting delay timer to match required delays...");
         calculation.AdjustDelays(_delays);
         Sysout("> Adjusted delays:");
         Sysout("> " + _delays);
     }
     catch (IOException)
     {
         ExitWithError("> Could not open results file(s)!\n" + "> Please check the file name settings in IoBenchmark.properties."
                       );
     }
 }
Пример #4
0
 public WaitWhileDestroyPipeline(List <Item> destroyItems, Delays delays)
 {
     // Debug.Log(this.GetType());
     DestroyingPipeline.THIS.DestroyItems(destroyItems, delays, () =>
     {
         currentDestroyFinished = true;
         //            LevelManager.This.FindMatches();
     });
 }
Пример #5
0
 /// <summary>
 /// This method will remove a delay from the list of delays
 /// </summary>
 public static void RemoveDelay(char character)
 {
     if (CheckDelayExists(character))
     {
         Delays.Remove(Delays.Find(x => x.Character == character));
     }
     else
     {
         throw new AutoplayerCustomDelayException("Trying to remove non-existent delay");
     }
 }
Пример #6
0
 /// <summary>
 /// This method will set a new time to a specified delay from the list of delays
 /// </summary>
 public static void ChangeDelay(char character, int newTime)
 {
     if (CheckDelayExists(character))
     {
         Delays.Find(x => x.Character == character).Time = newTime;
     }
     else
     {
         throw new AutoplayerCustomDelayException("Trying to modify non-existent delay");
     }
 }
Пример #7
0
 /// <summary>
 /// This method will add a delay to the list of delays
 /// </summary>
 public static void AddDelay(char character, int time)
 {
     if (!CheckDelayExists(character))
     {
         Delays.Add(new Delay(character, time));
     }
     else
     {
         throw new AutoplayerCustomDelayException("Trying to add already existing delay");
     }
 }
Пример #8
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (FinderID?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (RiskAnalysys?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (RisksDetected?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CrossBorders?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Delays?.GetHashCode() ?? 0);
            return(hashCode);
        }
Пример #9
0
        public void Selected()
        {
            if (_hasBeenSelected)
            {
                return;
            }

            _isHovering      = false;
            _hasBeenSelected = true;
            onSelected?.Invoke();
            StartCoroutine(Delays.DelayedAction(ResetSelectable, resetTime));
        }
Пример #10
0
        public DelayJustificationViewModel(TrainInformation LiveTrain)
        {
            CurrentTrain = LiveTrain;

            Delays = LiveTrain.Schedules.SelectMany(s => s.Delays.Where(d => d.Reason.IsNullOrWhiteSpace() && d.Schedule.Schedule.Station.ESTW.Stations.Any(st => Runtime.VisibleStations.Contains(st))))
                     .Select(delay => new DelayInfoViewModel(delay)).ToObservableCollection();
            Delays.ForEach(d => d.DelaySaved += __DelaySaved);

            if (Delays.Count > 0)
            {
                Delays.Last().IsLast = true;
            }
        }
Пример #11
0
            public void OnNext(T value)
            {
                DateTime now = DateTime.UtcNow;

                Values.Add(value);

                if (_previous != DateTime.MinValue)
                {
                    Delays.Add((int)(now - _previous).TotalMilliseconds);
                }

                NotificationThreadIds.Add(Thread.CurrentThread.ManagedThreadId);
                NotificationTaskIds.Add(Task.CurrentId);

                _previous = now;
            }
    public void DestroyItems(List <Item> items, Delays delays, Action callback)
    {
        if (LevelManager.THIS.DebugSettings.DestroyLog)
        {
            foreach (var item in items)
            {
                DebugLogKeeper.Log("Add to pipeline " + item, DebugLogKeeper.LogType.Destroying);
            }
        }
        var bunch = new DestroyBunch();

        bunch.items    = items.ToList();
        bunch.callback = callback;
        bunch.delays   = delays;
        pipeline.Add(bunch);
    }
 internal ServiceServer(Program program, Delays frozens)
 {
     _program = program;
     _frozens = frozens;
 }
Пример #14
0
 /// <summary>
 /// Creates a task that completes after a delay ± % of random deviation.
 /// </summary>
 public Task WaitRandomAsync(Delays delay)
 {
     return(WaitRandomAsync(delay, CancellationToken.None));
 }
Пример #15
0
 /// <summary>
 /// Creates a task that completes after a delay between range limits.
 /// </summary>
 public Task WaitRandomAsync(Delays from, Delays to)
 {
     return(WaitRandomAsync(from, to, CancellationToken.None));
 }
Пример #16
0
        /// <summary>
        /// This method will load a song and its settings from a file at the "path" variable's destination
        /// This loading method handles all previous save formats for backwards compatibility
        /// </summary>
        public static void LoadSong(string path)
        {
            Song.Clear();
            bool         errorWhileLoading = true;
            StreamReader sr        = new StreamReader(path);
            string       firstLine = sr.ReadLine();

            #region 2.1+ save format
            if (SupportedVersionsSave.Contains(firstLine))
            {
                if (sr.ReadLine() == "DELAYS")
                {
                    int delayCount = 0;
                    if (int.TryParse(sr.ReadLine(), out delayCount) && delayCount > 0)
                    {
                        for (int i = 0; i < delayCount; i++)
                        {
                            char delayChar;
                            int  delayTime = 0;
                            if (char.TryParse(sr.ReadLine(), out delayChar))
                            {
                                if (int.TryParse(sr.ReadLine(), out delayTime))
                                {
                                    Delays.Add(new Delay(delayChar, delayTime));
                                }
                            }
                        }
                    }
                }
                if (sr.ReadLine() == "CUSTOM NOTES")
                {
                    int noteCount = 0;
                    if (int.TryParse(sr.ReadLine(), out noteCount) && noteCount > 0)
                    {
                        for (int i = 0; i < noteCount; i++)
                        {
                            char origNoteChar;
                            char replaceNoteChar;
                            if (char.TryParse(sr.ReadLine(), out origNoteChar))
                            {
                                if (char.TryParse(sr.ReadLine(), out replaceNoteChar))
                                {
                                    WindowsInput.Native.VirtualKeyCode vkOld;
                                    WindowsInput.Native.VirtualKeyCode vkNew;
                                    try
                                    {
                                        VirtualDictionary.TryGetValue(origNoteChar, out vkOld);
                                        VirtualDictionary.TryGetValue(replaceNoteChar, out vkNew);

                                        if (vkOld == 0 || vkNew == 0)
                                        {
                                            return;
                                        }
                                    }
                                    catch (ArgumentNullException)
                                    {
                                        return;
                                    }

                                    CustomNotes.Add(new Note(origNoteChar, vkOld, char.IsUpper(origNoteChar)), new Note(replaceNoteChar, vkNew, char.IsUpper(replaceNoteChar)));
                                }
                            }
                        }
                    }
                }
                if (sr.ReadLine() == "SPEEDS")
                {
                    int normalSpeed, fastSpeed;
                    int.TryParse(sr.ReadLine(), out normalSpeed);
                    int.TryParse(sr.ReadLine(), out fastSpeed);
                    DelayAtNormalSpeed = normalSpeed;
                    DelayAtFastSpeed   = fastSpeed;
                }
                if (sr.ReadLine() == "NOTES")
                {
                    int noteCount = 0;
                    if (int.TryParse(sr.ReadLine(), out noteCount) && noteCount > 0)
                    {
                        AddNotesFromString(sr.ReadToEnd());
                    }
                    errorWhileLoading = false;
                }
            }
            #endregion
            #region 2.0 save format (for backwards compatibility)
            if (firstLine == "DELAYS")
            {
                int delayCount = 0;
                if (int.TryParse(sr.ReadLine(), out delayCount) && delayCount > 0)
                {
                    for (int i = 0; i < delayCount; i++)
                    {
                        char delayChar;
                        int  delayTime = 0;
                        if (char.TryParse(sr.ReadLine(), out delayChar))
                        {
                            if (int.TryParse(sr.ReadLine(), out delayTime))
                            {
                                Delays.Add(new Delay(delayChar, delayTime));
                            }
                        }
                    }
                }
                if (sr.ReadLine() == "NOTES")
                {
                    int noteCount = 0;
                    if (int.TryParse(sr.ReadLine(), out noteCount) && noteCount > 0)
                    {
                        AddNotesFromString(sr.ReadToEnd());
                    }
                    errorWhileLoading = false;
                }
            }
            #endregion
            #region 1.2.2 save format (For backwards compatibility)
            else if (firstLine == "CUSTOM DELAYS")
            {
                int delayCount = 0;
                if (int.TryParse(sr.ReadLine(), out delayCount))
                {
                    if (sr.ReadLine() == "NORMAL DELAY")
                    {
                        if (int.TryParse(sr.ReadLine(), out delayAtNormalSpeed))
                        {
                            Delays.Add(new Delay(' ', DelayAtNormalSpeed));
                            if (sr.ReadLine() == "FAST DELAY")
                            {
                                if (int.TryParse(sr.ReadLine(), out delayAtFastSpeed))
                                {
                                    if (delayCount != 0)
                                    {
                                        for (int i = 0; i < delayCount; i++)
                                        {
                                            int  customDelayIndex = 0;
                                            int  customDelayTime  = 0;
                                            char customDelayChar;

                                            if (sr.ReadLine() == "CUSTOM DELAY INDEX")
                                            {
                                                if (int.TryParse(sr.ReadLine(), out customDelayIndex))
                                                {
                                                    if (sr.ReadLine() == "CUSTOM DELAY CHARACTER")
                                                    {
                                                        if (char.TryParse(sr.ReadLine(), out customDelayChar))
                                                        {
                                                            if (sr.ReadLine() == "CUSTOM DELAY TIME")
                                                            {
                                                                if (int.TryParse(sr.ReadLine(), out customDelayTime))
                                                                {
                                                                    Delays.Add(new Delay(customDelayChar, customDelayTime));
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (sr.ReadLine() == "NOTES")
                                    {
                                        AddNotesFromString(sr.ReadToEnd());
                                        errorWhileLoading = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            #region 1.0 save format (For backwards compatibility)
            else if (firstLine == "NORMAL DELAY")
            {
                if (int.TryParse(sr.ReadLine(), out delayAtNormalSpeed))
                {
                    if (sr.ReadLine() == "FAST DELAY")
                    {
                        if (int.TryParse(sr.ReadLine(), out delayAtFastSpeed))
                        {
                            if (sr.ReadLine() == "NOTES")
                            {
                                AddNotesFromString(sr.ReadToEnd());
                                errorWhileLoading = false;
                            }
                        }
                    }
                }
            }
            #endregion
            sr.Close();
            if (errorWhileLoading)
            {
                LoadFailed?.Invoke();
                throw new AutoplayerLoadFailedException("No compatible save format was found!");
            }
            LoadCompleted?.Invoke();
        }
Пример #17
0
 /// <summary>
 /// This method will remove all delays from the list of delays
 /// </summary>
 public static void ResetDelays()
 {
     Delays.Clear();
 }
Пример #18
0
 /// <summary>
 /// Creates a task that completes after a delay ± % of random deviation.
 /// </summary>
 public Task WaitRandomAsync(Delays delay, CancellationToken token)
 {
     return(WaitRandomAsync((int)delay, token));
 }
Пример #19
0
 /// <summary>
 /// This method will check if a delay exists in the list of delays
 /// If it does, it returns true, otherwise it returns false
 /// </summary>
 public static bool CheckDelayExists(char character)
 {
     return(Delays.Find(x => x.Character == character) != null);
 }
Пример #20
0
        /// <summary>
        /// This method will process a given character and add a corrosponding note to the song
        /// </summary>
        public static void AddNoteFromChar(char note)
        {
            Delay delay = Delays.Find(x => x.Character == note);

            //Start multinote building if the input is a [
            if (note == '[')
            {
                if (buildingMultiNote)
                {
                    AddingNotesFailed?.Invoke();
                    throw new AutoplayerInvalidMultiNoteException("A multi note cannot be defined whithin a multinote definition!");
                }
                buildingMultiNote = true;
                multiNoteBuffer.Clear();
            }
            //Stop multinote building if the input is a ] and add a multinote
            else if (note == ']')
            {
                if (!buildingMultiNote)
                {
                    AddingNotesFailed?.Invoke();
                    throw new AutoplayerMultiNoteNotDefinedException("A multi note must have a start before the end!");
                }
                buildingMultiNote = false;
                Song.Add(new MultiNote(multiNoteBuffer.ToArray(), multiNoteIsHighNote));
                multiNoteBuffer.Clear();
            }
            //Start fast speed if the input is a {
            else if (note == '{')
            {
                //If it's part of a multinote we want to add it to the multinote buffer
                //Otherwise add it as a single note
                if (buildingMultiNote)
                {
                    AddingNotesFailed?.Invoke();
                    throw new AutoplayerInvalidMultiNoteException("A speed change note cannot be defined whithin a multinote definition!");
                }
                else
                {
                    Song.Add(new SpeedChangeNote(true));
                }
            }
            //Stop fast speed if the input is a }
            else if (note == '}')
            {
                if (buildingMultiNote)
                {
                    AddingNotesFailed?.Invoke();
                    throw new AutoplayerInvalidMultiNoteException("A speed change note cannot be defined whithin a multinote definition!");
                }
                else
                {
                    Song.Add(new SpeedChangeNote(false));
                }
            }
            //If the input is registered as a delay, add a delay note
            else if (delay != null)
            {
                if (buildingMultiNote)
                {
                    AddingNotesFailed?.Invoke();
                    throw new AutoplayerInvalidMultiNoteException("A delay note cannot be defined whithin a multinote definition!");
                }
                else
                {
                    Song.Add(new DelayNote(delay.Character, delay.Time));
                }
            }
            //If we reach a newline, we just ignore it
            else if (note == '\n' || note == '\r')
            {
                return;
            }
            //If it didn't match any case, it must be a normal note
            else
            {
                WindowsInput.Native.VirtualKeyCode vk;
                try
                {
                    VirtualDictionary.TryGetValue(char.ToUpper(note), out vk);

                    if (vk == 0)
                    {
                        return;
                    }
                }
                catch (ArgumentNullException)
                {
                    return;
                }

                //This will check if the note is an uppercase letter, or if the note is in the list of high notes
                bool isHighNote = char.IsUpper(note) || AlwaysHighNotes.Contains(note);

                if (buildingMultiNote)
                {
                    if (multiNoteBuffer.Count == 0)
                    {
                        multiNoteIsHighNote = char.IsUpper(note) || AlwaysHighNotes.Contains(note);
                    }

                    if (isHighNote != multiNoteIsHighNote)
                    {
                        throw new AutoplayerNoteCreationFailedException($"A multinote cannot contain both high and low keys!");
                    }

                    multiNoteBuffer.Add(new Note(note, vk, isHighNote));
                }
                else
                {
                    Song.Add(new Note(note, vk, isHighNote));
                }
            }
        }
Пример #21
0
 /// <summary>
 /// Creates a task that completes after a delay between range limits.
 /// </summary>
 public Task WaitRandomAsync(Delays from, Delays to, CancellationToken token)
 {
     return(WaitRandomAsync((int)from, (int)to, token));
 }
Пример #22
0
        private void InitAnimationOrImage(Image image)
        {
            Animatable  = false;
            RepeatCount = -1;
            BitmapFrames.Clear();
            Delays.Clear();

            var source = image.Source as BitmapSource;

            if (source == null)
            {
                return;
            }
            var decoder = GetDecoder(source) as GifBitmapDecoder;

            if (decoder != null && decoder.Frames.Count > 1)
            {
                var fullSize = GetFullSize(decoder);

                var          animation     = new ObjectAnimationUsingKeyFrames();
                var          totalDuration = TimeSpan.Zero;
                BitmapSource prevFrame     = null;
                foreach (var rawFrame in decoder.Frames)
                {
                    var info = GetFrameInfo(rawFrame);

                    var frame = MakeFrame(
                        fullSize,
                        rawFrame, info,
                        prevFrame);

                    BitmapFrames.Add(frame);
                    Delays.Add(info.Delay);

                    var keyFrame = new DiscreteObjectKeyFrame(frame, totalDuration);
                    animation.KeyFrames.Add(keyFrame);
                    totalDuration += info.Delay;

                    if (info.DisposalMethod == FrameDisposalMethod.Replace || info.DisposalMethod == FrameDisposalMethod.Combine)
                    {
                        prevFrame = frame;
                    }
                    else if (info.DisposalMethod == FrameDisposalMethod.RestoreBackground)
                    {
                        prevFrame = IsFullFrame(info, fullSize) ? null : ClearArea(frame, info);
                    }
                }

                animation.Duration = totalDuration;

                RepeatCount = GetRepeatCount(decoder);
                animation.RepeatBehavior = (RepeatCount == 0) ? RepeatBehavior.Forever : new RepeatBehavior(RepeatCount);

                if (animation.KeyFrames.Count > 0)
                {
                    image.Source = (ImageSource)animation.KeyFrames[0].Value;
                }
                else
                {
                    image.Source = decoder.Frames[0];
                }
                image.BeginAnimation(Image.SourceProperty, animation);
                Animatable = true;
            }
            else
            {
                BitmapFrames.Add(source);
                Delays.Add(TimeSpan.Zero);
            }
        }
Пример #23
0
 internal ServiceClientWithState(Form1 form, Delays frozens)
 {
     _form    = form;
     _frozens = frozens;
     State    = State.Playing;
 }