Esempio n. 1
0
        public static async void RequestFilterStates(FaceStateViewModel parentState)
        {
            if (parentState.Error == true)
            {
                foreach (FaceStateViewModel state in parentState.FilterStates)
                {
                    state.Loading = false;
                    state.Error   = true;
                }
            }

            parentState.Code = await Task.Run(() =>
            {
                RestRequest request = new RestRequest("", Method.POST);
                AddHeaders(request);

                try
                {
                    request.AddFile("file", parentState.FilePath, "rb");
                }
                catch
                {
                    return(null);
                }

                string code = client.Execute <UploadResponse>(request).Data.Code;

                return(code);
            });

            foreach (FaceStateViewModel state in parentState.FilterStates)
            {
                RequestLoad(state);
            }
        }
Esempio n. 2
0
        public static async void UploadParentState(FaceStateViewModel parentState)
        {
            parentState.Code = await Task.Run(() => Client.UploadImage(parentState.FilePath));

            if (parentState.Code == null)
            {
                parentState.Error = true;
            }

            parentState.Uploaded = true;
        }
Esempio n. 3
0
        public static async void RequestLoad(FaceStateViewModel state)
        {
            BitmapImage image = await Task.Run(() =>
            {
                return(GetFiterImage(state.ParentState?.Code, state.Type));
            });

            state.Loading = false;
            state.Image   = image;
            state.Error   = image == null;
        }
Esempio n. 4
0
        public static async void RequestLoad(FaceStateViewModel state)
        {
            var image = await Task.Run(() => Client.GetFiterImage(state.ParentState?.Code, state.Type));

            state.Loading = false;
            state.Loaded  = true;
            Dispatcher.CurrentDispatcher.Invoke(() =>
            {
                state.Image = image;
                state.Error = image == null;
            });
        }