From: <che...@us...> - 2007-06-17 11:03:10
|
Revision: 564 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=564&view=rev Author: chef_koch Date: 2007-06-17 04:03:06 -0700 (Sun, 17 Jun 2007) Log Message: ----------- code cleanup of LaunchFile() 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-17 10:51:25 UTC (rev 563) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ApplicationItems/ApplicationItem.cs 2007-06-17 11:03:06 UTC (rev 564) @@ -425,83 +425,61 @@ public virtual void LaunchFile(FileItem curFileItem, bool mpGuiMode) { string curFilename = curFileItem.Filename; - if (curFilename == "") - { - return; - } + if (curFilename == "") return; // Launch File by item if (mpGuiMode) - { curFileItem.UpdateLaunchInfo(); - } + ProcessStartInfo procStart = new ProcessStartInfo(); - if (Filename != "") - { - // use the APPLICATION launcher and add current file information - procStart.FileName = Filename; // filename of the application - // set the arguments: one of the arguments is the fileitem-filename - procStart.Arguments = " " + this.Arguments + " "; + if (this.Filename != "") + { // use the APPLICATION launcher and add current file information + + // filename of the application + procStart.FileName = this.Filename; + + // avoid double quotes around the filename-argument..... if (UseQuotes) - { - // avoid double quotes around the filename-argument..... curFilename = "\"" + (curFileItem.Filename.TrimStart('\"')).TrimEnd('\"') + "\""; - } - if (procStart.Arguments.IndexOf("%FILEnoPATHnoEXT%") >= 0) - { + // set the arguments: one of the arguments is the fileitem-filename + if (this.Arguments.Contains("%FILEnoPATHnoEXT%")) // ex. kawaks: // winkawaks.exe alpham2 // => filename without path and extension is necessary! - string filenameNoPathNoExt = curFileItem.ExtractFileName(); - filenameNoPathNoExt = (filenameNoPathNoExt.TrimStart('\"')).TrimEnd('\"'); - filenameNoPathNoExt = Path.GetFileNameWithoutExtension(filenameNoPathNoExt); - procStart.Arguments = procStart.Arguments.Replace("%FILEnoPATHnoEXT%", filenameNoPathNoExt); - } + procStart.Arguments = " " + this.Arguments.Replace("%FILEnoPATHnoEXT%", Path.GetFileNameWithoutExtension(curFileItem.Filename)); + else if (this.Arguments.Contains("%FILE%")) + // placeholder found => replace the placeholder by the correct filename + procStart.Arguments = " " + this.Arguments.Replace("%FILE%", curFilename); else - { - // the fileitem-argument can be positioned anywhere in the argument string... - if (procStart.Arguments.IndexOf("%FILE%") == -1) - { - // no placeholder found => default handling: add the fileitem as the last argument - procStart.Arguments = procStart.Arguments + curFilename; - } - else - { - // placeholder found => replace the placeholder by the correct filename - procStart.Arguments = procStart.Arguments.Replace("%FILE%", curFilename); - } - } - procStart.WorkingDirectory = StartupDir; - if (procStart.WorkingDirectory.IndexOf("%FILEDIR%") != -1) - { - procStart.WorkingDirectory = procStart.WorkingDirectory.Replace("%FILEDIR%", Path.GetDirectoryName(curFileItem.Filename)); - } - procStart.UseShellExecute = UseShellExecute; + // no placeholder found => default handling: add the fileitem as the last argument + procStart.Arguments = " " + this.Arguments + " " + curFilename; + + // set WorkingDirectory + if (this.StartupDir.Contains("%FILEDIR%")) + procStart.WorkingDirectory = this.StartupDir.Replace("%FILEDIR%", Path.GetDirectoryName(curFileItem.Filename)); + else + procStart.WorkingDirectory = this.StartupDir; } else { // application has no launch-file // => try to make a correct launch using the current FILE object procStart.FileName = curFileItem.Filename; - procStart.WorkingDirectory = Path.GetFullPath(curFileItem.Filename); - - if (StartupDir != "") - { - if (StartupDir.Contains("%FILEDIR%")) - { - procStart.WorkingDirectory = procStart.WorkingDirectory.Replace("%FILEDIR%", Path.GetDirectoryName(curFileItem.Filename)); - } - else - { - procStart.WorkingDirectory = StartupDir; - } - } - - procStart.UseShellExecute = UseShellExecute; + // set WorkingDirectory + if (this.StartupDir == "") + procStart.WorkingDirectory = Path.GetDirectoryName(curFileItem.Filename); + else if (this.StartupDir.Contains("%FILEDIR%")) + procStart.WorkingDirectory = this.StartupDir.Replace("%FILEDIR%", Path.GetDirectoryName(curFileItem.Filename)); + else + procStart.WorkingDirectory = this.StartupDir; } + + // set UseShellExecute + procStart.UseShellExecute = this.UseShellExecute; + // set WindowStyle procStart.WindowStyle = this.WindowStyle; this.LaunchErrorMsg = ""; @@ -509,14 +487,11 @@ { DoPreLaunch(); - if (mpGuiMode) { AutoPlay.StopListening(); if (g_Player.Playing) - { g_Player.Stop(); - } } proc = new Process(); @@ -524,15 +499,13 @@ proc.Exited += new EventHandler(proc_Exited); proc.StartInfo = procStart; - ProgramUtils.StartProcess(proc, WaitForExit); + ProgramUtils.StartProcess(proc, this.WaitForExit); - if (mpGuiMode) { //GUIGraphicsContext.DX9Device.Reset(GUIGraphicsContext.DX9Device.PresentationParameters); AutoPlay.StartListening(); } - } catch (Exception ex) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |