From: <nor...@us...> - 2007-08-03 08:07:23
|
Revision: 786 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=786&view=rev Author: northern_sky Date: 2007-08-03 01:07:10 -0700 (Fri, 03 Aug 2007) Log Message: ----------- replaced SystemDefault with mapping to PlatformId Modified Paths: -------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.Designer.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.Designer.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.Designer.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemFactory.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramUtils.cs trunk/plugins/myGUIProgramsAlt/README.txt Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -24,6 +24,7 @@ #endregion using System; + using System.Collections; using System.Collections.Generic; using System.IO; @@ -38,97 +39,97 @@ namespace GUIPrograms.Database { - /// <summary> - /// DBhandling methods - /// </summary> - public class DatabaseHandler - { + /// <summary> + /// DBhandling methods + /// </summary> + public class DatabaseHandler + { - private static SQLiteConnection sqlLiteConn = null; + private static SQLiteConnection sqlLiteConn = null; - static List<ApplicationItem> globalApplicationItemList = new List<ApplicationItem>(); - private const string DATABASEFILE = "myProgramsAltDatabaseV1.db3"; + static List<ApplicationItem> globalApplicationItemList = new List<ApplicationItem>(); + private const string DATABASEFILE = "myProgramsAltDatabaseV1.db3"; - public static bool useMPsThumbDirectory = false; + public static bool useMPsThumbDirectory = false; - // singleton. Dont allow any instance of this class - private DatabaseHandler() { } + // singleton. Dont allow any instance of this class + private DatabaseHandler() { } - static DatabaseHandler() - { - string DatabasePath = Config.GetFile( Config.Dir.Database, DATABASEFILE ); + static DatabaseHandler() + { + string DatabasePath = Config.GetFile(Config.Dir.Database, DATABASEFILE); - try - { + try + { - //check if database exists - if ( !File.Exists( DatabasePath ) ) - { - SQLiteConnection.CreateFile( Config.GetFile( Config.Dir.Database, DATABASEFILE ) ); - string connString = "Data Source=" + Config.GetFile( Config.Dir.Database, DATABASEFILE ); - sqlLiteConn = new SQLiteConnection( connString ); + //check if database exists + if (!File.Exists(DatabasePath)) + { + SQLiteConnection.CreateFile(DatabasePath); + string connString = "Data Source=" + Config.GetFile(Config.Dir.Database, DATABASEFILE); + sqlLiteConn = new SQLiteConnection(connString); - SetPragmas(); + SetPragmas(); - // make sure the DB-structure is complete - CreateDBTables(); + // make sure the DB-structure is complete + CreateDBTables(); - //fill upp some default lexicon values - InsertDefaultDBValues(); - } - else - { - string connString = "Data Source=" + Config.GetFile( Config.Dir.Database, DATABASEFILE ) + ";Version=3"; - sqlLiteConn = new SQLiteConnection( connString ); - } - //globalApplicationItemList = new ApplicationItemList(sqlDB, new ApplicationItem.FilelinkLaunchEventHandler(LaunchFilelink)); - LoadAllApplicationItems(); - } - catch ( SQLiteException ex ) - { - Log.Info( "programdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace ); - } - } - static private void SetPragmas() - { - ExecuteStmtNonQuery( "PRAGMA default_cache_size=3000" ); - ExecuteStmtNonQuery( "PRAGMA count_changes=1" ); - ExecuteStmtNonQuery( "PRAGMA short_column_names=1" ); - ExecuteStmtNonQuery( "PRAGMA auto_vacuum=1" ); + //fill upp some default lexicon values + InsertDefaultDBValues(); + } + else + { + string connString = "Data Source=" + Config.GetFile(Config.Dir.Database, DATABASEFILE) + ";Version=3"; + sqlLiteConn = new SQLiteConnection(connString); + } + //globalApplicationItemList = new ApplicationItemList(sqlDB, new ApplicationItem.FilelinkLaunchEventHandler(LaunchFilelink)); + LoadAllApplicationItems(); + } + catch (SQLiteException ex) + { + Log.Info("programdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); + } + } + static private void SetPragmas() + { + ExecuteStmtNonQuery("PRAGMA default_cache_size=3000"); + ExecuteStmtNonQuery("PRAGMA count_changes=1"); + ExecuteStmtNonQuery("PRAGMA short_column_names=1"); + ExecuteStmtNonQuery("PRAGMA auto_vacuum=1"); - } + } - /*static void LaunchFilelink(FilelinkItem curLink, bool MPGUIMode) - { - ApplicationItem targetApp = globalApplicationItemList.GetAppByID(curLink.TargetAppID); - if (targetApp != null) - { - targetApp.LaunchFile(curLink, MPGUIMode); - } - }*/ + /*static void LaunchFilelink(FilelinkItem curLink, bool MPGUIMode) + { + ApplicationItem targetApp = globalApplicationItemList.GetAppByID(curLink.TargetAppID); + if (targetApp != null) + { + targetApp.LaunchFile(curLink, MPGUIMode); + } + }*/ - // we can always keep an connection open in sqllite.. - //to expensive closing it - public static SQLiteConnection SqlLiteConn - { - get - { - if ( sqlLiteConn.State == ConnectionState.Closed ) - { - sqlLiteConn.Open(); - } - return sqlLiteConn; - } - } + // we can always keep an connection open in sqllite.. + //to expensive closing it + public static SQLiteConnection SqlLiteConn + { + get + { + if (sqlLiteConn.State == ConnectionState.Closed) + { + sqlLiteConn.Open(); + } + return sqlLiteConn; + } + } - /// <summary> - /// Create db tables etc,if not already exist - /// </summary> - /// <returns></returns> - static bool CreateDBTables() - { - string sqlStmt = @"CREATE TABLE + /// <summary> + /// Create db tables etc,if not already exist + /// </summary> + /// <returns></returns> + static bool CreateDBTables() + { + string sqlStmt = @"CREATE TABLE tblApplicationItem ( applicationId INTEGER PRIMARY KEY, @@ -150,63 +151,63 @@ importValidImagesOnly BOOL, iposition INTEGER, refreshGUIAllowed BOOL, - systemdefault TEXT, + platformId INTEGER, waitForExit BOOL, preLaunch TEXT, postLaunch TEXT )"; - ExecuteStmtNonQuery( sqlStmt ); + ExecuteStmtNonQuery(sqlStmt); - sqlStmt = @"CREATE TABLE tblFileItem (fileid INTEGER PRIMARY KEY, applicationId INTEGER, title TEXT, filename TEXT, imagefile TEXT, mainGenreId INTEGER, subGenreId INTEGER, country TEXT, manufacturerId INTEGER, year INTEGER, rating INTEGER, overview TEXT, platformId INTEGER, lastTimeLaunched TEXT, launchcount INTEGER, categorydata TEXT, gameInfoUrl TEXT)"; - ExecuteStmtNonQuery( sqlStmt ); - sqlStmt = @"CREATE TABLE tblFilterItem (applicationId INTEGER, grouperAppID INTEGER, fileID INTEGER, filename TEXT, tag INTEGER)"; - ExecuteStmtNonQuery( sqlStmt ); - sqlStmt = @"CREATE TABLE tblSetting (settingid INTEGER PRIMARY KEY, key TEXT, value TEXT)"; - ExecuteStmtNonQuery( sqlStmt ); + sqlStmt = @"CREATE TABLE tblFileItem (fileid INTEGER PRIMARY KEY, applicationId INTEGER, title TEXT, filename TEXT, imagefile TEXT, mainGenreId INTEGER, subGenreId INTEGER, country TEXT, manufacturerId INTEGER, year INTEGER, rating INTEGER, overview TEXT, platformId INTEGER, lastTimeLaunched TEXT, launchcount INTEGER, categorydata TEXT, gameInfoUrl TEXT)"; + ExecuteStmtNonQuery(sqlStmt); + sqlStmt = @"CREATE TABLE tblFilterItem (applicationId INTEGER, grouperAppID INTEGER, fileID INTEGER, filename TEXT, tag INTEGER)"; + ExecuteStmtNonQuery(sqlStmt); + sqlStmt = @"CREATE TABLE tblSetting (settingid INTEGER PRIMARY KEY, key TEXT, value TEXT)"; + ExecuteStmtNonQuery(sqlStmt); - sqlStmt = @"CREATE TABLE + sqlStmt = @"CREATE TABLE tblGenre ( genreId INTEGER PRIMARY KEY, genre TEXT )"; - ExecuteStmtNonQuery( sqlStmt ); - sqlStmt = @"CREATE TABLE + ExecuteStmtNonQuery(sqlStmt); + sqlStmt = @"CREATE TABLE tblPlatform ( platformId INTEGER PRIMARY KEY, platform TEXT )"; - ExecuteStmtNonQuery( sqlStmt ); - sqlStmt = @"CREATE TABLE + ExecuteStmtNonQuery(sqlStmt); + sqlStmt = @"CREATE TABLE tblManufacturer ( manufacturerId INTEGER PRIMARY KEY, manufacturer TEXT )"; - ExecuteStmtNonQuery( sqlStmt ); + ExecuteStmtNonQuery(sqlStmt); - sqlStmt = @"CREATE INDEX idxFile1 ON tblFileItem(applicationId)"; - ExecuteStmtNonQuery( sqlStmt ); - sqlStmt = @"CREATE INDEX idxApp1 ON tblApplicationItem(fatherNodeId)"; - ExecuteStmtNonQuery( sqlStmt ); - sqlStmt = @"CREATE UNIQUE INDEX idxFilterItem1 ON tblFilterItem(applicationId, fileID, grouperAppID)"; - ExecuteStmtNonQuery( sqlStmt ); + sqlStmt = @"CREATE INDEX idxFile1 ON tblFileItem(applicationId)"; + ExecuteStmtNonQuery(sqlStmt); + sqlStmt = @"CREATE INDEX idxApp1 ON tblApplicationItem(fatherNodeId)"; + ExecuteStmtNonQuery(sqlStmt); + sqlStmt = @"CREATE UNIQUE INDEX idxFilterItem1 ON tblFilterItem(applicationId, fileID, grouperAppID)"; + ExecuteStmtNonQuery(sqlStmt); - return true; - } + return true; + } - /// <summary> - /// Inserting some default values so that the db is preloaded - /// Should always be there. - /// </summary> - private static void InsertDefaultDBValues() - { + /// <summary> + /// Inserting some default values so that the db is preloaded + /// Should always be there. + /// </summary> + private static void InsertDefaultDBValues() + { - string sqlStmt = @"INSERT INTO + string sqlStmt = @"INSERT INTO tblGenre ( genre @@ -216,9 +217,9 @@ 'Unknown' )"; - ExecuteStmtNonQuery( sqlStmt ); + ExecuteStmtNonQuery(sqlStmt); - sqlStmt = @"INSERT INTO + sqlStmt = @"INSERT INTO tblManufacturer ( manufacturer @@ -229,9 +230,9 @@ )"; - ExecuteStmtNonQuery( sqlStmt ); + ExecuteStmtNonQuery(sqlStmt); - sqlStmt = @"INSERT INTO + sqlStmt = @"INSERT INTO tblPlatform ( platform @@ -241,27 +242,27 @@ 'Unknown' )"; - ExecuteStmtNonQuery( sqlStmt ); + ExecuteStmtNonQuery(sqlStmt); - using ( SQLiteTransaction transaction = SqlLiteConn.BeginTransaction() ) - { - FillDefaultDBLexiconHelper( "tblPlatform", "platform", CreateSystemLexiconList() ); - FillDefaultDBLexiconHelper( "tblManufacturer", "manufacturer", CreateManufacturerLexiconList() ); - FillDefaultDBLexiconHelper( "tblGenre", "genre", CreateGenreLexiconList() ); + using (SQLiteTransaction transaction = SqlLiteConn.BeginTransaction()) + { + FillDefaultDBLexiconHelper("tblPlatform", "platform", CreateSystemLexiconList()); + FillDefaultDBLexiconHelper("tblManufacturer", "manufacturer", CreateManufacturerLexiconList()); + FillDefaultDBLexiconHelper("tblGenre", "genre", CreateGenreLexiconList()); - transaction.Commit(); - } + transaction.Commit(); + } - } + } - private static void FillDefaultDBLexiconHelper(string tableName, string columnName, List<string> itemList) - { - SQLiteParameter[] paramCollection = new SQLiteParameter[1]; - SQLiteParameter paramInsertValue = new SQLiteParameter( "@insertValue", DbType.String ); - paramCollection[0] = paramInsertValue; + private static void FillDefaultDBLexiconHelper(string tableName, string columnName, List<string> itemList) + { + SQLiteParameter[] paramCollection = new SQLiteParameter[1]; + SQLiteParameter paramInsertValue = new SQLiteParameter("@insertValue", DbType.String); + paramCollection[0] = paramInsertValue; - string sqlStmt = @" + string sqlStmt = @" INSERT INTO " + tableName + @" ( @@ -272,22 +273,22 @@ @insertValue );"; - foreach ( string insertValue in itemList ) - { + foreach (string insertValue in itemList) + { - paramCollection[0].Value = insertValue; - ExecuteStmtNonQuery( sqlStmt, paramCollection ); - } - } + paramCollection[0].Value = insertValue; + ExecuteStmtNonQuery(sqlStmt, paramCollection); + } + } - #region dbsettings - static public string ReadSetting(string Key) - { - string sqlStmt = string.Empty; + #region dbsettings + static public string ReadSetting(string Key) + { + string sqlStmt = string.Empty; - string keyValue = string.Empty; - sqlStmt = @" + string keyValue = string.Empty; + sqlStmt = @" SELECT value @@ -298,19 +299,19 @@ key ='" + Key + "'"; - object o = ExecuteStmtScalar( sqlStmt ); - if ( o != null ) - { - keyValue = o.ToString(); - } - return keyValue; - } + object o = ExecuteStmtScalar(sqlStmt); + if (o != null) + { + keyValue = o.ToString(); + } + return keyValue; + } - static int CountKey(string Key) - { - string sqlStmt = string.Empty; - int keyValue = 0; - sqlStmt = @" + static int CountKey(string Key) + { + string sqlStmt = string.Empty; + int keyValue = 0; + sqlStmt = @" SELECT COUNT(*) @@ -319,22 +320,22 @@ WHERE key ='" + Key + "'"; - keyValue = Convert.ToInt32( ExecuteStmtScalar( sqlStmt ) ); - return keyValue; - } + keyValue = Convert.ToInt32(ExecuteStmtScalar(sqlStmt)); + return keyValue; + } - static public bool KeyExists(string Key) - { - return ( CountKey( Key ) > 0 ); - } + static public bool KeyExists(string Key) + { + return (CountKey(Key) > 0); + } - static public void WriteSetting(string Key, string Value) - { - string sqlStmt = string.Empty; + static public void WriteSetting(string Key, string Value) + { + string sqlStmt = string.Empty; - if ( KeyExists( Key ) ) - { - sqlStmt = @" + if (KeyExists(Key)) + { + sqlStmt = @" UPDATE tblSetting @@ -344,34 +345,34 @@ WHERE key = '" + Key + "'"; - } - else - { - sqlStmt = @" + } + else + { + sqlStmt = @" INSERT INTO tblSetting (key, value) VALUES('" + Key + "', '" + Value + "')"; - } - ExecuteStmtNonQuery( sqlStmt ); - } + } + ExecuteStmtNonQuery(sqlStmt); + } - static public void DeleteSetting(string Key) - { + static public void DeleteSetting(string Key) + { - string sqlStmt = "DELETE FROM tblSetting WHERE key = '" + Key + "'"; - ExecuteStmtNonQuery( sqlStmt ); - } - #endregion dbsettings + string sqlStmt = "DELETE FROM tblSetting WHERE key = '" + Key + "'"; + ExecuteStmtNonQuery(sqlStmt); + } + #endregion dbsettings - public static int LexiconDataExists(string tableName, string columnName, string fieldValue) - { + public static int LexiconDataExists(string tableName, string columnName, string fieldValue) + { - SQLiteParameter[] parameterArray = new SQLiteParameter[1]; - parameterArray[0] = GetParameter<string>( fieldValue, "@fieldValue", DbType.String ); + SQLiteParameter[] parameterArray = new SQLiteParameter[1]; + parameterArray[0] = GetParameter<string>(fieldValue, "@fieldValue", DbType.String); - string sqlStmt = @" + string sqlStmt = @" SELECT " + columnName + @"id @@ -381,7 +382,7 @@ WHERE " + columnName + @" LIKE @fieldValue"; - string sqlStmtInsert = @" + string sqlStmtInsert = @" INSERT INTO " + tableName + @" ( @@ -392,224 +393,243 @@ @fieldValue );"; - try - { + try + { - int lexiconId= ExecuteStmtScalar<Int32>( sqlStmt, parameterArray); + int lexiconId = ExecuteStmtScalar<Int32>(sqlStmt, parameterArray); - //lexion didnt exist, we save it - if ( lexiconId == 0 ) - { - ExecuteStmtNonQuery( sqlStmtInsert,parameterArray ); - return ExecuteStmtScalar<Int32>( sqlStmt,parameterArray ); - } - else - { - return lexiconId; - } - } - catch ( SQLiteException ex ) - { - throw ex; - } - } + //lexion didnt exist, we save it + if (lexiconId == 0) + { + ExecuteStmtNonQuery(sqlStmtInsert, parameterArray); + return ExecuteStmtScalar<Int32>(sqlStmt, parameterArray); + } + else + { + return lexiconId; + } + } + catch (SQLiteException ex) + { + throw ex; + } + } - #region default lexiconvalues - private static List<string> CreateGenreLexiconList() - { - List<string> genreList = new List<string>(); + #region default lexiconvalues + private static List<string> CreateGenreLexiconList() + { + List<string> genreList = new List<string>(); - genreList.Add( "Shooter" ); - genreList.Add( "Platform" ); - genreList.Add( "Adventure" ); + genreList.Add("Shooter"); + genreList.Add("Platform"); + genreList.Add("Adventure"); - return genreList; - } + return genreList; + } - private static List<string> CreateManufacturerLexiconList() - { - List<string> manufacturerList = new List<string>(); + private static List<string> CreateManufacturerLexiconList() + { + List<string> manufacturerList = new List<string>(); - manufacturerList.Add( "Sega" ); - manufacturerList.Add( "Nintendo" ); - manufacturerList.Add( "Konami" ); + manufacturerList.Add("Sega"); + manufacturerList.Add("Nintendo"); + manufacturerList.Add("Konami"); - return manufacturerList; - } + return manufacturerList; + } - private static List<string> CreateSystemLexiconList() - { - List<string> systemList = new List<string>(); + private static List<string> CreateSystemLexiconList() + { + List<string> systemList = new List<string>(); + systemList.Add(""); + systemList.Add("Atari 5200"); + systemList.Add("Atari 7800"); + systemList.Add("Atari Lynx"); + systemList.Add("Atari ST"); + systemList.Add("Atari Video Computer System"); + systemList.Add("Commodore 64/128"); + systemList.Add("Commodore Amiga"); + systemList.Add("Game Boy"); + systemList.Add("Game Boy Advance"); + systemList.Add("Game Boy Color"); + systemList.Add("Neo Geo"); + systemList.Add("Nintendo 64"); + systemList.Add("Nintendo Entertainment System"); + systemList.Add("PlayStation"); + systemList.Add("Sega Dreamcast"); + systemList.Add("Sega Game Gear"); + systemList.Add("Sega Genesis"); + systemList.Add("Sega Master System"); + systemList.Add("Super NES"); + systemList.Add("TurboGrafx-16"); + systemList.Add("Arcade"); + systemList.Add("PC"); + return systemList; + } - systemList.Add( "Sega Mastersystem" ); - systemList.Add( "Arcade" ); - systemList.Add( "PC" ); - return systemList; - } + #endregion default lexiconvalues - #endregion default lexiconvalues + static public List<ApplicationItem> ApplicationItemList + { + get + { + return globalApplicationItemList; + } + } - static public List<ApplicationItem> ApplicationItemList - { - get - { - return globalApplicationItemList; - } - } + static public ItemType GetItemType(string columnName, string tableName, int id) + { + ItemType itemType = ItemType.UNKNOWN; - static public ItemType GetItemType(string columnName, string tableName, int id) - { - ItemType itemType = ItemType.UNKNOWN; + string sqlStmt = "select " + columnName + " from " + tableName + " where applicationid = " + id; - string sqlStmt = "select " + columnName + " from " + tableName + " where applicationid = " + id; + itemType = ProgramUtils.StringToSourceType(ExecuteStmtScalar(sqlStmt).ToString()); + return itemType; + } - itemType = ProgramUtils.StringToSourceType( ExecuteStmtScalar( sqlStmt ).ToString() ); - return itemType; - } + #region dataaccess help methods - #region dataaccess help methods + public static DataTable ExecuteStmtDataTable(string stmt) + { + DataTable dataTable = new DataTable(); - public static DataTable ExecuteStmtDataTable(string stmt) - { - DataTable dataTable = new DataTable(); + try + { - try - { + using (SQLiteCommand command = new SQLiteCommand(SqlLiteConn)) + { + command.CommandText = stmt; + using (SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(command)) + { + dataAdapter.Fill(dataTable); + } + } + } + catch (Exception exception) + { + throw exception; + } + return dataTable; + } - using ( SQLiteCommand command = new SQLiteCommand( SqlLiteConn ) ) - { - command.CommandText = stmt; - using ( SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter( command ) ) - { - dataAdapter.Fill( dataTable ); - } - } - } - catch ( Exception exception ) - { - throw exception; - } - return dataTable; - } + public static void ExecuteStmtNonQuery(string stmt) + { + try + { + using (SQLiteCommand command = new SQLiteCommand(SqlLiteConn)) + { + command.CommandText = stmt; + command.ExecuteNonQuery(); + } + } + catch (Exception exception) + { + throw exception; + } + } - public static void ExecuteStmtNonQuery(string stmt) - { - try - { - using ( SQLiteCommand command = new SQLiteCommand( SqlLiteConn ) ) - { - command.CommandText = stmt; - command.ExecuteNonQuery(); - } - } - catch ( Exception exception ) - { - throw exception; - } - } + public static void ExecuteStmtNonQuery(string stmt, SQLiteParameter[] paramcollection) + { + try + { + using (SQLiteCommand command = new SQLiteCommand(SqlLiteConn)) + { + command.CommandText = stmt; + command.Parameters.AddRange(paramcollection); + command.ExecuteNonQuery(); + } + } + catch (Exception exception) + { + throw exception; + } + } - public static void ExecuteStmtNonQuery(string stmt, SQLiteParameter[] paramcollection) - { - try - { - using ( SQLiteCommand command = new SQLiteCommand( SqlLiteConn ) ) - { - command.CommandText = stmt; - command.Parameters.AddRange( paramcollection ); - command.ExecuteNonQuery(); - } - } - catch ( Exception exception ) - { - throw exception; - } - } + public static T ExecuteStmtScalar<T>(string stmt, SQLiteParameter[] paramcollection) + { - public static T ExecuteStmtScalar<T>(string stmt, SQLiteParameter[] paramcollection) - { - object o = null; - try - { - using ( SQLiteCommand command = new SQLiteCommand( SqlLiteConn ) ) - { - command.CommandText = stmt; - command.Parameters.AddRange( paramcollection ); - o = command.ExecuteScalar(); + try + { + using (SQLiteCommand command = new SQLiteCommand(SqlLiteConn)) + { + command.CommandText = stmt; + command.Parameters.AddRange(paramcollection); + o = command.ExecuteScalar(); - if (o != null) - { - return (T) Convert.ChangeType(o, typeof(T)); - } - return default(T); - - } - } - catch ( Exception exception ) - { - throw exception; - } - } + if (o != null) + { + return (T)Convert.ChangeType(o, typeof(T)); + } + return default(T); + } + } + catch (Exception exception) + { + throw exception; + } + } - public static object ExecuteStmtScalar(string stmt) - { - object o = null; - try - { - using ( SQLiteCommand command = new SQLiteCommand( SqlLiteConn ) ) - { - command.CommandText = stmt; - o = command.ExecuteScalar(); - } - } - catch ( Exception exception ) - { - throw exception; - } - return o; - } - public static SQLiteParameter GetParameter<G>(G value, string parameterName, DbType type) - { - SQLiteParameter parameter = new SQLiteParameter(parameterName,type); - parameter.Value = value; + public static object ExecuteStmtScalar(string stmt) + { + object o = null; + try + { + using (SQLiteCommand command = new SQLiteCommand(SqlLiteConn)) + { + command.CommandText = stmt; + o = command.ExecuteScalar(); + } + } + catch (Exception exception) + { + throw exception; + } + return o; + } - return parameter; - } + public static SQLiteParameter GetParameter<G>(G value, string parameterName, DbType type) + { + SQLiteParameter parameter = new SQLiteParameter(parameterName, type); + parameter.Value = value; - #endregion dataaccess help methods + return parameter; + } - public static void LoadAllApplicationItems() - { - try - { - globalApplicationItemList.Clear(); + #endregion dataaccess help methods - using ( SQLiteCommand command = SqlLiteConn.CreateCommand() ) - { - command.CommandText = "SELECT * FROM tblApplicationItem order by iposition"; - using ( SQLiteDataReader dataReader = command.ExecuteReader() ) - { - while ( dataReader.Read() ) - { - ApplicationItem applicationItem = ( ApplicationItem ) ApplicationItemFactory.AppFactory.GetApplicationItem( GetItemType( "applicationItemType", "tblApplicationItem", Convert.ToInt32( dataReader["applicationId"] ) ), dataReader ); - // applicationItem.OnLaunchFilelink += new ApplicationItem.FilelinkLaunchEventHandler(LaunchFilelink); - globalApplicationItemList.Add( applicationItem ); - } + public static void LoadAllApplicationItems() + { + try + { + globalApplicationItemList.Clear(); - } - } - } - catch ( SQLiteException ex ) - { - Log.Info( "programdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace ); - } - } - } + using (SQLiteCommand command = SqlLiteConn.CreateCommand()) + { + command.CommandText = "SELECT * FROM tblApplicationItem order by iposition"; + using (SQLiteDataReader dataReader = command.ExecuteReader()) + { + while (dataReader.Read()) + { + ApplicationItem applicationItem = (ApplicationItem)ApplicationItemFactory.AppFactory.GetApplicationItem(GetItemType("applicationItemType", "tblApplicationItem", Convert.ToInt32(dataReader["applicationId"])), dataReader); + // applicationItem.OnLaunchFilelink += new ApplicationItem.FilelinkLaunchEventHandler(LaunchFilelink); + globalApplicationItemList.Add(applicationItem); + } + + } + } + } + catch (SQLiteException ex) + { + Log.Info("programdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); + } + } + } } Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -863,6 +863,8 @@ } } + + private void gamebaseDBButton_Click(object sender, EventArgs e) { openFileDialog.FileName = this.gamebaseDBTextBox.Text; Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.Designer.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.Designer.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.Designer.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -72,7 +72,7 @@ this.enabledCheckbox.AutoSize = true; this.enabledCheckbox.Location = new System.Drawing.Point(427, 17); this.enabledCheckbox.Name = "enabledCheckbox"; - this.enabledCheckbox.Size = new System.Drawing.Size(64, 17); + this.enabledCheckbox.Size = new System.Drawing.Size(65, 17); this.enabledCheckbox.TabIndex = 1; this.enabledCheckbox.Text = "Enabled"; this.enabledCheckbox.UseVisualStyleBackColor = true; @@ -100,7 +100,7 @@ this.titleTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.titleTextBox.Location = new System.Drawing.Point(94, 44); this.titleTextBox.Name = "titleTextBox"; - this.titleTextBox.Size = new System.Drawing.Size(325, 21); + this.titleTextBox.Size = new System.Drawing.Size(325, 20); this.titleTextBox.TabIndex = 4; // // applicationExeButton @@ -118,7 +118,7 @@ this.shellexecuteCheckBox.AutoSize = true; this.shellexecuteCheckBox.Location = new System.Drawing.Point(7, 322); this.shellexecuteCheckBox.Name = "shellexecuteCheckBox"; - this.shellexecuteCheckBox.Size = new System.Drawing.Size(87, 17); + this.shellexecuteCheckBox.Size = new System.Drawing.Size(88, 17); this.shellexecuteCheckBox.TabIndex = 7; this.shellexecuteCheckBox.Text = "ShellExecute"; this.shellexecuteCheckBox.UseVisualStyleBackColor = true; @@ -129,7 +129,7 @@ this.waitExitCheckBox.AutoSize = true; this.waitExitCheckBox.Location = new System.Drawing.Point(7, 368); this.waitExitCheckBox.Name = "waitExitCheckBox"; - this.waitExitCheckBox.Size = new System.Drawing.Size(86, 17); + this.waitExitCheckBox.Size = new System.Drawing.Size(82, 17); this.waitExitCheckBox.TabIndex = 8; this.waitExitCheckBox.Text = "Wait for exit"; this.waitExitCheckBox.UseVisualStyleBackColor = true; @@ -157,7 +157,7 @@ this.applicationImageTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.applicationImageTextBox.Location = new System.Drawing.Point(94, 97); this.applicationImageTextBox.Name = "applicationImageTextBox"; - this.applicationImageTextBox.Size = new System.Drawing.Size(325, 21); + this.applicationImageTextBox.Size = new System.Drawing.Size(325, 20); this.applicationImageTextBox.TabIndex = 13; // // applicationArgumentsTextBox @@ -165,7 +165,7 @@ this.applicationArgumentsTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.applicationArgumentsTextBox.Location = new System.Drawing.Point(94, 123); this.applicationArgumentsTextBox.Name = "applicationArgumentsTextBox"; - this.applicationArgumentsTextBox.Size = new System.Drawing.Size(325, 21); + this.applicationArgumentsTextBox.Size = new System.Drawing.Size(325, 20); this.applicationArgumentsTextBox.TabIndex = 14; // // winStyleLabel @@ -206,7 +206,7 @@ this.quoteCheckBox.AutoSize = true; this.quoteCheckBox.Location = new System.Drawing.Point(7, 299); this.quoteCheckBox.Name = "quoteCheckBox"; - this.quoteCheckBox.Size = new System.Drawing.Size(104, 17); + this.quoteCheckBox.Size = new System.Drawing.Size(102, 17); this.quoteCheckBox.TabIndex = 19; this.quoteCheckBox.Text = "Quote filenames"; this.quoteCheckBox.UseVisualStyleBackColor = true; @@ -236,7 +236,7 @@ this.allowRefreshCheckBox.AutoSize = true; this.allowRefreshCheckBox.Location = new System.Drawing.Point(7, 345); this.allowRefreshCheckBox.Name = "allowRefreshCheckBox"; - this.allowRefreshCheckBox.Size = new System.Drawing.Size(159, 17); + this.allowRefreshCheckBox.Size = new System.Drawing.Size(154, 17); this.allowRefreshCheckBox.TabIndex = 30; this.allowRefreshCheckBox.Text = "Allow refresh in mediaportal"; this.allowRefreshCheckBox.UseVisualStyleBackColor = true; @@ -257,7 +257,7 @@ this.applicationExeTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.applicationExeTextBox.Location = new System.Drawing.Point(94, 71); this.applicationExeTextBox.Name = "applicationExeTextBox"; - this.applicationExeTextBox.Size = new System.Drawing.Size(325, 21); + this.applicationExeTextBox.Size = new System.Drawing.Size(325, 20); this.applicationExeTextBox.TabIndex = 32; this.applicationExeTextBox.TextChanged += new System.EventHandler(this.applicationExeTextBox_TextChanged); // Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -140,6 +140,7 @@ toolTip.SetToolTip(applicationExeTextBox, "Program you wish to execute, include the full path (mandatory if ShellExecute is " + "OFF)"); toolTip.SetToolTip(allowRefreshCheckBox, "Check this if users can run the import through the REFRESH button in MediaPortal."); toolTip.SetToolTip(prePostButton, "Configure an command to run as pre or post of the main filelaunching ie explorer; joy2key; etc .Separate with ;."); + } protected void applicationExeButton_Click(object sender, EventArgs e) @@ -214,5 +215,10 @@ if (File.Exists(applicationExeTextBox.Text)) startupDirComboBox.Items.Add(Path.GetDirectoryName(applicationExeTextBox.Text)); } + + + + + } } \ No newline at end of file Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.Designer.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.Designer.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.Designer.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -28,6 +28,8 @@ /// </summary> private void InitializeComponent() { + this.platformComboBox = new System.Windows.Forms.ComboBox(); + this.platformLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // enabledCheckbox @@ -53,16 +55,17 @@ // this.toolTip.SetToolTip(this.applicationImageTextBox, "Optional filename for an image to display in MediaPortal"); // + // applicationArgumentsTextBox + // + this.toolTip.SetToolTip(this.applicationArgumentsTextBox, "Optional arguments that are needed to launch the program \r\n\r\n(advanced hint: Use " + + "%FILE% if the filename needs to be placed in some specific place between several" + + " arguments)"); + // // winStyleComboBox // this.toolTip.SetToolTip(this.winStyleComboBox, "Appearance of the launched program. \r\nTry HIDDEN or MINIMIZED for a seamless inte" + "gration in MediaPortal"); // - // startupDirTextBox - // - this.toolTip.SetToolTip(this.startupDirComboBox, "Optional path that is passed as the launch-directory \r\n\r\n(advanced hint: Use %FIL" + - "EDIR% if you want to use the directory where the launched file is stored)"); - // // quoteCheckBox // this.toolTip.SetToolTip(this.quoteCheckBox, "Quotes are usually needed to handle filenames with spaces correctly. \r\nAvoid doub" + @@ -72,14 +75,59 @@ // this.toolTip.SetToolTip(this.allowRefreshCheckBox, "Check this if users can run the import through the REFRESH button in MediaPortal." + ""); - // + // platformComboBox + // + this.platformComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.platformComboBox.FormattingEnabled = true; + this.platformComboBox.Location = new System.Drawing.Point(94, 204); + this.platformComboBox.Name = "platformComboBox"; + this.platformComboBox.Size = new System.Drawing.Size(325, 21); + this.platformComboBox.TabIndex = 42; + // + // platformLabel + // + this.platformLabel.AutoSize = true; + this.platformLabel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.platformLabel.Location = new System.Drawing.Point(3, 207); + this.platformLabel.Name = "platformLabel"; + this.platformLabel.Size = new System.Drawing.Size(84, 13); + this.platformLabel.TabIndex = 41; + this.platformLabel.Text = "Default platform:"; + // // AppSettingsDirCache // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.platformComboBox); + this.Controls.Add(this.platformLabel); this.Name = "AppSettingsDirCache"; this.Load += new System.EventHandler(this.AppSettingsDirCache_Load); + this.Controls.SetChildIndex(this.winTypeLabel, 0); + this.Controls.SetChildIndex(this.enabledCheckbox, 0); + this.Controls.SetChildIndex(this.titleLabel, 0); + this.Controls.SetChildIndex(this.applicationExeLabel, 0); + this.Controls.SetChildIndex(this.titleTextBox, 0); + this.Controls.SetChildIndex(this.applicationExeButton, 0); + this.Controls.SetChildIndex(this.shellexecuteCheckBox, 0); + this.Controls.SetChildIndex(this.waitExitCheckBox, 0); + this.Controls.SetChildIndex(this.applicationImageLabel, 0); + this.Controls.SetChildIndex(this.applicationArgumentsLabel, 0); + this.Controls.SetChildIndex(this.applicationImageTextBox, 0); + this.Controls.SetChildIndex(this.applicationArgumentsTextBox, 0); + this.Controls.SetChildIndex(this.winStyleLabel, 0); + this.Controls.SetChildIndex(this.winStyleComboBox, 0); + this.Controls.SetChildIndex(this.startupDirLabel, 0); + this.Controls.SetChildIndex(this.quoteCheckBox, 0); + this.Controls.SetChildIndex(this.applicationImageButton, 0); + this.Controls.SetChildIndex(this.startupDirButton, 0); + this.Controls.SetChildIndex(this.allowRefreshCheckBox, 0); + this.Controls.SetChildIndex(this.informationLabel, 0); + this.Controls.SetChildIndex(this.applicationExeTextBox, 0); + this.Controls.SetChildIndex(this.prePostButton, 0); + this.Controls.SetChildIndex(this.startupDirComboBox, 0); + this.Controls.SetChildIndex(this.platformLabel, 0); + this.Controls.SetChildIndex(this.platformComboBox, 0); this.ResumeLayout(false); this.PerformLayout(); @@ -87,5 +135,8 @@ #endregion + protected System.Windows.Forms.ComboBox platformComboBox; + protected System.Windows.Forms.Label platformLabel; + } } \ No newline at end of file Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -47,6 +47,7 @@ public override bool AppItemToForm(ApplicationItem curApp) { + ProgramUtils.FillComboBox("tblPlatform", "platform", platformComboBox); base.AppItemToForm(curApp); enabledCheckbox.Checked = curApp.Enabled; titleTextBox.Text = curApp.Title; @@ -59,6 +60,9 @@ waitExitCheckBox.Checked = (curApp.WaitForExit); applicationImageTextBox.Text = curApp.Imagefile; allowRefreshCheckBox.Checked = curApp.RefreshGUIAllowed; + if(curApp.PlatformId != 0){ + platformComboBox.SelectedValue = curApp.PlatformId; + } return true; } @@ -77,6 +81,7 @@ curApp.SourceType = ItemType.DIRCACHE; curApp.Imagefile = applicationImageTextBox.Text; curApp.RefreshGUIAllowed = (allowRefreshCheckBox.Checked); + curApp.PlatformId =(int) platformComboBox.SelectedValue; } @@ -120,6 +125,10 @@ //untiil we really do something with this option in appdircache.. allowRefreshCheckBox.Checked = false; + + + + } } } \ No newline at end of file Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.Designer.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.Designer.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.Designer.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -335,28 +335,7 @@ this.filterComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.filterComboBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.filterComboBox.Items.AddRange(new object[] { - "Arcade", - "Atari 5200", - "Atari 7800", - "Atari Lynx", - "Atari ST", - "Atari Video Computer System", - "Commodore 64/128", - "Commodore Amiga", - "Game Boy", - "Game Boy Advance", - "Game Boy Color", - "Neo Geo", - "Nintendo 64", - "Nintendo Entertainment System", - "PlayStation", - "Sega Dreamcast", - "Sega Game Gear", - "Sega Genesis", - "Sega Master System", - "Super NES", - "TurboGrafx-16"}); + this.filterComboBox.Location = new System.Drawing.Point(63, 22); this.filterComboBox.Name = "filterComboBox"; this.filterComboBox.Size = new System.Drawing.Size(132, 21); Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileInfoScraperForm.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -32,6 +32,7 @@ using System.Text; using System.Threading; using System.Windows.Forms; +using System.Data.SQLite; using GUIPrograms; using GUIPrograms.Database; @@ -63,17 +64,20 @@ } } + + void SetCurApp(ApplicationItem value) { curApp = value; if (curApp != null) { - filterComboBox.Text = curApp.SystemDefault; + filterComboBox.SelectedValue = curApp.PlatformId; } } public void Setup() { + SyncFileList(); UpdateButtonStates(); ChangeScraperSaveType(ScraperSaveType.DataAndImages); @@ -82,6 +86,7 @@ public FileInfoScraperForm() { InitializeComponent(); + ProgramUtils.FillComboBox("tblPlatform", "platform", filterComboBox); } #endregion @@ -122,6 +127,8 @@ return result; } + + private void SelectBestMatch(ListViewItem curItem) { if (curItem.Tag == null) return; @@ -438,7 +445,7 @@ { if ((curApp != null) && (filterComboBox.Text != "")) { - curApp.SystemDefault = filterComboBox.Text; + curApp.PlatformId = (int) filterComboBox.SelectedValue; //m_CurApp.Write(); } this.Close(); Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -70,6 +70,7 @@ private bool profilesIsLoaded = false; private const string ROOTNODENAME = "Applications"; private const int POSITIONHOLDER = 10; + #endregion @@ -1027,50 +1028,12 @@ private void UpdateComboBoxes() { - FillComboBox("tblPlatform", "platform", removePlatformComboBox); - FillComboBox("tblManufacturer", "manufacturer", removeManufacturerComboBox); - FillComboBox("tblGenre", "genre", removeGenreComboBox); + ProgramUtils.FillComboBox("tblPlatform", "platform", removePlatformComboBox); + ProgramUtils.FillComboBox("tblManufacturer", "manufacturer", removeManufacturerComboBox); + ProgramUtils.FillComboBox("tblGenre", "genre", removeGenreComboBox); } - private void FillComboBox(string tableName, string orderBy, ComboBox comboBox) - { - List<ListItem> listItemList = new List<ListItem>(); - - string sqlStmt = @" - SELECT - * - - FROM - " + tableName + @" - - ORDER BY " + orderBy; - - try - { - - SQLiteCommand command = new SQLiteCommand(DatabaseHandler.SqlLiteConn); - - command.CommandText = sqlStmt; - using (SQLiteDataReader dataReader = command.ExecuteReader()) - { - while (dataReader.Read()) - { - ListItem listItem = new ListItem(dataReader[1].ToString(), Convert.ToInt32(dataReader[0])); - listItemList.Add(listItem); - } - } - } - catch (Exception exception) - { - throw exception; - } - - comboBox.DataSource = listItemList; - comboBox.ValueMember = "Value"; - comboBox.DisplayMember = "Text"; - - } - + private void mameImportToolStripMenuItem_Click(object sender, EventArgs e) { AddApplication(ItemType.MAMEDIRECT); @@ -1125,6 +1088,7 @@ { DeleteData("tblPlatform", "platformId", this.removePlatformComboBox.SelectedValue.ToString()); UpdateFileItems("platformId", this.removePlatformComboBox.SelectedValue.ToString()); + UpdateApplicationItem("platformId", this.removePlatformComboBox.SelectedValue.ToString()); UpdateComboBoxes(); } @@ -1177,7 +1141,31 @@ } } + //if something was removed that is in a fileitem + //set it to as default value (unknown) + private void UpdateApplicationItem(string removedField, string removedValue) + { + string sqlStmt = @" + UPDATE + tblApplicationItem + + SET + " + removedField + @" = 1 + + WHERE + " + removedField + @" = " + removedValue; + try + { + DatabaseHandler.ExecuteStmtNonQuery(sqlStmt); + } + catch (Exception exception) + { + throw exception; + } + } + + private void DeleteData(string tableName, string column, string uniqueValue) { //never remove 1 (unknown) @@ -1205,28 +1193,6 @@ UpdateComboBoxes(); } - public class ListItem - { - private string text; - - public string Text - { - get { return text; } - set { text = value; } - } - private int value; - - public int Value - { - get { return this.value; } - set { this.value = value; } - } - - public ListItem(string label, int data) - { - text = label; - value = data; - } - } + } } \ No newline at end of file Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -87,7 +87,7 @@ string validExtensions; bool importValidImagesOnly; - string systemDefault; + int platformId; string launchErrorMsg; // two magic image-slideshow counters @@ -259,10 +259,10 @@ set { importValidImagesOnly = value; } } - public string SystemDefault + public int PlatformId { - get { return systemDefault; } - set { systemDefault = value; } + get { return platformId; } + set { platformId = value; } } public string LaunchErrorMsg { @@ -307,7 +307,7 @@ validExtensions = ""; appPosition = 0; importValidImagesOnly = false; - systemDefault = ""; + platformId = 0; waitForExit = true; filesAreLoaded = false; preLaunch = ""; @@ -727,7 +727,7 @@ parameterArray[16] = DatabaseHandler.GetParameter<int>( Position, "@position", DbType.Int32 ); parameterArray[17] = DatabaseHandler.GetParameter<bool>( Enabled, "@enabled", DbType.Boolean); parameterArray[18] = DatabaseHandler.GetParameter<bool>( RefreshGUIAllowed, "@refreshGUIAllowed", DbType.Boolean ); - parameterArray[19] = DatabaseHandler.GetParameter<string>( SystemDefault, "@systemDefault", DbType.String); + parameterArray[19] = DatabaseHandler.GetParameter<int>( PlatformId, "@platformId", DbType.Int32); parameterArray[20] = DatabaseHandler.GetParameter<bool>( WaitForExit, "@waitForExit", DbType.Boolean); parameterArray[21] = DatabaseHandler.GetParameter<string>( PreLaunch, "@preLaunch", DbType.String); parameterArray[22] = DatabaseHandler.GetParameter<string>( PostLaunch, "@postLaunch", DbType.String); @@ -765,7 +765,7 @@ iposition, enabled, refreshGUIAllowed, - systemDefault, + platformId, waitForExit, preLaunch, postLaunch @@ -791,7 +791,7 @@ @position, @enabled, @refreshGUIAllowed, - @systemDefault, + @platformId, @waitForExit, @preLaunch, @postLaunch @@ -832,7 +832,7 @@ parameterArray[16] = DatabaseHandler.GetParameter<int>( Position, "@position", DbType.Int32); parameterArray[17] = DatabaseHandler.GetParameter<bool>( Enabled, "@enabled", DbType.Boolean); parameterArray[18] = DatabaseHandler.GetParameter<bool>( RefreshGUIAllowed, "@refreshGUIAllowed", DbType.Boolean ); - parameterArray[19] = DatabaseHandler.GetParameter<string>( SystemDefault, "@systemDefault", DbType.String ); + parameterArray[19] = DatabaseHandler.GetParameter<int>( PlatformId, "@platformId", DbType.Int32 ); parameterArray[20] = DatabaseHandler.GetParameter<bool>( WaitForExit, "@waitForExit", DbType.Boolean ); parameterArray[21] = DatabaseHandler.GetParameter<string>( PreLaunch, "@preLaunch", DbType.String ); parameterArray[22] = DatabaseHandler.GetParameter<string>( PostLaunch, "@postLaunch", DbType.String ); @@ -861,7 +861,7 @@ iposition = @position, enabled = @enabled, refreshGUIAllowed = @refreshGUIAllowed, - systemDefault = @systemDefault, + platformId = @platformId, waitForExit = @waitForExit, preLaunch = @preLaunch, postLaunch = @postLaunch @@ -1030,7 +1030,7 @@ this.WaitForExit = sourceApp.WaitForExit; this.PreLaunch = sourceApp.PreLaunch; this.PostLaunch = sourceApp.PostLaunch; - this.SystemDefault = sourceApp.SystemDefault; + this.PlatformId = sourceApp.PlatformId; } Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemFactory.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemFactory.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemFactory.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -122,7 +122,7 @@ item.ImportValidImagesOnly =(bool) dataReader["importvalidimagesonly"]; item.Position = Convert.ToInt32(dataReader["iposition"]); item.RefreshGUIAllowed = (bool) dataReader["refreshGUIAllowed"]; - item.SystemDefault = (string) dataReader["systemdefault"]; + item.PlatformId = Convert.ToInt32(dataReader["platformId"]); item.WaitForExit =(bool) dataReader["waitforexit"]; item.PreLaunch = (string) dataReader["preLaunch"]; item.PostLaunch =(string) dataReader["postLaunch"]; Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramUtils.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramUtils.cs 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramUtils.cs 2007-08-03 08:07:10 UTC (rev 786) @@ -28,6 +28,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Data.SQLite; using System.Drawing; using System.Drawing.Imaging; using System.IO; @@ -45,6 +46,8 @@ using MediaPortal.GUI.Library; using MediaPortal.Util; +using GUIPrograms.Database; + namespace GUIPrograms { #region enums @@ -325,5 +328,67 @@ return Result; } + + public class ListItem + { + private string text; + + public string Text + { + get { return text; } + set { text = value; } + } + private int value; + + public int Value + { + get { return this.value; } + set { this.value = value; } + } + + public ListItem(string label, int data) + { + text = label; + value = data; + } + } + public static void FillComboBox(string tableName, string orderBy, ComboBox comboBox) + { + List<ListItem> listItemList = new List<ListItem>(); + + string sqlStmt = @" + SELECT + * + + FROM + " + tableName + @" + + ORDER BY " + orderBy; + + try + { + + SQLiteCommand command = new SQLiteCommand(DatabaseHandler.SqlLiteConn); + + command.CommandText = sqlStmt; + using (SQLiteDataReader dataReader = command.ExecuteReader()) + { + while (dataReader.Read()) + { + ListItem listItem = new ListItem(dataReader[1].ToString(), Convert.ToInt32(dataReader[0])); + listItemList.Add(listItem); + } + } + } + catch (Exception exception) + { + throw exception; + } + + comboBox.DataSource = listItemList; + comboBox.ValueMember = "Value"; + comboBox.DisplayMember = "Text"; + + } } } \ No newline at end of file Modified: trunk/plugins/myGUIProgramsAlt/README.txt =================================================================== --- trunk/plugins/myGUIProgramsAlt/README.txt 2007-08-02 15:43:42 UTC (rev 785) +++ trunk/plugins/myGUIProgramsAlt/README.txt 2007-08-03 08:07:10 UTC (rev 786) @@ -19,7 +19,7 @@ Database/views: grouping added, fileinfodetails -Allgamesupport updated. +Allgamesupport updated./thanks chefkoch Fileinfoscraper reworked Mame, Gamebase support partially rewritten. @@ -46,16 +46,14 @@ - Appsettingsrootform: do not use inheritance, make this individual, so we easily can add global-options etc. - Dynamic checkbox list in the different filesview, allow us to "plugin" as many options we want for a special appitem -DB - - - add platformid instead of system default..application item - ThumbnailSupport: - [low] genre: thumbs for genre, for example it could be created on AllGame lookup, for first file with this genre - - ....... +Genre: + - Change to genre/categoryinstead. + --------------------- .: Things to clear :. --------------------- @@ -97,23 +95,20 @@ -> 2. can be renamed by plugin, when renaming the appItem -> 3. there could be a msgBox, which asks the user what to do, 1. or 2. ? go for two!! -------------------------------------------------------------------------------------- -Above: mabey add an advanced option for the user. In short, allowing a merge between "easy setup" (as above) +Above: maybe add an advanced option for the user. In short, allowing a merge between "easy setup" (as above) and total control filepaths etc. -MyEmu... +MyEmu...i think Add some more specific emulator support.. - - using emulator ids??? can be used for - - filter in fileinfoscraperForm.. we got system id's now.. so feel free to implement.Will add emulator table at some point. - - - easier application image assigning together with thumbsdir -> we also could provide icons for most common system + - using emulator ids??? yes at some point. this could benefit automatic downloads etc + - easier application image assigning together with thumbsdir -> we also could provide icons for most common system ConfigurationTool redesign: - - saving the path to file for import - - saving the path to image dir, or using thumbsDir of MP, are there any pros? + - saving the path to file for import. ????? what??? + - saving the path to image dir, or using thumbsDir of MP, are there any pros? - Iso moun... [truncated message content] |