Example #1
0
 private void LogWarning(string message, params object[] args)
 {
     if (OnWarning != null)
     {
         OnWarning.Invoke(this, new NotificationMessage(string.Format(message, args)));
     }
 }
Example #2
0
    IEnumerator StartTimer()
    {
        while (_levelInProgress && _timeLeft > 0)
        {
            yield return(new WaitForSeconds(1));

            _timeLeft -= 1;
            OnTimeChanged?.Invoke(_timeLeft);


            if (_nextWarningIndex < TimeLeftWhenWarningPlays.Count)
            {
                if (_nextWarningIndex > 0 && _timeLeft > TimeLeftWhenWarningPlays[_nextWarningIndex - 1])
                {
                    _nextWarningIndex--;
                }

                if (_timeLeft == TimeLeftWhenWarningPlays[_nextWarningIndex])
                {
                    OnWarning?.Invoke(_timeLeft);
                    _nextWarningIndex++;
                }
            }

            if (_timeLeft == 0)
            {
                WhenTimeRunsOut();
            }
        }
    }
Example #3
0
 /*
  * It's button func on WarningButton
  */
 public void OnWarningBackClicked()
 {
     audioM.Click();
     OnWarning?.Invoke(this, new WarningArgs {
         action = WindowAction.Close
     });
 }
Example #4
0
 /*
  * It's button func on WarningButton
  */
 public void OnWarningConfirmClicked()
 {
     audioM.Click();
     // SEND WARNING TO US
     Debug.LogWarning("Warning on the question!");
     OnWarning?.Invoke(this, new WarningArgs {
         action = WindowAction.Confirm
     });
 }
Example #5
0
        //public Player(ISkin skin) : base(skin)
        //{

        //}

        public override Task <bool> Play(bool loop)
        {
            return(Task.Run(() =>
            {
                if (!Locked && Items.Count > 0)
                {
                    Playing = true;
                    PlayerStartedEvent?.Invoke(Items, null, Locked, Volume, Playing);
                }

                if (Playing)
                {
                    int numLoop = 0;

                    numLoop = (loop == false) ? 1 : 5;

                    //Skin.NewScreen();

                    for (int j = 0; j < numLoop; j++)
                    {
                        foreach (var item in Items)
                        {
                            try
                            {
                                ViewPlayList(item);

                                SongStartedEvent?.Invoke(Items, item, Locked, Volume, Playing);

                                soundPlayer.SoundLocation = item.Path;
                                soundPlayer.PlaySync();
                                //soundPlayer.Play();
                            }
                            catch (FileNotFoundException)
                            {
                                OnWarning?.Invoke("Файл не найден");
                                throw new FailedToPlayException("Файл не найден", item.Path);
                            }
                            catch (InvalidOperationException)
                            {
                                OnWarning?.Invoke("Проверте расширение файла");
                                throw new System.Exception("Проверте расширение файла");
                            }
                            Console.ResetColor();
                        }
                    }

                    Playing = false;
                    System.Threading.Thread.Sleep(2000);
                }
                return Playing;
            }));

            //else Skin.Render("Player is Locked");
        }
Example #6
0
        private void InitListeners()
        {
            m_nativeEngine.OnInfo += (string message) =>
            {
                OnInfo?.Invoke(message);
            };

            m_nativeEngine.OnWarning += (string message) =>
            {
                OnWarning?.Invoke(message);
            };

            m_nativeEngine.OnError += (string message) =>
            {
                OnError?.Invoke(message);
            };
        }
Example #7
0
        internal static void Log(string msg, LogType type = LogType.Info)
        {
            switch (type)
            {
            case LogType.Info:
                OnInfo?.Invoke(msg);
                break;

            case LogType.Warning:
                OnWarning?.Invoke(msg);
                break;

            case LogType.Error:
                OnError?.Invoke(msg);
                break;
            }
        }
Example #8
0
        private void OnEngineHttpMessageEnd([In][MarshalAs(UnmanagedType.LPStr)] string requestHeaders, uint requestHeadersLength, [In] IntPtr requestBody, uint requestBodyLength, [In][MarshalAs(UnmanagedType.LPStr)] string responseHeaders, uint responseHeadersLength, [In] IntPtr responseBody, uint responseBodyLength, ref bool shouldBlock, NativeCustomResponseStreamWriter customBlockResponseStreamWriter)
        {
            byte[] requestBodyManaged  = null;
            byte[] responseBodyManaged = null;

            if (requestBody != IntPtr.Zero)
            {
                requestBodyManaged = new byte[requestBodyLength];
                Marshal.Copy(requestBody, requestBodyManaged, 0, requestBodyManaged.Length);
            }

            if (responseBody != IntPtr.Zero)
            {
                responseBodyManaged = new byte[requestBodyLength];
                Marshal.Copy(responseBody, responseBodyManaged, 0, responseBodyManaged.Length);
            }

            ResponseWriter thisWriter = (byte[] responseData) =>
            {
                var myNativeWriter = customBlockResponseStreamWriter;
                if (myNativeWriter == null)
                {
                    OnWarning?.Invoke("Native response writers exhausted.");
                }

                myNativeWriter?.Invoke(responseData, (uint)responseData.Length);

                GC.KeepAlive(myNativeWriter);
            };

            var shouldBlockManaged = false;

            HttpMessageEndCallback?.Invoke(requestHeaders, requestBodyManaged, responseHeaders, responseBodyManaged, out shouldBlockManaged, thisWriter);

            shouldBlock = shouldBlockManaged;
        }
