Skip to content

Commit f2aaba8

Browse files
committed
Fix label size setting not affecting UI and empty dropdown on fresh install
1 parent 2924ab3 commit f2aaba8

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

AppGroup/EditGroupWindow.xaml.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,29 @@ await Task.Run(async () =>
543543
});
544544
}
545545
}
546+
else {
547+
// Config file doesn't exist (fresh install) - initialize with defaults
548+
DispatcherQueue.TryEnqueue(() =>
549+
{
550+
groupName = "";
551+
GroupHeader.IsOn = false;
552+
GroupNameTextBox.Text = string.Empty;
553+
GroupColComboBox.Items.Clear();
554+
selectedIconPath = string.Empty;
555+
IconPreviewImage.Source = new BitmapImage(new Uri("ms-appx:///default_preview.png"));
556+
557+
ApplicationCount.Text = string.Empty;
558+
ExeFiles.Clear();
559+
IconGridComboBox.Items.Clear();
560+
IconGridComboBox.Visibility = Visibility.Collapsed;
561+
562+
// Initialize label settings for new groups on fresh install
563+
InitializeLabelSizeComboBox();
564+
ShowLabels.IsOn = false;
565+
LabelSizePanel.Opacity = 0.5;
566+
LabelSizeComboBox.IsEnabled = false;
567+
});
568+
}
546569

547570
await Task.Run(() => Task.Delay(100));
548571

AppGroup/IconCache.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static async Task<BitmapImage> LoadImageFromPathAsync(string filePath) {
6161
return bitmapImage;
6262
}
6363
public static async Task<string> GetIconPathAsync(string filePath) {
64-
if (string.IsNullOrEmpty(filePath)) return null;
64+
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) return null;
6565

6666
string cacheKey = ComputeFileCacheKey(filePath);
6767

@@ -103,6 +103,9 @@ public static void SaveIconCache() {
103103
}
104104

105105
public static string ComputeFileCacheKey(string filePath) {
106+
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) {
107+
return filePath ?? string.Empty;
108+
}
106109
var fileInfo = new FileInfo(filePath);
107110
return $"{filePath}_{fileInfo.LastWriteTimeUtc}_{fileInfo.Length}";
108111
}

AppGroup/PopupWindow.xaml.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ private void InitializeTemplates() {
208208
VerticalAlignment=""Center""/>
209209
</ItemsPanelTemplate>");
210210

211+
// Label templates will be created dynamically in CreateLabelTemplates() with the actual font size
212+
}
213+
214+
// Create label templates with the specified font size
215+
private void CreateLabelTemplates(int fontSize) {
211216
// Create item template with labels
212217
const int EFFECTIVE_BUTTON_WIDTH_WITH_LABEL = BUTTON_SIZE_WITH_LABEL + (BUTTON_MARGIN * 2);
213218
_itemTemplateWithLabel = (DataTemplate)XamlReader.Load(
@@ -225,7 +230,7 @@ private void InitializeTemplates() {
225230
HorizontalAlignment=""Center""
226231
Margin=""4,6,4,2"" />
227232
<TextBlock Text=""{{Binding ToolTip}}""
228-
FontSize=""{DEFAULT_LABEL_SIZE}""
233+
FontSize=""{fontSize}""
229234
TextTrimming=""CharacterEllipsis""
230235
TextAlignment=""Center""
231236
HorizontalAlignment=""Center""
@@ -263,7 +268,7 @@ private void InitializeTemplates() {
263268
VerticalAlignment=""Center""
264269
Margin=""0,0,8,0"" />
265270
<TextBlock Text=""{{Binding ToolTip}}""
266-
FontSize=""{DEFAULT_LABEL_SIZE}""
271+
FontSize=""{fontSize}""
267272
TextTrimming=""CharacterEllipsis""
268273
VerticalAlignment=""Center""
269274
MaxWidth=""{BUTTON_WIDTH_HORIZONTAL_LABEL - ICON_SIZE - 12}""
@@ -345,6 +350,11 @@ private void InitializeWindow() {
345350
_labelSize = filteredGroup.Value.LabelSize > 0 ? filteredGroup.Value.LabelSize : DEFAULT_LABEL_SIZE;
346351
_currentColumns = maxColumns;
347352

353+
// Create label templates with the actual font size from config
354+
if (_showLabels) {
355+
CreateLabelTemplates(_labelSize);
356+
}
357+
348358
if (!int.TryParse(filteredGroup.Key, out _groupId)) {
349359
Debug.WriteLine($"Error: Group key '{filteredGroup.Key}' is not a valid integer ID");
350360
return;

0 commit comments

Comments
 (0)