Skip to content

Commit 188c409

Browse files
committed
Adjust Reset Logic
1 parent 4fd05f5 commit 188c409

File tree

2 files changed

+70
-23
lines changed

2 files changed

+70
-23
lines changed

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
BorderThickness="1"
167167
Style="{StaticResource SettingSeparatorStyle}" />
168168
<Slider
169-
Name="resultItemFontSize"
169+
Name="ResultItemFontSize"
170170
Width="140"
171171
Margin="8 8 8 0"
172172
VerticalAlignment="Center"
@@ -212,7 +212,7 @@
212212
BorderThickness="1"
213213
Style="{StaticResource SettingSeparatorStyle}" />
214214
<Slider
215-
Name="resultSubItemFontSize"
215+
Name="ResultSubItemFontSize"
216216
Width="140"
217217
Margin="8 8 8 0"
218218
VerticalAlignment="Center"

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System;
2+
using System.Drawing;
3+
using System.Windows;
24
using System.Windows.Controls;
5+
using System.Windows.Media;
36
using System.Windows.Navigation;
47
using Flow.Launcher.SettingPages.ViewModels;
58
using Page = ModernWpf.Controls.Page;
@@ -31,30 +34,74 @@ private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArg
3134

3235
private void Reset_Click(object sender, System.Windows.RoutedEventArgs e)
3336
{
34-
//QueryBoxFont = "Segoe UI";
35-
//QueryBoxFontStyle = "Normal";
36-
//QueryBoxFontWeight = "Normal";
37-
//QueryBoxFontStretch = "Normal";
38-
//QueryBoxFontSize = 20;
37+
/*The FamilyTypeface should initialize all of its various properties.*/
38+
FamilyTypeface targetTypeface = new FamilyTypeface { Stretch = FontStretches.Normal, Weight = FontWeights.Normal, Style = FontStyles.Normal };
39+
3940
QueryBoxFontSize.Value = 20;
41+
QueryBoxFontComboBox.SelectedIndex = SearchFontIndex("Segoe UI", QueryBoxFontComboBox);
42+
QueryBoxFontStyleComboBox.SelectedIndex = SearchFontStyleIndex(targetTypeface, QueryBoxFontStyleComboBox);
43+
44+
ResultItemFontComboBox.SelectedIndex = SearchFontIndex("Segoe UI", ResultItemFontComboBox);
45+
ResultItemFontStyleComboBox.SelectedIndex = SearchFontStyleIndex(targetTypeface, ResultItemFontStyleComboBox);
46+
ResultItemFontSize.Value = 16;
47+
48+
ResultSubItemFontComboBox.SelectedIndex = SearchFontIndex("Segoe UI", ResultSubItemFontComboBox);
49+
ResultSubItemFontStyleComboBox.SelectedIndex = SearchFontStyleIndex(targetTypeface, ResultSubItemFontStyleComboBox);
50+
ResultSubItemFontSize.Value = 13;
4051

41-
//ResultFont = "Segoe UI";
42-
//ResultFontStyle = "Normal";
43-
//ResultFontWeight = "Normal";
44-
//ResultFontStretch = "Normal";
45-
//ResultItemFontSize = 16;
46-
resultItemFontSize.Value = 16;
47-
48-
//ResultSubFont = "Segoe UI";
49-
//ResultSubFontStyle = "Normal";
50-
//ResultSubFontWeight = "Normal";
51-
//ResultSubFontStretch = "Normal";
52-
//ResultSubItemFontSize = 13;
53-
resultSubItemFontSize.Value = 13;
54-
//ItemHeightSize = 58;
55-
//WindowHeightSize = 42;
5652
WindowHeightValue.Value = 42;
5753
ItemHeightValue.Value = 58;
58-
//_viewModel.ResetCustomize();
54+
}
55+
public int SearchFontIndex(string str, ComboBox combo)
56+
{
57+
int index = -1;
58+
string targetFont = str;
59+
60+
for (int i = 0; i < combo.Items.Count; i++)
61+
{
62+
if (combo.Items[i].ToString() == targetFont)
63+
{
64+
index = i;
65+
break;
66+
}
67+
}
68+
69+
if (index != -1)
70+
{
71+
return index;
72+
}
73+
else
74+
{
75+
// If there no Default Value.
76+
return 0;
77+
}
78+
}
79+
public int SearchFontStyleIndex(FamilyTypeface targetTypeface, ComboBox combo)
80+
{
81+
int index = -1;
82+
83+
for (int i = 0; i < combo.Items.Count; i++)
84+
{
85+
if (combo.Items[i] is FamilyTypeface)
86+
{
87+
FamilyTypeface typefaceItem = (FamilyTypeface)combo.Items[i];
88+
if (typefaceItem.Stretch == targetTypeface.Stretch &&
89+
typefaceItem.Weight == targetTypeface.Weight &&
90+
typefaceItem.Style == targetTypeface.Style)
91+
{
92+
index = i;
93+
break;
94+
}
95+
}
96+
}
97+
98+
if (index != -1)
99+
{
100+
return index;
101+
}
102+
else
103+
{
104+
return 0;
105+
}
59106
}
60107
}

0 commit comments

Comments
 (0)