Skip to content

Commit 4706f01

Browse files
Merge pull request #2 from aspose-omr-cloud/18.8
18.8
2 parents bcd7489 + 2aca35a commit 4706f01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1428
-221
lines changed

Aspose.OMR.Client/Aspose.OMR.Client/Aspose.OMR.Client.csproj

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
</PropertyGroup>
4242
<ItemGroup>
4343
<Reference Include="Aspose.OMR.Cloud.SDK, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
44-
<HintPath>..\packages\Aspose.OMR-Cloud.1.0.2\lib\Aspose.OMR.Cloud.SDK.dll</HintPath>
44+
<HintPath>..\packages\Aspose.OMR-Cloud.1.0.3\lib\Aspose.OMR.Cloud.SDK.dll</HintPath>
4545
</Reference>
46-
<Reference Include="Aspose.Storage-Cloud, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
47-
<HintPath>..\packages\Aspose.Storage-Cloud.1.1.1\lib\Aspose.Storage-Cloud.dll</HintPath>
46+
<Reference Include="Aspose.Storage.Cloud.Sdk, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
47+
<HintPath>..\packages\Aspose.Storage-Cloud.18.3.0\lib\net20\Aspose.Storage.Cloud.Sdk.dll</HintPath>
4848
</Reference>
4949
<Reference Include="Microsoft.VisualBasic" />
5050
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -74,6 +74,7 @@
7474
<Generator>MSBuild:Compile</Generator>
7575
<SubType>Designer</SubType>
7676
</ApplicationDefinition>
77+
<Compile Include="Controls\ClipAreaElement.cs" />
7778
<Compile Include="Controls\EnumBindingSourceExtension.cs" />
7879
<Compile Include="Controls\OmrBarcodeElement.cs" />
7980
<Compile Include="Controls\OmrGridElement.cs" />
@@ -113,13 +114,15 @@
113114
<Compile Include="Converters\BubbleBrushConverter.cs" />
114115
<Compile Include="Converters\ImageConverter.cs" />
115116
<Compile Include="CoreApi.cs" />
117+
<Compile Include="Utility\ClippedArea.cs" />
116118
<Compile Include="Utility\CloudStorageManager.cs" />
117119
<Compile Include="Utility\DialogManager.cs" />
118120
<Compile Include="Utility\EnumExtensions.cs" />
119121
<Compile Include="Utility\FileToUpload.cs" />
120122
<Compile Include="Utility\GlobalConstants.cs" />
121123
<Compile Include="Utility\HelpManager.cs" />
122124
<Compile Include="Utility\ImageProcessor.cs" />
125+
<Compile Include="Utility\ImageRecognitionResult.cs" />
123126
<Compile Include="Utility\OmrFunctions.cs" />
124127
<Compile Include="Utility\PreprocessingConfiguration.cs" />
125128
<Compile Include="Utility\PreprocessingConfigurationManager.cs" />
@@ -133,6 +136,8 @@
133136
<Compile Include="Utility\UserSettingsUtility.cs" />
134137
<Compile Include="ViewModels\BarcodeViewModel.cs" />
135138
<Compile Include="ViewModels\BaseQuestionViewModel.cs" />
139+
<Compile Include="ViewModels\ClipAreaPreviewViewModel.cs" />
140+
<Compile Include="ViewModels\ClipAreaViewModel.cs" />
136141
<Compile Include="ViewModels\CorrectionErrorsViewModel.cs" />
137142
<Compile Include="ViewModels\CredentialsViewModel.cs" />
138143
<Compile Include="ViewModels\CustomMappingViewModel.cs" />
@@ -176,6 +181,12 @@
176181
<Compile Include="Views\BarcodePropertiesView.xaml.cs">
177182
<DependentUpon>BarcodePropertiesView.xaml</DependentUpon>
178183
</Compile>
184+
<Compile Include="Views\ClipAreaPropertiesView.xaml.cs">
185+
<DependentUpon>ClipAreaPropertiesView.xaml</DependentUpon>
186+
</Compile>
187+
<Compile Include="Views\ClipAreaView.xaml.cs">
188+
<DependentUpon>ClipAreaView.xaml</DependentUpon>
189+
</Compile>
179190
<Compile Include="Views\CommonPropertiesView.xaml.cs">
180191
<DependentUpon>CommonPropertiesView.xaml</DependentUpon>
181192
</Compile>
@@ -247,6 +258,14 @@
247258
<SubType>Designer</SubType>
248259
<Generator>MSBuild:Compile</Generator>
249260
</Page>
261+
<Page Include="Views\ClipAreaPropertiesView.xaml">
262+
<SubType>Designer</SubType>
263+
<Generator>MSBuild:Compile</Generator>
264+
</Page>
265+
<Page Include="Views\ClipAreaView.xaml">
266+
<SubType>Designer</SubType>
267+
<Generator>MSBuild:Compile</Generator>
268+
</Page>
250269
<Page Include="Views\CommonPropertiesView.xaml">
251270
<SubType>Designer</SubType>
252271
<Generator>MSBuild:Compile</Generator>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright (c) 2018 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* Licensed under the MIT (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://github.com/aspose-omr-cloud/aspose-omr-cloud-dotnet/blob/master/LICENSE
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
namespace Aspose.OMR.Client.Controls
17+
{
18+
using System.Windows.Documents;
19+
using System.Windows.Input;
20+
21+
/// <summary>
22+
/// Class containing logic for Clip Area visual control
23+
/// </summary>
24+
public class ClipAreaElement : BaseOmrElement
25+
{
26+
/// <summary>
27+
/// Add or remove adorners based on selection
28+
/// </summary>
29+
/// <param name="isSelected">IsSelected property value</param>
30+
protected override void UpdateAdorners(bool isSelected)
31+
{
32+
if (isSelected)
33+
{
34+
this.AddAdorners();
35+
}
36+
else
37+
{
38+
this.ClearAdorners();
39+
}
40+
}
41+
42+
/// <summary>
43+
/// Handles preview mouse down event
44+
/// </summary>
45+
/// <param name="e">The event args</param>
46+
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
47+
{
48+
base.OnPreviewMouseDown(e);
49+
50+
// update selection
51+
if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
52+
{
53+
// if key modifiers used -> reverse selection (select if was unselected and vice versa)
54+
this.IsSelected = !this.IsSelected;
55+
}
56+
else if (!this.IsSelected)
57+
{
58+
// no modifiers used and item wasn't selected -> clear selection on canvas and select item
59+
ControlHelper.FindParentCanvas(this).ClearSelection();
60+
this.IsSelected = true;
61+
}
62+
63+
this.Focus();
64+
e.Handled = false;
65+
}
66+
67+
/// <summary>
68+
/// Adds question adorner to adorner layer
69+
/// Can be customized with specific adorner
70+
/// </summary>
71+
private void AddAdorners()
72+
{
73+
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
74+
QuestionAdorner adorner = new QuestionAdorner(this);
75+
adornerLayer.Add(adorner);
76+
}
77+
78+
/// <summary>
79+
/// Removes all adorners from adorner layer
80+
/// </summary>
81+
private void ClearAdorners()
82+
{
83+
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
84+
Adorner[] adorners = adornerLayer.GetAdorners(this);
85+
86+
if (adorners != null)
87+
{
88+
foreach (Adorner adorner in adorners)
89+
{
90+
adornerLayer.Remove(adorner);
91+
}
92+
}
93+
}
94+
}
95+
}

Aspose.OMR.Client/Aspose.OMR.Client/Controls/CustomCanvas.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ protected override void OnMouseMove(MouseEventArgs e)
117117
{
118118
this.mode = SelectionRectnagleModes.Barcode;
119119
}
120+
else if (dataContext.IsAddingClipArea)
121+
{
122+
this.mode = SelectionRectnagleModes.Barcode;
123+
}
120124

121125
RubberbandAdorner adorner = new RubberbandAdorner(this, this.dragStartPoint, this.mode);
122126
adorner.MouseUp += this.AdornerMouseUp;

Aspose.OMR.Client/Aspose.OMR.Client/Controls/OmrBarcodeElement.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
using System;
17-
using System.Collections.Generic;
18-
using System.Linq;
19-
using System.Text;
20-
using System.Threading.Tasks;
21-
using System.Windows.Documents;
22-
using System.Windows.Input;
2316

2417
namespace Aspose.OMR.Client.Controls
2518
{
19+
using System.Windows.Documents;
20+
using System.Windows.Input;
21+
22+
/// <summary>
23+
/// Class containing logic for Barcode visual control
24+
/// </summary>
2625
public class OmrBarcodeElement : BaseOmrElement
2726
{
2827
/// <summary>

Aspose.OMR.Client/Aspose.OMR.Client/Controls/RubberbandAdorner.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ public RubberbandAdorner(CustomCanvas canvas, Point? dragStartPoint, SelectionRe
9393
this.toSelect = false;
9494
break;
9595
}
96+
97+
case SelectionRectnagleModes.ClipArea:
98+
{
99+
this.rubberandBrush = (Brush)Application.Current.FindResource("MainItemsBrush");
100+
this.toSelect = false;
101+
break;
102+
}
96103
}
97104

98105
this.rubberbandPen = new Pen(this.rubberandBrush, 1);

Aspose.OMR.Client/Aspose.OMR.Client/CoreApi.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ namespace Aspose.OMR.Client
2424
using Storage.Cloud.Sdk.Model;
2525
using Storage.Cloud.Sdk;
2626
using Storage.Cloud.Sdk.Model.Requests;
27-
using Com.Aspose.Omr.Api;
2827
using Com.Aspose.Omr.Model;
28+
using Com.Aspose.Omr.Api;
2929
using TemplateModel;
3030
using Utility;
3131
using ViewModels;
@@ -108,6 +108,7 @@ public static TemplateGenerationContent GenerateTemplate(string descriptionFileN
108108
byte[] imageFile = responseResult.ResponseFiles.First(x => x.Name.Contains(".png")).Data;
109109

110110
TemplateViewModel templateViewModel = TemplateSerializer.JsonToTemplate(Encoding.UTF8.GetString(template));
111+
templateViewModel.ImageFileFormat = ".png";
111112

112113
TemplateGenerationContent generationContent = new TemplateGenerationContent();
113114
generationContent.ImageData = imageFile;
@@ -174,7 +175,7 @@ public static FinalizationData FinalizeTemplate(string templateName, byte[] temp
174175
/// <param name="wasUploaded">Indicates if image was already uploaded on cloud</param>
175176
/// <param name="additionalParams">The additional parameters</param>
176177
/// <returns>Recognition results</returns>
177-
public static string RecognizeImage(string imageName, byte[] imageData, string templateId, bool wasUploaded, string additionalParams)
178+
public static ImageRecognitionResult RecognizeImage(string imageName, byte[] imageData, string templateId, bool wasUploaded, string additionalParams)
178179
{
179180
OMRResponse response = RunOmrTask(OmrFunctions.RecognizeImage, imageName, imageData, templateId, wasUploaded, true, additionalParams);
180181

@@ -191,8 +192,22 @@ public static string RecognizeImage(string imageName, byte[] imageData, string t
191192
throw new Exception(builder.ToString());
192193
}
193194

194-
string result = Encoding.UTF8.GetString(response.Payload.Result.ResponseFiles[0].Data);
195-
return result;
195+
ImageRecognitionResult recognitionResult = new ImageRecognitionResult();
196+
197+
foreach (Com.Aspose.Omr.Model.FileInfo file in responseResult.ResponseFiles)
198+
{
199+
if (file.Name.Contains(".dat"))
200+
{
201+
byte[] answersBytes = responseResult.ResponseFiles.First(x => x.Name.Contains(".dat")).Data;
202+
recognitionResult.RecognizedAnswers = Encoding.UTF8.GetString(answersBytes);
203+
}
204+
else if (file.Name.Contains(".jpg"))
205+
{
206+
recognitionResult.ClippedAreas.Add(new KeyValuePair<string, byte[]>(file.Name, file.Data));
207+
}
208+
}
209+
210+
return recognitionResult;
196211
}
197212

198213
/// <summary>
@@ -320,7 +335,6 @@ public static void StorageUploadImages(Dictionary<string, byte[]> imagesToUpload
320335
{
321336
BusyIndicatorManager.UpdateText("Uploading image " + item.Key + "...");
322337

323-
324338
string baseHost = new Uri(Basepath).GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped).ToString();
325339
Configuration storageConfiguration = new Configuration();
326340
storageConfiguration.AppKey = AppKey;

Aspose.OMR.Client/Aspose.OMR.Client/Properties/Resources.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Aspose.OMR.Client/Aspose.OMR.Client/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,6 @@
121121
<value>RootCanvas</value>
122122
</data>
123123
<data name="Version" xml:space="preserve">
124-
<value>18.6</value>
124+
<value>18.8</value>
125125
</data>
126126
</root>

Aspose.OMR.Client/Aspose.OMR.Client/RecognitionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
namespace Aspose.OMR.Client
1717
{
1818
/// <summary>
19-
/// Represent recognition result info for single question
19+
/// Represents recognition result info for single question
2020
/// </summary>
2121
public class RecognitionResult
2222
{

0 commit comments

Comments
 (0)