|
1 | 1 | using System;
|
| 2 | +using System.Drawing; |
| 3 | +using System.Windows; |
2 | 4 | using System.Windows.Controls;
|
| 5 | +using System.Windows.Media; |
3 | 6 | using System.Windows.Navigation;
|
4 | 7 | using Flow.Launcher.SettingPages.ViewModels;
|
5 | 8 | using Page = ModernWpf.Controls.Page;
|
@@ -31,30 +34,74 @@ private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArg
|
31 | 34 |
|
32 | 35 | private void Reset_Click(object sender, System.Windows.RoutedEventArgs e)
|
33 | 36 | {
|
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 | + |
39 | 40 | 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; |
40 | 51 |
|
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; |
56 | 52 | WindowHeightValue.Value = 42;
|
57 | 53 | 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 | + } |
59 | 106 | }
|
60 | 107 | }
|
0 commit comments