Skip to content

Commit

Permalink
增加当前订阅进度显示
Browse files Browse the repository at this point in the history
  • Loading branch information
aiqinxuancai committed Sep 15, 2023
1 parent db92981 commit 7a63241
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 24 deletions.
65 changes: 46 additions & 19 deletions WkyFast/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,52 @@
</ui:TitleBar.Header>-->
</ui:TitleBar>

<ui:NavigationStore
Grid.Column="0"
Grid.Row="1"
Frame="{Binding ElementName=MainFrame}"
SelectedPageIndex="0" >
<ui:NavigationStore.Items>
<ui:NavigationItem
Content="任务"
Icon="TextBulletListSquare20"
PageTag="home"
PageType="{x:Type view:WkyTaskListView}" Cursor="Hand" />
<ui:NavigationItem Content="订阅" Icon="AppFolder24" PageTag="subscription" PageType="{x:Type view:WkySubscriptionListView}" Cursor="Hand"/>
<!--<ui:NavigationItem Content="Mail" Icon="Mail24" />-->
</ui:NavigationStore.Items>
<ui:NavigationStore.Footer>
<ui:NavigationItem Content="主页" Icon="Home24" Click="NavigationItem_Home_Click" />
<ui:NavigationItem Content="设置" Icon="Settings24" PageTag="settings" PageType="{x:Type view:WkyFastSettingView}" Cursor="Hand" ></ui:NavigationItem>
</ui:NavigationStore.Footer>
</ui:NavigationStore>
<Grid Grid.Column="0" Grid.Row="1">
<ProgressBar x:Name="subscriptionProgressBar" Visibility="Hidden" Width="40" Height="8" VerticalAlignment="Top" Margin="0,65,0,0"></ProgressBar>

<ui:NavigationStore
Frame="{Binding ElementName=MainFrame}"
SelectedPageIndex="0" >
<ui:NavigationStore.Items>
<ui:NavigationItem
Icon="TextBulletListSquare20"
PageTag="home"
PageType="{x:Type view:WkyTaskListView}" Cursor="Hand" >
<Grid>
<TextBlock Text="任务"></TextBlock>
</Grid>
</ui:NavigationItem>
<ui:NavigationItem PageTag="subscription" PageType="{x:Type view:WkySubscriptionListView}" Cursor="Hand">
<ui:NavigationItem.Icon>

<ui:SymbolRegular>
AppFolder24
</ui:SymbolRegular>


</ui:NavigationItem.Icon>
<Grid>
<TextBlock Text="订阅" HorizontalAlignment="Center"></TextBlock>

</Grid>
</ui:NavigationItem>
<!--<ui:NavigationItem Content="Mail" Icon="Mail24" />-->
</ui:NavigationStore.Items>
<ui:NavigationStore.Footer>
<ui:NavigationItem Icon="Home24" Click="NavigationItem_Home_Click" >
<Grid>
<TextBlock Text="主页"></TextBlock>
</Grid>
</ui:NavigationItem>
<ui:NavigationItem Icon="Settings24" PageTag="settings" PageType="{x:Type view:WkyFastSettingView}" Cursor="Hand" >
<Grid>
<TextBlock Text="设置"></TextBlock>
</Grid>
</ui:NavigationItem>
</ui:NavigationStore.Footer>
</ui:NavigationStore>
</Grid>


<Frame
x:Name="MainFrame"
Expand Down
27 changes: 26 additions & 1 deletion WkyFast/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,39 @@ public MainWindow()
private async void MetroWindow_Loaded(object sender, RoutedEventArgs e)
{
ActionVersion.CheckVersion();

SubscriptionManager.Instance.OnSubscriptionProgressChanged += SubscriptionManager_OnSubscriptionProgressChanged;


VisibilityAnimation.SetAnimationType(WkyLoginDialog, VisibilityAnimation.AnimationType.Fade);
await LoginFunc();

}

private void SubscriptionManager_OnSubscriptionProgressChanged(int now, int max)
{

this.Dispatcher.Invoke(new Action(() =>
{
if (max > 0 && now != max)
{
//进程中
this.subscriptionProgressBar.Visibility = Visibility.Visible;
this.subscriptionProgressBar.Value = now;
this.subscriptionProgressBar.Maximum = max;
}
else
{
this.subscriptionProgressBar.Visibility = Visibility.Hidden;
this.subscriptionProgressBar.Value = 0;
this.subscriptionProgressBar.Maximum = 1;
}
}));


}

/// <summary>
/// 重新登录
/// </summary>
Expand Down
15 changes: 12 additions & 3 deletions WkyFast/Service/SubscriptionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ namespace WkyFast.Service
{
public class SubscriptionManager
{

public event Action<int, int> OnSubscriptionProgressChanged;

private static SubscriptionManager instance = new SubscriptionManager();

public static SubscriptionManager Instance
Expand Down Expand Up @@ -75,6 +76,7 @@ public SubscriptionManager()
{
_tokenSource.Cancel();
}

//private void SubscriptionModel_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
//{
// Save();
Expand Down Expand Up @@ -291,13 +293,20 @@ private async void CheckSubscription()
var copyList = new List<SubscriptionModel>(SubscriptionModel);


foreach (var subscription in copyList)
OnSubscriptionProgressChanged?.Invoke(0, copyList.Count);

for (int i = 0; i < copyList.Count; i++)
{
lock (_look)
{
CheckSubscriptionOne(subscription);
CheckSubscriptionOne(copyList[i]);
}

OnSubscriptionProgressChanged?.Invoke(i, copyList.Count);
}

OnSubscriptionProgressChanged?.Invoke(copyList.Count, copyList.Count);

Subscribing = false;
}

Expand Down
2 changes: 1 addition & 1 deletion WkyFast/WkyFast.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="PropertyChanged.Fody" Version="4.0.3" />
<PackageReference Include="System.ServiceModel.Syndication" Version="6.0.0" />
<PackageReference Include="WPF-UI" Version="2.0.3" />
<PackageReference Include="WPF-UI" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 7a63241

Please sign in to comment.