From: <nor...@us...> - 2007-07-07 21:11:01
|
Revision: 676 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=676&view=rev Author: northern_sky Date: 2007-07-07 14:10:58 -0700 (Sat, 07 Jul 2007) Log Message: ----------- merged programsort, added base for sorting. Modified Paths: -------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ApplicationItems/ApplicationItem.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/ProgramViews.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramSort.cs Added Paths: ----------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/skin/ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/skin/BlueTwo/ Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ApplicationItems/ApplicationItem.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ApplicationItems/ApplicationItem.cs 2007-07-06 05:03:26 UTC (rev 675) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ApplicationItems/ApplicationItem.cs 2007-07-07 21:10:58 UTC (rev 676) @@ -40,6 +40,7 @@ using GUIPrograms.Database; using GUIPrograms.FileItems; + namespace GUIPrograms.ApplicationItems { public class ApplicationItem @@ -67,6 +68,7 @@ int appPosition; string currentView = ""; + public bool filesAreLoaded = false; // load on demand.... protected FileItemList fileList = null; public bool linksAreLoaded = false; // load on demand.... @@ -98,7 +100,7 @@ string lastFilepath = ""; // cached path //private DatabaseSorter dbPc = new DatabaseSorter(); - private ProgramSort dbPc = new ProgramSort(ProgramSort.SortMethod.Name, true); + //private ProgramSort dbPc = new ProgramSort(ProgramSort.SortMethod.Name, true); #endregion @@ -213,6 +215,8 @@ get { return currentView; } set { currentView = value; } } + + public FileItemList Files { // load on demand.... @@ -312,16 +316,18 @@ } - public int CurrentSortIndex - { + /* public int CurrentSortIndex + { get { return GetCurrentSortIndex(); } - set { SetCurrentSortIndex(value); } - } - public bool CurrentSortIsAscending - { - get { return GetCurrentSortIsAscending(); } - set { SetCurrentSortIsAscending(value); } - } + set { SetCurrentSortIndex(value); } + + }*/ + /* public bool CurrentSortIsAscending + { + get { return GetCurrentSortIsAscending(); } + set { SetCurrentSortIsAscending(value); } + + } */ #endregion @@ -764,10 +770,10 @@ */ } - public virtual void OnSortToggle(GUIFacadeControl view) + /* public virtual void OnSortToggle(GUIFacadeControl view) { - dbPc.SortAscending = (!dbPc.SortAscending); - view.Sort(dbPc); + // dbPc.SortAscending = (!dbPc.SortAscending); + //view.Sort(dbPc); } public virtual int GetCurrentSortIndex() @@ -794,7 +800,7 @@ { dbPc.SortAscending = newValue; } - + */ #endregion Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/ProgramViews.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/ProgramViews.cs 2007-07-06 05:03:26 UTC (rev 675) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/Design/ProgramViews.cs 2007-07-07 21:10:58 UTC (rev 676) @@ -305,7 +305,7 @@ cbOperators.SelectionChangeCommitted += new EventHandler(ComboBox_SelectionChangeCommitted); //Create the combo box object and set its properties - SyncedComboBox cbView = new SyncedComboBox("ViewAs"); + SyncedComboBox cbView = new SyncedComboBox("ViewLayout"); foreach (string strText in viewsAs) cbView.Items.Add(strText); cbView.Grid = dataGrid; @@ -329,7 +329,7 @@ arrColumnNames[1] = "Operator"; arrColumnNames[2] = "Restriction"; arrColumnNames[3] = "Limit"; - arrColumnNames[4] = "ViewAs"; + arrColumnNames[4] = "ViewLayout"; arrColumnNames[5] = "SortBy"; //Create the Data Table object which will then be used to hold Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs 2007-07-06 05:03:26 UTC (rev 675) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIPrograms.cs 2007-07-07 21:10:58 UTC (rev 676) @@ -94,7 +94,7 @@ } public string Author() { - return "Reconstruct by Northern & chefkoch"; + return "Reconstruct by Northern/Chefkoch"; } public void ShowPlugin() { @@ -140,8 +140,8 @@ [Serializable] public class MapSettings { - protected int sortBy; - protected int viewAs; + protected int sortMethod; + protected int viewLayout; protected bool sortAscending; protected int lastApplicationID; protected int lastFileID; @@ -150,8 +150,8 @@ public MapSettings() { - sortBy = 0; //name - viewAs = 0; //list + sortMethod = 0; //name + viewLayout = 0; //list sortAscending = true; overviewVisible = true; lastApplicationID = -1; @@ -160,18 +160,18 @@ } - [XmlElement("SortBy")] - public int SortBy + [XmlElement("SortMethod")] + public int SortMethod { - get { return sortBy; } - set { sortBy = value; } + get { return sortMethod; } + set { sortMethod = value; } } - [XmlElement("ViewAs")] - public int ViewAs + [XmlElement("ViewLayout")] + public int ViewLayout { - get { return viewAs; } - set { viewAs = value; } + get { return viewLayout; } + set { viewLayout = value; } } [XmlElement("SortAscending")] @@ -210,34 +210,38 @@ } - public string ViewAsText + public string ViewLayoutTextName { - get { return GetViewAsText(); } + get { return GetViewLayoutAsText(); } } - public void SwitchToNextView() + public void SwitchToNextViewLayout() { - switch ((Layout)ViewAs) + switch ((Layout)ViewLayout) { case Layout.List: - ViewAs = (int)Layout.Icons; + ViewLayout = (int)Layout.Icons; + break; case Layout.Icons: - ViewAs = (int)Layout.LargeIcons; + ViewLayout = (int)Layout.LargeIcons; + break; case Layout.LargeIcons: - ViewAs = (int)Layout.FilmStrip; + ViewLayout = (int)Layout.FilmStrip; + break; case Layout.FilmStrip: - ViewAs = (int)Layout.List; + ViewLayout = (int)Layout.List; + break; } } - string GetViewAsText() + string GetViewLayoutAsText() { string result = ""; - switch ((Layout)ViewAs) + switch ((Layout)ViewLayout) { case Layout.List: result = GUILocalizeStrings.Get(101); @@ -261,33 +265,33 @@ { using (Settings xmlwriter = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { - switch ((Layout)mapSettings.ViewAs) + switch ((Layout)mapSettings.ViewLayout) { case Layout.List: - xmlwriter.SetValue("myprograms", "viewby", "list"); + xmlwriter.SetValue("myprograms", "viewLayout", "list"); break; case Layout.Icons: - xmlwriter.SetValue("myprograms", "viewby", "icons"); + xmlwriter.SetValue("myprograms", "viewLayout", "icons"); break; case Layout.LargeIcons: - xmlwriter.SetValue("myprograms", "viewby", "largeicons"); + xmlwriter.SetValue("myprograms", "viewLayout", "largeicons"); break; case Layout.FilmStrip: - xmlwriter.SetValue("myprograms", "viewby", "filmstrip"); + xmlwriter.SetValue("myprograms", "viewLayout", "filmstrip"); break; } xmlwriter.SetValue("myprograms", "lastAppID", mapSettings.LastAppID.ToString()); // xmlwriter.SetValue("myprograms", "lastViewLevel", mapSettings.LastViewLevel.ToString()); xmlwriter.SetValue("myprograms", "lastViewLevel", DatabaseHandler.ViewHandler.CurrentLevel); - xmlwriter.SetValue("myprograms", "sortby", mapSettings.SortBy); + xmlwriter.SetValue("myprograms", "sortMethod", mapSettings.SortMethod); // avoid bool conversion...... don't wanna know why it doesn't work! :-( if (mapSettings.SortAscending) { - xmlwriter.SetValue("myprograms", "sortasc", "yes"); + xmlwriter.SetValue("myprograms", "sortASC", "yes"); } else { - xmlwriter.SetValue("myprograms", "sortasc", "no"); + xmlwriter.SetValue("myprograms", "sortASC", "no"); } if (mapSettings.OverviewVisible) @@ -300,13 +304,14 @@ } xmlwriter.SetValue("myprograms", "startWindow", StartWindow.ToString()); - xmlwriter.SetValue("myprograms", "startview", CurrentView); + xmlwriter.SetValue("myprograms", "startview", (int)CurrentLayout); } } void LoadSettings() { string _slideSpeed = DatabaseHandler.ReadSetting(ProgramUtils.cSLIDESPEED); + if ((_slideSpeed != "") && (_slideSpeed != null)) { slideSpeed = int.Parse(_slideSpeed); @@ -315,26 +320,22 @@ using (Settings xmlreader = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { string curText = ""; - curText = xmlreader.GetValueAsString("myprograms", "viewby", "list"); - if (curText == "list") - mapSettings.ViewAs = (int)Layout.List; - else if (curText == "icons") - mapSettings.ViewAs = (int)Layout.Icons; - else if (curText == "largeicons") - mapSettings.ViewAs = (int)Layout.LargeIcons; - else if (curText == "filmstrip") - mapSettings.ViewAs = (int)Layout.FilmStrip; - else - mapSettings.ViewAs = (int)Layout.List; + curText = xmlreader.GetValueAsString("myprograms", "viewLayout", "list"); + if (curText == "list") mapSettings.ViewLayout = (int)Layout.List; + else if (curText == "icons") mapSettings.ViewLayout = (int)Layout.Icons; + else if (curText == "largeicons") mapSettings.ViewLayout = (int)Layout.LargeIcons; + else if (curText == "filmstrip") mapSettings.ViewLayout = (int)Layout.FilmStrip; + else mapSettings.ViewLayout = (int)Layout.List; + + CurrentSortMethod = (ProgramSort.SortMethod)xmlreader.GetValueAsInt("myprograms", "sortMethod", (int)ProgramSort.SortMethod.Name); + mapSettings.LastAppID = xmlreader.GetValueAsInt("myprograms", "lastAppID", -1); mapSettings.LastViewLevel = xmlreader.GetValueAsInt("myprograms", "lastViewLevel", -1); - mapSettings.SortBy = xmlreader.GetValueAsInt("myprograms", "sortby", 0); - mapSettings.SortAscending = xmlreader.GetValueAsBool("myprograms", "sortasc", true); - mapSettings.OverviewVisible = xmlreader.GetValueAsBool("myprograms", "sortasc", true); + mapSettings.SortAscending = xmlreader.GetValueAsBool("myprograms", "sortASC", true); + mapSettings.OverviewVisible = xmlreader.GetValueAsBool("myprograms", "sortASC", true); StartWindow = xmlreader.GetValueAsInt("myprograms", "startWindow", GetID); - CurrentView = xmlreader.GetValueAsString("myprograms", "startview", String.Empty); } } @@ -345,8 +346,8 @@ { mapSettings.LastAppID = xmlreader.GetValueAsInt("myprograms", "lastAppID", -1); mapSettings.LastViewLevel = xmlreader.GetValueAsInt("myprograms", "lastViewLevel", -1); - mapSettings.SortBy = xmlreader.GetValueAsInt("myprograms", "sortby", 0); - mapSettings.SortAscending = xmlreader.GetValueAsBool("myprograms", "sortasc", true); + mapSettings.SortMethod = xmlreader.GetValueAsInt("myprograms", "sortMethod", 0); + mapSettings.SortAscending = xmlreader.GetValueAsBool("myprograms", "sortAsc", true); mapSettings.OverviewVisible = xmlreader.GetValueAsBool("myprograms", "overviewvisible", true); } } @@ -374,7 +375,7 @@ #region SkinControls - enum Layout + public enum Layout { List = 0, Icons = 1, @@ -385,11 +386,12 @@ // Buttons [SkinControl(2)] protected GUIButtonControl btnViewAs = null; - [SkinControl(3)] - protected GUIButtonControl btnRefresh = null; + [SkinControlAttribute(3)] + protected GUISortButtonControl btnSortBy = null; [SkinControl(4)] protected GUIButtonControl btnViews = null; - + [SkinControl(5)] + protected GUIButtonControl btnRefresh = null; //Images [SkinControl(6)] protected GUIImage screenShotImage = null; @@ -411,12 +413,6 @@ skipInit = true; } - ~GUIPrograms() - { - SaveSettings(); - //FolderSettings.DeleteFolderSetting("root", "Programs"); - } - #endregion #region Init / DeInit @@ -450,8 +446,7 @@ if (lastApp != null) { lastFilepath = lastApp.DefaultFilepath(); - lastApp.CurrentSortIndex = mapSettings.SortBy; - lastApp.CurrentSortIsAscending = mapSettings.SortAscending; + this.CurrentSortAsc = mapSettings.SortAscending; DatabaseHandler.ViewHandler.CurrentLevel = mapSettings.LastViewLevel; } else @@ -467,24 +462,25 @@ #region Base & Content Variables + static int startWindow = (int)GUIWindow.Window.WINDOW_FILES; - + protected ProgramSort.SortMethod currentSortMethod = ProgramSort.SortMethod.Name; + string currentView = ""; + bool currentSortAsc = true; + static ApplicationItemList applicationList = DatabaseHandler.ApplicationItemList; MapSettings mapSettings = new MapSettings(); DirectoryHistory itemHistory = new DirectoryHistory(); ApplicationItem lastApp = null; + string lastFilepath = ""; int selectedItemIndex = -1; int slideSpeed = 3000; // speed in milliseconds between two slides long slideTime = 0; + public Layout currentLayout = Layout.List; bool skipInit = false; - static string currentView = ""; - Layout[,] layout; - bool[,] sortasc; - ProgramSort.SortMethod[,] sortby; - static string _thumbnailPath = string.Empty; static string _lastThumbnailPath = string.Empty; @@ -507,129 +503,36 @@ } } + public string CurrentView + { + get { return currentView; } + set { currentView = value; } + } + public int StartWindow { get { return startWindow; } set { startWindow = value; } } - public string CurrentView + public virtual Layout CurrentLayout { - get { return currentView; } - set { currentView = value; } + get { return currentLayout; } + set { currentLayout = value; } } - Layout CurrentLayout - {//maybe we can remove this property, not sure if we would need it - get - { - if (DatabaseHandler.ViewHandler.View == null) - return Layout.List; - - if (layout == null) - { - layout = new Layout[DatabaseHandler.ViewHandler.Views.Count, 50]; - - List<String> viewStrings = new List<String>(); - viewStrings.Add("List"); - viewStrings.Add("Icons"); - viewStrings.Add("Big Icons"); - viewStrings.Add("Filmstrip"); - - for (int i = 0; i < DatabaseHandler.ViewHandler.Views.Count; ++i) - { - for (int j = 0; j < DatabaseHandler.ViewHandler.Views[i].Filters.Count; ++j) - { - FilterDefinition def = (FilterDefinition)DatabaseHandler.ViewHandler.Views[i].Filters[j]; - int defaultView = viewStrings.IndexOf(def.DefaultView); - - if (defaultView != -1) - layout[i, j] = (Layout)defaultView; - else - layout[i, j] = Layout.List; - } - } - } - - return layout[DatabaseHandler.ViewHandler.Views.IndexOf(DatabaseHandler.ViewHandler.View), DatabaseHandler.ViewHandler.CurrentLevel]; - } - set - { - layout[DatabaseHandler.ViewHandler.Views.IndexOf(DatabaseHandler.ViewHandler.View), DatabaseHandler.ViewHandler.CurrentLevel] = value; - } - } - bool CurrentSortAsc { - get - { - if (DatabaseHandler.ViewHandler.View == null) - return true; - - if (sortasc == null) - { - sortasc = new bool[DatabaseHandler.ViewHandler.Views.Count, 50]; - - for (int i = 0; i < DatabaseHandler.ViewHandler.Views.Count; ++i) - { - for (int j = 0; j < DatabaseHandler.ViewHandler.Views[i].Filters.Count; ++j) - { - FilterDefinition def = (FilterDefinition)DatabaseHandler.ViewHandler.Views[i].Filters[j]; - sortasc[i, j] = def.SortAscending; - } - } - } - - return sortasc[DatabaseHandler.ViewHandler.Views.IndexOf(DatabaseHandler.ViewHandler.View), DatabaseHandler.ViewHandler.CurrentLevel]; - } - set - { - sortasc[DatabaseHandler.ViewHandler.Views.IndexOf(DatabaseHandler.ViewHandler.View), DatabaseHandler.ViewHandler.CurrentLevel] = value; - } + get { return currentSortAsc; } + set { currentSortAsc = value; } } - ProgramSort.SortMethod CurrentSortMethod + protected virtual ProgramSort.SortMethod CurrentSortMethod { - get - { - if (DatabaseHandler.ViewHandler.View == null) - return ProgramSort.SortMethod.Name; - - if (sortby == null) - { - sortby = new ProgramSort.SortMethod[DatabaseHandler.ViewHandler.Views.Count, 50]; - - List<String> sortStrings = new List<String>(); - sortStrings.Add("Name"); - sortStrings.Add("Title"); - sortStrings.Add("Filename"); - sortStrings.Add("Rating"); - sortStrings.Add("LaunchCount"); - sortStrings.Add("LastTimeLaunched"); - - for (int i = 0; i < DatabaseHandler.ViewHandler.Views.Count; ++i) - { - for (int j = 0; j < DatabaseHandler.ViewHandler.Views[i].Filters.Count; ++j) - { - FilterDefinition def = (FilterDefinition)DatabaseHandler.ViewHandler.Views[i].Filters[j]; - int defaultSort = sortStrings.IndexOf(def.DefaultSort); - - if (defaultSort != -1) - sortby[i, j] = (ProgramSort.SortMethod)defaultSort; - else - sortby[i, j] = ProgramSort.SortMethod.Name; - } - } - } - - return sortby[DatabaseHandler.ViewHandler.Views.IndexOf(DatabaseHandler.ViewHandler.View), DatabaseHandler.ViewHandler.CurrentLevel]; - } - set - { - sortby[DatabaseHandler.ViewHandler.Views.IndexOf(DatabaseHandler.ViewHandler.View), DatabaseHandler.ViewHandler.CurrentLevel] = value; - } + get { return currentSortMethod; } + set { currentSortMethod = value; } } - + GUIListItem GetSelectedItem() { return facadeView.SelectedListItem; @@ -697,9 +600,13 @@ protected override void OnPageLoad() { - string view = CurrentView; - DatabaseHandler.ViewHandler.CurrentView = view; + //string view = CurrentView; + base.OnPageLoad(); + + if (btnSortBy != null) + btnSortBy.SortChanged += new SortEventHandler(SortChanged); + InitMyPrograms(); } @@ -709,6 +616,14 @@ base.OnPageDestroy(newWindowId); } + void SortChanged(object sender, SortEventArgs args) + { + this.CurrentSortAsc = args.Order != System.Windows.Forms.SortOrder.Descending; + + OnSort(); + UpdateButtonStates(); + } + public override void OnAction(Action action) { switch (action.wID) @@ -717,7 +632,7 @@ case Action.ActionType.ACTION_PREVIOUS_MENU: // <U> keypress BackItemClicked(); - UpdateButtons(); + UpdateButtonStates(); break; case Action.ActionType.ACTION_CLOSE_DIALOG: SaveFolderSettings(""); @@ -757,7 +672,24 @@ base.OnClicked(controlId, control, actionType); if (control == btnViewAs) { - mapSettings.SwitchToNextView(); + mapSettings.SwitchToNextViewLayout(); + + switch (mapSettings.ViewLayout) + { + case (int)Layout.List: + CurrentLayout = Layout.Icons; + break; + case (int)Layout.Icons: + CurrentLayout = Layout.LargeIcons; + break; + case (int)Layout.LargeIcons: + CurrentLayout = Layout.FilmStrip; + break; + case (int)Layout.FilmStrip: + CurrentLayout = Layout.List; + break; + } + ShowThumbPanel(); } @@ -768,7 +700,7 @@ lastApp.Refresh(true); lastFilepath = lastApp.DefaultFilepath(); // todo: reset viewHandler - UpdateButtons(); + UpdateButtonStates(); UpdateListControl(); } } @@ -776,6 +708,11 @@ { OnShowViews(); } + else if (control == btnSortBy) + { + OnShowSort(); + } + else if (control == facadeView) { // application or file-item was clicked.... @@ -858,12 +795,16 @@ #region Display - void UpdateButtons() + protected virtual void UpdateButtonStates() { + string sortBy = string.Empty; + GUIPropertyManager.SetProperty("#view", DatabaseHandler.ViewHandler.LocalizedCurrentView); - btnViewAs.Label = mapSettings.ViewAsText; btnRefresh.IsVisible = RefreshButtonVisible(); + facadeView.IsVisible = true; + GUIControl.FocusControl(GetID, facadeView.GetID); + // display apptitle if available..... if (lastApp != null) { @@ -888,13 +829,43 @@ GUIPropertyManager.SetProperty("#curheader", GUILocalizeStrings.Get(0)); } } + + btnViewAs.Label = mapSettings.ViewLayoutTextName; + + switch (CurrentSortMethod) + { + case ProgramSort.SortMethod.Name: + sortBy = GUILocalizeStrings.Get(103); + break; + case ProgramSort.SortMethod.Title: + sortBy = GUILocalizeStrings.Get(268); + break; + case ProgramSort.SortMethod.Filename: + sortBy = GUILocalizeStrings.Get(363); + break; + case ProgramSort.SortMethod.Rating: + sortBy = GUILocalizeStrings.Get(367); + break; + case ProgramSort.SortMethod.LastTimeLaunched: //tmp + sortBy = GUILocalizeStrings.Get(31); + break; + case ProgramSort.SortMethod.LaunchCount: + sortBy = GUILocalizeStrings.Get(30); //tmp + break; + } + + if (btnSortBy != null) + { + btnSortBy.Label = sortBy; + btnSortBy.IsAscending = CurrentSortAsc; + } } void ShowThumbPanel() { int itemIndex = facadeView.SelectedListItemIndex; - switch ((Layout)mapSettings.ViewAs) + switch ((Layout)mapSettings.ViewLayout) { case Layout.List: facadeView.View = GUIFacadeControl.ViewMode.List; @@ -915,7 +886,7 @@ } facadeView.SelectedListItemIndex = itemIndex; - UpdateButtons(); + UpdateButtonStates(); } void RenderThumbnail(float timePassed) @@ -1120,7 +1091,7 @@ } } } - UpdateButtons(); + UpdateButtonStates(); UpdateListControl(); RestoreItemIndex(lastApp, lastFilepath); } @@ -1319,6 +1290,9 @@ } } + + + void OnClick() { GUIListItem item = GetSelectedItem(); @@ -1335,17 +1309,148 @@ if (item.Label.Equals(ProgramUtils.cBackLabel)) { BackItemClicked(); - UpdateButtons(); + UpdateButtonStates(); } else { // application-item or subfolder FolderItemClicked(item); - UpdateButtons(); + UpdateButtonStates(); } } } + protected void OnShowSort() + { + GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); + if (dlg == null) + return; + dlg.Reset(); + dlg.SetHeading(495); + + dlg.AddLocalizedString(103); // name + dlg.AddLocalizedString(268); // title + dlg.AddLocalizedString(363); // filename + dlg.AddLocalizedString(367); // rating + dlg.AddLocalizedString(30);//"LaunchCount"//whats the maopping to these??? + dlg.AddLocalizedString(31); //dlg.Add("LastLaunched"); + + + dlg.DoModal(GetID); + + if (dlg.SelectedLabel == -1) + return; + + switch (dlg.SelectedId) + { + case 103: + CurrentSortMethod = ProgramSort.SortMethod.Name; + break; + case 268: + CurrentSortMethod = ProgramSort.SortMethod.Title; + break; + case 363: + CurrentSortMethod = ProgramSort.SortMethod.Filename; + break; + case 367: + CurrentSortMethod = ProgramSort.SortMethod.Rating; + break; + case 20: + CurrentSortMethod = ProgramSort.SortMethod.LaunchCount; + break; + case 31: + CurrentSortMethod = ProgramSort.SortMethod.LastTimeLaunched; + break; + default: + CurrentSortMethod = ProgramSort.SortMethod.Name; + break; + } + + OnSort(); + GUIControl.FocusControl(GetID, btnSortBy.GetID); + } + + protected virtual void OnSort() + { + //SetLabels(); + facadeView.Sort(new ProgramSort(CurrentSortMethod, CurrentSortAsc)); + UpdateButtonStates(); + } + + protected virtual void SetLabels() + { + ProgramSort.SortMethod method = CurrentSortMethod; + + /* for (int i = 0; i < facadeView.Count; ++i) + { + GUIListItem item = facadeView[i]; + MusicTag tag = (MusicTag)item.MusicTag; + if (tag != null) + { + string trackNr = String.Format("{0:00}", tag.Track); + string fileSize = MediaPortal.Util.Utils.GetSize(item.Size); + string year = tag.Year.ToString(); + string filename = MediaPortal.Util.Utils.GetFilename(item.Path); + // For an index view, don't translate the duration + string duration = ""; + // When in Shares View, the View = null + if (handler.View != null) + { + FilterDefinition filter = (FilterDefinition)handler.View.Filters[handler.CurrentLevel]; + if (filter.SqlOperator == "group") + { + duration = Convert.ToString(tag.Duration); + } + else + { + duration = MediaPortal.Util.Utils.SecondsToHMSString(tag.Duration); + } + } + else + { + duration = MediaPortal.Util.Utils.SecondsToHMSString(tag.Duration); + } + string rating = tag.Rating.ToString(); + if (tag.Track <= 0) + trackNr = ""; + if (tag.Year < 1900) + year = ""; + + string date = ""; + if (item.FileInfo != null) + date = item.FileInfo.ModificationTime.ToShortDateString() + " " + item.FileInfo.ModificationTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat); + ; + + string line1 = _sortTags1[(int)method]; + string line2 = _sortTags2[(int)method]; + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%track%", trackNr); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%track%", trackNr); + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%filesize%", fileSize); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%filesize%", fileSize); + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%artist%", tag.Artist); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%artist%", tag.Artist); + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%album%", tag.Album); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%album%", tag.Album); + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%title%", tag.Title); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%title%", tag.Title); + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%year%", year); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%year%", year); + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%filename%", filename); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%filename%", filename); + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%rating%", rating); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%rating%", rating); + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%duration%", duration); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%duration%", duration); + line1 = MediaPortal.Util.Utils.ReplaceTag(line1, "%date%", date); + line2 = MediaPortal.Util.Utils.ReplaceTag(line2, "%date%", date); + item.Label = line1; + item.Label2 = line2; + } + }*/ + } + + + void OnInfo() { // <F3> keypress @@ -1403,7 +1508,7 @@ { int nNewWindow = (int)Window.WINDOW_FILES; StartWindow = nNewWindow; - CurrentView = ""; + CurrentLayout = Layout.List; DatabaseHandler.ViewHandler.CurrentView = null; if (nNewWindow != GetID) { @@ -1414,6 +1519,7 @@ { ViewDefinition selectedView = (ViewDefinition)DatabaseHandler.ViewHandler.Views[dlg.SelectedLabel - 1]; CurrentView = selectedView.Name; + DatabaseHandler.ViewHandler.CurrentView = selectedView.Name; int nNewWindow = (int)Window.WINDOW_FILES; if (GetID != nNewWindow) @@ -1432,7 +1538,7 @@ } } } - UpdateButtons(); + UpdateButtonStates(); UpdateListControl(); } Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj 2007-07-06 05:03:26 UTC (rev 675) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/GUIProgramsAlt.csproj 2007-07-07 21:10:58 UTC (rev 676) @@ -165,6 +165,7 @@ <ItemGroup> <Content Include="MetaData\myProgramsAltFileDetailsInfo.xml" /> <Content Include="MetaData\myProgramsAltPreconfiguration.xml" /> + <Content Include="skin\BlueTwo\myprograms.xml" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Design\AppFilesImportProgress.resx"> Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramSort.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramSort.cs 2007-07-06 05:03:26 UTC (rev 675) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramSort.cs 2007-07-07 21:10:58 UTC (rev 676) @@ -32,6 +32,7 @@ using GUIPrograms.Database; using GUIPrograms.FileItems; +using GUIPrograms.ApplicationItems; namespace GUIPrograms { @@ -55,16 +56,6 @@ bool sortAscending = true; - public bool SortAscending - { - get { return sortAscending; } - set { sortAscending = value; } - } - public int CurrentSortMethodIndex - { - get { return (int) currentSortMethod; } - set { SetCurrentSortMethodAsIndex(value); } - } public ProgramSort(SortMethod method, bool ascending) { @@ -74,9 +65,22 @@ public int Compare(GUIListItem item1, GUIListItem item2) { + if (item1 == item2) return 0; if (item1 == null) return -1; if (item2 == null) return -1; + if (item1.MusicTag == null) return -1; + if (item2.MusicTag == null) return -1; + + if (item1.MusicTag.GetType().BaseType.Name == "ApplicationItem") return -1;//quick fix for not allowing applicationsitems... be solve by inheritence etc + if (item2.MusicTag.GetType().BaseType.Name == "ApplicationItem") return -1;//quick fix for not allowing applicationsitems... be solve by inheritence etc + if (item1.MusicTag.GetType().BaseType.Name == "ProgramFilterItem") return -1;//quick fix for not allowing applicationsitems... be solve by inheritence etc + if (item2.MusicTag.GetType().BaseType.Name == "ProgramFilterItem") return -1;//quick fix for not allowing applicationsitems... be solve by inheritence etc + + + + + if (item1 == null) return -1; if (item1.IsFolder && item1.Label == "..") return -1; if (item2.IsFolder && item2.Label == "..") return -1; if (item1.IsFolder && !item2.IsFolder) return -1; @@ -172,47 +176,5 @@ } return 0; } - - public string CurrentSortMethodAsText - { - get - { - return GetCurrentSortMethodAsText(); - } - } - - private string GetCurrentSortMethodAsText() - { - string strLine = ""; - SortMethod method = currentSortMethod; - switch (method) - { - case SortMethod.Name: - strLine = GUILocalizeStrings.Get(103); - break; - case SortMethod.LaunchCount: - strLine = GUILocalizeStrings.Get(13016); - break; - case SortMethod.LastTimeLaunched: - strLine = GUILocalizeStrings.Get(13017); - break; - case SortMethod.Rating: - strLine = GUILocalizeStrings.Get(13018); - break; - } - return strLine; - } - - private void SetCurrentSortMethodAsIndex(int value) - { - try - { - currentSortMethod = (SortMethod)value; - } - catch - { - currentSortMethod = 0; - } - } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |