Skip to content

Commit efd4cfc

Browse files
committed
[style] 规范命名
1 parent 45c017c commit efd4cfc

File tree

10 files changed

+98
-98
lines changed

10 files changed

+98
-98
lines changed

FluentWeather.Uwp/Behaviors/ButtonContentSnapBehavior.cs

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ public class ButtonContentSnapBehavior : Behavior<ButtonBase>
1616
{
1717
private const double DurationSeconds = 0.3;
1818

19-
private bool attached;
20-
private long paddingChangedEventToken;
21-
private long contentChangedEventToken;
22-
private VisualStateGroup? visualStateGroup;
23-
private ContentPresenter? contentPresenter;
24-
private Visual? contentVisual;
25-
26-
private Compositor compositor;
27-
private CompositionPropertySet propSet;
28-
private Vector3KeyFrameAnimation translationAnimation1;
29-
private Vector3KeyFrameAnimation translationAnimation2;
19+
private bool _attached;
20+
private long _paddingChangedEventToken;
21+
private long _contentChangedEventToken;
22+
private VisualStateGroup? _visualStateGroup;
23+
private ContentPresenter? _contentPresenter;
24+
private Visual? _contentVisual;
25+
26+
private Compositor _compositor;
27+
private CompositionPropertySet _propSet;
28+
private Vector3KeyFrameAnimation _translationAnimation1;
29+
private Vector3KeyFrameAnimation _translationAnimation2;
3030

3131

3232

@@ -47,22 +47,22 @@ public ButtonContentSnapType SnapType
4747

4848
private void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
4949
{
50-
compositor = ElementCompositionPreview.GetElementVisual(AssociatedObject).Compositor;
50+
_compositor = ElementCompositionPreview.GetElementVisual(AssociatedObject).Compositor;
5151
//compositor = CompositionTarget.GetCompositorForCurrentThread();
5252

53-
propSet = compositor.CreatePropertySet();
54-
propSet.InsertVector3("Offset", Vector3.Zero);
53+
_propSet = _compositor.CreatePropertySet();
54+
_propSet.InsertVector3("Offset", Vector3.Zero);
5555

56-
translationAnimation1 = compositor.CreateVector3KeyFrameAnimation();
57-
translationAnimation1.InsertKeyFrame(1, Vector3.Zero);
58-
translationAnimation1.Duration = TimeSpan.FromSeconds(DurationSeconds);
59-
translationAnimation1.StopBehavior = AnimationStopBehavior.LeaveCurrentValue;
56+
_translationAnimation1 = _compositor.CreateVector3KeyFrameAnimation();
57+
_translationAnimation1.InsertKeyFrame(1, Vector3.Zero);
58+
_translationAnimation1.Duration = TimeSpan.FromSeconds(DurationSeconds);
59+
_translationAnimation1.StopBehavior = AnimationStopBehavior.LeaveCurrentValue;
6060

61-
translationAnimation2 = compositor.CreateVector3KeyFrameAnimation();
62-
translationAnimation2.InsertExpressionKeyFrame(1, "propSet.Offset");
63-
translationAnimation2.Duration = TimeSpan.FromSeconds(DurationSeconds);
64-
translationAnimation2.SetReferenceParameter("propSet", propSet);
65-
translationAnimation2.StopBehavior = AnimationStopBehavior.LeaveCurrentValue;
61+
_translationAnimation2 = _compositor.CreateVector3KeyFrameAnimation();
62+
_translationAnimation2.InsertExpressionKeyFrame(1, "propSet.Offset");
63+
_translationAnimation2.Duration = TimeSpan.FromSeconds(DurationSeconds);
64+
_translationAnimation2.SetReferenceParameter("propSet", _propSet);
65+
_translationAnimation2.StopBehavior = AnimationStopBehavior.LeaveCurrentValue;
6666
TryLoadContent((ButtonBase)sender);
6767
}
6868

@@ -101,66 +101,66 @@ private void TryLoadContent(ButtonBase? button)
101101

102102
private void LoadContent(ButtonBase button)
103103
{
104-
if (attached) return;
104+
if (_attached) return;
105105

106-
paddingChangedEventToken = button.RegisterPropertyChangedCallback(Control.PaddingProperty, OnPaddingPropertyChanged);
107-
visualStateGroup = VisualStateManager.GetVisualStateGroups((FrameworkElement)VisualTreeHelper.GetChild(button, 0)).FirstOrDefault(c => c.Name == "CommonStates");
106+
_paddingChangedEventToken = button.RegisterPropertyChangedCallback(Control.PaddingProperty, OnPaddingPropertyChanged);
107+
_visualStateGroup = VisualStateManager.GetVisualStateGroups((FrameworkElement)VisualTreeHelper.GetChild(button, 0)).FirstOrDefault(c => c.Name == "CommonStates");
108108

109-
if (visualStateGroup != null)
109+
if (_visualStateGroup != null)
110110
{
111-
visualStateGroup.CurrentStateChanging += VisualStateGroup_CurrentStateChanging;
111+
_visualStateGroup.CurrentStateChanging += VisualStateGroup_CurrentStateChanging;
112112
}
113113

114-
contentPresenter = FindChild<ContentPresenter>(button);
114+
_contentPresenter = FindChild<ContentPresenter>(button);
115115

116-
if (contentPresenter != null)
116+
if (_contentPresenter != null)
117117
{
118-
contentChangedEventToken = contentPresenter.RegisterPropertyChangedCallback(ContentPresenter.ContentProperty, OnContentChanged);
119-
var actualContent = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;
118+
_contentChangedEventToken = _contentPresenter.RegisterPropertyChangedCallback(ContentPresenter.ContentProperty, OnContentChanged);
119+
var actualContent = VisualTreeHelper.GetChild(_contentPresenter, 0) as UIElement;
120120

121121
if (actualContent != null)
122122
{
123-
contentVisual = ElementCompositionPreview.GetElementVisual(actualContent);
124-
contentVisual.IsPixelSnappingEnabled = true;
123+
_contentVisual = ElementCompositionPreview.GetElementVisual(actualContent);
124+
_contentVisual.IsPixelSnappingEnabled = true;
125125
ElementCompositionPreview.SetIsTranslationEnabled(actualContent, true);
126126
}
127127
}
128128

129-
attached = true;
129+
_attached = true;
130130
UpdateSnapType();
131131
}
132132

133133
private void UnloadContent(ButtonBase button)
134134
{
135-
if (!attached) return;
135+
if (!_attached) return;
136136

137-
attached = false;
137+
_attached = false;
138138

139139
button.LayoutUpdated += AssociatedObject_LayoutUpdated;
140140

141-
button.UnregisterPropertyChangedCallback(Control.PaddingProperty, paddingChangedEventToken);
142-
paddingChangedEventToken = 0;
141+
button.UnregisterPropertyChangedCallback(Control.PaddingProperty, _paddingChangedEventToken);
142+
_paddingChangedEventToken = 0;
143143

144-
if (visualStateGroup != null)
144+
if (_visualStateGroup != null)
145145
{
146-
visualStateGroup.CurrentStateChanging -= VisualStateGroup_CurrentStateChanging;
146+
_visualStateGroup.CurrentStateChanging -= VisualStateGroup_CurrentStateChanging;
147147
}
148-
visualStateGroup = null;
148+
_visualStateGroup = null;
149149

150-
if (contentPresenter != null)
150+
if (_contentPresenter != null)
151151
{
152-
contentPresenter.UnregisterPropertyChangedCallback(ContentPresenter.ContentProperty, contentChangedEventToken);
153-
contentChangedEventToken = 0;
154-
contentPresenter = null;
152+
_contentPresenter.UnregisterPropertyChangedCallback(ContentPresenter.ContentProperty, _contentChangedEventToken);
153+
_contentChangedEventToken = 0;
154+
_contentPresenter = null;
155155
}
156156

157-
if (contentVisual != null)
157+
if (_contentVisual != null)
158158
{
159-
contentVisual.StopAnimation("Translation");
160-
contentVisual = null;
159+
_contentVisual.StopAnimation("Translation");
160+
_contentVisual = null;
161161
}
162162

163-
propSet.InsertVector3("Offset", Vector3.Zero);
163+
_propSet.InsertVector3("Offset", Vector3.Zero);
164164
}
165165

166166
protected override void OnAttached()
@@ -194,36 +194,36 @@ private void OnPaddingPropertyChanged(DependencyObject sender, DependencyPropert
194194

195195
private void OnContentChanged(DependencyObject sender, DependencyProperty dp)
196196
{
197-
if (attached && contentPresenter != null)
197+
if (_attached && _contentPresenter != null)
198198
{
199-
if (contentVisual != null)
199+
if (_contentVisual != null)
200200
{
201-
contentVisual.StopAnimation("Translation");
202-
contentVisual = null;
201+
_contentVisual.StopAnimation("Translation");
202+
_contentVisual = null;
203203
}
204204

205-
var actualContent = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;
205+
var actualContent = VisualTreeHelper.GetChild(_contentPresenter, 0) as UIElement;
206206

207207
if (actualContent != null)
208208
{
209-
contentVisual = ElementCompositionPreview.GetElementVisual(actualContent);
210-
contentVisual.IsPixelSnappingEnabled = true;
209+
_contentVisual = ElementCompositionPreview.GetElementVisual(actualContent);
210+
_contentVisual.IsPixelSnappingEnabled = true;
211211
ElementCompositionPreview.SetIsTranslationEnabled(actualContent, true);
212212
}
213213
}
214214
}
215215

216216
private void VisualStateGroup_CurrentStateChanging(object sender, VisualStateChangedEventArgs e)
217217
{
218-
if (!attached || contentVisual == null) return;
218+
if (!_attached || _contentVisual == null) return;
219219

220220
if (e.NewState?.Name == "PointerOver" || e.NewState?.Name == "Pressed")
221221
{
222-
contentVisual.StartAnimation("Translation", translationAnimation1);
222+
_contentVisual.StartAnimation("Translation", _translationAnimation1);
223223
}
224224
else
225225
{
226-
contentVisual.StartAnimation("Translation", translationAnimation2);
226+
_contentVisual.StartAnimation("Translation", _translationAnimation2);
227227
}
228228
}
229229

@@ -233,14 +233,14 @@ private void UpdateSnapType()
233233
var button = AssociatedObject;
234234
if (button == null) return;
235235

236-
if (attached)
236+
if (_attached)
237237
{
238238
var hover = false;
239239

240-
if (visualStateGroup != null)
240+
if (_visualStateGroup != null)
241241
{
242-
hover = visualStateGroup.CurrentState?.Name == "PointerOver"
243-
|| visualStateGroup.CurrentState?.Name == "Pressed";
242+
hover = _visualStateGroup.CurrentState?.Name == "PointerOver"
243+
|| _visualStateGroup.CurrentState?.Name == "Pressed";
244244
}
245245

246246
var padding = button.Padding;
@@ -254,19 +254,19 @@ private void UpdateSnapType()
254254
_ => Vector3.Zero
255255
};
256256

257-
propSet.InsertVector3("Offset", offset);
257+
_propSet.InsertVector3("Offset", offset);
258258

259-
if (contentVisual != null)
259+
if (_contentVisual != null)
260260
{
261-
contentVisual.StopAnimation("Translation");
261+
_contentVisual.StopAnimation("Translation");
262262

263263
if (hover)
264264
{
265-
contentVisual.Properties.InsertVector3("Translation", Vector3.Zero);
265+
_contentVisual.Properties.InsertVector3("Translation", Vector3.Zero);
266266
}
267267
else
268268
{
269-
contentVisual.Properties.InsertVector3("Translation", offset);
269+
_contentVisual.Properties.InsertVector3("Translation", offset);
270270
}
271271
}
272272
}

FluentWeather.Uwp/Controls/Dialogs/SetLocationDialog.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public SetLocationDialog()
3838
}
3939
}
4040
[ObservableProperty]
41-
private string query;
41+
private string _query;
4242
[ObservableProperty]
43-
private ObservableCollection<GeolocationBase> suggestedCities = new();
43+
private ObservableCollection<GeolocationBase> _suggestedCities = new();
4444
[ObservableProperty]
45-
private GeolocationBase chosenGeolocation;
45+
private GeolocationBase _chosenGeolocation;
4646

4747
private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
4848
{

FluentWeather.Uwp/Controls/Dialogs/TyphoonDialog.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949
<TextBlock
5050
Width="20"
5151
Margin="4,4,0,0"
52-
maps:MapControl.Location="{x:Bind point24}"
52+
maps:MapControl.Location="{x:Bind _point24}"
5353
Foreground="#CCFFFF00"
5454
Text="24小时警戒线"
5555
TextWrapping="Wrap" />
5656
<TextBlock
5757
Width="20"
5858
Margin="4,4,0,0"
59-
maps:MapControl.Location="{x:Bind point48}"
59+
maps:MapControl.Location="{x:Bind _point48}"
6060
Foreground="#99FFFF00"
6161
Text="48小时警戒线"
6262
TextWrapping="Wrap" />

FluentWeather.Uwp/Controls/Dialogs/TyphoonDialog.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public TyphoonDialog()
4343
}
4444
public const string MapStyleSheetJson = "{\"version\":\"1.*\",\"settings\":{},\"elements\":{\"transportation\":{\"visible\":false},\"road\":{\"labelVisible\":false}}}";
4545
[ObservableProperty]
46-
private ObservableCollection<TyphoonTrackBase> tracks = new();
46+
private ObservableCollection<TyphoonTrackBase> _tracks = new();
4747
[ObservableProperty]
48-
private ObservableCollection<TyphoonBase> typhoons = new();
48+
private ObservableCollection<TyphoonBase> _typhoons = new();
4949
public async void GetTyphoons()
5050
{
5151
if(Common.Settings.QWeatherDomain is "devapi.qweather.com")
@@ -217,8 +217,8 @@ public void ShowWarningLines()
217217
TyphoonMap.MapElements.Add(line24);
218218
TyphoonMap.MapElements.Add(line48);
219219
}
220-
private readonly Geopoint point24 = new Geopoint(new BasicGeoposition { Longitude = 127, Latitude = 34 });
221-
private readonly Geopoint point48 = new Geopoint(new BasicGeoposition { Longitude = 132, Latitude = 34 });
220+
private readonly Geopoint _point24 = new Geopoint(new BasicGeoposition { Longitude = 127, Latitude = 34 });
221+
private readonly Geopoint _point48 = new Geopoint(new BasicGeoposition { Longitude = 132, Latitude = 34 });
222222

