Esempio n. 1
0
        public string ToBase64String()
        {
            var dateFormat = string.IsNullOrEmpty(AppSettings.PayseraDateFormat) ? "yyyy-MM-dd HH:mm:ss" : AppSettings.PayseraDateFormat;

            if (TimeLimit == DateTime.MinValue)
            {
                TimeLimit = DateTime.Now.AddMinutes(60);
            }

            var @params = new NameValueCollection
            {
                { "projectid", ProjectId },
                { "orderid", OrderId },
                { "accepturl", AcceptUrl },
                { "cancelurl", CancelUrl },
                { "callbackurl", CallbackUrl },
                { "version", Version },
                { "lang", Language },
                { "amount", Amount.HasValue ? Amount.Value.ToString(CultureInfo.InvariantCulture) : string.Empty },
                { "currency", Currency },
                { "payment", Payment },
                { "country", Country },
                { "paytext", PayText },
                { "p_firstname", PayerFirstName },
                { "p_lastname", PayerLastName },
                { "p_email", PayerEmail },
                { "p_street", PaypalStreet },
                { "p_city", PayerCity },
                { "p_state", PayerState },
                { "p_zip", PayerZip },
                { "p_countrycode", PayerCountryCode },
                { "time_limit", TimeLimit.ToString(dateFormat) },
                { "personcode", PersonCode },
                { "test", Test.ToString("1") },
                { "repeatrequest", RepeatRequest.ToString("0") }
            };

            if (AllowedPayments.Any())
            {
                @params.Add("only_payments", AllowedPayments.Aggregate((i, j) => i + "," + j));
            }
            if (DisallowedPayments.Any())
            {
                @params.Add("disalow_payments", DisallowedPayments.Aggregate((i, j) => i + "," + j));
            }

            // Add additional parameter if he is not already in the list of params
            var items = AdditionalParameters.AllKeys.SelectMany(AdditionalParameters.GetValues, (k, v) => new { key = k, value = v });

            foreach (var item in items)
            {
                if ([email protected](item.key))
                {
                    @params.Add(item.key, item.value);
                }
            }

            return(@params.ToQueryString().EncodeBase64UrlSafe());
        }
Esempio n. 2
0
        void _twitchChatEngine_MessageReceived(string username, string message)
        {
            Dispatcher.Invoke(delegate()
            {
                var item = new ChatLogItem()
                {
                    Message  = message,
                    Username = username
                };

                ChatLog.Items.Insert(0, item);
                if (ChatLog.Items.Count > 25)
                {
                    ChatLog.Items.RemoveAt(ChatLog.Items.Count - 1);
                }
            });

            var messageUpper = message.ToUpper();

            var isChannelOwner = _channelOwners.Any(p => string.Equals(p.Trim(), username.Trim(), StringComparison.OrdinalIgnoreCase));
            var split          = messageUpper.Split(' ');

            switch (split[0])
            {
            case "REPEAT":
                if (_repeatRequest == null && split.Length > 1)
                {
                    int amount;
                    if (int.TryParse(split[1], out amount))
                    {
                        //amount can be between 2 and 15.
                        amount = Math.Min(Math.Max(amount, 2), 25);

                        _repeatRequest = new RepeatRequest()
                        {
                            Amount        = amount,
                            RequestAuthor = username,
                            CommandIndex  = _lastCommandIndex
                        };
                    }
                }
                break;

            //allows power-users to reposition the window.
            case "REPOSITION":
                if (isChannelOwner && split.Length > 2)
                {
                    int x;
                    int y;
                    if (int.TryParse(split[1], out x) && int.TryParse(split[2], out y))
                    {
                        Dispatcher.Invoke(delegate()
                        {
                            Left = x;
                            Top  = y;
                        });
                    }
                }
                break;

            case "MODESWITCH":
                if (_twitchChatEngine.IsOperator(username) && split.Length > 1)
                {
                    var mode = split[1].ToUpper();
                    if (mode == "SLOW")
                    {
                        _gameboy.StopSpeedMode();
                        _slowmotionCountdown = 0;
                    }
                    else if (mode == "SPEED")
                    {
                        _gameboy.StartSpeedMode();
                        _slowmotionCountdown = SpeedyTime;
                    }
                }
                break;

            case "RESTART":
                if (isChannelOwner)
                {
                    using (var myProcess = Process.GetCurrentProcess())
                    {
                        Process.Start(myProcess.ProcessName + ".exe");
                    }
                }
                break;
            }
        }
