} // end of method IconSetChanged // Load all available icon packs private void LoadInstalledIconPacks() { if (WeatherLionMain.iconPackList.Count > 0) { WeatherLionMain.iconPackList.Clear(); WeatherLionMain.iconSetControls.Clear(); WeatherLionMain.iconPacksLoaded = false; }// end of if block WeatherLionMain.iconPackList = UtilityMethod.GetSubdirectories("res/assets/img/weather_images"); WeatherLionMain.iconSetControls = new Hashtable(); // Add icon packs dynamically foreach (string packName in WeatherLionMain.iconPackList) { FlowLayoutPanel iconSelectionContainer = new FlowLayoutPanel { Size = new Size(140, 148) }; //iconSelectionContainer.BorderStyle = BorderStyle.FixedSingle; var margin = iconSelectionContainer.Margin; margin.Bottom = 10; iconSelectionContainer.Margin = margin; Label packTitle = new Label { AutoSize = false, Text = UtilityMethod.ToProperCase(packName), TextAlign = ContentAlignment.MiddleCenter, Size = new Size(iconSelectionContainer.Width, 20), Font = new Font("Arial", 11, FontStyle.Bold) }; string wiPath = $@"{AppDomain.CurrentDomain.BaseDirectory}res\assets\img\weather_images\"; bool previewImageExists = File.Exists($@"{wiPath}{packName}\preview_image.png"); string displayIcon = previewImageExists ? "preview_image.png" : "weather_10.png"; string wxIcon = $@"{wiPath}{packName}\{displayIcon}"; PictureBox packDefaultImage = new PictureBox { ImageLocation = wxIcon, Name = $"pic{UtilityMethod.ToProperCase(packName)}", SizeMode = PictureBoxSizeMode.Zoom, Size = new Size(iconSelectionContainer.Width, 100), Tag = packName.ToLower() }; RadioButton iconSelector = new RadioButton { AutoSize = false, BackColor = Color.Transparent, CheckAlign = ContentAlignment.MiddleCenter, Name = $"rad{UtilityMethod.ToProperCase(packName)}", Size = new Size(iconSelectionContainer.Width, 14), Tag = packName.ToLower() }; iconSelector.CheckedChanged += new EventHandler(IconSetChanged); iconSelectionContainer.Controls.Add(packTitle); iconSelectionContainer.Controls.Add(packDefaultImage); iconSelectionContainer.Controls.Add(iconSelector); // Add icon selections to FlowLayoutPanel flpIconSet.Controls.Add(iconSelectionContainer); List <Control> components = new List <Control> { packTitle, // Add the component that displays the icon pack title packDefaultImage, // Add the component that displays the icon pack default image iconSelector // Add the component that displays the radio button to select the pack }; WeatherLionMain.iconSetControls.Add(packName, components); }// end of foreach loop //string set = "hero"; //(un-comment during testing) string set = WeatherLionMain.storedPreferences.StoredPreferences.IconSet; ((RadioButton) ((List <Control>) WeatherLionMain.iconSetControls[set])[2]).Checked = true; WeatherLionMain.iconPacksLoaded = true; StringBuilder packs = new StringBuilder(string.Join(", ", WeatherLionMain.iconPackList.ToArray())); packs.Insert(packs.ToString().LastIndexOf(",") + 1, " and"); UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO, $"Icon Packs Installed: {packs.ToString()}", $"{TAG}::LoadInstalledIconPacks"); }// end of method LoadInstalledIconPacks
} // end of method Init private static void HealthCheck() { // the program CANNOT RUN with the assets directory if (!Directory.Exists(ASSETS_PATH)) { UtilityMethod.MissingRequirementsPrompt("Missing Assets Directory"); }// end of if block else { UtilityMethod.subDirectoriesFound.Clear(); // clear any previous list List <string> iconPacks = UtilityMethod.GetSubdirectories(WEATHER_ICONS_PATH); if (iconPacks == null || iconPacks.Count == 0) { UtilityMethod.MissingRequirementsPrompt("Empty Assets Directory"); }// end of if block else { UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO, "Found " + iconPacks.Count + " icon " + (iconPacks.Count > 1 ? "packs..." : "pack..."), $"{TAG}::HealthCheck"); if (!iconPacks.Contains(DEFAULT_ICON_SET)) { UtilityMethod.MissingRequirementsPrompt("Missing Default Icons"); }// end of if block else if (!iconPacks.Contains(Preference.GetSavedPreferences().StoredPreferences.IconSet)) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.WARNING, $"The {storedPreferences.StoredPreferences.IconSet.ToUpper()}" + $" icon pack could not be found so the default {DEFAULT_ICON_SET.ToUpper()}" + " will be used!", $"{TAG}::HealthCheck"); Preference.SaveProgramConfiguration("prefs", "IconSet", "default"); }// end of else if block else { string iconsInUse = $"{WEATHER_ICONS_PATH}{storedPreferences.StoredPreferences.IconSet}/"; int imageCount = UtilityMethod.GetFileCount(iconsInUse); if (imageCount < 23) { UtilityMethod.MissingRequirementsPrompt("Insufficient Icon Count"); }// end of if block else { UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO, $"Found {imageCount}" + (imageCount > 1 ? " images" : " image") + " in the " + UtilityMethod.ToProperCase(storedPreferences.StoredPreferences.IconSet) + " icon pack...", $"{TAG}::HealthCheck"); }// end of else block // check for the background and icon images if (!Directory.Exists(WIDGET_BACKGROUNDS_PATH)) { UtilityMethod.MissingRequirementsPrompt("Missing Background Image Directory"); }// end of if block else { imageCount = UtilityMethod.GetFileCount(WIDGET_BACKGROUNDS_PATH); if (imageCount < 3) { UtilityMethod.MissingRequirementsPrompt(imageCount > 1 ? "Missing Background Images" : "Missing Background Image"); }// end of if block else { UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO, "Found " + imageCount + (imageCount > 1 ? " images" : " image") + " in the backgrounds directory...", $"{TAG}::HealthCheck"); } // end of else block } // end of else block if (!Directory.Exists(WIDGET_ICONS_PATH)) { UtilityMethod.MissingRequirementsPrompt("Missing Background Image Directory"); }// end of if block else { imageCount = UtilityMethod.GetFileCount(WIDGET_ICONS_PATH); if (imageCount < 11) { UtilityMethod.MissingRequirementsPrompt(imageCount > 1 ? "Missing Icon Images" : "Missing Icon Image"); }// end of if block else { UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO, "Found " + imageCount + (imageCount > 1 ? " images" : " image") + " in the icons directory...", $"{TAG}::HealthCheck"); } // end of else block } // end of else block } // end of else block } // end of else block } // end of else block } // end of method HealthCheck