From: <nor...@us...> - 2007-07-24 20:20:49
|
Revision: 758 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=758&view=rev Author: northern_sky Date: 2007-07-24 13:20:46 -0700 (Tue, 24 Jul 2007) Log Message: ----------- misc wip Modified Paths: -------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesImportProgress.Designer.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesImportProgress.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.Designer.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemFactory.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemGrouper.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemMame.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/BaseItem.cs Removed Paths: ------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemList.cs Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Database/DatabaseHandler.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -44,7 +44,7 @@ public class DatabaseHandler { public static SQLiteClient sqlDB = null; - static ApplicationItemList dbHandlerApplicationItemList = null; + static List<ApplicationItem> globalApplicationItemList = new List<ApplicationItem>(); private const string DATABASEFILE = "myProgramsAltDatabaseV1.db3"; public static bool useMPsThumbDirectory = false; @@ -76,22 +76,25 @@ sqlDB = new SQLiteClient(Config.GetFile(Config.Dir.Database, DATABASEFILE)); } + //globalApplicationItemList = new ApplicationItemList(sqlDB, new ApplicationItem.FilelinkLaunchEventHandler(LaunchFilelink)); + LoadAllApplicationItems(); } catch (SQLiteException ex) { Log.Info("programdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); } - dbHandlerApplicationItemList = new ApplicationItemList(sqlDB, new ApplicationItem.FilelinkLaunchEventHandler(LaunchFilelink)); + + } - static void LaunchFilelink(FilelinkItem curLink, bool MPGUIMode) + /*static void LaunchFilelink(FilelinkItem curLink, bool MPGUIMode) { - ApplicationItem targetApp = dbHandlerApplicationItemList.GetAppByID(curLink.TargetAppID); + ApplicationItem targetApp = globalApplicationItemList.GetAppByID(curLink.TargetAppID); if (targetApp != null) { targetApp.LaunchFile(curLink, MPGUIMode); } - } + }*/ /// <summary> /// Create db tables etc,if not already exist @@ -401,12 +404,35 @@ - static public ApplicationItemList ApplicationItemList + static public List<ApplicationItem> ApplicationItemList { get { - return dbHandlerApplicationItemList; + return globalApplicationItemList; } } + + public static void LoadAllApplicationItems() + { + try + { + globalApplicationItemList.Clear(); + SQLiteResultSet results = sqlDB.Execute("select * from tblApplicationItem order by iposition"); + + if (results.Rows.Count == 0) + return; + + for (int row = 0; row < results.Rows.Count; row++) + { + ApplicationItem applicationItem = (ApplicationItem)ApplicationItemFactory.AppFactory.GetApplicationItem( ProgramUtils.GetSourceType(results, row, "applicationItemType"), results, row); + // 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/AppFilesImportProgress.Designer.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesImportProgress.Designer.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesImportProgress.Designer.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -1,6 +1,6 @@ namespace GUIPrograms.Design { - partial class AppFilesImportProgress + partial class AppSettingsFilesImportProgress { /// <summary> /// Required designer variable. @@ -98,13 +98,13 @@ this.progressTextBox.Size = new System.Drawing.Size(477, 47); this.progressTextBox.TabIndex = 34; // - // AppFilesImportProgress + // AppSettingsFilesImportProgress // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.progressTextBox); this.Controls.Add(this.progressBar); - this.Name = "AppFilesImportProgress"; + this.Name = "AppSettingsFilesImportProgress"; this.Load += new System.EventHandler(this.AppFilesImportProgress_Load); this.Controls.SetChildIndex(this.prePostButton, 0); this.Controls.SetChildIndex(this.winTypeLabel, 0); Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesImportProgress.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesImportProgress.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesImportProgress.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -36,14 +36,14 @@ namespace GUIPrograms.Design { - public partial class AppFilesImportProgress : AppSettingsBase + public partial class AppSettingsFilesImportProgress : AppSettingsBase { private bool isImportRunning; private ApplicationItem curApp; const string importStartedText = "=== import started..."; const string importFinishedText = "=== import finished."; - public AppFilesImportProgress() + public AppSettingsFilesImportProgress() { InitializeComponent(); } Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.Designer.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.Designer.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.Designer.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -1,6 +1,6 @@ namespace GUIPrograms.Design { - partial class AppFilesView + partial class AppSettingsFilesView { /// <summary> /// Required designer variable. @@ -29,7 +29,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppFilesView)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppSettingsFilesView)); this.fileListView = new System.Windows.Forms.ListView(); this.fileTitle = new System.Windows.Forms.ColumnHeader(); this.smallImageList = new System.Windows.Forms.ImageList(this.components); @@ -391,13 +391,13 @@ // this.openFileDialog.FileName = "openFileDialog1"; // - // AppFilesView + // AppSettingsFilesView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.FileSettingsGroupBox); this.Controls.Add(this.filesGroupBox); - this.Name = "AppFilesView"; + this.Name = "AppSettingsFilesView"; this.Size = new System.Drawing.Size(521, 574); this.Load += new System.EventHandler(this.AppFilesView_Load); this.contextFavouritesMenuStrip.ResumeLayout(false); Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppFilesView.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -38,14 +38,14 @@ namespace GUIPrograms.Design { - public partial class AppFilesView : UserControl + public partial class AppSettingsFilesView : UserControl { - private ApplicationItemList apps = DatabaseHandler.ApplicationItemList; + private List<ApplicationItem> apps = DatabaseHandler.ApplicationItemList; public event EventHandler OnRefreshClick; private ApplicationItem currentApplication = null; public event EventHandler OnImageFolderSearch; - public AppFilesView() + public AppSettingsFilesView() { InitializeComponent(); } Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/AppSettingsBase.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -63,12 +63,6 @@ return true; } - public virtual bool Applist2Form(ApplicationItemList apps) - { - // virtual! - return true; - } - public virtual void FormToAppItem(ApplicationItem curApp) { if (curApp != null) Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/SetupForm.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -1,3 +1,5 @@ +#region Imports + using System; using System.Collections.Generic; using System.ComponentModel; @@ -16,43 +18,122 @@ using GUIPrograms; using GUIPrograms.Items; +#endregion +//#region Enums +//#endregion +//#region Delegates +//#endregion + +//#region Events +//#endregion + + + + + +#region Properties +// Public Properties +#endregion + +#region Public Methods +#endregion + +#region Private Methods +#endregion + +#region <Base class> Overloads +#endregion + +#region <Interface> Implementations +// region for each interface +#endregion + namespace GUIPrograms.Design { public partial class SetupForm : Form { - private ApplicationItemList globalApplicationList = DatabaseHandler.ApplicationItemList; - private AppSettingsDirCache sectionDirCache = new AppSettingsDirCache(); - private AppSettingsMame sectionMameDirect = new AppSettingsMame(); - private AppSettingsGamebase appSettingsGameBase = new AppSettingsGamebase(); - private AppSettingsGrouper sectionGrouper = new AppSettingsGrouper(); - private ProgramViews programView = new ProgramViews(); - private AppSettingsRoot sectionRoot = new AppSettingsRoot(); - private AppFilesView filesView = new AppFilesView(); + #region Variables - private AppFilesImportProgress filesProgress = new AppFilesImportProgress(); + private List<ApplicationItem> globalApplicationList = DatabaseHandler.ApplicationItemList; + private AppSettingsDirCache appSettingsDirCache = new AppSettingsDirCache(); + private AppSettingsMame appSettingsMame = new AppSettingsMame(); + private AppSettingsGamebase appSettingsGameBase = new AppSettingsGamebase(); + private AppSettingsGrouper appSettingsGrouper = new AppSettingsGrouper(); + private ProgramViews appSettingsProgramView = new ProgramViews(); + private AppSettingsRoot appSettingsRoot = new AppSettingsRoot(); + private AppSettingsFilesView appSettingsFileEditView = new AppSettingsFilesView(); + private AppSettingsFilesImportProgress filesProgress = new AppSettingsFilesImportProgress(); private AppSettingsBase pageCurrentSettings = null; - private bool profilesLoaded = false; + private bool profilesIsLoaded = false; private const string ROOTNODENAME = "Applications"; private const int POSITIONHOLDER = 10; + #endregion + #region Constructors/Destructors + public SetupForm() { - - - InitializeComponent(); - filesView.OnRefreshClick += new EventHandler(this.RefreshClick); + + appSettingsFileEditView.OnRefreshClick += new EventHandler(this.RefreshClick); //when imagefolder was clicked on filesview... - filesView.OnImageFolderSearch += new EventHandler(this.ImageSearchClick); + appSettingsFileEditView.OnImageFolderSearch += new EventHandler(this.ImageSearchClick); } + #endregion + #region Private Methods + #region Treeview helper Methods + private void RemoveNodeAndUpdateTree(TreeNode treeNode) + { + //update sibling level + ApplicationItem application = GetTreeNodeApplicationItem(treeNode); + //get last node at same level as treenode + TreeNode tmpNode = treeNode.Parent.LastNode; + ApplicationItem tmpApplication = GetTreeNodeApplicationItem(tmpNode); + + + if (tmpNode != treeNode) + { + //remember where to stop updating.. + int stopPosition = application.Position; + + //remove node from tree + treeNode.Remove(); + + //start rearrangeposition + while ((tmpNode.PrevNode != null) && (tmpApplication.Position > stopPosition)) + { + application = GetTreeNodeApplicationItem(tmpNode); + application.Position = application.Position - POSITIONHOLDER; + application.InsertOrUpdateSettings(); + + tmpNode = tmpNode.PrevNode; + tmpApplication = GetTreeNodeApplicationItem(tmpNode); + + } + + //node under root + if (tmpNode.PrevNode == null) + { + application = GetTreeNodeApplicationItem(tmpNode); + application.Position = POSITIONHOLDER; + application.InsertOrUpdateSettings(); + } + } + else//is lastnode.just remove,, + { + treeNode.Remove(); + } + + } + /// <summary> /// Gets the path to selected treenode in format0;2;0 etc /// </summary> @@ -119,7 +200,7 @@ /// <param name="FatherID"></param> private void AttachChildNodes(TreeNode Parent, int FatherID) { - foreach (ApplicationItem applicationItem in globalApplicationList.AppsOfFatherID(FatherID)) + foreach (ApplicationItem applicationItem in AppsOfFatherID(FatherID)) { TreeNode currentNode = new TreeNode(applicationItem.Title); @@ -130,7 +211,20 @@ } + public List<ApplicationItem> AppsOfFatherID(int FatherID) + { + List<ApplicationItem> applicationItemList = new List<ApplicationItem>(); + foreach (ApplicationItem curApp in globalApplicationList) + { + if (curApp.FatherID == FatherID) + { + applicationItemList.Add(curApp); + } + } + return applicationItemList; + } + /// <summary> /// Updates the whole treeview /// </summary> @@ -247,19 +341,17 @@ #endregion Treeview helper Methods - - + private void AttachFilesView() { this.tabControl.TabPages["directoryTabPage"].Controls.Clear(); - this.tabControl.TabPages["directoryTabPage"].Controls.Add(filesView); - + this.tabControl.TabPages["directoryTabPage"].Controls.Add(appSettingsFileEditView); } private void AttachProgramsView() { this.tabControl.TabPages["viewTabPage"].Controls.Clear(); - this.tabControl.TabPages["viewTabPage"].Controls.Add(programView); + this.tabControl.TabPages["viewTabPage"].Controls.Add(appSettingsProgramView); } private void AttachImportRunningView() @@ -268,8 +360,8 @@ this.tabControl.TabPages["directoryTabPage"].Controls.Add(filesProgress); } + - private AppSettingsBase GetCurrentSettingsPage() { AppSettingsBase appSettings = null; @@ -280,13 +372,13 @@ switch (currentApplication.SourceType) { case ItemType.DIRCACHE: - appSettings = sectionDirCache; + appSettings = appSettingsDirCache; break; case ItemType.MAMEDIRECT: - appSettings = sectionMameDirect; + appSettings = appSettingsMame; break; case ItemType.GROUPER: - appSettings = sectionGrouper; + appSettings = appSettingsGrouper; break; case ItemType.GAMEBASE: appSettings = this.appSettingsGameBase; @@ -295,7 +387,7 @@ } else { - appSettings = sectionRoot; + appSettings = appSettingsRoot; } return appSettings; } @@ -319,7 +411,7 @@ { tabControl.Controls.Add(this.directoryTabPage); } - filesView.Refresh(curApp); + appSettingsFileEditView.Refresh(curApp); } private void AddViewsPage() @@ -399,8 +491,6 @@ } } - - private bool SaveAppItem() { bool success = true; @@ -413,11 +503,11 @@ { if (pageCurrentSettings.EntriesOK(currentApplication)) { - if (filesView.EntriesOK()) + if (appSettingsFileEditView.EntriesOK()) { pageCurrentSettings.FormToAppItem(currentApplication); - filesView.FillApplicationItem(currentApplication); + appSettingsFileEditView.FillApplicationItem(currentApplication); if (currentApplication != null) @@ -466,7 +556,7 @@ ApplicationItem currentApplication = GetTreeNodeApplicationItem(treeView.SelectedNode); if (currentApplication != null) { - deleteApplicationToolStripMenuItem.Enabled = (globalApplicationList.AppsOfFatherID(currentApplication.AppID).Count == 0); // groupitems are only deletable if no children exist + deleteApplicationToolStripMenuItem.Enabled = (AppsOfFatherID(currentApplication.AppID).Count == 0); // groupitems are only deletable if no children exist } } @@ -493,7 +583,7 @@ int id = 0; string titleNode = string.Empty; - if (!profilesLoaded) + if (!profilesIsLoaded) { this.emulatorSetupToolStripMenuItem.DropDownItems.Clear(); @@ -529,7 +619,7 @@ } } - profilesLoaded = true; + profilesIsLoaded = true; } } @@ -553,7 +643,7 @@ ApplicationItem tempApp = new ApplicationItem(curApp.db); tempApp.LoadFromXmlProfile(node); pageCurrentSettings.LoadFromAppItem(tempApp); - filesView.FileExtensionsText = tempApp.ValidExtensions; + appSettingsFileEditView.FileExtensionsText = tempApp.ValidExtensions; } } @@ -574,21 +664,33 @@ //ADD POSITION CHECK? - globalApplicationList.LoadAll(); + DatabaseHandler.LoadAllApplicationItems(); UpdateTree(); } } } + public int GetMaxPosition(int fatherID) + { + int res = 0; + foreach (ApplicationItem curApp in globalApplicationList) + { + if ((curApp.FatherID == fatherID) && (curApp.Position > res)) + { + res = curApp.Position; + } + } + return res; + } private void AddApplication(ItemType newSourceType) { if (SaveAppItem()) { - ApplicationItem newApplication = (ApplicationItem) ApplicationItemFactory.AppFactory.GetApplicationItem(DatabaseHandler.sqlDB, newSourceType,null,0); + ApplicationItem newApplication = (ApplicationItem)ApplicationItemFactory.AppFactory.GetApplicationItem(newSourceType, null, 0); globalApplicationList.Add(newApplication); newApplication.FatherID = GetTreeNodeApplicationItemId(); - newApplication.Position = globalApplicationList.GetMaxPosition(newApplication.FatherID) + 10; + newApplication.Position = GetMaxPosition(newApplication.FatherID) + 10; if (newApplication.Title == string.Empty) { @@ -596,7 +698,7 @@ } newApplication.SourceType = newSourceType; newApplication.InsertOrUpdateSettings(); - globalApplicationList.LoadAll(); + DatabaseHandler.LoadAllApplicationItems(); UpdateTree(); @@ -609,12 +711,26 @@ } } + private void BlockControls() + { + treeView.Enabled = false; + this.toolsStripMenuItem.Enabled = false; + } + + private void UnblockControls() + { + treeView.Enabled = true; + this.toolsStripMenuItem.Enabled = true; + } + + + #endregion Private Methods + #region Events private void SetupForm_Load(object sender, EventArgs e) { AttachFilesView(); - globalApplicationList.LoadAll(); // we need all globalApplicationList, whether enabled or not => reload with LoadALL AttachProgramsView(); UpdateTree(); FillProfileMenu(); @@ -671,8 +787,6 @@ DeleteApplication(); } - - private void treeView_DragEnter(object sender, DragEventArgs e) { e.Effect = e.AllowedEffect; @@ -687,50 +801,8 @@ } } - private void RemoveNodeAndUpdateTree(TreeNode treeNode) - { - //update sibling level - ApplicationItem application = GetTreeNodeApplicationItem(treeNode); - //get last node at same level as treenode - TreeNode tmpNode = treeNode.Parent.LastNode; - ApplicationItem tmpApplication = GetTreeNodeApplicationItem(tmpNode); + - - if (tmpNode != treeNode) - { - //remember where to stop updating.. - int stopPosition = application.Position; - - //remove node from tree - treeNode.Remove(); - - //start rearrangeposition - while ((tmpNode.PrevNode != null) && (tmpApplication.Position > stopPosition)) - { - application = GetTreeNodeApplicationItem(tmpNode); - application.Position = application.Position - POSITIONHOLDER; - application.InsertOrUpdateSettings(); - - tmpNode = tmpNode.PrevNode; - tmpApplication = GetTreeNodeApplicationItem(tmpNode); - - } - - //node under root - if (tmpNode.PrevNode == null) - { - application = GetTreeNodeApplicationItem(tmpNode); - application.Position = POSITIONHOLDER; - application.InsertOrUpdateSettings(); - } - } - else//is lastnode.just remove,, - { - treeNode.Remove(); - } - - } - private void treeView_DragDrop(object sender, DragEventArgs e) { // Retrieve the client coordinates of the drop location. @@ -833,7 +905,7 @@ } } - globalApplicationList.LoadAll(); + DatabaseHandler.LoadAllApplicationItems(); UpdateTree(); } } @@ -857,7 +929,7 @@ // save current applicationItem if switching to file-tab if (tabControl.SelectedIndex == 1) { - filesView.SetupFileView(); + appSettingsFileEditView.SetupFileView(); if (!SaveAppItem()) { tabControl.SelectedIndex = 0; @@ -868,7 +940,6 @@ if (tabControl.SelectedIndex == 0) { SaveAppItem(); - } } @@ -880,7 +951,6 @@ { if (pageCurrentSettings.EntriesOK(currentApplication)) { - pageCurrentSettings.FormToAppItem(currentApplication); if (currentApplication != null) { @@ -890,20 +960,9 @@ } } - #endregion Events + - private void BlockControls() - { - treeView.Enabled = false; - this.toolsStripMenuItem.Enabled = false; - } - - private void UnblockControls() - { - treeView.Enabled = true; - this.toolsStripMenuItem.Enabled = true; - } - + private void DoRefresh() { bool DoIt = false; @@ -926,7 +985,7 @@ { AttachImportRunningView(); BlockControls(); - filesView.FillApplicationItem(currentApplication); + appSettingsFileEditView.FillApplicationItem(currentApplication); filesProgress.CurApp = currentApplication; filesProgress.RunImport(); } @@ -957,6 +1016,9 @@ toolsStripMenuItem.Enabled = true; } } + + #endregion Events + private void UpdateComboBoxes() { FillComboBox("tblPlatform", "platform", removePlatformComboBox); @@ -964,33 +1026,6 @@ FillComboBox("tblGenre", "genre", removeGenreComboBox); } - - 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; - } - - - } - private void FillComboBox(string tableName, string orderBy, ComboBox comboBox) { @@ -1131,18 +1166,12 @@ try { - // - DatabaseHandler.sqlDB.Execute(sqlStmt); - - } catch (Exception exception) { throw exception; } - - } @@ -1158,9 +1187,6 @@ AND " + column + @" <> 1 "; - - - try { DatabaseHandler.sqlDB.Execute(sqlStmt); @@ -1176,8 +1202,28 @@ 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/GUIPrograms.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -407,7 +407,6 @@ public GUIPrograms() { GetID = (int)Window.WINDOW_FILES; - applicationList = DatabaseHandler.ApplicationItemList; LoadSettings(); skipInit = true; } @@ -433,6 +432,7 @@ void InitMyPrograms() { LoadFolderSettings(""); + if (skipInit) { mapSettings.LastAppID = -1; @@ -441,7 +441,7 @@ { LoadLastAppIDFromSettings(); // hacky load back the last applicationItem id, otherwise this can get lost from dx resets.... } - lastApp = applicationList.GetAppByID(mapSettings.LastAppID); + lastApp = GetAppByID(mapSettings.LastAppID); if (lastApp != null) { lastFilepath = lastApp.DefaultFilepath(); @@ -469,7 +469,7 @@ bool currentSortAsc = true; ProgramViewHandler viewHandler = ProgramViewHandler.Instance; - static ApplicationItemList applicationList = DatabaseHandler.ApplicationItemList; + List<ApplicationItem> allApplicationsList = DatabaseHandler.ApplicationItemList; public MapSettings mapSettings = new MapSettings(); DirectoryHistory itemHistory = new DirectoryHistory(); public ApplicationItem lastApp = null; @@ -494,7 +494,6 @@ get { return viewHandler; } set { viewHandler = value; } } - public static string ThumbnailPath { @@ -597,11 +596,9 @@ protected override void OnPageLoad() { - //string view = CurrentView; - base.OnPageLoad(); - if (btnSortBy != null) + if (btnSortBy != null) btnSortBy.SortChanged += new SortEventHandler(SortChanged); InitMyPrograms(); @@ -667,6 +664,7 @@ protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); + if (control == btnViewAs) { mapSettings.SwitchToNextViewLayout(); @@ -709,7 +707,6 @@ { OnShowSort(); } - else if (control == facadeView) { // application or file-item was clicked.... @@ -765,7 +762,7 @@ RenderThumbnail(timePassed); } - + #endregion #region Display @@ -785,7 +782,6 @@ btnRefresh.IsVisible = lastApp.RefreshGUIAllowed; } - facadeView.IsVisible = true; GUIControl.FocusControl(GetID, facadeView.GetID); @@ -870,7 +866,6 @@ screenShotImage.Visible = false; break; } - facadeView.SelectedListItemIndex = itemIndex; UpdateButtonStates(); } @@ -910,7 +905,6 @@ // only show big thumb if there is really one.... ThumbnailPath = appWithImg.GetCurThumb(item); // some modes look for thumbs differently } - appWithImg.NextThumb(); // try to find a next thumbnail slideTime = (DateTime.Now.Ticks / 10000); // reset timer! } @@ -946,19 +940,18 @@ // Refresh FileList if view has changed, while this appItem was not active if (lastApp.CurrentView != this.CurrentView) { - lastApp.LoadFiles(); lastApp.CurrentView = this.CurrentView; } - int totalFiles = lastApp.DisplayFiles(this.lastFilepath, facadeView); + int totalFiles = lastApp.DisplayFiles(lastApp.FileDirectory, facadeView); return (totalFiles); } int DisplayApps() { int totalApps = 0; - foreach (ApplicationItem applicationItem in applicationList.AppsOfFatherID(GetCurrentFatherID())) + foreach (ApplicationItem applicationItem in AppsOfFatherID(GetCurrentFatherID())) { if (applicationItem.Enabled) { @@ -999,7 +992,7 @@ return String.Format("applicationItem{0}#level{1}#sub_{2}", appID, viewLevel, pathSub); } - public void SaveItemIndex(string value, ApplicationItem app, string pathSub) + public void SaveItemIndex(string value, ApplicationItem app, string pathSub) { string key = BuildHistoryKey(app, ViewHandler.CurrentLevel, pathSub); itemHistory.Set(value, key); @@ -1035,7 +1028,7 @@ } else { - if (ViewHandler.RemoveFilterItem()) + if (ViewHandler.RemoveFilterItem()) { FilterItem curFilter; // force reload, this will load the next filter-level..... @@ -1064,7 +1057,7 @@ { // back item in application list clicked // go to father item - lastApp = applicationList.GetAppByID(lastApp.FatherID); + lastApp = GetAppByID(lastApp.FatherID); if (lastApp != null) { mapSettings.LastAppID = lastApp.AppID; @@ -1091,8 +1084,67 @@ } + public List<ApplicationItem> AppsOfFatherID(int FatherID) + { + List<ApplicationItem> applicationItemList = new List<ApplicationItem>(); + foreach (ApplicationItem curApp in allApplicationsList) + { + if (curApp.FatherID == FatherID) + { + applicationItemList.Add(curApp); + } + } + return applicationItemList; + } + public List<ApplicationItem> AppsOfFather(ApplicationItem father) + { + if (father == null) + { + return AppsOfFatherID(-1); // return children of root node! + } + else + { + return AppsOfFatherID(father.AppID); + } + } + + public int GetMaxPosition(int fatherID) + { + int res = 0; + foreach (ApplicationItem curApp in allApplicationsList) + { + if ((curApp.FatherID == fatherID) && (curApp.Position > res)) + { + res = curApp.Position; + } + } + return res; + } + + public ApplicationItem GetAppByID(int targetAppID) + { + foreach (ApplicationItem curApp in allApplicationsList) + { + if (curApp.AppID == targetAppID) + { + return curApp; + } + } + return null; + } + + /* public ApplicationItem CloneAppItem(ApplicationItem sourceApp) + { + ApplicationItem newApp = (ApplicationItem)ApplicationItemFactory.AppFactory.GetApplicationItem(sqlDB, sourceApp.SourceType, null, 0); + newApp.Assign(sourceApp); + newApp.AppID = -1; // to force a sql INSERT when written + Add(newApp); + return newApp; + }*/ + + void ScrapeFileInfo(FileItem curFile) { int minRelevance = 30; @@ -1199,16 +1251,15 @@ if (item.MusicTag != null) { - ((BaseItem)item.MusicTag).OnClick((BaseItem) item.MusicTag,this); - UpdateButtonStates(); - UpdateListControl(); + ((BaseItem)item.MusicTag).OnClick((BaseItem)item.MusicTag, this); + UpdateButtonStates(); + UpdateListControl(); } else if (item.Label.Equals(ProgramUtils.cBackLabel)) { // folder-item clicked.... selectedItemIndex = -1; BackItemClicked(); UpdateButtonStates(); - } } @@ -1269,9 +1320,6 @@ UpdateButtonStates(); } - - - protected void OnInfo() { @@ -1300,11 +1348,9 @@ { try { - for (int i = 0; i < facadeView.Count; ++i) { GUIListItem item = facadeView[i]; - ViewHandler.SetLabel(item.MusicTag as FileItem, ref item); } } Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj 2007-07-24 20:20:46 UTC (rev 758) @@ -143,7 +143,6 @@ <Compile Include="Items\ApplicationItemFactory.cs" /> <Compile Include="Items\ApplicationItemGameBase.cs" /> <Compile Include="Items\ApplicationItemGrouper.cs" /> - <Compile Include="Items\ApplicationItemList.cs" /> <Compile Include="Items\ApplicationItemMame.cs" /> <Compile Include="Items\BaseItem.cs" /> <Compile Include="Items\FileItem.cs" /> Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItem.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -336,6 +336,16 @@ + protected void LaunchFilelink(FilelinkItem curLink, bool MPGUIMode) + { + /*ApplicationItem targetApp = GetAppByID(curLink.TargetAppID); + if (targetApp != null) + { + targetApp.LaunchFile(curLink, MPGUIMode); + }*/ + } + + protected void SendRefreshInfo(string informationMessage, int progressBarCtr) { if (OnRefreshInfo != null) @@ -496,10 +506,6 @@ } } - protected virtual void LaunchFilelink(FilelinkItem curLink, bool MPGUIMode) - { - this.OnLaunchFilelink(curLink, MPGUIMode); - } void proc_Exited(object sender, EventArgs e) { Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemFactory.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemFactory.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemFactory.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -26,6 +26,7 @@ using SQLite.NET; using System; using GUIPrograms; +using GUIPrograms.Database; namespace GUIPrograms.Items { @@ -46,54 +47,54 @@ // nothing to create...... } - public BaseItem GetApplicationItem(SQLiteClient sqlDB, ItemType sourceType,SQLiteResultSet results, int iRecord) + public BaseItem GetApplicationItem(ItemType sourceType,SQLiteResultSet results, int iRecord) { BaseItem item = null; switch (sourceType) { case ItemType.DIRCACHE: - item = AppItemFactory(sqlDB, results, iRecord,ItemType.DIRCACHE); + item = AppItemFactory(results, iRecord,ItemType.DIRCACHE); break; case ItemType.MAMEDIRECT: - item = AppItemFactory(sqlDB, results, iRecord,ItemType.MAMEDIRECT); + item = AppItemFactory(results, iRecord,ItemType.MAMEDIRECT); break; case ItemType.GROUPER: - item = AppItemFactory(sqlDB, results, iRecord,ItemType.GROUPER); + item = AppItemFactory(results, iRecord,ItemType.GROUPER); break; case ItemType.GAMEBASE: - item = AppItemFactory(sqlDB, results, iRecord,ItemType.GAMEBASE); + item = AppItemFactory(results, iRecord,ItemType.GAMEBASE); break; case ItemType.FILEITEM: - item = FileItemFactory(sqlDB,results, iRecord); + item = FileItemFactory(results, iRecord); break; case ItemType.FILELINKITEM: - item = FilelinkItemFactory(sqlDB, results, iRecord); + item = FilelinkItemFactory(results, iRecord); break; case ItemType.FILTERITEM: - item = FilterItemFactory(sqlDB, results, iRecord); + item = FilterItemFactory(results, iRecord); break; } return item; } - private ApplicationItem AppItemFactory(SQLiteClient sqldb, SQLiteResultSet results, int recordIndex, ItemType sourceType) + private ApplicationItem AppItemFactory(SQLiteResultSet results, int recordIndex, ItemType sourceType) { ApplicationItem item = null;//= (ApplicationItem)appFactory.GetApplicationItem(sqlDB, ProgramUtils.GetSourceType(results, recordIndex, "applicationItemType"), null, 0); switch (sourceType) { case ItemType.DIRCACHE: - item = new ApplicationItemDirectoryCache(sqldb); + item = new ApplicationItemDirectoryCache(DatabaseHandler.sqlDB); break; case ItemType.MAMEDIRECT: - item = new ApplicationItemMame(sqldb); + item = new ApplicationItemMame(DatabaseHandler.sqlDB); break; case ItemType.GROUPER: - item = new ApplicationItemGrouper(sqldb); + item = new ApplicationItemGrouper(DatabaseHandler.sqlDB); break; case ItemType.GAMEBASE: - item = new ApplicationItemGameBase(sqldb); + item = new ApplicationItemGameBase(DatabaseHandler.sqlDB); break; } @@ -127,9 +128,9 @@ return item; } - private FileItem FileItemFactory(SQLiteClient sqlDB,SQLiteResultSet results, int iRecord) + private FileItem FileItemFactory(SQLiteResultSet results, int iRecord) { - FileItem newFile = new FileItem(sqlDB); + FileItem newFile = new FileItem(DatabaseHandler.sqlDB); newFile.FileID = ProgramUtils.GetIntDef(results, iRecord, "fileid", -1); newFile.AppID = ProgramUtils.GetIntDef(results, iRecord, "applicationId", -1); newFile.Title = ProgramUtils.Get(results, iRecord, "title"); @@ -154,9 +155,9 @@ return newFile; } - private FilterItem FilterItemFactory(SQLiteClient sqlDB,SQLiteResultSet results, int iRecord) + private FilterItem FilterItemFactory(SQLiteResultSet results, int iRecord) { - FilterItem filterItem = new FilterItem(sqlDB); + FilterItem filterItem = new FilterItem(DatabaseHandler.sqlDB); filterItem.Title = ProgramUtils.Get(results, iRecord, "title"); // newFile.LastTimeLaunched = ProgramUtils.GetDateDef(results, iRecord, "lastTimeLaunched", DateTime.MinValue); //newFile.LaunchCount = ProgramUtils.GetIntDef(results, iRecord, "launchcount", 0); ; @@ -164,9 +165,9 @@ } - private FilelinkItem FilelinkItemFactory(SQLiteClient sqlDB, SQLiteResultSet results, int iRecord) + private FilelinkItem FilelinkItemFactory( SQLiteResultSet results, int iRecord) { - FilelinkItem newLink = new FilelinkItem(sqlDB); + FilelinkItem newLink = new FilelinkItem(DatabaseHandler.sqlDB); newLink.FileID = ProgramUtils.GetIntDef(results, iRecord, "fileId", -1); newLink.AppID = ProgramUtils.GetIntDef(results, iRecord, "grouperAppId", -1); newLink.TargetAppID = ProgramUtils.GetIntDef(results, iRecord, "targetAppId", -1); Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemGrouper.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemGrouper.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemGrouper.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -143,13 +143,13 @@ { if (ViewHandler.IsFilterQuery) { - FilterItem curFile = (FilterItem)ApplicationItemFactory.AppFactory.GetApplicationItem(sqlDB, ItemType.FILTERITEM, results, curRow); + FilterItem curFile = (FilterItem)ApplicationItemFactory.AppFactory.GetApplicationItem( ItemType.FILTERITEM, results, curRow); ItemList.Add(curFile); } else { - FilelinkItem curFile = (FilelinkItem)ApplicationItemFactory.AppFactory.GetApplicationItem(sqlDB, ItemType.FILELINKITEM, results, curRow); + FilelinkItem curFile = (FilelinkItem)ApplicationItemFactory.AppFactory.GetApplicationItem( ItemType.FILELINKITEM, results, curRow); ItemList.Add(curFile); } } Deleted: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemList.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemList.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemList.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -1,149 +0,0 @@ -#region Copyright (C) 2005-2007 Team MediaPortal - -/* - * Copyright (C) 2005-2007 Team MediaPortal - * http://www.team-mediaportal.com - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#endregion - -using System.Collections.Generic; -using SQLite.NET; - -using GUIPrograms; -using GUIPrograms.Database; -using GUIPrograms.Items; - -using MediaPortal.GUI.Library; - -namespace GUIPrograms.Items -{ - /// <summary> - /// Summary description for ApplicationItemList. - /// </summary> - public class ApplicationItemList : List<ApplicationItem> - { - public static SQLiteClient sqlDB = null; - - static ApplicationItemFactory appFactory = ApplicationItemFactory.AppFactory; - - static public event ApplicationItem.FilelinkLaunchEventHandler OnLaunchFilelink = null; - - public ApplicationItemList(SQLiteClient initSqlDB, ApplicationItem.FilelinkLaunchEventHandler curHandler) - { - // constructor: save SQLiteDB object and load list from DB - sqlDB = initSqlDB; - OnLaunchFilelink += curHandler; - LoadAll(); - } - - public List<ApplicationItem> AppsOfFatherID(int FatherID) - { - List<ApplicationItem> applicationItemList = new List<ApplicationItem>(); - foreach (ApplicationItem curApp in this) - { - if (curApp.FatherID == FatherID) - { - applicationItemList.Add(curApp); - } - } - return applicationItemList; - } - - public List<ApplicationItem> AppsOfFather(ApplicationItem father) - { - if (father == null) - { - return AppsOfFatherID(-1); // return children of root node! - } - else - { - return AppsOfFatherID(father.AppID); - } - } - - - public ApplicationItem GetAppByID(int targetAppID) - { - foreach (ApplicationItem curApp in this) - { - if (curApp.AppID == targetAppID) - { - return curApp; - } - } - return null; - } - - public ApplicationItem CloneAppItem(ApplicationItem sourceApp) - { - ApplicationItem newApp = (ApplicationItem)appFactory.GetApplicationItem(sqlDB, sourceApp.SourceType,null,0); - newApp.Assign(sourceApp); - newApp.AppID = -1; // to force a sql INSERT when written - Add(newApp); - return newApp; - } - - - static void LaunchFilelink(FilelinkItem curLink, bool mpGuiMode) - { - OnLaunchFilelink(curLink, mpGuiMode); - } - - - public int GetMaxPosition(int fatherID) - { - int res = 0; - foreach (ApplicationItem curApp in this) - { - if ((curApp.FatherID == fatherID) && (curApp.Position > res)) - { - res = curApp.Position; - } - } - return res; - } - - public void LoadAll() - { - if (sqlDB == null) - return; - try - { - Clear(); - if (null == sqlDB) - return; - SQLiteResultSet results; - results = sqlDB.Execute("select * from tblApplicationItem order by iposition"); - if (results.Rows.Count == 0) - return; - for (int row = 0; row < results.Rows.Count; row++) - { - ApplicationItem currentApplicationItem = (ApplicationItem) ApplicationItemFactory.AppFactory.GetApplicationItem(sqlDB,ProgramUtils.GetSourceType(results, row, "applicationItemType"),results, row ); - currentApplicationItem.OnLaunchFilelink += new ApplicationItem.FilelinkLaunchEventHandler(LaunchFilelink); - Add(currentApplicationItem); - } - } - catch (SQLiteException ex) - { - Log.Info("programdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); - } - } - } -} Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemMame.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemMame.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/ApplicationItemMame.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -64,7 +64,12 @@ set { importOriginalsOnly = value; } } + public override string CurrentFilePath() + { + return this.FileDirectory; + } + override public bool ProfileLoadingAllowed() { return true; Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/BaseItem.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/BaseItem.cs 2007-07-24 14:24:00 UTC (rev 757) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Items/BaseItem.cs 2007-07-24 20:20:46 UTC (rev 758) @@ -138,12 +138,12 @@ { if (ViewHandler.IsFilterQuery) { - FilterItem curFile = (FilterItem)ApplicationItemFactory.AppFactory.GetApplicationItem(sqlDB, ItemType.FILTERITEM, results, curRow); + FilterItem curFile = (FilterItem)ApplicationItemFactory.AppFactory.GetApplicationItem(ItemType.FILTERITEM, results, curRow); ItemList.Add(curFile); } else { - FileItem curFile =(FileItem) ApplicationItemFactory.AppFactory.GetApplicationItem(sqlDB,ItemType.FILEITEM,results, curRow); + FileItem curFile =(FileItem) ApplicationItemFactory.AppFactory.GetApplicationItem(ItemType.FILEITEM,results, curRow); ItemList.Add(curFile); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |