From: <hap...@us...> - 2007-04-02 21:54:51
|
Revision: 283 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=283&view=rev Author: happytalk Date: 2007-04-02 14:54:43 -0700 (Mon, 02 Apr 2007) Log Message: ----------- Fixed so esc from search goes back to no selection. Modified NewString Left/Right/Mid Modified Paths: -------------- trunk/plugins/MyFilms/CString.cs trunk/plugins/MyFilms/MesFilms.cs Modified: trunk/plugins/MyFilms/CString.cs =================================================================== --- trunk/plugins/MyFilms/CString.cs 2007-04-02 21:33:01 UTC (rev 282) +++ trunk/plugins/MyFilms/CString.cs 2007-04-02 21:54:43 UTC (rev 283) @@ -47,11 +47,11 @@ /// <summary>Return left hand part of a string</summary> /// <param name="source">string to split</param> /// <param name="length">Number of characters to return</param> - /// <returns>Returns left part of the string OR complete original string if length less than 1</returns> + /// <returns>Returns left part of the string OR complete original string if length less than 1 or greater than string length</returns> public static string Left(string source, int length) { if( source == null ) throw new ArgumentNullException("source"); - if (length > 0) + if (length > 0 && length < source.Length) return source.Substring(0, length); else return source; @@ -62,12 +62,10 @@ /// <summary>Returns right part of a string</summary> /// <param name="source">string to split</param> /// <param name="length">Number of characters to return</param> - /// <returns>Returns right part of the string OR complete original string if length less than 1</returns> + /// <returns>Returns right part of the string OR complete original string if length less than 1 or greater than string length</returns> public static string Right(string source, int length) { - if (source == null) throw new ArgumentNullException("source"); - - if (length > 0) + if (length > 0 && length < source.Length) return source.Substring(source.Length - length); else return source; @@ -81,8 +79,7 @@ /// <returns>Returns right part of the string</returns> public static string Mid(string source, int index) { - if (source == null) throw new ArgumentNullException("source"); - return source.Substring(index); + return Mid(source, index, 0); } @@ -91,12 +88,19 @@ /// <summary>Returns middle part of a string</summary> /// <param name="source">string to split</param> /// <param name="index">Position in string to start extract</param> - /// <param name="length">Number of characters to extract</param> + /// <param name="length">Number of characters to extract. If 0 extract all to end</param> /// <returns>Returns middle part of string</returns> public static string Mid(string source, int index, int length) { if (source == null) throw new ArgumentNullException("source"); - return source.Substring(index, length); + if (index >= 0 && index < source.Length) + { + if (length == 0) length = source.Length; + length = Min(length, source.Length - index + 1); + return source.Substring(index, length); + } + else + return ""; } #endregion Modified: trunk/plugins/MyFilms/MesFilms.cs =================================================================== --- trunk/plugins/MyFilms/MesFilms.cs 2007-04-02 21:33:01 UTC (rev 282) +++ trunk/plugins/MyFilms/MesFilms.cs 2007-04-02 21:54:43 UTC (rev 283) @@ -519,17 +519,10 @@ string SelItem; if (StrTitleSelect == "") { - string WStrTxtSelect =""; - try - { - WStrTxtSelect = StrTxtSelect.Substring(0, 9); - } - catch - { } - if (WStrTxtSelect == "Selection") + if (NewString.Left(StrTxtSelect, 9) == "Selection" || (StrTxtSelect == "" && boolselect)) //original code block refactored {//jump back to main full list boolselect = false; - StrTxtSelect = ""; + StrSelect = StrTxtSelect = ""; l_index = 0; GetFilmList(); return true; @@ -537,18 +530,7 @@ if (StrTxtSelect == "") { - if (boolselect) - {//jump back to main full list - boolselect = false; - StrTxtSelect = ""; - l_index = 0; - GetFilmList(); - } - else - { - StrTxtSelect = ""; - return false; - } + return false; } else { // Jump back to prev view_display (categorised by year, genre etc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |