Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Commandbar laylout #5

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions freeRSS/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@
x:Class="freeRSS.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:freeRSS"
xmlns:common="using:freeRSS.Common"
xmlns:controls="using:Microsoft.UI.Xaml.Controls">
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
xmlns:local="using:freeRSS">







<Application.Resources>
<!-- Application-specific resources -->
<!-- Application-specific resources -->
<ResourceDictionary>

<common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<common:DateTimeOffSetStringToDateTime x:Key="StringToDateTimeConverter" />
<common:boolToWidthAllConverter x:Key="BoolToWidthAllConverter" />
<common:BooleanToNullableConverter x:Key="BooleanToNullableConverter"/>
<common:BooleanToNullableConverter x:Key="BooleanToNullableConverter" />

<ResourceDictionary.MergedDictionaries>

<!--


<!--
Styles that define common aspects of the platform look and feel
Required by Visual Studio project and item templates
-->
-->
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<ResourceDictionary Source="/Styles/style.xaml" />

Expand Down
498 changes: 304 additions & 194 deletions freeRSS/MainPage.xaml

Large diffs are not rendered by default.

88 changes: 52 additions & 36 deletions freeRSS/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ public sealed partial class MainPage : Page

private bool IsSeted = false;

private FeedsListItemViewModel _addbutton;
private FeedsListItemViewModel _addbutton = new FeedsListItemViewModel();
private FeedsListItemViewModel _editbutton = new FeedsListItemViewModel();
private FeedsListItemViewModel _oldselected = new FeedsListItemViewModel();


