From: <nor...@us...> - 2007-08-19 23:23:23
|
Revision: 847 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=847&view=rev Author: northern_sky Date: 2007-08-19 16:23:20 -0700 (Sun, 19 Aug 2007) Log Message: ----------- misc cleanup, added abstract class for import, changed skin a bit, Modified Paths: -------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsGamebase.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsGrouper.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsMame.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileDetailsForm.Designer.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileDetailsForm.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/GamebaseImport.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/MameImport.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemDirectoryCache.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemFactory.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemGameBase.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemGrouper.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemMame.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/FileItem.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Properties/Resources.Designer.cs Added Paths: ----------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/DirectoryImport.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/ImportBase.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/skin/BlueTwo/myProgramsAlt.xml Removed Paths: ------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/skin/BlueTwo/myprograms.xml Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -445,8 +445,18 @@ } } + public ApplicationItem GetAppByID(int targetAppID) + { + foreach (ApplicationItem curApp in globalApplicationItemList) + { + if (curApp.ApplicationItemId == targetAppID) + { + return curApp; + } + } + return null; + } - #endregion Public Methods #region Private Methods Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -195,7 +195,7 @@ } else { - string imageDirectorys = string.Join(";", currentApplication.imageDirs); + string imageDirectorys = string.Join(";", currentApplication.ImageDirsSplitted); this.imageDirsTextBox.Text = imageDirectorys; } @@ -383,11 +383,11 @@ OnImageFolderSearch(this, null); } //get all imagedirs - /* for (int i = 0; i < currentApplication.imageDirs.Length; i++) + /* for (int i = 0; i < currentApplication.imageDirsSplitted.Length; i++) { - if (!currentApplication.imageDirs[i].ToString().Equals("")) + if (!currentApplication.imageDirsSplitted[i].ToString().Equals("")) { - imageDirsList.Add(currentApplication.imageDirs[i]); + imageDirsList.Add(currentApplication.imageDirsSplitted[i]); } } @@ -526,7 +526,7 @@ { // if (file.IsFolder) //{ - //ChangeFilePath(file.Filename); // filename becomes filepath in next view... :) + //ChangeFilePath(file.Executable); // executable becomes filepath in next view... :) //} //else //{ @@ -578,7 +578,7 @@ foreach (ApplicationItem app in apps) { - if (app.SourceType == ItemType.GROUPER) + if (app.Item_Type == ItemType.GROUPER) { ToolStripMenuItem newMenu = new ToolStripMenuItem(app.Title); newMenu.Tag = app.ApplicationItemId; @@ -653,7 +653,7 @@ if ((currentApplication is ApplicationItemGameBase)) { - applicationItem.Source = this.gamebaseDBTextBox.Text; + applicationItem.ApplicationItemSource = this.gamebaseDBTextBox.Text; } } @@ -739,7 +739,7 @@ this.gamebaseDBTextBox.Visible = true; this.gamebaseDBButton.Visible = true; this.gamebaseLabel.Visible = true; - this.gamebaseDBTextBox.Text = currentApplication.Source; + this.gamebaseDBTextBox.Text = currentApplication.ApplicationItemSource; } if ((currentApplication is ApplicationItemGrouper)) Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -56,7 +56,7 @@ enabledCheckbox.Checked = curApp.Enabled; titleTextBox.Text = curApp.Title; - applicationExeTextBox.Text = curApp.Filename; + applicationExeTextBox.Text = curApp.Executable; applicationArgumentsTextBox.Text = curApp.Arguments; // Pre-Post-Launch preCommandTextBox.Text = curApp.PreLaunch; @@ -86,7 +86,7 @@ curApp.Enabled = enabledCheckbox.Checked; curApp.Title = titleTextBox.Text; - curApp.Filename = applicationExeTextBox.Text; + curApp.Executable = applicationExeTextBox.Text; curApp.Arguments = applicationArgumentsTextBox.Text; // Pre-Post-Launch curApp.PreLaunch = preCommandTextBox.Text; Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsDirCache.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -75,7 +75,7 @@ curApp.UseShellExecute = shellexecuteCheckBox.Checked; curApp.UseQuotes = quoteCheckBox.Checked; curApp.WaitForExit = waitExitCheckBox.Checked; - curApp.SourceType = ItemType.DIRCACHE; + curApp.Item_Type = ItemType.DIRCACHE; curApp.RefreshGUIAllowed = allowRefreshCheckBox.Checked; curApp.PlatformId = (int)platformComboBox.SelectedValue; } @@ -105,7 +105,7 @@ public override void LoadFromAppItem(ApplicationItem applicationItem) { titleTextBox.Text = applicationItem.Title; - applicationExeTextBox.Text = applicationItem.Filename; + applicationExeTextBox.Text = applicationItem.Executable; applicationArgumentsTextBox.Text = applicationItem.Arguments; startupDirComboBox.Text = applicationItem.StartupDir; Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsGamebase.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsGamebase.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsGamebase.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -64,7 +64,7 @@ curApp.UseShellExecute = this.shellexecuteCheckBox.Checked; curApp.UseQuotes = this.quoteCheckBox.Checked; curApp.WaitForExit = this.waitExitCheckBox.Checked; - curApp.SourceType = ItemType.GAMEBASE; + curApp.Item_Type = ItemType.GAMEBASE; curApp.RefreshGUIAllowed = this.allowRefreshCheckBox.Checked; } Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsGrouper.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsGrouper.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsGrouper.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -53,7 +53,7 @@ { base.SaveSettings(curApp); - curApp.SourceType = ItemType.GROUPER; + curApp.Item_Type = ItemType.GROUPER; } Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsMame.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsMame.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsMame.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -55,7 +55,7 @@ { base.SaveSettings(curApp); - curApp.SourceType = ItemType.MAMEDIRECT; + curApp.Item_Type = ItemType.MAMEDIRECT; curApp.RefreshGUIAllowed = true; } Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileDetailsForm.Designer.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileDetailsForm.Designer.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileDetailsForm.Designer.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -378,7 +378,7 @@ this.lblFilename.Name = "lblFilename"; this.lblFilename.Size = new System.Drawing.Size(52, 13); this.lblFilename.TabIndex = 45; - this.lblFilename.Text = "Filename:"; + this.lblFilename.Text = "Executable:"; // // btnFilename // Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileDetailsForm.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileDetailsForm.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/FileDetailsForm.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -216,7 +216,7 @@ { conditionChecker.Clear(); conditionChecker.DoCheck(CurFile.Title != "", "No title entered!"); - //01.04.05 no filename is FINE :-) conditionChecker.DoCheck(CurFile.Filename != "", "No filename entered!"); + //01.04.05 no executable is FINE :-) conditionChecker.DoCheck(CurFile.Executable != "", "No executable entered!"); if (!conditionChecker.IsOk) { string strHeader = "The following entries are invalid: \r\n\r\n"; Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -343,7 +343,7 @@ ApplicationItem currentApplication = GetTreeNodeApplicationItem(treeView.SelectedNode); if (currentApplication == null) return appSettingsRoot; - switch (currentApplication.SourceType) + switch (currentApplication.Item_Type) { case ItemType.DIRCACHE: return appSettingsDirCache; @@ -528,7 +528,7 @@ else { ApplicationItem curApp = this.GetTreeNodeApplicationItem(treeView.SelectedNode); - if ((curApp.SourceType == ItemType.MAMEDIRECT) || (curApp.SourceType == ItemType.GAMEBASE)) + if ((curApp.Item_Type == ItemType.MAMEDIRECT) || (curApp.Item_Type == ItemType.GAMEBASE)) { this.premadeConfigurationsToolStripMenuItem.Enabled = false; } @@ -661,7 +661,7 @@ { newApplication.Title = "New item"; } - newApplication.SourceType = newSourceType; + newApplication.Item_Type = newSourceType; newApplication.InsertOrUpdateSettings(); dbHandlerInstance.LoadAllApplicationItems(); Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -446,7 +446,7 @@ { LoadLastAppIDFromSettings(); // hacky load back the last applicationItem id, otherwise this can get lost from dx resets.... } - lastApp = GetAppByID(mapSettings.LastAppID); + lastApp = this.dbHandlerInstance.GetAppByID(mapSettings.LastAppID); if (lastApp != null) { prevFilepath = lastApp.DefaultFilepath(); @@ -591,7 +591,7 @@ public override bool Init() { - return Load(GUIGraphicsContext.Skin + @"\myprograms.xml"); + return Load(GUIGraphicsContext.Skin + @"\myProgramsAlt.xml"); } protected override void OnPageLoad() @@ -926,7 +926,7 @@ lastApp.CurrentView = ViewHandler.CurrentView; } int totalFiles = 0; - totalFiles = totalFiles + DisplayItemList(lastApp.filePath, lastApp.ItemList, facadeView); + totalFiles = totalFiles + DisplayItemList(lastApp.ItemList, facadeView); return (totalFiles); } @@ -1048,7 +1048,7 @@ { // back item in application list clicked // go to father item - lastApp = GetAppByID(lastApp.FatherID); + lastApp = this.dbHandlerInstance.GetAppByID(lastApp.FatherID); if (lastApp != null) { mapSettings.LastAppID = lastApp.ApplicationItemId; @@ -1114,21 +1114,11 @@ return res; } - public ApplicationItem GetAppByID(int targetAppID) - { - foreach (ApplicationItem curApp in globalApplicationList) - { - if (curApp.ApplicationItemId == targetAppID) - { - return curApp; - } - } - return null; - } + /* public ApplicationItem CloneAppItem(ApplicationItem sourceApp) { - ApplicationItem newApp = (ApplicationItem)ItemFactory.itemFactoryInstance.GetItem(sqlDB, sourceApp.SourceType, null, 0); + ApplicationItem newApp = (ApplicationItem)ItemFactory.itemFactoryInstance.GetItem(sqlDB, sourceApp.Item_Type, null, 0); newApp.Assign(sourceApp); newApp.ApplicationItemId = -1; // to force a sql INSERT when written Add(newApp); @@ -1304,7 +1294,7 @@ #region moved from BaseItem - public int DisplayItemList(string filePath, List<object> dbItems, GUIFacadeControl facadeView) + public int DisplayItemList(List<object> dbItems, GUIFacadeControl facadeView) { int totalItems = 0; Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj 2007-08-19 23:23:20 UTC (rev 847) @@ -137,7 +137,9 @@ <Compile Include="GUIPrograms.cs" /> <Compile Include="GUIProgramsAltFileInfo.cs" /> <Compile Include="Imports\AllGameScraper.cs" /> + <Compile Include="Imports\DirectoryImport.cs" /> <Compile Include="Imports\GamebaseImport.cs" /> + <Compile Include="Imports\ImportBase.cs" /> <Compile Include="Imports\MameImport.cs" /> <Compile Include="Items\ApplicationItem.cs" /> <Compile Include="Items\ApplicationItemDirectoryCache.cs" /> @@ -161,7 +163,7 @@ </ItemGroup> <ItemGroup> <Content Include="MetaData\myProgramsAltPreconfiguration.xml" /> - <Content Include="skin\BlueTwo\myprograms.xml" /> + <Content Include="skin\BlueTwo\myprogramsAlt.xml" /> <Content Include="skin\BlueTwo\myProgramsAltFileInfo.xml" /> <Content Include="SqlNet\System.Data.SQLite.DLL" /> </ItemGroup> Added: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/DirectoryImport.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/DirectoryImport.cs (rev 0) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/DirectoryImport.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using MediaPortal.GUI.Library; + + +using GUIPrograms.Items; +using GUIPrograms; +using GUIPrograms.Database; +using System.Data.SQLite; + +using System.IO; + +namespace GUIPrograms.Imports +{ + public class DirectoryImport: ImportBase + { + private ApplicationItem applicationItem = null; + private DatabaseHandler dbHandlerInstance = DatabaseHandler.DBHandlerInstance; + + public DirectoryImport(ApplicationItem objApp) + { + applicationItem = objApp; + OnReadNewFile += new MyEventHandler(applicationItem.ReadNewFile); + } + + public void DeInit() + { + OnReadNewFile -= new MyEventHandler(applicationItem.ReadNewFile); + } + + + + private void ImportFileItem(FileInfo fileInfo) + { + FileItem curFile = new FileItem(); + curFile.FileID = -1; // to force an INSERT statement when writing the item + curFile.AppID = applicationItem.ApplicationItemId; + curFile.Title = Path.GetFileNameWithoutExtension(fileInfo.Name); + curFile.Filename = fileInfo.FullName; + + //curFile.Imagefile = GetThumbsFile(fileInfo, curFile.Title); + curFile.Imagefile = ImportImageFiles(curFile.Filename, curFile.Title, applicationItem); + + // not imported properties => set default values + curFile.LastTimeLaunched = DateTime.MinValue; + curFile.LaunchCount = 0; + curFile.Write(); + } + + private void DeleteOrphaned() + { + string TheFileName; + foreach (FileItem DBfile in applicationItem.ItemList) + { + + TheFileName = DBfile.Filename; + + //if (!DBfile.IsFolder) + //{ + if (!File.Exists(TheFileName)) { DBfile.Delete(); } + //} + //else + //{ + //if (!Directory.Exists(TheFileName)) { DBfile.Delete(); } + + //} + + } + } + + private void ImportFile(string dirPath, bool mpGuiMode) + { + + FileInfo fileInDir = null; + if (Directory.Exists(dirPath)) + { + DirectoryInfo directoryInfo = new DirectoryInfo(dirPath); + FileSystemInfo[] allUnderLyingFiles = directoryInfo.GetFileSystemInfos(); + + for (int i = 0; i < allUnderLyingFiles.Length; i++) + { + if (allUnderLyingFiles[i] is FileInfo) + { + Boolean FileExists = false; + + fileInDir = (FileInfo)allUnderLyingFiles[i]; + + foreach (FileItem DBfile in applicationItem.ItemList) + { + if (DBfile.Filename == fileInDir.FullName) + { + FileExists = true; + break;//ugly + } + } + if (!FileExists) + { + ImportFileItem(fileInDir); + //UpdateProgressDialog(fileInDir, mpGuiMode); + } + }//if dir found,, recurse + else if (allUnderLyingFiles[i] is DirectoryInfo) + { + DirectoryInfo directory = (DirectoryInfo)allUnderLyingFiles[i]; + ImportFile(directory.FullName, mpGuiMode); + } + } + } + } + + public void StartImport(string[] fileDirPaths, bool mpGuiMode) + { + using (SQLiteTransaction transaction = dbHandlerInstance.SqlLiteConn.BeginTransaction()) + { + DeleteOrphaned(); + //get all maindirs + foreach (string dirPath in fileDirPaths) + { + ImportFile(dirPath, mpGuiMode); + } + transaction.Commit(); + } + } + } +} Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/GamebaseImport.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/GamebaseImport.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/GamebaseImport.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -40,28 +40,25 @@ /// <summary> /// Summary description for GamebaseImport. /// </summary> - public class GamebaseImport + public class GamebaseImport : ImportBase { private ApplicationItem applicationItem = null; - - // event: read new file - public delegate void MyEventHandler(string informationMessage, int progressBarCtr); - - public event MyEventHandler OnReadNewFile = null; - public event MyEventHandler OnSendMessage = null; - - public GamebaseImport(ApplicationItem objApp) { - applicationItem = objApp; + OnReadNewFile += new MyEventHandler(applicationItem.ReadNewFile); } + public void DeInit() + { + OnReadNewFile -= new MyEventHandler(applicationItem.ReadNewFile); + } + void DBImportGamebaseItem(OleDbDataReader myReader, string romFilename, string imgFilename, int curPos, int maxGames) { - + FileItem curFile = new FileItem(); curFile.FileID = -1; // to force an INSERT statement when writing the item curFile.AppID = applicationItem.ApplicationItemId; @@ -71,7 +68,7 @@ string strGenre1 = myReader["ParentGenre"].ToString(); string strGenre2 = myReader["Genre"].ToString(); - int LexiconId = DatabaseHandler.DBHandlerInstance.LexiconDataExists("tblGenre", "genre", strGenre1); + int LexiconId = DatabaseHandler.DBHandlerInstance.LexiconDataExists("tblGenre", "genre", strGenre1); curFile.GenreId = LexiconId; LexiconId = DatabaseHandler.DBHandlerInstance.LexiconDataExists("tblGenre", "genre", strGenre2); @@ -99,14 +96,15 @@ curFile.LaunchCount = 0; curFile.Write(); //this.OnReadNewFile(curFile.Title, curPos, maxGames); // send event to whom it may concern.... - this.OnReadNewFile(curFile.Title, (int)(100 * (((double)curPos) / maxGames))); + //this.OnReadNewFile(curFile.Title, (int)(100 * (((double)curPos) / maxGames))); + SendDisplayText(curFile.Title, (int)(100 * (((double)curPos) / maxGames))); return; } - public void Start() + public void StartImport() { // string strCon = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=C:\\media\\GameBase\\snes\\Snes.mdb"; - string strCon = String.Format("Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source={0}", applicationItem.Source); + string strCon = String.Format("Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source={0}", applicationItem.ApplicationItemSource); //Make a Select Command for querying the gamebase-MDB-file string sqlStrCount = "SELECT count(*) FROM Games"; @@ -144,69 +142,66 @@ { using (OleDbConnection myCon = new OleDbConnection(strCon)) { - - using (OleDbCommand myCmd = new OleDbCommand(sqlStr, myCon)) - { - using (SQLiteTransaction transaction = DatabaseHandler.DBHandlerInstance.SqlLiteConn.BeginTransaction()) - - { + using (OleDbCommand myCmd = new OleDbCommand(sqlStr, myCon)) + { + + using (SQLiteTransaction transaction = DatabaseHandler.DBHandlerInstance.SqlLiteConn.BeginTransaction()) + { myCon.Open(); int maxGames = CountGames(myCon, sqlStrCount); - - - using (OleDbDataReader myReader = myCmd.ExecuteReader()) - { - int i = 0; - while (myReader.Read()) - { - i++; - curRomname = myReader["Filename"].ToString(); - curFullRomname = applicationItem.FileDirectory + "\\" + curRomname; - if (applicationItem.ImageDirectory != "") - { - curTitleImage = applicationItem.imageDirs[0] + "\\" + myReader["ScrnshotFilename"].ToString(); - } - else - { - curTitleImage = ""; - } + using (OleDbDataReader myReader = myCmd.ExecuteReader()) + { - if (File.Exists(curFullRomname)) - { - // rom-name from gamebase exists in users filedirectory - // => ready to import item - bDoImport = true; + int i = 0; + while (myReader.Read()) + { + i++; + curRomname = myReader["Filename"].ToString(); + curFullRomname = applicationItem.FileDirectory + "\\" + curRomname; - if (applicationItem.ImportValidImagesOnly) - { - // skip item if no thumbnail image is found - bDoImport = ((curTitleImage != null) && (curTitleImage != "") && (File.Exists(curTitleImage))); - } - - if (bDoImport) - { - DBImportGamebaseItem(myReader, curFullRomname, curTitleImage, i, maxGames); + if (applicationItem.ImageDirectory != "") + { + curTitleImage = applicationItem.ImageDirsSplitted[0] + "\\" + myReader["ScrnshotFilename"].ToString(); + } + else + { + curTitleImage = ""; + } - } - else - { - Log.Info("*skipped* gamebase game {0} image{1}", curRomname, curTitleImage); - } + if (File.Exists(curFullRomname)) + { + // rom-name from gamebase exists in users filedirectory + // => ready to import item + bDoImport = true; - } - else - { - Log.Info("*missing* gamebase game {0}", curRomname); - } + if (applicationItem.ImportValidImagesOnly) + { + // skip item if no thumbnail image is found + bDoImport = ((curTitleImage != null) && (curTitleImage != "") && (File.Exists(curTitleImage))); } + + if (bDoImport) + { + DBImportGamebaseItem(myReader, curFullRomname, curTitleImage, i, maxGames); + + } + else + { + Log.Info("*skipped* gamebase game {0} image{1}", curRomname, curTitleImage); + } + } - transaction.Commit(); + else + { + Log.Info("*missing* gamebase game {0}", curRomname); + } } - - + } + transaction.Commit(); + } } } } @@ -216,14 +211,6 @@ } } - void SendText(string informationMessage, int progressBarCtr) - { - if (OnSendMessage != null) - { - OnSendMessage(informationMessage, progressBarCtr); - } - } - int CountGames(OleDbConnection myCon, string sqlStrCount) { int res = 0; Added: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/ImportBase.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/ImportBase.cs (rev 0) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/ImportBase.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using System.IO; +using GUIPrograms.Items; + +namespace GUIPrograms.Imports +{ + public abstract class ImportBase + { + // event: read new file + protected delegate void MyEventHandler(string informationMessage, int progressBarCtr); + + protected event MyEventHandler OnReadNewFile = null; + + protected void SendDisplayText(string displayText, int progressBarCtr) + { + if (OnReadNewFile != null) + { + OnReadNewFile(displayText, progressBarCtr); + } + } + + protected string ImportImageFiles(string fileName, string fileTitle,ApplicationItem applicationItem) + { + string thumb = ""; + + if (applicationItem.ImageDirsSplitted.Length > 0) + { + foreach (string imageDir in applicationItem.ImageDirsSplitted) + { + if (Directory.Exists(imageDir)) + { + string[] matchesJPG = Directory.GetFiles(imageDir, Path.GetFileNameWithoutExtension(fileName) + ".jpg"); + string[] matchesGIF = Directory.GetFiles(imageDir, Path.GetFileNameWithoutExtension(fileName) + ".gif"); + string[] matchesPNG = Directory.GetFiles(imageDir, Path.GetFileNameWithoutExtension(fileName) + ".png"); + if (matchesJPG.Length > 0) + { + thumb = matchesJPG[0]; + } + else if (matchesGIF.Length > 0) + { + thumb = matchesGIF[0]; + } + else if (matchesPNG.Length > 0) + { + thumb = matchesPNG[0]; + } + else + { + matchesJPG = Directory.GetFiles(imageDir, Path.GetFileNameWithoutExtension(fileName) + "*.jpg"); + matchesGIF = Directory.GetFiles(imageDir, Path.GetFileNameWithoutExtension(fileName) + "*.gif"); + matchesPNG = Directory.GetFiles(imageDir, Path.GetFileNameWithoutExtension(fileName) + "*.png"); + if (matchesJPG.Length > 0) + { + thumb = matchesJPG[0]; + } + else if (matchesGIF.Length > 0) + { + thumb = matchesGIF[0]; + } + else if (matchesPNG.Length > 0) + { + thumb = matchesPNG[0]; + } + + } + } + } + } + return thumb; + } + + } +} Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/MameImport.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/MameImport.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Imports/MameImport.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -46,15 +46,10 @@ /// <summary> /// Summary description for MameImport. /// </summary> - public class MameImport + public class MameImport : ImportBase { ApplicationItem currentApplication = null; - // event: read new file - public delegate void MyEventHandler(string informationMessage, int progressBarCtr); - - public event MyEventHandler OnReadNewFile = null; - public event MyEventHandler OnSendMessage = null; ConditionChecker Checker = new ConditionChecker(); Regex regexMameGameName = new Regex(@"(?<romName>\w+)\s+""(?<gameName>.+)"""); Regex regexMameCloneName = new Regex(@"(?<cloneName>\w+)\s+(?<orgGameName>\w+)"); @@ -79,19 +74,24 @@ { currentApplication = applicationItem; + OnReadNewFile += new MyEventHandler(currentApplication.ReadNewFile); } + public void DeInit() + { + OnReadNewFile -= new MyEventHandler(currentApplication.ReadNewFile); + } void ReadListFull() { fullRomListDictionary.Clear(); string line = string.Empty; - SendText("generating mame list (full)", 10); + SendDisplayText("generating mame list (full)", 10); using (Process process = new Process()) { - ProcessStartInfo processStartInfo = new ProcessStartInfo(currentApplication.Filename); + ProcessStartInfo processStartInfo = new ProcessStartInfo(currentApplication.Executable); processStartInfo.Arguments = "-listfull"; processStartInfo.UseShellExecute = false; processStartInfo.RedirectStandardOutput = true; @@ -115,17 +115,16 @@ } } - void ReadListClones() { string line; if (((ApplicationItemMame)currentApplication).ImportOriginalsOnly) { - SendText("generating mame list (clones)", 20); + SendDisplayText("generating mame list (clones)", 20); using (Process process = new Process()) { - ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(currentApplication.Filename); + ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(currentApplication.Executable); myProcessStartInfo.Arguments = "-listclones"; myProcessStartInfo.UseShellExecute = false; myProcessStartInfo.RedirectStandardOutput = true; @@ -192,7 +191,6 @@ } } - void ReadCatverIni() { string line = string.Empty; @@ -238,37 +236,33 @@ return mameHistoryContainer; } - - bool CheckPrerequisites() { char separator = ';'; Checker.Clear(); string[] fileDirs = currentApplication.FileDirectory.Split(separator); - - - if (Checker.DoCheck(System.IO.File.Exists(currentApplication.Filename), "mame-application not found!")) + if (Checker.DoCheck(System.IO.File.Exists(currentApplication.Executable), "mame-application not found!")) { - mameDir = Path.GetDirectoryName(currentApplication.Filename); + mameDir = Path.GetDirectoryName(currentApplication.Executable); catverIniFile = mameDir + "\\catver.ini"; historyDatFile = mameDir + "\\history.dat"; } if (Checker.IsOk) { - SendText("Generating lists...", 0); + SendDisplayText("Generating lists...", 0); ReadListFull(); - SendText("Generating lists.....", 0); + SendDisplayText("Generating lists.....", 0); ReadListClones(); if (System.IO.File.Exists(catverIniFile)) { - SendText("Reading catver.ini.......", 0); + SendDisplayText("Reading catver.ini.......", 0); ReadCatverIni(); } if (System.IO.File.Exists(historyDatFile)) { - SendText("Reading history.dat............", 0); + SendDisplayText("Reading history.dat............", 0); ReadHistoryDat(); } @@ -287,25 +281,16 @@ return Checker.IsOk; } - void SendText(string informationMessage, int progressBarCtr) - { - if (OnSendMessage != null) - { - OnSendMessage(informationMessage, progressBarCtr); - } - } - public void Start() + public void StartImport() { if (!CheckPrerequisites()) { - OnSendMessage(Checker.Problems, 0); + SendDisplayText(Checker.Problems, 0); Log.Info("MameImporter: import failed! Details: {0}", Checker.Problems); return; } int i = 0; - //trick to slow down progressbarimport.. - localRomNames.Reverse(); double total = localRomNames.Count; @@ -318,8 +303,8 @@ } transaction.Commit(); } - - SendText("Import done...................", 100); + + SendDisplayText("Import done...................", 100); } @@ -367,11 +352,11 @@ FileItem curFile = new FileItem(); curFile.AppID = currentApplication.ApplicationItemId; curFile.Filename = fullRomname; - curFile.Imagefile = GetImageFile(curRomname); + curFile.Imagefile = ImportImageFiles(curFile.Filename, curFile.Title, currentApplication); if ((curFile.Imagefile == "") && (currentApplication.ImportValidImagesOnly)) { - this.SendText("", (int)(100 * (((double)count) / total))); + SendDisplayText("", (int)(100 * (((double)count) / total))); return; } if (this.fullRomListDictionary.ContainsKey(curRomname)) @@ -419,7 +404,7 @@ ProcessFullEntry(curFile, fullEntry); ProcessGenreEntry(curFile, genreEntry); - + int LexiconId = DatabaseHandler.DBHandlerInstance.LexiconDataExists("tblPlatform", "platform", "Arcade"); curFile.PlatformId = LexiconId; @@ -427,7 +412,7 @@ curFile.Write(); // OnReadNewFile(curFile.Title, count, localRomNames.Length); - this.SendText(curFile.Title, (int)(100 * (((double)count) / total))); + SendDisplayText(curFile.Title, (int)(100 * (((double)count) / total))); } } @@ -435,11 +420,11 @@ } else { - this.SendText("", (int)(100 * (((double)count) / total))); + SendDisplayText("", (int)(100 * (((double)count) / total))); } } - void ProcessFullEntry(FileItem curFile, string fullEntry) + void ProcessFullEntry(FileItem curFile, string fullEntry) { // mspacman "Ms. Pac-Man" Match m = regexMameGameName.Match(fullEntry); @@ -483,45 +468,6 @@ } // mspacman=Maze } - - - string GetImageFile(string curRomname) - { - string res = ""; - string imgFolder = ""; - int i = 0; - while ((res == "") && (i < currentApplication.imageDirs.Length)) - { - imgFolder = currentApplication.imageDirs[i]; - res = GetImageFileOfFolder(curRomname, imgFolder); - i++; - } - return res; - } - - string GetImageFileOfFolder(string curRomname, string imgFolder) - { - string res = ""; - if (Directory.Exists(imgFolder)) - { - string filenameNoExtension = imgFolder + "\\" + curRomname; - if (File.Exists(Path.ChangeExtension(filenameNoExtension, ".png"))) - { - res = Path.ChangeExtension(filenameNoExtension, ".png"); - } - else if (File.Exists(Path.ChangeExtension(filenameNoExtension, ".jpg"))) - { - res = Path.ChangeExtension(filenameNoExtension, ".jpg"); - } - else if (File.Exists(Path.ChangeExtension(filenameNoExtension, ".gif"))) - { - res = Path.ChangeExtension(filenameNoExtension, ".gif"); - } - } - return res; - } - - public class MameHistoryContainer { @@ -549,6 +495,5 @@ } } - } } \ No newline at end of file Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -37,6 +37,7 @@ using MediaPortal.GUI.Library; using MediaPortal.Player; using MediaPortal.Ripper; +using MediaPortal.Dialogs; using MediaPortal.Util; using GUIPrograms; @@ -65,10 +66,12 @@ protected int GetID = ProgramUtils.GetID; protected DatabaseHandler dbHandlerInstance = DatabaseHandler.DBHandlerInstance; + protected GUIDialogProgress progressDialog = null; + int appID; int fatherID; string title; - string filename; + string executable; string arguments; ProcessWindowStyle windowStyle; @@ -81,22 +84,22 @@ private List<ImportOption> importOptionList; bool enabled; int appPosition; - string currentView = ""; - public List<object> ItemList = new List<object>(); + public List<object> ItemList = new List<object>();//fileitems or links public bool filesAreLoaded = false; // load on demand.... public bool linksAreLoaded = false; // load on demand.... bool importMamePlaychoice10 = false; bool importMameMahjong = false; bool refreshGUIAllowed = false; - public string filePath = ""; - ItemType sourceType; - string sourceFile; + ItemType itemType; + string applicationItemSource; string imageFile; string imageDirectories; // in one string for sqlite db field - public string[] imageDirs; // imageDirectories splitted + private string[] imageDirsSplitted; // imageDirectories splitted + + string fileDirectory; string validExtensions; bool importValidImagesOnly; @@ -134,10 +137,10 @@ set { title = value; } } - public string Filename + public string Executable { - get { return filename; } - set { filename = value; } + get { return executable; } + set { executable = value; } } public string Imagefile { @@ -227,34 +230,39 @@ get { return fileDirectory; } set { fileDirectory = value; } } + public string ImageDirectory { get { return imageDirectories; } - set { SetImageDirectory(value); } - } - private void SetImageDirectory(string value) - { - imageDirectories = value; - imageDirs = imageDirectories.Split(';'); - for (int i = 0; i < imageDirs.Length; i++) + set { - imageDirs[i] = imageDirs[i].Trim(); - // hack the \n away.... - // imageDirs[i] = imageDirs[i].TrimStart('\n'); - // hack trailing backslashes away - imageDirs[i] = imageDirs[i].TrimEnd('\\'); + imageDirectories = value; + + //also do the split + imageDirsSplitted = imageDirectories.Split(';'); + for (int i = 0; i < imageDirsSplitted.Length; i++) + { + imageDirsSplitted[i] = imageDirsSplitted[i].Trim(); + imageDirsSplitted[i] = imageDirsSplitted[i].TrimEnd('\\'); + } } } - public string Source + + public string[] ImageDirsSplitted { - get { return sourceFile; } - set { sourceFile = value; } + get { return imageDirsSplitted; } } - public ItemType SourceType + + public string ApplicationItemSource { - get { return sourceType; } - set { sourceType = value; } + get { return applicationItemSource; } + set { applicationItemSource = value; } } + public ItemType Item_Type + { + get { return itemType; } + set { itemType = value; } + } public string ValidExtensions { get { return validExtensions; } @@ -271,6 +279,7 @@ get { return platformId; } set { platformId = value; } } + public string LaunchErrorMsg { get { return launchErrorMsg; } @@ -288,15 +297,15 @@ appID = -1; fatherID = -1; title = ""; - filename = ""; + executable = ""; arguments = ""; windowStyle = ProcessWindowStyle.Normal; startupDir = "%FILEDIR%"; useShellExecute = false; useQuotes = true; enabled = true; - sourceType = ItemType.UNKNOWN; - sourceFile = ""; + itemType = ItemType.UNKNOWN; + applicationItemSource = ""; imageFile = ""; fileDirectory = ""; imageDirectories = ""; @@ -315,16 +324,34 @@ #region protected methods - protected void LaunchFilelink(FilelinkItem curLink, bool MPGUIMode) + + protected void ShowProgressDialog(string headerText) { - /*ApplicationItem targetApp = GetAppByID(curLink.TargetAppID); - if (targetApp != null) + progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); + progressDialog.ShowWaitCursor = true; + progressDialog.SetHeading(headerText); + progressDialog.SetLine(0,headerText); + progressDialog.SetLine(1, ""); + progressDialog.SetLine(2, ""); + progressDialog.StartModal(GetID); + progressDialog.Progress(); + } + + public void ReadNewFile(string informationMessage, int progressBarCtr) + { + if (progressDialog != null) { - targetApp.LaunchFile(curLink, MPGUIMode); - }*/ + progressDialog.SetLine(2, String.Format("{0} {1}", GUILocalizeStrings.Get(13005), informationMessage)); // "last imported file {0}" + /* if ((curPos > 0) && (maxPos > 0)) + { + int perc = 100 * curPos / maxPos; + guiDialogProgress.SetPercentage(perc); + }*/ + progressDialog.Progress(); + } + SendRefreshInfo(String.Format("{0} {1}", GUILocalizeStrings.Get(13005), informationMessage), progressBarCtr); } - protected void SendRefreshInfo(string informationMessage, int progressBarCtr) { if (OnRefreshInfo != null) @@ -398,11 +425,15 @@ } } + protected virtual void Import(bool mpGUIMode) + { + //override + } + #endregion protected methods #region Public Methods - public virtual string CurrentFilePath() { return this.FileDirectory; @@ -414,14 +445,14 @@ this.ApplicationItemId = sourceApp.ApplicationItemId; this.FatherID = sourceApp.FatherID; this.Title = sourceApp.Title; - this.Filename = sourceApp.Filename; + this.Executable = sourceApp.Executable; this.Arguments = sourceApp.Arguments; this.WindowStyle = sourceApp.WindowStyle; this.StartupDir = sourceApp.StartupDir; this.UseShellExecute = sourceApp.UseShellExecute; this.UseQuotes = sourceApp.UseQuotes; - this.SourceType = sourceApp.SourceType; - this.Source = sourceApp.Source; + this.Item_Type = sourceApp.Item_Type; + this.ApplicationItemSource = sourceApp.ApplicationItemSource; this.Imagefile = sourceApp.Imagefile; this.FileDirectory = sourceApp.FileDirectory; this.ImageDirectory = sourceApp.ImageDirectory; @@ -432,7 +463,6 @@ this.PreLaunch = sourceApp.PreLaunch; this.PostLaunch = sourceApp.PostLaunch; this.PlatformId = sourceApp.PlatformId; - } public FileItem PrevFile(FileItem curFile) @@ -467,7 +497,6 @@ { FileItem curFileItem = launchItem; if (curFileItem == null) return; - this.LaunchFile(curFileItem, true); } @@ -476,19 +505,17 @@ string filename = fileItem.Filename; if (filename == "") return; - // Launch File by item - if (mpGuiMode) - fileItem.UpdateLaunchInfo(); + fileItem.UpdateLaunchInfo(); ProcessStartInfo procStart = new ProcessStartInfo(); - if (this.Filename != "") - { // use the APPLICATION launcher and add current file information + // use the APPLICATION launcher and add current file information + if (this.Executable != "") + { + // executable of the application + procStart.FileName = this.Executable; - // filename of the application - procStart.FileName = this.Filename; - - // double quotes around the filename-argument..... + // double quotes around the executable-argument..... if (UseQuotes) filename = "\"" + fileItem.Filename + "\""; @@ -496,7 +523,7 @@ if (this.Arguments.Contains("%FILEnoPATHnoEXT%")) // ex. kawaks: // winkawaks.exe alpham2 - // => filename without path and extension is necessary! + // => executable without path and extension is necessary! procStart.Arguments = " " + this.Arguments.Replace("%FILEnoPATHnoEXT%", Path.GetFileNameWithoutExtension(fileItem.Filename)); else if (this.Arguments.Contains("%FILE%")) // placeholder found => replace the placeholder by the correct filename @@ -625,10 +652,60 @@ // descendant classes do that! } - #endregion Public Methods + public void LoadFromXmlProfile(XmlNode node) + { + XmlNode titleNode = node.SelectSingleNode("title"); + if (titleNode != null) + { + this.Title = titleNode.InnerText; + } + XmlNode launchingAppNode = node.SelectSingleNode("launchingApplication"); + if (launchingAppNode != null) + { + this.Executable = launchingAppNode.InnerText; + } + XmlNode useShellExecuteNode = node.SelectSingleNode("useShellExecute"); + if (useShellExecuteNode != null) + { + this.UseShellExecute = ProgramUtils.StrToBoolean(useShellExecuteNode.InnerText); + } + + XmlNode argumentsNode = node.SelectSingleNode("arguments"); + if (argumentsNode != null) + { + this.Arguments = argumentsNode.InnerText; + } + + XmlNode windowStyleNode = node.SelectSingleNode("windowStyle"); + if (windowStyleNode != null) + { + this.WindowStyle = ProgramUtils.StringToWindowStyle(windowStyleNode.InnerText); + } + + XmlNode startupDirNode = node.SelectSingleNode("startupDir"); + if (startupDirNode != null) + { + this.StartupDir = startupDirNode.InnerText; + } + + XmlNode useQuotesNode = node.SelectSingleNode("useQuotes"); + if (useQuotesNode != null) + { + this.UseQuotes = ProgramUtils.StrToBoolean(useQuotesNode.InnerText); + } + + XmlNode fileExtensioneNode = node.SelectSingleNode("fileextensions"); + if (fileExtensioneNode != null) + { + this.ValidExtensions = fileExtensioneNode.InnerText; + } + } + + #endregion Public Methods + #region Database stuff /// <summary> @@ -656,14 +733,14 @@ parameterArray[0] = dbHandlerInstance.GetParameter<int>(ApplicationItemId, "@applicationItemId", DbType.Int32); parameterArray[1] = dbHandlerInstance.GetParameter<int>(FatherID, "@fatherNodeId", DbType.Int32); parameterArray[2] = dbHandlerInstance.GetParameter<string>(Title, "@title", DbType.String); - parameterArray[3] = dbHandlerInstance.GetParameter<string>(Filename, "@filename", DbType.String); + parameterArray[3] = dbHandlerInstance.GetParameter<string>(Executable, "@filename", DbType.String); parameterArray[4] = dbHandlerInstance.GetParameter<string>(Arguments, "@arguments", DbType.String); parameterArray[5] = dbHandlerInstance.GetParameter<string>(ProgramUtils.WindowStyleToStr(WindowStyle), "@windowStyle", DbType.String); parameterArray[6] = dbHandlerInstance.GetParameter<string>(StartupDir, "@startupDir", DbType.String); parameterArray[7] = dbHandlerInstance.GetParameter<bool>(UseShellExecute, "@useShellExecute", DbType.Boolean); parameterArray[8] = dbHandlerInstance.GetParameter<bool>(UseQuotes, "@useQuotes", DbType.Boolean); - parameterArray[9] = dbHandlerInstance.GetParameter<string>(ProgramUtils.ApplicationTypeToString(SourceType), "@applicationItemType", DbType.String); - parameterArray[10] = dbHandlerInstance.GetParameter<string>(Source, "@source", DbType.String); + parameterArray[9] = dbHandlerInstance.GetParameter<string>(ProgramUtils.ApplicationTypeToString(Item_Type), "@applicationItemType", DbType.String); + parameterArray[10] = dbHandlerInstance.GetParameter<string>(ApplicationItemSource, "@source", DbType.String); parameterArray[11] = dbHandlerInstance.GetParameter<string>(imageFile, "@imageFile", DbType.String); parameterArray[12] = dbHandlerInstance.GetParameter<string>(FileDirectory, "@fileDirectory", DbType.String); parameterArray[13] = dbHandlerInstance.GetParameter<string>(ImageDirectory, "@imageDirectory", DbType.String); @@ -754,14 +831,14 @@ parameterArray[0] = dbHandlerInstance.GetParameter<int>(ApplicationItemId, "@applicationItemId", DbType.Int32); parameterArray[1] = dbHandlerInstance.GetParameter<int>(FatherID, "@fatherNodeId", DbType.Int32); parameterArray[2] = dbHandlerInstance.GetParameter<string>(Title, "@title", DbType.String); - parameterArray[3] = dbHandlerInstance.GetParameter<string>(Filename, "@filename", DbType.String); + parameterArray[3] = dbHandlerInstance.GetParameter<string>(Executable, "@filename", DbType.String); parameterArray[4] = dbHandlerInstance.GetParameter<string>(Arguments, "@arguments", DbType.String); parameterArray[5] = dbHandlerInstance.GetParameter<string>(ProgramUtils.WindowStyleToStr(WindowStyle), "@windowStyle", DbType.String); parameterArray[6] = dbHandlerInstance.GetParameter<string>(StartupDir, "@startupDir", DbType.String); parameterArray[7] = dbHandlerInstance.GetParameter<bool>(UseShellExecute, "@useShellExecute", DbType.Boolean); parameterArray[8] = dbHandlerInstance.GetParameter<bool>(UseQuotes, "@useQuotes", DbType.Boolean); - parameterArray[9] = dbHandlerInstance.GetParameter<string>(ProgramUtils.ApplicationTypeToString(SourceType), "@applicationItemType", DbType.String); - parameterArray[10] = dbHandlerInstance.GetParameter<string>(Source, "@source", DbType.String); + parameterArray[9] = dbHandlerInstance.GetParameter<string>(ProgramUtils.ApplicationTypeToString(Item_Type), "@applicationItemType", DbType.String); + parameterArray[10] = dbHandlerInstance.GetParameter<string>(ApplicationItemSource, "@source", DbType.String); parameterArray[11] = dbHandlerInstance.GetParameter<string>(imageFile, "@imageFile", DbType.String); parameterArray[12] = dbHandlerInstance.GetParameter<string>(FileDirectory, "@fileDirectory", DbType.String); parameterArray[13] = dbHandlerInstance.GetParameter<string>(ImageDirectory, "@imageDirectory", DbType.String); @@ -866,8 +943,6 @@ public virtual void LoadFiles() { - lastFilepath = ""; - filePath = ""; ItemList = dbHandlerInstance.LoadItemList(ApplicationItemId, ItemList, ""); filesAreLoaded = true; } @@ -942,22 +1017,24 @@ #region imagedirectory stuff // get next imagedirectory that holds at least one image for a fileitem - // * m_pFile: the file we're looking images for + // * the file we're looking images for private void GetNextThumbFolderIndex(FileItem fileItem) { if (fileItem == null) return; + bool foundThumb = false; + while (!foundThumb) { thumbFolderIndex++; - if (thumbFolderIndex >= imageDirs.Length) + if (thumbFolderIndex >= imageDirsSplitted.Length) { thumbFolderIndex = -1; foundThumb = true; } else { - string candFolder = imageDirs[thumbFolderIndex]; + string candFolder = imageDirsSplitted[thumbFolderIndex]; string candThumb = candFolder + "\\" + Path.GetFileName(fileItem.Imagefile); if (candThumb.ToLower() != fileItem.Imagefile.ToLower()) { @@ -1007,7 +1084,7 @@ } else { - string curFolder = imageDirs[thumbFolderIndex]; + string curFolder = imageDirsSplitted[thumbFolderIndex]; curThumb = curFolder + "\\" + Path.GetFileName(fileItem.Imagefile); } @@ -1073,56 +1150,6 @@ #endregion - public void LoadFromXmlProfile(XmlNode node) - { - - XmlNode titleNode = node.SelectSingleNode("title"); - if (titleNode != null) - { - this.Title = titleNode.InnerText; - } - - XmlNode launchingAppNode = node.SelectSingleNode("launchingApplication"); - if (launchingAppNode != null) - { - this.Filename = launchingAppNode.InnerText; - } - - XmlNode useShellExecuteNode = node.SelectSingleNode("useShellExecute"); - if (useShellExecuteNode != null) - { - this.UseShellExecute = ProgramUtils.StrToBoolean(useShellExecuteNode.InnerText); - } - - XmlNode argumentsNode = node.SelectSingleNode("arguments"); - if (argumentsNode != null) - { - this.Arguments = argumentsNode.InnerText; - } - - XmlNode windowStyleNode = node.SelectSingleNode("windowStyle"); - if (windowStyleNode != null) - { - this.WindowStyle = ProgramUtils.StringToWindowStyle(windowStyleNode.InnerText); - } - - XmlNode startupDirNode = node.SelectSingleNode("startupDir"); - if (startupDirNode != null) - { - this.StartupDir = startupDirNode.InnerText; - } - - XmlNode useQuotesNode = node.SelectSingleNode("useQuotes"); - if (useQuotesNode != null) - { - this.UseQuotes = ProgramUtils.StrToBoolean(useQuotesNode.InnerText); - } - - XmlNode fileExtensioneNode = node.SelectSingleNode("fileextensions"); - if (fileExtensioneNode != null) - { - this.ValidExtensions = fileExtensioneNode.InnerText; - } - } + } } \ No newline at end of file Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemDirectoryCache.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemDirectoryCache.cs 2007-08-19 14:44:46 UTC (rev 846) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemDirectoryCache.cs 2007-08-19 23:23:20 UTC (rev 847) @@ -23,6 +23,9 @@ #endregion + + +#region Imports using System; using System.Collections; using System.Collections.Generic; @@ -35,9 +38,13 @@ using MediaPortal.Util; using GUIPrograms; +using GUIPrograms.Imports; using GUIPrograms.Database; -using GUIPrograms.Items; +using GUIPrograms.Items; + +#endregion Imports + namespace GUIPrograms.Items { /// <summary> @@ -45,268 +52,57 @@ /// </summary> public class ApplicationItemDirectoryCache : ApplicationItem { - GUIDialogProgress progressDialog = null; - public ApplicationItemDirectoryCache() { } - private void ShowProgressDialog() - { - progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); - progressDialog.ShowWaitCursor = true; - progressDialog.SetHeading(GUILocalizeStrings.Get(13014)); - progressDialog.SetLine(0, GUILocalizeStrings.Get(13014)); - progressDialog.SetLine(1, ""); - progressDialog.SetLine(2, ""); - progressDialog.StartModal(GetID); - progressDialog.Progress(); - } + #region ApplicationItem Overloads - private void CloseProgressDialog() + public override string DefaultFilepath() { - progressDialog.Close(); + return this.FileDirectory; } - private string GetThumbsFile(FileInfo file, string fileTitle) + public override bool ProfileLoadingAllowed() { - string thumbFolder = ""; - - if (imageDirs.Length > 0) - { - string mainImgFolder = ""; - - foreach (string imgFolder in imageDirs) - { - if (System.IO.Directory.Exists(imgFolder)) - { - mainImgFolder = imgFolder; - } - } - - if ("" != mainImgFolder) - { - string curDir = mainImgFolder + "\\"; - string filenameNoExtension = mainImgFolder + "\\" + file.Name; - filenameNoExtension = Path.ChangeExtension(filenameNoExtension, null); - filenameNoExtension = Path.GetFileNameWithoutExtension(filenameNoExtension); - - string[] exactMatchesJPG = Directory.GetFiles(curDir, filenameNoExtension + ".jpg"); - string[] exactMatchesGIF = Directory.GetFiles(curDir, filenameNoExtension + ".gif"); - string[] exactMatchesPNG = Directory.GetFiles(curDir, filenameNoExtension + ".png"); - if (exactMatchesJPG.Length > 0) - { - thumbFolder = exactMatchesJPG[0]; - } - else if (exactMatchesGIF.Length > 0) - { - thumbFolder = exactMatchesGIF[0]; - } - else if (exactMatchesPNG.Length > 0) - { ... [truncated message content] |