forked from microsoft/Cognitive-Samples-IntelligentKiosk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Form Recognizer demo and Overlay Control (microsoft#105)
* Add Form Recognizer demo + Overlay Control * Update keys on the Insurance Claim Automation demo + minor fixes * minor fixes * small fix * Simplify animation logic * small updates
- Loading branch information
Albert Davletov
authored
Aug 10, 2020
1 parent
6d15dbf
commit 1dd0eb6
Showing
72 changed files
with
7,182 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. | ||
// | ||
// Microsoft Cognitive Services: http://www.microsoft.com/cognitive | ||
// | ||
// Microsoft Cognitive Services Github: | ||
// https://github.com/Microsoft/Cognitive | ||
// | ||
// Copyright (c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// MIT License: | ||
// Permission is hereby granted, free of charge, to any person obtaining | ||
// a copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to | ||
// the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
using Microsoft.Azure.Storage; | ||
using Microsoft.Azure.Storage.Auth; | ||
using Microsoft.Azure.Storage.Blob; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Windows.Storage; | ||
|
||
namespace IntelligentKioskSample | ||
{ | ||
class AzureBlobHelper | ||
{ | ||
public static CloudBlobContainer GetCloudBlobContainer(string storageAccount, string storageKey, string containerName) | ||
{ | ||
CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(new StorageCredentials(storageAccount, storageKey), true); | ||
CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient(); | ||
return blobClient?.GetContainerReference(containerName); | ||
} | ||
|
||
public static async Task UploadStorageFilesToContainerAsync(IEnumerable<StorageFile> storageFiles, CloudBlobContainer container) | ||
{ | ||
await container.CreateIfNotExistsAsync(BlobContainerPublicAccessType.Blob, new BlobRequestOptions(), new OperationContext()); | ||
|
||
// Upload our images | ||
foreach (StorageFile storageFile in storageFiles) | ||
{ | ||
CloudBlockBlob imageBlob = container.GetBlockBlobReference(storageFile.Name); | ||
using (var stream = await storageFile.OpenStreamForReadAsync()) | ||
{ | ||
await imageBlob.UploadFromStreamAsync(stream); | ||
} | ||
} | ||
} | ||
|
||
public static string GetContainerSasToken(CloudBlobContainer container, int sharedAccessStartTimeInMinutes, int sharedAccessExpiryTimeInMinutes) | ||
{ | ||
SharedAccessBlobPolicy sasPolicy = new SharedAccessBlobPolicy | ||
{ | ||
Permissions = SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read, | ||
SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-sharedAccessStartTimeInMinutes), | ||
SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(sharedAccessExpiryTimeInMinutes) | ||
}; | ||
|
||
return $"{container.Uri}{container.GetSharedAccessSignature(sasPolicy)}"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. | ||
// | ||
// Microsoft Cognitive Services: http://www.microsoft.com/cognitive | ||
// | ||
// Microsoft Cognitive Services Github: | ||
// https://github.com/Microsoft/Cognitive | ||
// | ||
// Copyright (c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// MIT License: | ||
// Permission is hereby granted, free of charge, to any person obtaining | ||
// a copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to | ||
// the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
using IntelligentKioskSample.Extensions; | ||
using System.Collections.Generic; | ||
using Windows.UI.Xaml; | ||
|
||
namespace IntelligentKioskSample.Controls.Animation | ||
{ | ||
public class AnimationHelper | ||
{ | ||
public static readonly DependencyProperty BaseAnimationsProperty = DependencyProperty.RegisterAttached("BaseAnimations", typeof(List<BaseAnimation>), typeof(AnimationHelper), new PropertyMetadata(null)); | ||
|
||
public static List<BaseAnimation> GetAnimations(DependencyObject obj) | ||
{ | ||
return (List<BaseAnimation>)obj.GetValue(BaseAnimationsProperty); | ||
} | ||
|
||
public static void SetAnimations(DependencyObject obj, List<BaseAnimation> value) | ||
{ | ||
obj.SetValue(BaseAnimationsProperty, value); | ||
} | ||
|
||
internal static void AddAnimation(BaseAnimation animation) | ||
{ | ||
var list = VerifyList(animation); | ||
int index = list.IndexOfItem(x => x.Equivalent(animation)); | ||
if (index != -1) | ||
{ | ||
var item = list[index]; | ||
item.Retain(); | ||
item.Stop(); | ||
list.RemoveAt(index); | ||
} | ||
|
||
list.Add(animation); | ||
} | ||
|
||
internal static void RemoveAnimation(BaseAnimation animation) | ||
{ | ||
var list = GetAnimations(animation.Element); | ||
if (list != null) | ||
{ | ||
animation.Retain(); | ||
animation.Stop(); | ||
list.Remove(animation); | ||
} | ||
} | ||
|
||
private static List<BaseAnimation> VerifyList(BaseAnimation animation) | ||
{ | ||
var list = GetAnimations(animation.Element); | ||
if (list == null) | ||
{ | ||
SetAnimations(animation.Element, list = new List<BaseAnimation>()); | ||
} | ||
return list; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. | ||
// | ||
// Microsoft Cognitive Services: http://www.microsoft.com/cognitive | ||
// | ||
// Microsoft Cognitive Services Github: | ||
// https://github.com/Microsoft/Cognitive | ||
// | ||
// Copyright (c) Microsoft Corporation | ||
// All rights reserved. | ||
// | ||
// MIT License: | ||
// Permission is hereby granted, free of charge, to any person obtaining | ||
// a copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to | ||
// the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
using IntelligentKioskSample.Extensions; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Media.Animation; | ||
|
||
namespace IntelligentKioskSample.Controls.Animation | ||
{ | ||
public class BaseAnimationCompleteEventArgs | ||
{ | ||
public bool NaturallyCompleted { get; set; } | ||
} | ||
|
||
public abstract class BaseAnimation | ||
{ | ||
public static readonly EasingFunctionBase DefaultOut = new QuadraticEase() { EasingMode = EasingMode.EaseOut }; | ||
public static readonly EasingFunctionBase DefaultIn = new QuadraticEase() { EasingMode = EasingMode.EaseIn }; | ||
public static readonly EasingFunctionBase DefaultInOut = new QuadraticEase() { EasingMode = EasingMode.EaseInOut }; | ||
|
||
private Storyboard storyboard; | ||
private BaseAnimationCompleteEventArgs completeResult = new BaseAnimationCompleteEventArgs() { NaturallyCompleted = true }; | ||
|
||
public bool ForceFinalValueRetained { get; set; } | ||
public FrameworkElement Element { get; protected set; } | ||
|
||
public Task<BaseAnimationCompleteEventArgs> Activate(FrameworkElement element) | ||
{ | ||
return Activate(element, false); | ||
} | ||
|
||
public async Task<BaseAnimationCompleteEventArgs> Activate(FrameworkElement element, bool forceFinalValueRetained) | ||
{ | ||
if (Element != null) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
ForceFinalValueRetained = forceFinalValueRetained; | ||
Element = element; | ||
storyboard = CreateStoryboard(); | ||
AnimationHelper.AddAnimation(this); | ||
await storyboard.BeginAsync(); | ||
|
||
storyboard = null; | ||
AnimationHelper.RemoveAnimation(this); | ||
Element = null; | ||
|
||
var result = completeResult; | ||
return result; | ||
} | ||
|
||
public void Stop() | ||
{ | ||
if (storyboard != null) | ||
{ | ||
storyboard.Stop(); | ||
completeResult.NaturallyCompleted = false; | ||
} | ||
} | ||
|
||
public virtual bool Equivalent(BaseAnimation animation) | ||
{ | ||
return animation.GetType() == GetType(); | ||
} | ||
|
||
protected abstract Storyboard CreateStoryboard(); | ||
|
||
public abstract void Retain(); | ||
} | ||
} |
Oops, something went wrong.