Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZjzMisaka committed Jun 27, 2024
1 parent 56dfce2 commit a8a4b5a
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Powork/Constant/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
public static class Location
{
public const string Temp = "Temp";
public const string Icon = "/Image/icon.ico";
public const string FlashIcon = "/Image/icon_flash.ico";
}
}
10 changes: 10 additions & 0 deletions Powork/Constant/Setting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Powork.Constant
{
public static class Setting
{
public const string Theme = "Theme";
public const string Dark = "Dark";
public const string Light = "Light";
public const string Language = "Language";
}
}
4 changes: 4 additions & 0 deletions Powork/Resources/StringResource.en-US.ui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<sys:String x:Key="Share">Share</sys:String>
<sys:String x:Key="Memo">Memo</sys:String>
<sys:String x:Key="Setting">Setting</sys:String>
<sys:String x:Key="Unknown">Unknown</sys:String>
<sys:String x:Key="MessageFromUser">({0}) Message from {1}</sys:String>
<sys:String x:Key="MessageFromTeam">({0}) Message from team {1}</sys:String>

<!-- MessgaePage -->
<sys:String x:Key="DropHere">DROP HERE</sys:String>
Expand All @@ -27,6 +30,7 @@
<sys:String x:Key="ShareTime">Share time</sys:String>
<sys:String x:Key="CreateTime">Create time</sys:String>
<sys:String x:Key="ModifiedTime">Modified time</sys:String>
<sys:String x:Key="UserSharing">{0}'s Sharing</sys:String>

<!-- SelectUserWindow -->
<sys:String x:Key="SelectUser">Select user</sys:String>
Expand Down
4 changes: 4 additions & 0 deletions Powork/Resources/StringResource.ja-JP.ui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<sys:String x:Key="Share">シェア</sys:String>
<sys:String x:Key="Memo">メモ</sys:String>
<sys:String x:Key="Setting">設定</sys:String>
<sys:String x:Key="Unknown">未知</sys:String>
<sys:String x:Key="MessageFromUser">({0}) {1}からのメッセージ</sys:String>
<sys:String x:Key="MessageFromTeam">({0}) チーム{1}からのメッセージ</sys:String>

<!-- MessgaePage -->
<sys:String x:Key="DropHere">ここにドロップ</sys:String>
Expand All @@ -27,6 +30,7 @@
<sys:String x:Key="ShareTime">共有日時</sys:String>
<sys:String x:Key="CreateTime">作成日時</sys:String>
<sys:String x:Key="ModifiedTime">更新日時</sys:String>
<sys:String x:Key="UserSharing">{0}の共有フォルダ</sys:String>

<!-- SelectUserWindow -->
<sys:String x:Key="SelectUser">ユーザーを選択</sys:String>
Expand Down
4 changes: 4 additions & 0 deletions Powork/Resources/StringResource.zh-CN.ui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<sys:String x:Key="Share">分享</sys:String>
<sys:String x:Key="Memo">笔记</sys:String>
<sys:String x:Key="Setting">设置</sys:String>
<sys:String x:Key="Unknown">未知</sys:String>
<sys:String x:Key="MessageFromUser">({0}) 来自{1}的消息</sys:String>
<sys:String x:Key="MessageFromTeam">({0}) 来自团队{1}的消息</sys:String>

<!-- MessgaePage -->
<sys:String x:Key="DropHere">拖放至此</sys:String>
Expand All @@ -27,6 +30,7 @@
<sys:String x:Key="ShareTime">分享时间</sys:String>
<sys:String x:Key="CreateTime">创建时间</sys:String>
<sys:String x:Key="ModifiedTime">修改时间</sys:String>
<sys:String x:Key="UserSharing">{0}的分享</sys:String>

<!-- SelectUserWindow -->
<sys:String x:Key="SelectUser">选择用户</sys:String>
Expand Down
34 changes: 17 additions & 17 deletions Powork/ViewModel/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,17 @@ public MainWindowViewModel(INavigationService navigationService)

CommonRepository.CreateDatabase();
CommonRepository.CreateTable();
SettingRepository.SetDefault("Theme", "Dark");
SettingRepository.SetDefault("Language", CultureInfo.CurrentUICulture.Name);
SettingRepository.SetDefault(Setting.Theme, Setting.Dark);
SettingRepository.SetDefault(Setting.Language, CultureInfo.CurrentUICulture.Name);

ApplicationThemeManager.Changed += ThemeChanged;

string theme = SettingRepository.SelectSetting("Theme");
if (theme == "Dark")
string theme = SettingRepository.SelectSetting(Setting.Theme);
if (theme == Setting.Dark)
{
SwitchDarkTheme();
}
else if (theme == "Light")
else if (theme == Setting.Light)
{
SwitchLightTheme();
}
Expand Down Expand Up @@ -258,19 +258,19 @@ private void LanguageSelected(string language)
}
}

