Skip to content

Commit

Permalink
User and Word add
Browse files Browse the repository at this point in the history
User Interface change
  • Loading branch information
AnilOsmanTur committed Aug 28, 2018
1 parent 66ad649 commit 95234ba
Show file tree
Hide file tree
Showing 49 changed files with 240 additions and 31,513 deletions.
11 changes: 11 additions & 0 deletions KinectRecorder/AddUser.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Window x:Class="KinectRecorder.AddUser"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="AddUser" Height="113.91" Width="302.256">
<Grid>
<Button x:Name="okBtn" Content="OK" HorizontalAlignment="Left" Margin="209,53,0,0" VerticalAlignment="Top" Width="75" FontWeight="Bold" Click="okBtn_Click"/>
<TextBox x:Name="NameBox" HorizontalAlignment="Left" Height="26" Margin="10,10,0,0" TextWrapping="Wrap" Text="Meymet" VerticalAlignment="Top" Width="194" FontSize="14"/>
<Label Content="Name" HorizontalAlignment="Left" Margin="209,10,0,0" VerticalAlignment="Top" Width="75" FontSize="14" Height="26" FontWeight="Bold"/>

</Grid>
</Window>
36 changes: 36 additions & 0 deletions KinectRecorder/AddUser.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace KinectRecorder
{
/// <summary>
/// Interaction logic for AddUser.xaml
/// </summary>
public partial class AddUser : Window
{
public string userName = "";

public AddUser()
{
InitializeComponent();
}

private void okBtn_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
this.userName = NameBox.Text;
}

}
}
11 changes: 11 additions & 0 deletions KinectRecorder/AddWord.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Window x:Class="KinectRecorder.AddWord"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="AddWord" Height="111.654" Width="298.872">
<Grid>
<Button x:Name="okBtn" Content="OK" HorizontalAlignment="Left" Margin="206,51,0,0" VerticalAlignment="Top" Width="75" FontWeight="Bold" Click="okBtn_Click"/>
<TextBox x:Name="WordNameBox" HorizontalAlignment="Left" Height="26" Margin="10,10,0,0" TextWrapping="Wrap" Text="pota" VerticalAlignment="Top" Width="194" FontSize="14"/>
<Label Content="Word" HorizontalAlignment="Left" Margin="209,10,0,0" VerticalAlignment="Top" Width="75" FontSize="14" Height="26" FontWeight="Bold"/>

</Grid>
</Window>
35 changes: 35 additions & 0 deletions KinectRecorder/AddWord.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace KinectRecorder
{
/// <summary>
/// Interaction logic for AddWord.xaml
/// </summary>
public partial class AddWord : Window
{
public string wordName = "";

public AddWord()
{
InitializeComponent();
}

private void okBtn_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
this.wordName = WordNameBox.Text;
}
}
}
18 changes: 17 additions & 1 deletion KinectRecorder/KinectRecorder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AddUser.xaml.cs">
<DependentUpon>AddUser.xaml</DependentUpon>
</Compile>
<Compile Include="AddWord.xaml.cs">
<DependentUpon>AddWord.xaml</DependentUpon>
</Compile>
<Compile Include="BodyIndexHandler.cs" />
<Compile Include="HeaderUnit.cs" />
<Compile Include="InfraredHandler.cs" />
Expand All @@ -128,6 +134,14 @@
<Compile Include="DepthHandler.cs" />
<Compile Include="SkeletonHandler.cs" />
<Compile Include="Word.cs" />
<Page Include="AddUser.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="AddWord.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -159,7 +173,9 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
13 changes: 13 additions & 0 deletions KinectRecorder/KinectRecorder.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>
123 changes: 117 additions & 6 deletions KinectRecorder/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public partial class MainWindow : Window, INotifyPropertyChanged
private CsvWriter headerWriter;
//private HeaderUnit headerUnit;

private StreamWriter streamWord;
private CsvWriter wordWriter;

private StreamWriter streamUser;
private CsvWriter userWriter;

/// <summary>
/// INotifyPropertyChangedPropertyChanged event to allow window controls to bind to changeable data
/// </summary>
Expand Down Expand Up @@ -216,6 +222,15 @@ private void MainWindow_Closing(object sender, CancelEventArgs e)
headerWriter.Dispose();
streamHeader.Dispose();
}

if(userWriter != null)
{
streamWord.Dispose();
streamUser.Dispose();

wordWriter.Dispose();
userWriter.Dispose();
}

}