Example #9
0
        private void OnEngineHttpMessageBegin([In][MarshalAs(UnmanagedType.LPStr)] string requestHeaders, uint requestHeadersLength, [In] IntPtr requestBody, uint requestBodyLength, [In][MarshalAs(UnmanagedType.LPStr)] string responseHeaders, uint responseHeadersLength, [In] IntPtr responseBody, uint responseBodyLength, ref uint nextAction, NativeCustomResponseStreamWriter customBlockResponseStreamWriter)
        {
            byte[] requestBodyManaged  = null;
            byte[] responseBodyManaged = null;

            if (requestBody != IntPtr.Zero)
            {
                requestBodyManaged = new byte[requestBodyLength];
                Marshal.Copy(requestBody, requestBodyManaged, 0, requestBodyManaged.Length);
            }

            if (responseBody != IntPtr.Zero)
            {
                responseBodyManaged = new byte[requestBodyLength];
                Marshal.Copy(responseBody, responseBodyManaged, 0, responseBodyManaged.Length);
            }

            ResponseWriter thisWriter = (byte[] responseData) =>
            {
                var myNativeWriter = customBlockResponseStreamWriter;
                if (myNativeWriter == null)
                {
                    OnWarning?.Invoke("Native response writers exhausted.");
                }

                myNativeWriter?.Invoke(responseData, (uint)responseData.Length);

                GC.KeepAlive(myNativeWriter);
            };

            var managedNextAction = ProxyNextAction.AllowAndIgnoreContentAndResponse;

            HttpMessageBeginCallback?.Invoke(requestHeaders, requestBodyManaged, responseHeaders, responseBodyManaged, out managedNextAction, thisWriter);

            nextAction = (uint)managedNextAction;
        }
Example #10
0
 protected bool Warn(string message, bool returnVal = false)
 {
     OnWarning?.Invoke(message);
     return(returnVal);
 }
Example #11
0
 public static void Warning(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) =>
 OnWarning?.Invoke(message, file, line);
Example #12
0
 private void OnEngineWarning(string message, uint messageLength)
 {
     OnWarning?.Invoke(message);
 }
Example #13
0
        public async void Create()
        {
            try
            {
                HttpResponseMessage response = await _registrationClient.GetAsync("https://www.instagram.com");

                var responseCookies = _cookieContainer.GetCookies(new Uri("https://www.instagram.com")).Cast <Cookie>().ToList();

                _registrationClient.DefaultRequestHeaders.Add("Origin", "https://www.instagram.com");
                _registrationClient.DefaultRequestHeaders.Add("Referer", "https://www.instagram.com/");
                _registrationClient.DefaultRequestHeaders.Add("X-Requested-With", "XMLHttpRequest");
                _registrationClient.DefaultRequestHeaders.Add("X-Instagram-AJAX", "1");
                _registrationClient.DefaultRequestHeaders.Add("X-CSRFToken", responseCookies[0].Value);

                HtmlDocument htmlDocument = new HtmlDocument();
                htmlDocument.LoadHtml(await response.Content.ReadAsStringAsync());

                var    javascriptEngine = new Jurassic.ScriptEngine();
                object evalResult       = javascriptEngine.Evaluate("(function() { var window = {}; " + htmlDocument.DocumentNode.SelectNodes("//script[@type='text/javascript']")[4].InnerHtml + " return window._sharedData; })()");

                JObject scriptJson = JObject.Parse(JSONObject.Stringify(javascriptEngine, evalResult));

                _cookieContainer.Add(new Cookie("ig_pr", scriptJson["display_properties_server_guess"]["pixel_ratio"].ToString())
                {
                    Domain = "instagram.com"
                });
                _cookieContainer.Add(new Cookie("ig_vw", scriptJson["display_properties_server_guess"]["viewport_width"].ToString())
                {
                    Domain = "instagram.com"
                });

                NameValueCollection queryString = HttpUtility.ParseQueryString(string.Empty);

                queryString["first_name"] = _instagramUsername;
                queryString["username"]   = _instagramUsername;
                queryString["password"]   = _instagramPassword;
                queryString["email"]      = _instagramEmail;

                StringContent queryStringContent = new StringContent(queryString.ToString());
                queryStringContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");

                HttpResponseMessage creationResponse = await _registrationClient.PostAsync("https://www.instagram.com/accounts/web_create_ajax/", queryStringContent);

                JObject responseJson = JObject.Parse(await creationResponse.Content.ReadAsStringAsync());

                if (responseJson["account_created"].ToObject <bool>())
                {
                    if (OnSuccess != null)
                    {
                        OnSuccess.BeginInvoke(this, null, null);
                    }
                }
                else
                {
                    if (responseJson["errors"] != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();

                        foreach (JProperty error in responseJson["errors"])
                        {
                            stringBuilder.Append(error.Value[0] + " ");
                        }

                        if (OnWarning != null)
                        {
                            OnWarning.BeginInvoke(stringBuilder.ToString(), null, null);
                        }
                    }
                }
            }
            catch (Exception ioException) when(ioException is IOException)
            {
            }
            catch (Exception requestException) when(requestException is HttpRequestException)
            {
                if (requestException.InnerException is WebException)
                {
                    if (((WebException)requestException.InnerException).Status == WebExceptionStatus.ConnectFailure)
                    {
                        if (OnFailure != null)
                        {
                            OnFailure.BeginInvoke(string.Format("'{0}' failed to connect to Instagram.", Proxy), null, null);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //ignore the other exceptions
            }
        }