} // class ModeViewSettings #region Static methods public static UiBroadcastListSettings GetDefaultSettings() { var result = new UiBroadcastListSettings(); result.CurrentMode = View.Tile; result.ShowGridlines = true; result.ShowInactiveServices = true; result.ShowOutOfPackage = true; result.TilesPerRow = 4; result.ViewSettings = new ModeViewSettings(); result.ViewSettings.Details = UiBroadcastListModeSettings.GetDefaultSettings(View.Details); result.ViewSettings.LargeIcon = UiBroadcastListModeSettings.GetDefaultSettings(View.LargeIcon); result.ViewSettings.SmallIcon = UiBroadcastListModeSettings.GetDefaultSettings(View.SmallIcon); result.ViewSettings.List = UiBroadcastListModeSettings.GetDefaultSettings(View.List); result.ViewSettings.Tile = UiBroadcastListModeSettings.GetDefaultSettings(View.Tile); result.GlobalSortColumns = ServiceSortComparer.GetSuggestedSortColumns(UiBroadcastListColumn.Number, true, 3); result.UseGlobalSortColumns = false; // force creation of ColumnWidth field var dummy = result.ColumnWidth[0]; return(result); } // GetDefaultSettings
public static UiBroadcastListModeSettings GetDefaultSettings(View mode) { var result = new UiBroadcastListModeSettings(); result.Sort = ServiceSortComparer.GetSuggestedSortColumns(UiBroadcastListColumn.Number, true, 3); switch (mode) { case View.Details: result.Columns = new List <UiBroadcastListColumn>(5); result.Columns.Add(UiBroadcastListColumn.Number); result.Columns.Add(UiBroadcastListColumn.Name); result.Columns.Add(UiBroadcastListColumn.Description); result.Columns.Add(UiBroadcastListColumn.DvbType); result.Columns.Add(UiBroadcastListColumn.LocationUrl); result.LogoSize = LogoSize.Size32; break; case View.LargeIcon: result.Columns = new List <UiBroadcastListColumn>(1); result.Columns.Add(UiBroadcastListColumn.NumberAndNameCrlf); result.LogoSize = LogoSize.Size48; break; case View.SmallIcon: result.Columns = new List <UiBroadcastListColumn>(1); result.Columns.Add(UiBroadcastListColumn.Number); result.LogoSize = LogoSize.Size32; break; case View.List: result.Columns = new List <UiBroadcastListColumn>(1); result.Columns.Add(UiBroadcastListColumn.NumberAndName); result.LogoSize = LogoSize.Size32; break; case View.Tile: result.Columns = new List <UiBroadcastListColumn>(2); result.Columns.Add(UiBroadcastListColumn.NumberAndName); result.Columns.Add(UiBroadcastListColumn.DvbType); result.LogoSize = LogoSize.Size48; break; default: throw new IndexOutOfRangeException(); } // switch return(result); } // GetDefaultSettings
} // ListView_SelectedIndexChanged void ListView_ColumnClick(object sender, ColumnClickEventArgs e) { var sortColumn = new UiBroadcastListSortColumn(); sortColumn.Column = Settings.CurrentColumns[e.Column]; sortColumn.IsAscending = sortColumn.Column == SelectedSort.Column? !SelectedSort.IsAscending : true; if (Settings.UseGlobalSortColumns) { Settings.GlobalSortColumns = ServiceSortComparer.GetSuggestedSortColumns(sortColumn.Column, sortColumn.IsAscending, 3); } else { Settings[Settings.CurrentMode].Sort = ServiceSortComparer.GetSuggestedSortColumns(sortColumn.Column, sortColumn.IsAscending, 3); } // if-else SaveSettings(Settings); ApplySorting(); } // ListView_ColumnClick
} // ApplyCosmeticSettings private void ApplySorting() { if ((BroadcastServices == null) || (BroadcastServices.Count == 0)) { return; } // select sorting column var sortingColumns = Settings.UseGlobalSortColumns ? Settings.GlobalSortColumns : Settings[Settings.CurrentMode].Sort; var sortingColumn = sortingColumns[0]; SelectedSort = sortingColumn; if (sortingColumn.Column == UiBroadcastListColumn.None) { SortedBroadcastServices = fieldBroadcastServices; } else { var comparer = new ServiceSortComparer(Settings, sortingColumns); SortedBroadcastServices = fieldBroadcastServices.OrderBy(item => item, comparer); } // if-else // force use of SortedBroadcastServices when filling the list DisplayedBroadcastServices = null; FillList(); // Update the 'arrow' in the header if (Settings.CurrentMode == View.Details) { var q = from index in Enumerable.Range(0, Settings.CurrentColumns.Count) where Settings.CurrentColumns[index] == sortingColumn.Column select index; var columnIndex = q.DefaultIfEmpty(-1).First(); ListView.Sort(columnIndex, sortingColumn.IsAscending); } // if } // ApplySorting