} // InitListViewControl private void ApplySettings(UiBroadcastListSettings newSettings) { // save existing settings var oldSettings = fieldOldSettings; // save new settings fieldOldSettings = XmlSerialization.Clone(newSettings); fieldSettings = newSettings; // rebuild list? if (NeedToRebuildList(oldSettings, newSettings)) { BuildListLayout(); } else { ListView.BeginUpdate(); // apply new sorting? if (NeedToApplySorting(oldSettings, newSettings)) { ApplySorting(); } else { // apply cosmetic changes? ApplyCosmeticSettings(oldSettings, newSettings); } // if-else ListView.EndUpdate(); } // if-else } // ApplySettings
} // 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
} // ApplySorting private bool NeedToRebuildList(UiBroadcastListSettings oldSettings, UiBroadcastListSettings newSettings) { // new settings? if (oldSettings == null) { return(true); } //view mode changed? if (oldSettings.CurrentMode != newSettings.CurrentMode) { return(true); } // number of columns changed? var oldColumns = oldSettings.CurrentColumns; var newColums = newSettings.CurrentColumns; if (oldColumns.Count != newColums.Count) { return(true); } // columns changed for (int index = 0; index < oldColumns.Count; index++) { if (oldColumns[index] != newColums[index]) { return(true); } // if } // for // show/hide changed if (oldSettings.ShowHiddenServices != newSettings.ShowHiddenServices) { return(true); } if (oldSettings.ShowInactiveServices != newSettings.ShowInactiveServices) { return(true); } if (oldSettings.ShowOutOfPackage != newSettings.ShowOutOfPackage) { return(true); } return(false); } // NeedToRebuildList
} // NeedToRebuildList private bool NeedToApplySorting(UiBroadcastListSettings oldSettings, UiBroadcastListSettings newSettings) { // global sort column changed? if (oldSettings.UseGlobalSortColumns != newSettings.UseGlobalSortColumns) { return(true); } if (newSettings.UseGlobalSortColumns) { return(!CompareSortColumns(oldSettings.GlobalSortColumns, newSettings.GlobalSortColumns)); } // if // current mode sort column changed? var oldModeSettings = oldSettings[oldSettings.CurrentMode]; var newModeSettings = newSettings[newSettings.CurrentMode]; return(!CompareSortColumns(oldModeSettings.Sort, newModeSettings.Sort)); } // NeedToApplySorting
} // FillList private bool ApplyCosmeticSettings(UiBroadcastListSettings oldSettings, UiBroadcastListSettings newSettings) { var changed = false; if ((oldSettings == null) || (oldSettings.ShowGridlines != newSettings.ShowGridlines)) { ListView.GridLines = newSettings.ShowGridlines; changed = true; } // if if ((oldSettings == null) || (oldSettings.TilesPerRow != newSettings.TilesPerRow)) { var tilesPerRow = Math.Max(newSettings.TilesPerRow, 1); ListView.TileSize = new Size((ListView.Width - SystemInformation.VerticalScrollBarWidth - 6) / tilesPerRow, ListView.LargeImageList.ImageSize.Height + 6); } // if return(changed); } // ApplyCosmeticSettings
} // GetColumnData #endregion public UiBroadcastListManager(ListViewSortable listView, UiBroadcastListSettings settings, ImageList smallImageList, ImageList largeImageList, bool overrideDesignSettings) { if (listView == null) { throw new ArgumentNullException("listView"); } if (settings == null) { throw new ArgumentNullException("settings"); } ListView = listView; SmallImageList = smallImageList; LargeImageList = largeImageList; FontNormal = new Font("Segoe UI Semibold", 10.0f, FontStyle.Regular); FontNormalHidden = new Font("Segoe UI Semibold", 9.5f, FontStyle.Regular); FontNormalNotAvailable = new Font("Segoe UI", 9, FontStyle.Regular); FontDetails = new Font(ListView.Font.OriginalFontName, ListView.Font.SizeInPoints, FontStyle.Regular); FontDetailsBold = new Font("Tahoma", 10.5f, FontStyle.Bold); InitListViewControl(overrideDesignSettings); ApplySettings(settings); } // constructor
public ServiceSortComparer(UiBroadcastListSettings settings, IList <UiBroadcastListSortColumn> sort) { Settings = settings; Sort = sort; Buffer = new StringBuilder(512); } // constructor
} // GetItemType public IConfigurationItem CreateDefault() { return(UiBroadcastListSettings.GetDefaultSettings()); } // CreateDefault
} // ApplySettings private void SaveSettings(UiBroadcastListSettings settings) { UiBroadcastListSettingsRegistration.Settings = settings; AppUiConfiguration.Current.Save(); } // SaveSettings