Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
hauerCodes committed Dec 14, 2014
1 parent 8d4a9e3 commit 2500806
Show file tree
Hide file tree
Showing 16 changed files with 550 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Graphics.Display;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;

namespace NumberRecognizer.App.Common
{
/// <summary>
/// Wertkonverter, der TRUE in <see cref="Visibility.Visible"/> und FALSE in
/// <see cref="Visibility.Collapsed"/> übersetzt.
/// </summary>
public class BooleanToVisibilityConverter : IValueConverter
{
/// <summary>
/// Ändert die Quelldaten vor der Übergabe an das Ziel zur Anzeige in der Benutzeroberfläche.
/// </summary>
/// <param name="value">Die Quelldaten, die ans Ziel übergeben werden.</param>
/// <param name="targetType">Der Typ der Zieleigenschaft. Dadurch wird ein anderer Typ verwendet, abhängig davon, ob Sie mit Microsoft .NET oder Visual&amp;nbsp;C++-Komponentenerweiterungen (C++/CX) programmieren. Siehe Hinweise.</param>
/// <param name="parameter">Ein optionaler Parameter, der in der Konverterlogik verwendet wird.</param>
/// <param name="language">Die Sprache der Konvertierung.</param>
/// <returns>
/// Der Wert, der an die Zielabhängigkeitseigenschaft übergeben werden soll.
/// </returns>
public object Convert(object value, Type targetType, object parameter, string language)
{
if (parameter != null)
{
return (value is bool && (bool)value) ? Visibility.Collapsed : Visibility.Visible;
}
return (value is bool && (bool)value) ? Visibility.Visible : Visibility.Collapsed;
}

/// <summary>
/// Ändert die Zieldaten vor der Übergabe an das Quellobjekt. Diese Methode wird nur in TwoWay-Bindungen aufgerufen.
/// </summary>
/// <param name="value">Die Zieldaten, die an die Quelle übergeben werden.</param>
/// <param name="targetType">Der Typ der Zieleigenschaft, angegeben durch eine Hilfestruktur, die den Typnamen umschließt.</param>
/// <param name="parameter">Ein optionaler Parameter, der in der Konverterlogik verwendet wird.</param>
/// <param name="language">Die Sprache der Konvertierung.</param>
/// <returns>
/// Der Wert, der an das Quellobjekt weitergeleitet wird.
/// </returns>
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value is Visibility && (Visibility)value == Visibility.Visible;
}
}
}
8 changes: 8 additions & 0 deletions NumberRecognizer/NumberRecognizer.App/Control/InkCanvasRT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ private static double Distance(Point p1, Point p2)
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RightTappedRoutedEventArgs"/> instance containing the event data.</param>
private void InkCanvasRT_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
ClearInk();
}