Expand Down Expand Up @@ -624,6 +639,10 @@ private void FileBrowseBtn_Click(object sender, RoutedEventArgs e)
openHeader();
readFile();
fillCombos();
openCsvWriters();

addUserBtn.IsEnabled = true;
addWordBtn.IsEnabled = true;
}
else
{
Expand All @@ -632,6 +651,41 @@ private void FileBrowseBtn_Click(object sender, RoutedEventArgs e)

}

private void openCsvWriters()
{

if (File.Exists(folderPath + "/sign_app_words.csv"))
{
streamWord = new StreamWriter(folderPath + "/sign_app_words.csv", true);
wordWriter = new CsvWriter(streamWord);
}
else
{
streamWord = new StreamWriter(folderPath +"/sign_app_words.csv");
wordWriter = new CsvWriter(streamWord);

wordWriter.WriteHeader<HeaderUnit>();
wordWriter.NextRecordAsync();
streamWord.FlushAsync();
}

if (File.Exists(folderPath + "/sign_app_users.csv"))
{
streamUser = new StreamWriter(folderPath + "/sign_app_users.csv", true);
userWriter = new CsvWriter(streamUser);
}
else
{
streamUser = new StreamWriter(folderPath + "/sign_app_users.csv");
userWriter = new CsvWriter(streamUser);

userWriter.WriteHeader<User>();
userWriter.NextRecordAsync();
streamUser.FlushAsync();
}

}

private void repeatNumberText_TextChanged(object sender, TextChangedEventArgs e)
{

Expand Down Expand Up @@ -674,20 +728,25 @@ private void openHeader()

private void readFile()
{
var streamUsers = new StreamReader(folderPath+"/sign_app_users.csv");
var readerUsers = new CsvReader(streamUsers);
StreamReader streamUsers = new StreamReader(folderPath + "/sign_app_users.csv");
CsvReader readerUsers = new CsvReader(streamUsers);

var streamWords = new StreamReader(folderPath+"/sign_app_words.csv");
var readerWords = new CsvReader(streamWords);
StreamReader streamWords = new StreamReader(folderPath + "/sign_app_words.csv");
CsvReader readerWords = new CsvReader(streamWords);

users = readerUsers.GetRecords<User>().ToList<User>();
words = readerWords.GetRecords<Word>().ToList<Word>();


readerUsers.Dispose();
streamUsers.Dispose();

readerWords.Dispose();
streamWords.Dispose();
}

private void fillCombos()
{

foreach(User user in users)
{
userCombo.Items.Add(user.userName);
Expand Down Expand Up @@ -731,7 +790,7 @@ private void CreatePaths()
}
else
{
basePath = folderPath + "\\" + selectedWord.id.ToString() + "\\Sample";
basePath = folderPath + "\\" + selectedWord.id.ToString() + "\\Samples";
}

fileBasePath = basePath + "\\" + selectedUser.id.ToString() + "_" + repeatNumber + "_" + timeStamp;
Expand Down Expand Up @@ -805,12 +864,64 @@ private void previewBtn_Click(object sender, RoutedEventArgs e)

private void addWordBtn_Click(object sender, RoutedEventArgs e)
{
AddWord dlg = new AddWord();
dlg.Owner = this;

dlg.ShowDialog();

// Process data entered by user if dialog box is accepted
if (dlg.DialogResult == true)
{

if (users.Count > 0)
{
Word word = words[words.Count - 1];
word.id = word.id + 1;
word.word = dlg.wordName;

words.Add(word);

// combo box append
wordCombo.Items.Add(word.word);

wordWriter.WriteRecord<Word>(word);
wordWriter.NextRecordAsync();
streamWord.FlushAsync();
}

}

}

private void addUserBtn_Click(object sender, RoutedEventArgs e)
{

AddUser dlg = new AddUser();
dlg.Owner = this;

dlg.ShowDialog();

// Process data entered by user if dialog box is accepted
if (dlg.DialogResult == true)
{

if (users.Count > 0)
{
User user = users[users.Count - 1];
user.id = user.id + 1;
user.userName = dlg.userName;

users.Add(user);

// combo box append
userCombo.Items.Add(user.userName);

userWriter.WriteRecord<User>(user);
userWriter.NextRecordAsync();
streamUser.FlushAsync();
}

}
}


Expand Down
Binary file removed KinectRecorder/bin/Debug/Accord.Video.FFMPEG.dll
Binary file not shown.
Loading

0 comments on commit 95234ba

Please sign in to comment.