예제 #1
0
 /// <summary>
 ///		Método que recibe los mensajes de javaScript
 /// </summary>
 private void ReceiveJavaScriptMessage(object sender, CoreWebView2WebMessageReceivedEventArgs args)
 {
     FunctionExecute?.Invoke(this, new WebExplorerFunctionEventArgs(args.TryGetWebMessageAsString()));
     //String uri = args.TryGetWebMessageAsString();
     //addressBar.Text = uri;
     //webView.CoreWebView2.PostWebMessageAsString(uri);
 }
예제 #2
0
 public FunctionThread(FunctionExecute functionExecute, DrawLine dl, double xStart, Dispatcher dispatcher)
 {
     this.m_FunctionExecute = functionExecute;
     this.m_DrawLine = dl;
     this.m_XStart = xStart;
     this.m_Dispatcher = dispatcher;
     m_From = m_FunctionExecute.Range.From;
 }
예제 #3
0
        private void ExecuteStair()
        {
            FunctionExecute fe = m_FunctionExecute;
            double x1 = m_XStart;
            PrimesBigInteger incX = PrimesBigInteger.One;
            PrimesBigInteger inci = PrimesBigInteger.One;
            PrimesBigInteger div = (fe.Range.RangeAmount.CompareTo(PrimesBigInteger.ValueOf(10000)) > 0) ? PrimesBigInteger.Ten : PrimesBigInteger.OneHundred;
            if (fe.Range.RangeAmount.CompareTo(PrimesBigInteger.ValueOf(1000)) > 0 && fe.Function.CanEstimate)
            {
                inci = fe.Range.RangeAmount.Divide(div);
                incX = inci;
            }

            PrimesBigInteger i = m_From;
            while (i.CompareTo(fe.Range.To) <= 0 && !HasTerminateRequest())
            {
                Boolean awokenByTerminate = SuspendIfNeeded();

                if (awokenByTerminate)
                {
                    m_From = i;
                    return;
                }

                double param = i.DoubleValue;

                double formerY = fe.Function.FormerValue;
                double y = fe.Function.Execute(param);

                bool drawstair = !formerY.Equals(y) || formerY.Equals(double.NaN);
                if (formerY.Equals(double.NaN)) formerY = y;
                double x2 = x1 + double.Parse(incX.ToString());
                if (fe.Function.DrawTo.Equals(double.PositiveInfinity) || (x2 <= fe.Function.DrawTo && x2 <= fe.Range.To.DoubleValue))
                {
                    if (drawstair)
                    {
                        x2 -= double.Parse(incX.ToString());
                    }
                    if (!DrawLine(x1, x2, formerY, y, fe.Color, fe.Function)) break;
                    if (drawstair)
                    {
                        x2 += double.Parse(incX.ToString());
                        if (!DrawLine(x1, x2, y, y, fe.Color, fe.Function)) break;
                    }
                }

                x1 = x2;
                i = i.Add(inci);
            }
        }
 /// <summary>
 ///		Lanza los argumentos de una función javaScript
 /// </summary>
 internal void RaiseScriptArguments(string strJavaScriptArguments)
 {
     FunctionExecute?.Invoke(this, new WebExplorerFunctionEventArgs(strJavaScriptArguments));
 }
예제 #5
0
        /// <summary>
        /// This Method is gonna executed when then thread is startet
        /// </summary>
        protected override void OnDoWork()
        {
            if (OnFunctionStart != null)
                OnFunctionStart(m_FunctionExecute.Function);
            if (m_FunctionExecute != null && m_FunctionExecute.GetType() == typeof(FunctionExecute))
            {
                FunctionExecute fe = m_FunctionExecute;
                fe.Function.FunctionState = FunctionState.Running;
                if (fe.FunctionType == FunctionType.STAIR)
                {
                    ExecuteStair();
                }
                else
                {
                    double x1 = m_XStart;
                    PrimesBigInteger incX = PrimesBigInteger.One;
                    PrimesBigInteger inci = PrimesBigInteger.One;
                    PrimesBigInteger div = (fe.Range.RangeAmount.CompareTo(PrimesBigInteger.ValueOf(10000)) > 0) ? PrimesBigInteger.Ten : PrimesBigInteger.OneHundred;
                    if (fe.Range.RangeAmount.CompareTo(PrimesBigInteger.ValueOf(1000)) > 0 && fe.Function.CanEstimate)
                    {
                        inci = fe.Range.RangeAmount.Divide(div);
                        incX = inci;
                    }

                    PrimesBigInteger i = m_From;
                    while (i.CompareTo(fe.Range.To) <= 0 && !HasTerminateRequest())
                    //for (long i = m_From; i <= fe.Range.To * factor || !HasTerminateRequest(); i += inci)
                    {
                        Boolean awokenByTerminate = SuspendIfNeeded();

                        if (awokenByTerminate)
                        {
                            m_From = i;
                            return;
                        }

                        double param = double.Parse(i.ToString());
                        if (fe.Function.FormerValue.Equals(double.NaN))
                        {
                            try
                            {
                                fe.Function.Execute(param);
                            }
                            catch (ResultNotDefinedException) { x1 += double.Parse(incX.ToString()); continue; }
                        }
                        else
                        {
                            double formerY = fe.Function.FormerValue;
                            double y = fe.Function.Execute(param);

                            double x2 = x1 + double.Parse(incX.ToString());
                            if (fe.Function.DrawTo.Equals(double.PositiveInfinity) || x2 <= fe.Function.DrawTo)
                            {
                                if (fe.FunctionType == FunctionType.STAIR)
                                {
                                    if (!formerY.Equals(y))
                                    {
                                        x2 -= double.Parse(incX.ToString());
                                    }
                                }
                                if (!DrawLine(x1, x2, formerY, y, fe.Color, fe.Function)) break;

                                if (fe.FunctionType == FunctionType.STAIR)
                                {
                                    if (!formerY.Equals(y))
                                    {
                                        x2 += double.Parse(incX.ToString());
                                        if (!DrawLine(x1, x2, y, y, fe.Color, fe.Function)) break;
                                    }
                                }
                            }

                            x1 = x2;
                        }
                        i = i.Add(inci);
                    }
                }
                fe.Function.Reset();
                fe.Function.FunctionState = FunctionState.Stopped;
                if (OnFunctionStop != null)
                    OnFunctionStop(m_FunctionExecute.Function);
            }
        }