From: <che...@us...> - 2007-06-16 00:09:54
|
Revision: 557 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=557&view=rev Author: chef_koch Date: 2007-06-15 17:09:51 -0700 (Fri, 15 Jun 2007) Log Message: ----------- no code content changes, only ordered the code and added regions Modified Paths: -------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ApplicationItems/ApplicationItem.cs Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ApplicationItems/ApplicationItem.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ApplicationItems/ApplicationItem.cs 2007-06-15 23:36:24 UTC (rev 556) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ApplicationItems/ApplicationItem.cs 2007-06-16 00:09:51 UTC (rev 557) @@ -40,29 +40,42 @@ namespace GUIPrograms.ApplicationItems { - /// <summary> - /// Summary description for Application. - /// </summary> public class ApplicationItem { + #region Variables + protected static SQLiteClient sqlDB = null; - private DatabaseSorter dbPc = new DatabaseSorter(); - public delegate void FilelinkLaunchEventHandler(FilelinkItem curLink, bool mpGuiMode); - - public event FilelinkLaunchEventHandler OnLaunchFilelink = null; - int appID; int fatherID; string title; string shortTitle; string filename; + string arguments; ProcessWindowStyle windowStyle; - Process proc; string startupDir; - bool useShellExecute; bool useQuotes; + bool useShellExecute; + bool waitForExit; + string preLaunch; + string postLaunch; + + bool enabled; + bool enableGUIRefresh; + int appPosition; + + public bool filesAreLoaded = false; // load on demand.... + protected FileItemList fileList = null; + public bool linksAreLoaded = false; // load on demand.... + protected FilelinkItemList fileLinks = null; + + bool importMamePlaychoice10 = false; + bool importMameMahjong = false; + + + // more variables, maybe need some renaming or anything else + Process proc; ApplicationType sourceType; string sourceFile; string imageFile; @@ -71,24 +84,142 @@ string fileDirectory; string validExtensions; bool importValidImagesOnly; - int appPosition; - bool enabled; - bool enableGUIRefresh; + int pincode; int contentID; string systemDefault; - bool waitForExit; - string preLaunch; - string postLaunch; - bool importMamePlaychoice10 = false; + string launchErrorMsg; + // two magic image-slideshow counters + int thumbIndex = 0; + int thumbFolderIndex = -1; + + string lastFilepath = ""; // cached path + + private DatabaseSorter dbPc = new DatabaseSorter(); + + #endregion + + #region Properties + // Helper Routines + + public int AppID + { + get { return appID; } + set { appID = value; } + } + public int FatherID + { + get { return fatherID; } + set { fatherID = value; } + } + public string Title + { + get { return title; } + set { title = value; } + } + public string ShortTitle + { + get { return shortTitle; } + set { shortTitle = value; } + } + public string Filename + { + get { return filename; } + set { filename = value; } + } + + public string Arguments + { + get { return arguments; } + set { arguments = value; } + } + public ProcessWindowStyle WindowStyle + { + get { return windowStyle; } + set { windowStyle = value; } + } + public string Startupdir + { + get { return startupDir; } + set { startupDir = value; } + } + public bool UseQuotes + { + get { return useQuotes; } + set { useQuotes = value; } + } + public bool UseShellExecute + { + get { return useShellExecute; } + set { useShellExecute = value; } + } + public bool WaitForExit + { + get { return waitForExit; } + set { waitForExit = value; } + } + public string PreLaunch + { + get { return preLaunch; } + set { preLaunch = value; } + } + public string PostLaunch + { + get { return postLaunch; } + set { postLaunch = value; } + } + + public bool Enabled + { + get { return enabled; } + set { enabled = value; } + } + public bool EnableGUIRefresh + { + get { return enableGUIRefresh; } + set { enableGUIRefresh = value; } + } + public bool GUIRefreshPossible + { + get { return RefreshButtonVisible(); } + } + public int Position + { + get { return appPosition; } + set { appPosition = value; } + } + + public FileItemList Files + { + // load on demand.... + get + { + if (!filesAreLoaded) + { + LoadFiles(); + } + return fileList; + } + } + public FilelinkItemList Filelinks + { + // load on demand.... + get + { + if (!linksAreLoaded) + { + LoadFileLinks(); + } + return fileLinks; + } + } + public bool ImportMamePlaychoice10 { get { return importMamePlaychoice10; } set { importMamePlaychoice10 = value; } } - bool importMameMahjong = false; - public bool ImportMameMahjong { get { return importMameMahjong; } @@ -96,35 +227,102 @@ } - string launchErrorMsg; + // more Properties, maybe need some renaming or anything else + public string FileDirectory + { + 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++) + { + imageDirs[i] = imageDirs[i].Trim(); + // hack the \n away.... + // imageDirs[i] = imageDirs[i].TrimStart('\n'); + // hack trailing backslashes away + imageDirs[i] = imageDirs[i].TrimEnd('\\'); + } + } + public string Imagefile + { + get { return imageFile; } + set { imageFile = value; } + } + public string Source + { + get { return sourceFile; } + set { sourceFile = value; } + } + public ApplicationType SourceType + { + get { return sourceType; } + set { sourceType = value; } + } + public string ValidExtensions + { + get { return validExtensions; } + set { validExtensions = value; } + } + public bool ImportValidImagesOnly + { + get { return importValidImagesOnly; } + set { importValidImagesOnly = value; } + } + public int ContentID + { + get { return contentID; } + set { contentID = value; } + } + public string SystemDefault + { + get { return systemDefault; } + set { systemDefault = value; } + } + public string LaunchErrorMsg + { + get { return launchErrorMsg; } + set { launchErrorMsg = value; } + } - // two magic image-slideshow counters - int thumbIndex = 0; - int thumbFolderIndex = -1; - string lastFilepath = ""; // cached path + public SQLiteClient db + { + get { return sqlDB; } + } + public int CurrentSortIndex + { + get { return GetCurrentSortIndex(); } + set { SetCurrentSortIndex(value); } + } + public bool CurrentSortIsAscending + { + get { return GetCurrentSortIsAscending(); } + set { SetCurrentSortIsAscending(value); } + } - public bool filesAreLoaded = false; // load on demand.... - protected FileItemList fileList = null; + #endregion - public bool linksAreLoaded = false; - protected FilelinkItemList fileLinks = null; + #region Events + public delegate void FilelinkLaunchEventHandler(FilelinkItem curLink, bool mpGuiMode); + public event FilelinkLaunchEventHandler OnLaunchFilelink = null; + // event: read new file public delegate void RefreshInfoEventHandler(string informationMessage, int progressBarProgess); - public event RefreshInfoEventHandler OnRefreshInfo = null; - protected void SendRefreshInfo(string informationMessage, int progressBarCtr) - { - if (OnRefreshInfo != null) - { - OnRefreshInfo(informationMessage, progressBarCtr); - } - } + #endregion - protected int GetID = ProgramUtils.GetID; + #region Constructor public ApplicationItem(SQLiteClient initSqlDB) { @@ -162,24 +360,22 @@ } - public SQLiteClient db - { - get { return sqlDB; } - } + #endregion - public int CurrentSortIndex - { - get { return GetCurrentSortIndex(); } - set { SetCurrentSortIndex(value); } - } - public bool CurrentSortIsAscending + + + protected void SendRefreshInfo(string informationMessage, int progressBarCtr) { - get { return GetCurrentSortIsAscending(); } - set { SetCurrentSortIsAscending(value); } + if (OnRefreshInfo != null) + { + OnRefreshInfo(informationMessage, progressBarCtr); + } } + protected int GetID = ProgramUtils.GetID; + public FileItem PrevFile(FileItem curFile) { if (Files == null) @@ -214,7 +410,23 @@ return (FileItem)Files[index]; } + public virtual void LaunchFile(GUIListItem item) + { + // Launch File by GUILISTITEM + // => look for FileItem and launch it using the found object + if (item.MusicTag == null) + { + return; + } + FileItem curFile = (FileItem)item.MusicTag; + if (curFile == null) + { + return; + } + this.LaunchFile(curFile, true); + } + public virtual void LaunchFile(FileItem curFile, bool mpGuiMode) { string curFilename = curFile.Filename; @@ -345,6 +557,16 @@ } } + protected virtual void LaunchFilelink(FilelinkItem curLink, bool MPGUIMode) + { + this.OnLaunchFilelink(curLink, MPGUIMode); + } + + + + + + void proc_Exited(object sender, EventArgs e) { @@ -419,28 +641,6 @@ } } - public virtual void LaunchFile(GUIListItem item) - { - // Launch File by GUILISTITEM - // => look for FileItem and launch it using the found object - if (item.MusicTag == null) - { - return; - } - FileItem curFile = (FileItem)item.MusicTag; - - if (curFile == null) - { - return; - } - this.LaunchFile(curFile, true); - } - - protected virtual void LaunchFilelink(FilelinkItem curLink, bool MPGUIMode) - { - this.OnLaunchFilelink(curLink, MPGUIMode); - } - public virtual string DefaultFilepath() { return ""; // override this if the appitem can have subfolders @@ -496,7 +696,6 @@ return totalItems; } - void OnRetrieveCoverArt(GUIListItem gli) { if ((gli.MusicTag != null) && (gli.MusicTag is FileItem)) @@ -544,6 +743,31 @@ } } + public virtual void OnInfo(GUIListItem item, ref bool isOverviewVisible, ref ProgramInfoAction modalResult, ref int selectedFileID) + { + GUIFileInfo fileInfoDialog = (GUIFileInfo)GUIWindowManager.GetWindow(ProgramUtils.ProgramInfoID); + if (null != fileInfoDialog) + { + if (item.MusicTag == null) + { + return; + } + FileItem curFile = (FileItem)item.MusicTag; + fileInfoDialog.App = this; + fileInfoDialog.File = curFile; + fileInfoDialog.IsOverviewVisible = isOverviewVisible; + fileInfoDialog.DoModal(GetID); + isOverviewVisible = fileInfoDialog.IsOverviewVisible; + modalResult = fileInfoDialog.ModalResult; + selectedFileID = fileInfoDialog.SelectedFileID; + return; + } + } + + + + #region old sorting stuff, some(all) might be obsolete, but maybe usefull for improving new sorting method + public virtual void OnSort(GUIFacadeControl view, bool doSwitchState) { /* @@ -591,6 +815,10 @@ dbPc.sortAscending = newValue; } + #endregion + + + public virtual bool RefreshButtonVisible() { return false; // otherwise, override this in child class @@ -634,232 +862,8 @@ } - public virtual void OnInfo(GUIListItem item, ref bool isOverviewVisible, ref ProgramInfoAction modalResult, ref int selectedFileID) - { - GUIFileInfo fileInfoDialog = (GUIFileInfo)GUIWindowManager.GetWindow(ProgramUtils.ProgramInfoID); - if (null != fileInfoDialog) - { - if (item.MusicTag == null) - { - return; - } - FileItem curFile = (FileItem)item.MusicTag; - fileInfoDialog.App = this; - fileInfoDialog.File = curFile; - fileInfoDialog.IsOverviewVisible = isOverviewVisible; - fileInfoDialog.DoModal(GetID); - isOverviewVisible = fileInfoDialog.IsOverviewVisible; - modalResult = fileInfoDialog.ModalResult; - selectedFileID = fileInfoDialog.SelectedFileID; - return; - } - } + #region DB stuff - public int AppID - { - get { return appID; } - set { appID = value; } - } - - public int FatherID - { - get { return fatherID; } - set { fatherID = value; } - } - - public string Title - { - get { return title; } - set { title = value; } - } - - public string ShortTitle - { - get { return shortTitle; } - set { shortTitle = value; } - } - - public string Filename - { - get { return filename; } - set { filename = value; } - } - - public string Arguments - { - get { return arguments; } - set { arguments = value; } - } - - public bool UseQuotes - { - get { return useQuotes; } - set { useQuotes = value; } - } - - public bool UseShellExecute - { - get { return useShellExecute; } - set { useShellExecute = value; } - } - - public bool Enabled - { - get { return enabled; } - set { enabled = value; } - } - - public ProcessWindowStyle WindowStyle - { - get { return windowStyle; } - set { windowStyle = value; } - } - - public string Startupdir - { - get { return startupDir; } - set { startupDir = value; } - } - - public string FileDirectory - { - 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++) - { - imageDirs[i] = imageDirs[i].Trim(); - // hack the \n away.... - // imageDirs[i] = imageDirs[i].TrimStart('\n'); - // hack trailing backslashes away - imageDirs[i] = imageDirs[i].TrimEnd('\\'); - } - } - - public string Imagefile - { - get { return imageFile; } - set { imageFile = value; } - } - - public string Source - { - get { return sourceFile; } - set { sourceFile = value; } - } - - public ApplicationType SourceType - { - get { return sourceType; } - set { sourceType = value; } - } - - public string ValidExtensions - { - get { return validExtensions; } - set { validExtensions = value; } - } - - public bool ImportValidImagesOnly - { - get { return importValidImagesOnly; } - set { importValidImagesOnly = value; } - } - - public int Position - { - get { return appPosition; } - set { appPosition = value; } - } - - public int ContentID - { - get { return contentID; } - set { contentID = value; } - } - - public string SystemDefault - { - get { return systemDefault; } - set { systemDefault = value; } - } - - public bool WaitForExit - { - get { return waitForExit; } - set { waitForExit = value; } - } - - - public bool GUIRefreshPossible - { - get { return RefreshButtonVisible(); } - } - - public bool EnableGUIRefresh - { - get { return enableGUIRefresh; } - set { enableGUIRefresh = value; } - } - - public string LaunchErrorMsg - { - get { return launchErrorMsg; } - set { launchErrorMsg = value; } - } - - public string PreLaunch - { - get { return preLaunch; } - set { preLaunch = value; } - } - - public string PostLaunch - { - get { return postLaunch; } - set { postLaunch = value; } - } - - - public FileItemList Files - { - // load on demand.... - get - { - if (!filesAreLoaded) - { - LoadFiles(); - } - return fileList; - } - } - - - public FilelinkItemList Filelinks - { - // load on demand.... - get - { - if (!linksAreLoaded) - { - LoadFileLinks(); - } - return fileLinks; - } - } - - private int GetNewAppID() { // get an unused SQL application KEY-number @@ -961,8 +965,6 @@ } - - protected void DeleteFiles() { if ((AppID >= 0) && (sqlDB != null)) @@ -993,7 +995,6 @@ } } - public virtual void LoadFiles() { if (sqlDB != null) @@ -1031,6 +1032,20 @@ } } + public void InsertOrUpdateSettings() + { + if (appID == -1) + { + Insert(); + } + else + { + Update(); + } + } + + #endregion + protected virtual void FixFileLinks() { // after a import the appitem has completely new @@ -1074,25 +1089,11 @@ } - - public void InsertOrUpdateSettings() - { - if (appID == -1) - { - Insert(); - } - else - { - Update(); - } - } - public virtual string CurrentFilePath() { return this.FileDirectory; } - public void Assign(ApplicationItem sourceApp) { this.Enabled = sourceApp.Enabled; @@ -1122,9 +1123,8 @@ this.ContentID = sourceApp.ContentID; } + #region imagedirectory stuff - - // imagedirectory stuff // get next imagedirectory that holds at least one image for a fileitem // * m_pFile: the file we're looking images for private void GetNextThumbFolderIndex(FileItem fileItem) @@ -1178,7 +1178,6 @@ } } - public string GetCurThumb(FileItem fileItem) { string curThumb = ""; @@ -1226,6 +1225,7 @@ thumbIndex++; } + #endregion public void LoadFromXmlProfile(XmlNode node) { @@ -1278,6 +1278,5 @@ this.ValidExtensions = fileExtensioneNode.InnerText; } } - } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |