private async Task <bool> IsLogin()
 {
     try {
         return(await MatrixRequest.IsLogin());
     } catch (Exception e) {
         Debug.WriteLine($"Login Failed {e.Message}");
         return(false);
     }
 }
        /// <summary>
        /// Matrix API Post The GET request has an URL length limitation, which hurts for many locations per request. In those cases use a HTTP POST request with JSON data as input. The only parameter in the URL will be the key which stays in the URL. Both request scenarios are identically except that all singular parameter names are named as their plural for a POST request.
        /// </summary>
        /// <exception cref="ApiException">Thrown when fails to make API call</exception>
        /// <param name="key">Get your key at graphhopper.com</param>
        /// <param name="body"> (optional)</param>
        /// <returns>Task of ApiResponse (MatrixResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <MatrixResponse> > MatrixPostAsyncWithHttpInfo(string key, MatrixRequest body = null)
        {
            // verify the required parameter 'key' is set
            if (key == null)
            {
                throw new ApiException(400, "Missing required parameter 'key' when calling MatrixApi->MatrixPost");
            }

            var    localVarPath         = "/matrix";
            var    localVarPathParams   = new Dictionary <string, string>();
            var    localVarQueryParams  = new List <KeyValuePair <string, string> >();
            var    localVarHeaderParams = new Dictionary <string, string>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <string, string>();
            var    localVarFileParams   = new Dictionary <string, FileParameter>();
            object localVarPostBody     = null;

            // to determine the Content-Type header
            string[] localVarHttpContentTypes = new string[] {
            };
            string localVarHttpContentType    = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            string[] localVarHttpHeaderAccepts = new string[] {
                "application/json"
            };
            string localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (key != null)
            {
                localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "key", key));              // query parameter
            }
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("MatrixPost", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <MatrixResponse>(localVarStatusCode,
                                                    localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                    (MatrixResponse)Configuration.ApiClient.Deserialize(localVarResponse, typeof(MatrixResponse))));
        }
        /// <summary>
        /// Matrix API Post The GET request has an URL length limitation, which hurts for many locations per request. In those cases use a HTTP POST request with JSON data as input. The only parameter in the URL will be the key which stays in the URL. Both request scenarios are identically except that all singular parameter names are named as their plural for a POST request.
        /// </summary>
        /// <exception cref="ApiException">Thrown when fails to make API call</exception>
        /// <param name="key">Get your key at graphhopper.com</param>
        /// <param name="body"> (optional)</param>
        /// <returns>Task of MatrixResponse</returns>
        public async System.Threading.Tasks.Task <MatrixResponse> MatrixPostAsync(string key, MatrixRequest body = null)
        {
            ApiResponse <MatrixResponse> localVarResponse = await MatrixPostAsyncWithHttpInfo(key, body);

            return(localVarResponse.Data);
        }
        /// <summary>
        /// Matrix API Post The GET request has an URL length limitation, which hurts for many locations per request. In those cases use a HTTP POST request with JSON data as input. The only parameter in the URL will be the key which stays in the URL. Both request scenarios are identically except that all singular parameter names are named as their plural for a POST request.
        /// </summary>
        /// <exception cref="ApiException">Thrown when fails to make API call</exception>
        /// <param name="key">Get your key at graphhopper.com</param>
        /// <param name="body"> (optional)</param>
        /// <returns>MatrixResponse</returns>
        public MatrixResponse MatrixPost(string key, MatrixRequest body = null)
        {
            ApiResponse <MatrixResponse> localVarResponse = MatrixPostWithHttpInfo(key, body);

            return(localVarResponse.Data);
        }
Exemple #5
0
 public async Task toggleReadState()
 {
     await MatrixRequest.changeMsgState(this.msg_id, !this.is_read);
 }
Exemple #6
0
 public Task <int> SubmitProgramming()
 {
     return(MatrixRequest.SubmitProgramming(course_id, ca_id, Submissions));
 }
Exemple #7
0
        /// <summary>
        /// Matrix API Post The GET request has an URL length limitation, which hurts for many locations per request. In those cases use a HTTP POST request with JSON data as input. The only parameter in the URL will be the key which stays in the URL. Both request scenarios are identically except that all singular parameter names are named as their plural for a POST request.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="key">Get your key at graphhopper.com</param>
        /// <param name="body"> (optional)</param>
        /// <returns>ApiResponse of MatrixResponse</returns>
        public ApiResponse <MatrixResponse> MatrixPostWithHttpInfo(string key, MatrixRequest body = null)
        {
            // verify the required parameter 'key' is set
            if (key == null)
            {
                throw new ApiException(400, "Missing required parameter 'key' when calling MatrixApi->MatrixPost");
            }

            var    localVarPath         = "/matrix";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
            };
            String localVarHttpContentType    = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (key != null)
            {
                localVarQueryParams.Add("key", Configuration.ApiClient.ParameterToString(key));              // query parameter
            }
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("MatrixPost", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <MatrixResponse>(localVarStatusCode,
                                                    localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                    (MatrixResponse)Configuration.ApiClient.Deserialize(localVarResponse, typeof(MatrixResponse))));
        }
Exemple #8
0
        private void DoMaths()
        {
            MatrixRequest?.Invoke(); //updates matrix
            double t, toX, step;
            IEnumerable <double> points;

            double[,] ode;
            DiffMethod method;

            try
            {
                t      = DrawingInterval.From;
                toX    = DrawingInterval.To;
                step   = IntegrationStep;
                method = CurrentlySelectedMethod;
                points = VariableMatrix.Cast <double>();
                ode    = ConstMatrix;
            }
            catch (Exception e)
            {
                MessageBox.Show(Locale["#ParsingErrMsg"] + e.Message, Locale["#ParsingErr"], MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            var dynFun = new List <DynamicDiffFun>
            {
                (dt, vars) => ode[0, 0] * vars.x + ode[0, 1] * vars.y + ode[0, 2] * vars.z + ode[0, 3] * vars.w + ode[0, 4],
                (dt, vars) => ode[1, 0] * vars.x + ode[1, 1] * vars.y + ode[1, 2] * vars.z + ode[1, 3] * vars.w + ode[1, 4],
                (dt, vars) => ode[2, 0] * vars.x + ode[2, 1] * vars.y + ode[2, 2] * vars.z + ode[2, 3] * vars.w + ode[2, 4],
                (dt, vars) => ode[3, 0] * vars.x + ode[3, 1] * vars.y + ode[3, 2] * vars.z + ode[3, 3] * vars.w + ode[3, 4]
            };

            var coeffFunctions = new List <string> {
                "x", "y", "z", "w"
            };

            //Test case:
            // *Produces beautiful e^ 2x
            //*
            //*
            // var dynFun = new List<DifferentialService.DynamicDiffFun>
            //{
            //     (dt, variables) => -2*variables.x+4*variables.y,
            //     (dt, variables) => 3*variables.x-variables.y
            //};
            // var coeffFunctions = new List<string> { "x", "y", };
            // var points = new double[] { 1, 1 };

            RungeKuttaMethod rungeKuttaMethod = Rk4;

            switch (method)
            {
            case DiffMethod.RK4:
                rungeKuttaMethod = Rk4;
                break;

            case DiffMethod.Ralston:
                rungeKuttaMethod = Ralston;
                break;
            }

            var cmp     = new List <DataPoint>();
            var results = coeffFunctions.Select(coeffFunction => new List <DataPoint>()).ToList();

            while (t < toX)
            {
                //kutta
                var result = rungeKuttaMethod(t, points, step, dynFun, coeffFunctions);

                var i = 0;
                foreach (var d in result)
                {
                    results[i++].Add(new DataPoint(t, d));
                }

                if (t + step > toX)
                {
                    step = toX - t;
                }
                points = result.ToArray();

                //draw compare
                if (CurrentlySelectedFunction != null)
                {
                    cmp.Add(new DataPoint(t, CurrentlySelectedFunction.GetValue(t)));
                }
                t += step;
            }

            //FUN FUN FUN FUN FUN FUN FUN FUN FUN FUN FUN FUN FUN
            //for (int i = 0; i < results.Count; i++)
            //{
            //    results[0][i] = new DataPoint(results[1][i].Y,results[0][i].Y);
            //}
            //FUN FUN FUN FUN FUN FUN FUN FUN FUN FUN FUN FUN FUN

            CoeffFunctionsAvaibleToDraw =
                coeffFunctions.Select((coeff, i) => new Tuple <string, List <DataPoint> >(coeff, results[i])).ToList();
            ComparisionDataPoints      = cmp;
            SelectedCoeffFunctionIndex = 0;
        }