Skip to content

Commit

Permalink
修复导航失效的问题;添加S.M.A.R.T.信息“当前值”;添加S.M.A.R.T.信息标题
Browse files Browse the repository at this point in the history
  • Loading branch information
1357310795 committed Mar 25, 2023
1 parent 3e3027e commit 884c5b1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
22 changes: 18 additions & 4 deletions DiskInfo/DiskInfo/Controls/DiskSmartInfoControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</UserControl.Resources>

<Grid>
<ItemsRepeater ItemsSource="{Binding List3}">
<ItemsRepeater ItemsSource="{Binding ListSMARTInfoDisplay}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<Grid>
Expand All @@ -31,16 +31,18 @@
<ColumnDefinition Width="36" />
<ColumnDefinition Width="5*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>
<Rectangle
Grid.Row="1"
Grid.Column="2"
Grid.ColumnSpan="3"
Grid.ColumnSpan="5"
Fill="{ThemeResource MyBrush}"
Opacity="0.2" />
<toolkit:UniformGrid
Grid.RowSpan="3"
Grid.RowSpan="5"
Columns="1"
Rows="3">
<Rectangle
Expand Down Expand Up @@ -71,12 +73,24 @@
Grid.Column="3"
Margin="8,2"
FontSize="14"
Text="{Binding Threshold}" />
Text="{Binding Current}" />
<TextBlock
Grid.Row="1"
Grid.Column="4"
Margin="8,2"
FontSize="14"
Text="{Binding Worst}" />
<TextBlock
Grid.Row="1"
Grid.Column="5"
Margin="8,2"
FontSize="14"
Text="{Binding Threshold}" />
<TextBlock
Grid.Row="1"
Grid.Column="6"
Margin="8,2"
FontSize="14"
Text="{Binding RawValue}" />
</Grid>
</DataTemplate>
Expand Down
6 changes: 3 additions & 3 deletions DiskInfo/DiskInfo/Pages/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
IsBackButtonVisible="Collapsed"
IsTabStop="False"
IsTitleBarAutoPaddingEnabled="True"
Loaded="NavigationView_Loaded"
OpenPaneLength="260"
PaneDisplayMode="Left"
PaneDisplayMode="Auto"
SelectionChanged="NavigationView_SelectionChanged">
<NavigationView.Resources>
<Thickness x:Key="NavigationViewContentMargin">0,0,0,0</Thickness>
Expand All @@ -45,7 +44,8 @@
<Frame
x:Name="NavigationViewFrame"
Margin="{x:Bind FrameMargin, Mode=OneWay}"
x:FieldModifier="public" />
x:FieldModifier="public"
CacheSize="0" />
</NavigationView>
<ProgressBar
x:Name="ProgressBar"
Expand Down
12 changes: 5 additions & 7 deletions DiskInfo/DiskInfo/Pages/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.UI.Xaml.Navigation;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using Windows.ApplicationModel.Resources;
Expand Down Expand Up @@ -66,6 +67,9 @@ public MainPage()
ActualThemeChanged += (sender, arg) => ThemeHelper.UpdateSystemCaptionButtonColors();
}
AddNavigationMenuItems();
NavigationViewFrame.Navigated += On_Navigated;
NavigationView.SelectedItem = NavigationView.MenuItems.FirstOrDefault();
NavigationView.PaneDisplayMode = NavigationViewPaneDisplayMode.Auto;
}
#endregion

Expand All @@ -87,13 +91,6 @@ private void AddNavigationMenuItems()

private void OnBackdropTypeChanged(BackdropHelper sender, object args) => RootBackground.Opacity = (BackdropType)args == BackdropType.DefaultColor ? 1 : 0;

private void NavigationView_Loaded(object sender, RoutedEventArgs e)
{
// Add handler for ContentFrame navigation.
NavigationViewFrame.Navigated += On_Navigated;
NavigationView.SelectedItem = NavigationView.MenuItems.FirstOrDefault();
NavigationView.PaneDisplayMode = NavigationViewPaneDisplayMode.Auto;
}
#endregion

#region 导航
Expand Down Expand Up @@ -127,6 +124,7 @@ private void NavigationView_Navigate(string NavItemTag, NavigationTransitionInfo
if (!(_page is null))
{
_ = NavigationViewFrame.Navigate(_page, parameter, TransitionInfo);
Debug.WriteLine($"Switch to page {parameter}");
}
}

Expand Down
10 changes: 6 additions & 4 deletions DiskInfo/DiskInfo/Pages/OverviewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial class OverviewPage : Page, INotifyPropertyChanged
public AtaSmartInfo Info { get; set; }
public List<DiskBasicInfoListItem> List1 { get; set; }
public List<DiskBasicInfoListItem> List2 { get; set; }
public List<DiskSmartInfoListItem> List3 { get; set; }
public List<DiskSmartInfoListItem> ListSMARTInfoDisplay { get; set; }


public static bool IsCelsius { get; set; } = true;
Expand Down Expand Up @@ -61,7 +61,7 @@ public void RefreshData(AtaSmartInfo info)
this.Info = info;
List1 = new List<DiskBasicInfoListItem>();
List2 = new List<DiskBasicInfoListItem>();
List3 = new List<DiskSmartInfoListItem>();

List1.Add(new DiskBasicInfoListItem("\xEEA1", "固件", Info.Firmware));
List1.Add(new DiskBasicInfoListItem("\xEE6F", "序列号", Info.SerialNumber));
List1.Add(new DiskBasicInfoListItem("\xF404", "接口", Info.Interface));
Expand All @@ -75,12 +75,14 @@ public void RefreshData(AtaSmartInfo info)
List1.Add(new DiskBasicInfoListItem("\xE74C", "支持的功能", Info.Features));
List1.Add(new DiskBasicInfoListItem("\xEEA1", "标准", Info.Standard));

ListSMARTInfoDisplay = new List<DiskSmartInfoListItem>();
ListSMARTInfoDisplay.Add(new DiskSmartInfoListItem("ID", "属性名称", "原始值", "临界值", "当前值", "最差值"));
foreach (SmartAttribute item in Info.Attributes)
List3.Add(new DiskSmartInfoListItem(item.Id, item.Name, item.RawValue, item.Threshold));
ListSMARTInfoDisplay.Add(new DiskSmartInfoListItem(item.Id, item.Name, item.RawValue, item.Threshold, item.Current, item.Worst));

OnPropertyChanged("List1");
OnPropertyChanged("List2");
OnPropertyChanged("List3");
OnPropertyChanged("ListSMARTInfoDisplay");
OnPropertyChanged("Info");
}

Expand Down
6 changes: 5 additions & 1 deletion DiskInfo/DiskInfo/ViewModels/DiskSmartInfoListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ namespace DiskInfo.ViewModels
{
public class DiskSmartInfoListItem
{
public DiskSmartInfoListItem(string id, string name, string rawValue, string threshold)
public DiskSmartInfoListItem(string id, string name, string rawValue, string threshold, string current, string worst)
{
Id = id;
Name = name;
RawValue = rawValue;
Threshold = threshold;
Current = current;
Worst = worst;
}

public string Id { get; set; }
public string Name { get; set; }
public string RawValue { get; set; }
public string Threshold { get; set; }
public string Current { get; set; }
public string Worst { get; set; }
}
}

0 comments on commit 884c5b1

Please sign in to comment.