/// <summary>
/// Clears the ink canvas.
/// </summary>
public void ClearInk()
{
this.Children.Clear();
this.inkManager = new InkManager();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using NumberRecognizer.Cloud.Contract.Data;

namespace NumberRecognizer.App.DataModel
{
public class LocalTrainingImage
{
public TrainingImage ImageData { get; set; }

public String LocalImagePath { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GalaSoft.MvvmLight;

namespace NumberRecognizer.App.DataModel
{
public class LocalTrainingImageGroup : ViewModelBase
{
/// <summary>
/// The titel
/// </summary>
private string title;

/// <summary>
/// Initializes a new instance of the <see cref="NetworkDataGroup"/> class.
/// </summary>
/// <param name="uniqueId">The unique identifier.</param>
/// <param name="title">The title.</param>
public LocalTrainingImageGroup(string uniqueId, string title)
{
this.UniqueId = uniqueId;
this.Title = title;
this.Items = new ObservableCollection<LocalTrainingImage>();
}

/// <summary>
/// Gets the unique identifier.
/// </summary>
/// <imgByte>
/// The unique identifier.
/// </imgByte>
public string UniqueId { get; private set; }

/// <summary>
/// Gets the title.
/// </summary>
/// <imgByte>
/// The title.
/// </imgByte>
public string Title
{
get
{
return title;
}
private set
{
this.title = value;
RaisePropertyChanged(() => Title);
}
}

/// <summary>
/// Gets the items.
/// </summary>
/// <imgByte>
/// The items.
/// </imgByte>
public ObservableCollection<LocalTrainingImage> Items { get; set; }
}
}
4 changes: 3 additions & 1 deletion NumberRecognizer/NumberRecognizer.App/Help/ImageHelperRT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static byte[] GetByteArrayFrom2DPixelArrayAsync(double[,] pixelArray2D)
/// <returns>
/// The red, green, blue, alpha byte array as bitmap image asynchronous.
/// </returns>
public static async Task SaveRGBAByteArrayAsBitmapImageAsync(byte[] rgbaByteArray, double width, double height, string name)
public static async Task<string> SaveRGBAByteArrayAsBitmapImageAsync(byte[] rgbaByteArray, double width, double height, string name)
{
var storageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(name + ".png", CreationCollisionOption.ReplaceExisting);

Expand All @@ -161,6 +161,8 @@ public static async Task SaveRGBAByteArrayAsBitmapImageAsync(byte[] rgbaByteArra
bitmapEncoder.BitmapTransform.InterpolationMode = BitmapInterpolationMode.NearestNeighbor;
await bitmapEncoder.FlushAsync();
}

return storageFile.Path;
}

/// <summary>
Expand Down
11 changes: 11 additions & 0 deletions NumberRecognizer/NumberRecognizer.App/NumberRecognizer.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Common\BooleanToVisibilityConverter.cs" />
<Compile Include="Control\InkCanvasRT.cs" />
<Compile Include="DataModel\LocalTrainingImage.cs" />
<Compile Include="DataModel\LocalTrainingImageGroup.cs" />
<Compile Include="DataModel\NetworkDataGroup.cs" />
<Compile Include="Help\ImageHelperRT.cs" />
<Compile Include="Service References\NumberRecognizerService\Reference.cs">
Expand All @@ -122,6 +125,7 @@
<Compile Include="ViewModel\CreateNetworkViewModel.cs" />
<Compile Include="ViewModel\GroupedNetworksDesignViewModel.cs" />
<Compile Include="ViewModel\GroupedNetworksViewModel.cs" />
<Compile Include="ViewModel\ValidateTrainingDataViewModel.cs" />
<Compile Include="View\GroupedNetworksPage.xaml.cs">
<DependentUpon>GroupedNetworksPage.xaml</DependentUpon>
</Compile>
Expand All @@ -139,6 +143,9 @@
<Compile Include="View\RecognizePage.xaml.cs">
<DependentUpon>RecognizePage.xaml</DependentUpon>
</Compile>
<Compile Include="View\ValidateTrainingDataPage.xaml.cs">
<DependentUpon>ValidateTrainingDataPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
Expand Down Expand Up @@ -208,6 +215,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\ValidateTrainingDataPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Reference Include="De.TorstenMandelkow.MetroChart, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://tempuri.org/" elementFormDefault="qualified" targetNamespace="http://tempuri.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation="http://numberrecognizer.cloudapp.net/NumberRecognizerService.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/NumberRecognizer.Cloud.Contract.Data" />
<xs:element name="GetNetworks">
Expand All @@ -13,7 +13,7 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CreateNetwork">
<xs:element name="ValidateTrainingData">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="networkName" nillable="true" type="xs:string" />
Expand All @@ -22,14 +22,14 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CreateNetworkResponse">
<xs:element name="ValidateTrainingDataResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="CreateNetworkResult" type="xs:boolean" />
<xs:element minOccurs="0" name="ValidateTrainingDataResult" type="xs:boolean" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CreateNetworkWithTrainingDataCopy">
<xs:element name="ValidateTrainingDataWithTrainingDataCopy">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="networkName" nillable="true" type="xs:string" />
Expand All @@ -39,10 +39,10 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CreateNetworkWithTrainingDataCopyResponse">
<xs:element name="ValidateTrainingDataWithTrainingDataCopyResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="CreateNetworkWithTrainingDataCopyResult" type="xs:boolean" />
<xs:element minOccurs="0" name="ValidateTrainingDataWithTrainingDataCopyResult" type="xs:boolean" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface INumberRecognizerService {
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INumberRecognizerService/GetNetworks", ReplyAction="http://tempuri.org/INumberRecognizerService/GetNetworksResponse")]
System.Threading.Tasks.Task<System.Collections.ObjectModel.ObservableCollection<NumberRecognizer.Cloud.Contract.Data.NetworkInfo>> GetNetworksAsync();

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INumberRecognizerService/CreateNetwork", ReplyAction="http://tempuri.org/INumberRecognizerService/CreateNetworkResponse")]
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INumberRecognizerService/ValidateTrainingData", ReplyAction="http://tempuri.org/INumberRecognizerService/CreateNetworkResponse")]
System.Threading.Tasks.Task<bool> CreateNetworkAsync(string networkName, string username, System.Collections.ObjectModel.ObservableCollection<NumberRecognizer.Cloud.Contract.Data.TrainingImage> individualTrainingsData);

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/INumberRecognizerService/CreateNetworkWithTrainingDataCopy", ReplyAction="http://tempuri.org/INumberRecognizerService/CreateNetworkWithTrainingDataCopyResp" +
Expand Down
11 changes: 11 additions & 0 deletions NumberRecognizer/NumberRecognizer.App/Style/AppStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,15 @@
<Setter Property="Height" Value="500"/>
</Style>

<Style x:Key="ClearButtonStyle" TargetType="Button" >
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontFamily" Value="Segoe UI Symbol" />
<Setter Property="Content" Value="&#xE107;"/>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Height" Value="40" />
<Setter Property="Width" Value="50" />
</Style>


</ResourceDictionary>
26 changes: 19 additions & 7 deletions NumberRecognizer/NumberRecognizer.App/View/CreateNetworkPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<x:Double x:Key="StrokeThickness">4.0</x:Double>
<x:Double x:Key="FontSize">40.0</x:Double>
<x:Double x:Key="InkHeight">100</x:Double>

<common:BooleanToVisibilityConverter x:Key="boolVisConverter" />
</Page.Resources>

<!--
Expand Down Expand Up @@ -56,6 +58,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
Expand All @@ -78,19 +81,18 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0" Grid.Column="0" Name="NameTextBox" FontSize="{StaticResource FontSize}"/>
<Button Grid.Column="1" Margin="10,0" Command="{Binding CreateNetwork}">Train Network</Button>
<TextBox Grid.Row="0" Grid.Column="0" Name="NameTextBox" FontSize="{StaticResource FontSize}" Text="{Binding NetworkName}"/>
<Button Grid.Column="1" Margin="10,0" Command="{Binding ValidateTrainingData}">Validate Training Images</Button>
</Grid>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Description:&#42;" Style="{StaticResource SubheaderTextBlockStyle}" VerticalAlignment="Center" HorizontalAlignment="Center"/>


<TextBlock Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="1" Text="Please write some Network Training Data Numbers on each Canvas."

<TextBlock Grid.Row="1" Grid.Column="1" Text="Please write at least one Network Training Data Number on each Canvas!"
Style="{StaticResource CustomTextBlockStyle}" Margin="0, 10"
Foreground="OrangeRed" VerticalAlignment="Center"/>
Foreground="OrangeRed" VerticalAlignment="Center" Visibility="{Binding IsValidationError, Converter={StaticResource boolVisConverter}}"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="0" Style="{StaticResource SubheaderTextBlockStyle}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<control:InkCanvasRT Grid.Row="2" Grid.Column="1" x:Name="InkCanvasRT0"
StrokeThickness="{StaticResource StrokeThickness}"
Height="{StaticResource InkHeight}" Margin="0,10" />
Height="{StaticResource InkHeight}" Margin="0,20,0,10" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="1" Style="{StaticResource SubheaderTextBlockStyle}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<control:InkCanvasRT Grid.Row="3" Grid.Column="1" x:Name="InkCanvasRT1"
StrokeThickness="{StaticResource StrokeThickness}"
Expand Down Expand Up @@ -127,6 +129,16 @@
<control:InkCanvasRT Grid.Row="11" Grid.Column="1" x:Name="InkCanvasRT9"
StrokeThickness="{StaticResource StrokeThickness}"
Height="{StaticResource InkHeight}" Margin="0,10"/>
<Button Grid.Column="2" Grid.Row="2" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="0" />
<Button Grid.Column="2" Grid.Row="3" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="1"/>
<Button Grid.Column="2" Grid.Row="4" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="2"/>
<Button Grid.Column="2" Grid.Row="5" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="3"/>
<Button Grid.Column="2" Grid.Row="6" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="4"/>
<Button Grid.Column="2" Grid.Row="7" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="5"/>
<Button Grid.Column="2" Grid.Row="8" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="6"/>
<Button Grid.Column="2" Grid.Row="9" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="7"/>
<Button Grid.Column="2" Grid.Row="10" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="8"/>
<Button Grid.Column="2" Grid.Row="11" Style="{StaticResource ClearButtonStyle}" Command="{Binding ClearInk}" CommandParameter="9"/>
</Grid>

</ScrollViewer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
using Windows.UI.Xaml.Shapes;

namespace NumberRecognizer.App
{

{
/// <summary>
/// A basic page that provides characteristics common to most applications.
/// </summary>
Expand Down Expand Up @@ -75,7 +74,7 @@ public NavigationHelper NavigationHelper
get { return this.navigationHelper; }
}

#region NavigationHelper registration
#region NavigationHelper-Registration

/// <summary>
/// Invoked when the Page is loaded and becomes the current source of a parent Frame.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@
AutomationProperties.Name="Back"
AutomationProperties.AutomationId="BackButton"
AutomationProperties.ItemType="Navigation Button"/>
<TextBlock x:Name="pageTitle" Text="{Binding NetworkName}" Style="{StaticResource CustomHeaderTextBlockStyle}" Grid.Column="1"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" >
<TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Style="{StaticResource CustomHeaderTextBlockStyle}" />
<TextBlock Text=" - " Foreground="OrangeRed" Style="{StaticResource CustomHeaderTextBlockStyle}" />
<TextBlock x:Name="pageSubTitle" Text="{Binding NetworkName}" Foreground="OrangeRed" Style="{StaticResource CustomHeaderTextBlockStyle}" />
</StackPanel>
</Grid>
</Grid>
</Page>
Loading

0 comments on commit 2500806

Please sign in to comment.