SettingRepository.UpdateSetting("Language", language);
SettingRepository.UpdateSetting(Setting.Language, language);
}

private void SwitchLightTheme()
{
ApplicationThemeManager.Apply(ApplicationTheme.Light, Wpf.Ui.Controls.WindowBackdropType.Auto, true);
SettingRepository.UpdateSetting("Theme", "Light");
SettingRepository.UpdateSetting(Setting.Theme, Setting.Light);
}

private void SwitchDarkTheme()
{
ApplicationThemeManager.Apply(ApplicationTheme.Dark, Wpf.Ui.Controls.WindowBackdropType.Auto, true);
SettingRepository.UpdateSetting("Theme", "Dark");
SettingRepository.UpdateSetting(Setting.Theme, Setting.Dark);
}

private void ViewOnGithub()
Expand All @@ -288,7 +288,7 @@ private void Exit()

private void WindowLoaded(RoutedEventArgs eventArgs)
{
TrayIcon = "/Image/icon.ico";
TrayIcon = Location.Icon;
ApplicationTitle = "Powork";
OpenNoticeButtonVisibility = Visibility.Collapsed;
DownloadPopupMenuEnable = false;
Expand Down Expand Up @@ -402,7 +402,7 @@ private void WindowLoaded(RoutedEventArgs eventArgs)
{
noticeViewModel = new NoticeViewModel();
noticeViewModel.Count = 1;
noticeViewModel.Notice = $"{noticeViewModel.Count} Message{(noticeViewModel.Count == 1 ? "" : "s")} from Team {teamName}";
noticeViewModel.Notice = string.Format(Application.Current.FindResource("MessageFromTeam").ToString(), noticeViewModel.Count, teamName);
noticeViewModel.TeamMessage = teamMessage;
_noticeInfoDic[teamMessage.TeamID] = noticeViewModel;
Application.Current.Dispatcher.Invoke(() =>
Expand All @@ -419,7 +419,7 @@ private void WindowLoaded(RoutedEventArgs eventArgs)
++noticeViewModel.Count;
Application.Current.Dispatcher.Invoke(() =>
{
noticeViewModel.Notice = $"{noticeViewModel.Count} Message{(noticeViewModel.Count == 1 ? "" : "s")} from Team {teamName}";
noticeViewModel.Notice = string.Format(Application.Current.FindResource("MessageFromTeam").ToString(), teamName);
});
}
}
Expand Down Expand Up @@ -450,7 +450,7 @@ private void WindowLoaded(RoutedEventArgs eventArgs)
{
noticeViewModel = new NoticeViewModel();
noticeViewModel.Count = 1;
noticeViewModel.Notice = $"{noticeViewModel.Count} Message{(noticeViewModel.Count == 1 ? "" : "s")} from {userMessage.SenderName}";
noticeViewModel.Notice = string.Format(Application.Current.FindResource("MessageFromUser").ToString(), userMessage.SenderName);
noticeViewModel.UserMessage = userMessage;
_noticeInfoDic[userMessage.SenderIP + userMessage.SenderName] = noticeViewModel;
Application.Current.Dispatcher.Invoke(() =>
Expand All @@ -464,7 +464,7 @@ private void WindowLoaded(RoutedEventArgs eventArgs)
++noticeViewModel.Count;
Application.Current.Dispatcher.Invoke(() =>
{
noticeViewModel.Notice = $"{noticeViewModel.Count} Message{(noticeViewModel.Count == 1 ? "" : "s")} from {userMessage.SenderName}";
noticeViewModel.Notice = string.Format(Application.Current.FindResource("MessageFromUser").ToString(), userMessage.SenderName);
});
}
}
Expand Down Expand Up @@ -816,18 +816,18 @@ private void StopBlinking()
{
_isBlinking = false;
_blinkTimer.Stop();
TrayIcon = "/Image/icon.ico";
TrayIcon = Location.Icon;
}

private void ToggleIcon()
{
if (TrayIcon == "/Image/icon.ico")
if (TrayIcon == Location.Icon)
{
TrayIcon = "/Image/icon_flash.ico";
TrayIcon = Location.FlashIcon;
}
else
{
TrayIcon = "/Image/icon.ico";
TrayIcon = Location.Icon;
}
}

Expand Down
3 changes: 2 additions & 1 deletion Powork/ViewModel/SharePageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Powork.Model;
using Powork.Repository;
using Powork.ViewModel.Inner;
using Windows.Networking.NetworkOperators;

namespace Powork.ViewModel
{
Expand Down Expand Up @@ -39,7 +40,7 @@ public bool IsSelf
private string _userName;
public string UserName
{
get => _userName + "'s Sharing";
get => string.Format(Application.Current.FindResource("UserSharing").ToString(), _userName);
set => SetProperty<string>(ref _userName, value);
}
public List<ShareInfoViewModel> SelectedItems => ShareInfoList.Where(x => x.IsSelected).ToList();
Expand Down

0 comments on commit a8a4b5a

Please sign in to comment.