223223
[RelayCommand]
224224
public void Close()

FluentWeather.Uwp/Controls/Settings/PersonalizationSettingSection.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<controls1:MarkdownTextBlock
107107
Width="400"
108108
Background="Transparent"
109-
Text="{x:Bind backgroundImageSettingInfo}"
109+
Text="{x:Bind _backgroundImageSettingInfo}"
110110
TextWrapping="Wrap" />
111111
</Flyout>
112112
</Button.Flyout>

FluentWeather.Uwp/Controls/Settings/PersonalizationSettingSection.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public PersonalizationSettingSection()
3535
{
3636
this.InitializeComponent();
3737
}
38-
private readonly string backgroundImageSettingInfo = "你也可以根据不同天气使用不同的背景\r\n\r\n方法:点击\"打开背景文件夹\",将背景图片**(PNG格式)**复制到此文件夹内,将图片按照以下格式重命名即可:\r\n\r\n| 天气 | 文件命名 |\r\n|-------|-------------------|\r\n| 晴 | Clear |\r\n| 多云 | PartlyCloudy |\r\n| 阴 | Cloudy |\r\n| 大雨 | HeavyRain |\r\n| 小雨/中雨 | LightRain |\r\n| 大雪 | HeavySnow |\r\n| 小雪/中雪 | LightSnow |\r\n| 雷阵雨 | ThunderyShowers |\r\n| 雷电 | ThunderyHeavyRain |\r\n| 雾/霾 | Fog ";
38+
private readonly string _backgroundImageSettingInfo = "你也可以根据不同天气使用不同的背景\r\n\r\n方法:点击\"打开背景文件夹\",将背景图片**(PNG格式)**复制到此文件夹内,将图片按照以下格式重命名即可:\r\n\r\n| 天气 | 文件命名 |\r\n|-------|-------------------|\r\n| 晴 | Clear |\r\n| 多云 | PartlyCloudy |\r\n| 阴 | Cloudy |\r\n| 大雨 | HeavyRain |\r\n| 小雨/中雨 | LightRain |\r\n| 大雪 | HeavySnow |\r\n| 小雪/中雪 | LightSnow |\r\n| 雷阵雨 | ThunderyShowers |\r\n| 雷电 | ThunderyHeavyRain |\r\n| 雾/霾 | Fog ";
3939
[RelayCommand]
4040
public async Task SetBackground(string type)
4141
{

FluentWeather.Uwp/Pages/RootPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void SetTitleBar()
9292
ThemeHelper.SetTitleBarColor(Common.Settings.ApplicationTheme);
9393
}
9494
[ObservableProperty]
95-
public bool canGoBack;
95+
private bool _canGoBack;
9696

9797
private void BackButton_Click(object sender, RoutedEventArgs e)
9898
{

FluentWeather.Uwp/ViewModels/CitiesPageViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ namespace FluentWeather.Uwp.ViewModels;
2525
public partial class CitiesPageViewModel:ObservableObject
2626
{
2727
[ObservableProperty]
28-
private ObservableCollection<GeolocationBase> cities;
28+
private ObservableCollection<GeolocationBase> _cities;
2929
[ObservableProperty]
30-
private GeolocationBase currentCity;
30+
private GeolocationBase _currentCity;
3131
[ObservableProperty]
32-
private string query;
32+
private string _query;
3333
[ObservableProperty]
34-
private List<GeolocationBase> suggestedCities;
34+
private List<GeolocationBase> _suggestedCities;
3535
public static CitiesPageViewModel Instance { get; private set; }
3636
public CitiesPageViewModel()
3737
{

0 commit comments

Comments
 (0)