public MainPage()
{
Expand All @@ -56,14 +59,11 @@ public MainPage()
FeedsList.SelectedItem = FeedsList.MenuItems.Count > 0 ? FeedsList.MenuItems[0] : null;
RSS_ArticleListView.SelectedIndex = RSS_ArticleListView.Items.Count > 0 ? 0 : -1;

_addbutton = new FeedsListItemViewModel();
_addbutton.IconElement = new SymbolIcon(Symbol.Add);
_addbutton.Title = "Add Subscription";
var editbutton = new NavigationViewItem();
editbutton.Icon = new SymbolIcon(Symbol.Edit);
editbutton.Tapped += EditFeedButton_Tapped;
editbutton.Content = new TextBlock() { Text = "Edit Subscription" };
FooterItems.Add((FeedsListItemViewModel)editbutton);
_editbutton.IconElement = new SymbolIcon(Symbol.Edit);
_editbutton.Title = "Edit Subscription";
FooterItems.Add(_editbutton);
FooterItems.Add(_addbutton);

foreach(var v in ViewModel.Feeds)
Expand Down Expand Up @@ -156,16 +156,26 @@ private async void FeedsList_ItemClick(Microsoft.UI.Xaml.Controls.NavigationView
{
FeedSetDialog AddFeedDialog = new FeedSetDialog();
await AddFeedDialog.ShowAsync();
FeedsList.SelectedItem = null;
FeedsList.SelectedItem = _oldselected;
}

try
else if(e.SelectedItem == _editbutton)
{
FeedsList.SelectedItem = null;
ViewModel.CurrentFeed = (FeedViewModel)e.SelectedItem;
RSS_ArticleListView.SelectedIndex = RSS_ArticleListView.Items.Count > 0 ? 0 : -1;
EditDialog editDialog = new EditDialog();
await editDialog.ShowAsync();
FeedsList.SelectedItem = _oldselected;
}
catch { }
else
{
_oldselected = (FeedsListItemViewModel)FeedsList.SelectedItem;
try
{
//FeedsList.SelectedItem = null;
ViewModel.CurrentFeed = (FeedViewModel)((FeedsListItemViewModel)e.SelectedItem).InnerObject;
RSS_ArticleListView.SelectedIndex = RSS_ArticleListView.Items.Count > 0 ? 0 : -1;
}
catch { }
}

}

/// <summary>
Expand All @@ -192,33 +202,39 @@ private async void SelectionChangedAsync()
LoadingProgressBar.IsActive = true;
ViewModel.CurrentArticle = (ArticleModel)RSS_ArticleListView.SelectedItem;
ViewModel.CurrentArticle.UnRead = false;
ArticleWebView.Source = ViewModel.CurrentArticle.Description;
ArticleWebView.NavigateToString(ViewModel.CurrentArticle.Description + ((App.Current.RequestedTheme == ApplicationTheme.Dark)? "<style>*{color:white;}</style>":""));
//AppStudio.Uwp.Controls.ParagraphStyle paragraphStyle = new AppStudio.Uwp.Controls.ParagraphStyle();
//paragraphStyle.Margin = new Thickness(0,0,0,10000);
//ArticleWebView.DocumentStyle.Span.Merge(paragraphStyle);
////paragraphStyle.Reset(ArticleWebView);
////ArticleWebView.DocumentStyle.P.Reset(ArticleWebView);
////ArticleWebView.DocumentStyle.P.Merge(paragraphStyle);
// 得在这里改改
//
// by Elipese
// 2023/7/16
//string content = "";
//if (ViewModel.CurrentArticle.Rtf == null)
//{
// Spire.Doc.Document doc = new Spire.Doc.Document();
// StringReader sr = new StringReader(ViewModel.CurrentArticle.Description + ((App.Current.RequestedTheme == ApplicationTheme.Dark) ? "<style>*{color:white;}</style>" : ""));
// doc.LoadHTML(sr, Spire.Doc.Documents.XHTMLValidationType.None);
// MemoryStream ms = new MemoryStream();
// doc.SaveToStream(ms, Spire.Doc.FileFormat.Rtf);
// byte[] data = ms.ToArray();
// sr.Close();
// ms.Close();
// doc.Close();
// content = Encoding.Default.GetString(data);
// ViewModel.CurrentArticle.Rtf = content;
//}
//else
//{
// content = ViewModel.CurrentArticle.Rtf;
//}
//string content = "";
//if (ViewModel.CurrentArticle.Rtf == null)
//{
// Spire.Doc.Document doc = new Spire.Doc.Document();
// StringReader sr = new StringReader(ViewModel.CurrentArticle.Description + ((App.Current.RequestedTheme == ApplicationTheme.Dark) ? "<style>*{color:white;}</style>" : ""));
// doc.LoadHTML(sr, Spire.Doc.Documents.XHTMLValidationType.None);
// MemoryStream ms = new MemoryStream();
// doc.SaveToStream(ms, Spire.Doc.FileFormat.Rtf);
// byte[] data = ms.ToArray();
// sr.Close();
// ms.Close();
// doc.Close();
// content = Encoding.Default.GetString(data);
// ViewModel.CurrentArticle.Rtf = content;
//}
//else
//{
// content = ViewModel.CurrentArticle.Rtf;
//}

// ArticleWebView.TextDocument.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, content);
ArticleWebView.Visibility = Visibility.Visible;
// ArticleWebView.TextDocument.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, content);
ArticleWebView.Visibility = Visibility.Visible;
//ArticleWebView.IsReadOnly = true;
LoadingProgressBar.IsActive = false;
LoadingProgressBar.Visibility = Visibility.Collapsed;
Expand Down
43 changes: 15 additions & 28 deletions freeRSS/View/EditDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ private void Cancel_ButtonClick(ContentDialog sender, ContentDialogButtonClickEv
/// </summary>
private async void DeleteArticlesButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
if (MainPage.Current.ViewModel.CurrentFeed.Id == 0)
{
errorTextBlock.Text = "You can not delete Article in Favourites";
return;
}
await MainPage.Current.ViewModel.CurrentFeed.ClearOutTimeArticlesAsync();
this.Hide();
}
Expand All @@ -92,32 +87,24 @@ private async void DeleteArticlesButton_Click(object sender, Windows.UI.Xaml.Rou
/// </summary>
private async void DeleteFeedButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
if (MainPage.Current.ViewModel.CurrentFeed.Id == 0)
{
errorTextBlock.Text = "You can not delete Favourites";
return;
}
else
{
// 删除
await MainPage.Current.ViewModel.CurrentFeed.RemoveRelatedArticlesAsync();
await MainPage.Current.ViewModel.CurrentFeed.RemoveAFeedAsync();
MainPage.Current.ViewModel.Feeds.Remove(MainPage.Current.ViewModel.CurrentFeed);
// 删除
await MainPage.Current.ViewModel.CurrentFeed.RemoveRelatedArticlesAsync();
await MainPage.Current.ViewModel.CurrentFeed.RemoveAFeedAsync();
MainPage.Current.ViewModel.Feeds.Remove(MainPage.Current.ViewModel.CurrentFeed);

// 重新初始化CurrentFeed 和 CurrentArticle
MainPage.Current.ViewModel.CurrentFeed = MainPage.Current.ViewModel.Feeds.Count == 0 ?
MainPage.Current.ViewModel.StarredFeed :
MainPage.Current.ViewModel.Feeds[0];
// 重新初始化CurrentFeed 和 CurrentArticle
MainPage.Current.ViewModel.CurrentFeed = MainPage.Current.ViewModel.Feeds.Count == 0 ?
MainPage.Current.ViewModel.StarredFeed :
MainPage.Current.ViewModel.Feeds[0];

if(MainPage.Current.ViewModel.CurrentFeed.Articles.Count > 0)
{
MainPage.Current.ViewModel.CurrentArticle = MainPage.Current.ViewModel.CurrentFeed.Articles[0] ?? null;
} else
{
MainPage.Current.ViewModel.CurrentArticle = null;
}
this.Hide();
if(MainPage.Current.ViewModel.CurrentFeed.Articles.Count > 0)
{
MainPage.Current.ViewModel.CurrentArticle = MainPage.Current.ViewModel.CurrentFeed.Articles[0] ?? null;
} else
{
MainPage.Current.ViewModel.CurrentArticle = null;
}
this.Hide();
}
}
}
1 change: 1 addition & 0 deletions freeRSS/ViewModels/FeedViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ public static implicit operator FeedsListItemViewModel(FeedViewModel feedViewMod
flivm.Title = feedViewModel._name;
flivm.SubTitle = feedViewModel._unreadNum.ToString();
flivm.IconElement = new ImageIcon() { Source = feedViewModel._shortcutIcon };
flivm.InnerObject = feedViewModel;
return flivm;
}
//public static explicit operator FeedsListItemViewModel(FeedViewModel feedViewModel)
Expand Down
16 changes: 14 additions & 2 deletions freeRSS/ViewModels/FeedsListItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@ public string SubTitle
}
}

private object _innerobject;
public object InnerObject
{
get { return _innerobject; }
set
{
SetProperty(ref _innerobject, value);
}
}

public static explicit operator FeedsListItemViewModel(Microsoft.UI.Xaml.Controls.NavigationViewItem item)
{
return new FeedsListItemViewModel()
{
Title = (item.Content as TextBlock).Text,
SubTitle = "",
IconElement = item.Icon
IconElement = item.Icon,
InnerObject = item
};
}

Expand All @@ -59,7 +70,8 @@ public static explicit operator FeedsListItemViewModel(NavigationViewItem v)
{
Title = (v.Content as TextBlock).Text,
SubTitle = "",
IconElement = v.Icon
IconElement = v.Icon,
InnerObject = v
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion freeRSS/freeRSS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyName>freeRSS</AssemblyName>
<DefaultLanguage>zh-CN</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22621.0</TargetPlatformVersion>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
Expand Down
4 changes: 2 additions & 2 deletions freeRSS/tile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<image src="Assets\StoreLogo.png"/>
</subgroup>
<subgroup>
<text hint-style="subTltle" hint-wrap="true" hint-maxLines="2">Titles</text>
<text hint-style="captionSubtle">PublishedDate</text>
<text id="1" hint-style="subTltle" hint-wrap="true" hint-maxLines="2">Titles</text>
<text id="2" hint-style="captionSubtle">PublishedDate</text>
</subgroup>
</group>

Expand Down