Esempio n. 3
0
        private async void StartKeyPressLoop()
        {
            var random = new Random((int)DateTime.UtcNow.Ticks);

            var lastTick  = DateTime.UtcNow;
            var lastStart = DateTime.UtcNow;

            const int SmallDelay = 2;

            var commandList = new LinkedList <string>();

            while (true)
            {
                var delay = SmallDelay;
                if (_slowmotionCountdown < 0)
                {
                    //disable turbo.
                    _gameboy.StopSpeedMode();

                    delay = 1500;

                    SlowMotionCountdown.Text = "Mode: Slowdown (Speed in: " + (SlowTime + _slowmotionCountdown) + " seconds)";
                }
                else
                {
                    //enable turbo.
                    _gameboy.StartSpeedMode();

                    SlowMotionCountdown.Text = "Mode: Speed (Slowdown in: " + _slowmotionCountdown + " seconds)";
                }

                Action command;

                string commandName;
                _lastCommandIndex = _repeatRequest == null?Math.Min(random.Next(0, 22), 21) : _repeatRequest.CommandIndex;

                switch (_lastCommandIndex)
                {
                case 0:
                case 7:
                case 13:
                    commandName = "→";
                    command     = _gameboy.TapRight;
                    break;

                case 1:
                case 8:
                case 14:
                    commandName = "←";
                    command     = _gameboy.TapLeft;
                    break;

                case 2:
                case 9:
                case 15:
                    commandName = "↓";
                    command     = _gameboy.TapDown;
                    break;

                case 3:
                case 10:
                case 16:
                    commandName = "↑";
                    command     = _gameboy.TapUp;
                    break;

                case 4:
                case 11:
                case 17:
                    commandName = "A";
                    command     = _gameboy.TapA;
                    break;

                case 5:
                case 12:
                case 18:
                    commandName = "B";
                    command     = _gameboy.TapB;
                    break;

                case 6:
                    if ((DateTime.UtcNow - lastStart).TotalSeconds > 10)
                    {
                        lastStart = DateTime.UtcNow;

                        commandName = "ST";
                        command     = delegate()
                        {
                            Thread.Sleep(10);
                            _gameboy.TapStart();
                            Thread.Sleep(100);
                            if (!_gameboy.IsInSpeedMode)
                            {
                                Thread.Sleep(1000);
                            }
                            _gameboy.TapStart();
                            Thread.Sleep(10);
                        };
                    }
                    else
                    {
                        continue;
                    }
                    break;

                case 19:
                case 20:
                case 21:
                    commandName = "SE";
                    command     = _gameboy.TapSelect;
                    break;

                default:
                    throw new InvalidOperationException();
                }

                var difference = (int)(DateTime.UtcNow - lastTick).TotalMilliseconds;
                await Task.Delay(Math.Max(delay - difference, 1));

                lastTick = DateTime.UtcNow;

                if (_repeatRequest != null)
                {
                    LastRepeat.Text = _repeatRequest.Amount + "X [" + commandName + "] by " + _repeatRequest.RequestAuthor;
                }

                commandList.AddFirst(commandName);
                if (commandList.Count > 50)
                {
                    commandList.RemoveLast();
                }

                Log.ItemsSource = null;
                Log.ItemsSource = commandList;

                var realTimeSpent    = DateTime.Now.Subtract(_startTime);
                var pokemonTimeSpent = new TimeSpan(realTimeSpent.Ticks * SpeedMultiplier);

                RealTimeSpent.Text    = realTimeSpent.Days + "d " + realTimeSpent.Hours.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "h " + realTimeSpent.Minutes.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "m " + realTimeSpent.Seconds.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "s";
                PokemonTimeSpent.Text = pokemonTimeSpent.Days + "d " + pokemonTimeSpent.Hours.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "h " + pokemonTimeSpent.Minutes.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "m " + pokemonTimeSpent.Seconds.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0') + "s";

                var repeat = _repeatRequest == null ? 1 : _repeatRequest.Amount;
                for (var i = 0; i < repeat; i++)
                {
                    command();
                    if (i != 0)
                    {
                        await Task.Delay(10);

                        if (!_gameboy.IsInSpeedMode)
                        {
                            await Task.Delay(500);
                        }
                    }
                }

                _repeatRequest = null;

                FormsApplication.DoEvents();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// This method echoes the ComplianceData request, using the HTTP PATCH method.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public override stt::Task <RepeatResponse> RepeatDataBodyPatchAsync(RepeatRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_RepeatRequest(ref request, ref callSettings);
     return(_callRepeatDataBodyPatch.Async(request, callSettings));
 }
Esempio n. 5
0
 /// <summary>
 /// Same as RepeatDataSimplePath, but with a trailing resource.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public override stt::Task <RepeatResponse> RepeatDataPathTrailingResourceAsync(RepeatRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_RepeatRequest(ref request, ref callSettings);
     return(_callRepeatDataPathTrailingResource.Async(request, callSettings));
 }
Esempio n. 6
0
 /// <summary>
 /// This method echoes the ComplianceData request, using the HTTP PUT method.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public override RepeatResponse RepeatDataBodyPut(RepeatRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_RepeatRequest(ref request, ref callSettings);
     return(_callRepeatDataBodyPut.Sync(request, callSettings));
 }
Esempio n. 7
0
 partial void Modify_RepeatRequest(ref RepeatRequest request, ref gaxgrpc::CallSettings settings);
Esempio n. 8
0
 /// <summary>
 /// This method echoes the ComplianceData request, using the HTTP PATCH method.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <RepeatResponse> RepeatDataBodyPatchAsync(RepeatRequest request, st::CancellationToken cancellationToken) =>
 RepeatDataBodyPatchAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
Esempio n. 9
0
 /// <summary>
 /// This method echoes the ComplianceData request, using the HTTP PATCH method.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <RepeatResponse> RepeatDataBodyPatchAsync(RepeatRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
Esempio n. 10
0
 /// <summary>
 /// This method echoes the ComplianceData request, using the HTTP PUT method.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual RepeatResponse RepeatDataBodyPut(RepeatRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
Esempio n. 11
0
 /// <summary>
 /// Same as RepeatDataSimplePath, but with a trailing resource.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual RepeatResponse RepeatDataPathTrailingResource(RepeatRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();