add binding to rom list retrieved from data base

This commit is contained in:
Duc Le
2015-06-18 22:29:52 +00:00
parent 4fadb321b0
commit 5fd8156ed9
9 changed files with 131 additions and 61 deletions
+4 -4
View File
@@ -10,8 +10,8 @@ using namespace Platform::Collections;
namespace VBA10
{
ROMDBEntry::ROMDBEntry(int locationtype, Platform::String^ displayname, Platform::String^ filename, Platform::String^ folderpath)
:_locationType(locationtype), _displayName(displayname), _fileName(filename), _folderPath(folderpath)
ROMDBEntry::ROMDBEntry(int locationtype, Platform::String^ displayname, Platform::String^ filename, Platform::String^ filepath)
:_locationType(locationtype), _displayName(displayname), _fileName(filename), _filePath(filepath)
{
_lastPlayed = DateTime{ 0 };
_autoSaveIndex = 0;
@@ -19,9 +19,9 @@ namespace VBA10
}
ROMDBEntry::ROMDBEntry(int locationtype, Platform::String^ displayname, Platform::String^ filename, Platform::String^ folderpath,
ROMDBEntry::ROMDBEntry(int locationtype, Platform::String^ displayname, Platform::String^ filename, Platform::String^ filepath,
DateTime lastplayed, int autosaveindex, Platform::String^ snapshoturi)
:_locationType(locationtype), _displayName(displayname), _fileName(filename), _folderPath(folderpath),
:_locationType(locationtype), _displayName(displayname), _fileName(filename), _filePath(filepath),
_lastPlayed(lastplayed), _autoSaveIndex(autosaveindex), _snapshotUri(snapshoturi)
{
+7 -7
View File
@@ -12,13 +12,13 @@ using namespace concurrency;
namespace VBA10
{
[Windows::UI::Xaml::Data::BindableAttribute]
public ref class ROMDBEntry sealed
{
public:
ROMDBEntry(int locationtype, Platform::String^ displayname, Platform::String^ filename, Platform::String^ folderpath);
ROMDBEntry(int locationtype, Platform::String^ displayname, Platform::String^ filename, Platform::String^ filepath);
ROMDBEntry(int locationtype, Platform::String^ displayname, Platform::String^ filename, Platform::String^ folderpath,
ROMDBEntry(int locationtype, Platform::String^ displayname, Platform::String^ filename, Platform::String^ filepath,
DateTime lastplayed, int autosaveindex, Platform::String^ snapshoturi);
//property int ID
@@ -71,15 +71,15 @@ namespace VBA10
}
}
property Platform::String^ FolderPath
property Platform::String^ FilePath
{
Platform::String^ get()
{
return _folderPath;
return _filePath;
}
void set(Platform::String^ value)
{
_folderPath = value;
_filePath = value;
}
}
@@ -124,7 +124,7 @@ namespace VBA10
int _locationType;
Platform::String^ _displayName;
Platform::String^ _fileName;
Platform::String^ _folderPath;
Platform::String^ _filePath;
Windows::Foundation::DateTime _lastPlayed;
int _autoSaveIndex;
Platform::String^ _snapshotUri;
+11 -4
View File
@@ -45,7 +45,7 @@ namespace VBA10
"LOCATIONTYPE INT NOT NULL,"\
"DISPLAYNAME TEXT NOT NULL,"\
"FILENAME INT NOT NULL,"\
"FOLDERPATH INT NOT NULL,"\
"FILEPATH INT NOT NULL,"\
"LASTPLAY INT NOT NULL,"\
"AUTOSAVEINDEX INT NOT NULL, "\
"SNAPSHOTURI TEXT NOT NULL );");
@@ -84,11 +84,15 @@ namespace VBA10
{
return create_task([this, entry]
{
Platform::String^ cmd = "INSERT INTO ROMTABLE (LOCATIONTYPE, DISPLAYNAME, FILENAME, FOLDERPATH, LASTPLAY, AUTOSAVEINDEX, SNAPSHOTURI) VALUES (";
//first add this rom to the list
_allROMDBEntries->Append(entry);
//prepare statement to add to rom table
Platform::String^ cmd = "INSERT INTO ROMTABLE (LOCATIONTYPE, DISPLAYNAME, FILENAME, FILEPATH, LASTPLAY, AUTOSAVEINDEX, SNAPSHOTURI) VALUES (";
cmd += entry->LocationType + ",";
cmd += "'" + entry->DisplayName + "',";
cmd += "'" + entry->FileName + "',";
cmd += "'" + entry->FolderPath + "',";
cmd += "'" + entry->FilePath + "',";
cmd += entry->LastPlay.UniversalTime + ",";
cmd += entry->AutoSaveIndex + ",";
cmd += "'" + entry->SnapshotUri + "')";
@@ -117,6 +121,7 @@ namespace VBA10
}).then([this, items](bool ret)
{
if (ret)
{
return create_iterative_task([this, items]
{
return create_task([this, items]
@@ -130,7 +135,9 @@ namespace VBA10
return statement->StepAsync();
});
});;
}
else
return create_task([] {});
}).then([items](task<void> t)
{
return items; //t.get();
+3 -3
View File
@@ -32,9 +32,9 @@ namespace VBA10
task<void> Initialize(void);
task<void> Add(ROMDBEntry^ entry);
task<Vector<ROMDBEntry^>^> RetrieveQuerry();
property WFC::IObservableVector<ROMDBEntry^>^ AllROMDBEntries
property PC::Vector<ROMDBEntry^>^ AllROMDBEntries
{
WFC::IObservableVector<ROMDBEntry^>^ get()
PC::Vector<ROMDBEntry^>^ get()
{
return _allROMDBEntries;
}
@@ -46,7 +46,7 @@ namespace VBA10
SQLiteWinRT::Database^ db;
SQLiteWinRT::Statement^ statement; //temporary pointer to store statement
WFC::IObservableVector<ROMDBEntry^>^ _allROMDBEntries;
PC::Vector<ROMDBEntry^>^ _allROMDBEntries;
};