Skip to content

Commit f9f3db8

Browse files
Create State class and make PasteState and AlwaysPresentCommandsState inherit the State class (#1360)
* Create State class and make PasteState and AlwaysPresentCommandsState inherit the State class * Better Chinese translation. * Move PasteState to InteractionViewModel
1 parent 39f8c87 commit f9f3db8

File tree

11 files changed

+26
-85
lines changed

11 files changed

+26
-85
lines changed

Files/App.xaml.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ public App()
7070

7171
RegisterUncaughtExceptionLogger();
7272

73-
Clipboard.ContentChanged += Clipboard_ContentChanged;
74-
Clipboard_ContentChanged(null, null);
75-
7673
#if !DEBUG
7774
AppCenter.Start("682666d1-51d3-4e4a-93d0-d028d43baaa0", typeof(Analytics), typeof(Crashes));
7875
#endif
@@ -183,27 +180,26 @@ public static void Clipboard_ContentChanged(object sender, object e)
183180
&& App.CurrentInstance.CurrentPageType != typeof(YourHome)
184181
&& !App.CurrentInstance.FilesystemViewModel.WorkingDirectory.StartsWith(AppSettings.RecycleBinPath))
185182
{
186-
App.PS.IsEnabled = true;
183+
App.InteractionViewModel.IsPasteEnabled = true;
187184
}
188185
else
189186
{
190-
App.PS.IsEnabled = false;
187+
App.InteractionViewModel.IsPasteEnabled = false;
191188
}
192189
}
193190
else
194191
{
195-
App.PS.IsEnabled = false;
192+
App.InteractionViewModel.IsPasteEnabled = false;
196193
}
197194
}
198195
catch (Exception)
199196
{
200-
App.PS.IsEnabled = false;
197+
App.InteractionViewModel.IsPasteEnabled = false;
201198
}
202199
}
203200

204201
public static Windows.UI.Xaml.UnhandledExceptionEventArgs ExceptionInfo { get; set; }
205202
public static string ExceptionStackTrace { get; set; }
206-
public static PasteState PS { get; set; } = new PasteState();
207203
public static List<string> pathsToDeleteAfterPaste = new List<string>();
208204

209205
/// <summary>

Files/Files.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@
247247
<DependentUpon>InstanceTabsView.xaml</DependentUpon>
248248
</Compile>
249249
<Compile Include="Interacts\Interaction.cs" />
250-
<Compile Include="Interacts\ItemInteractions.cs" />
251250
<Compile Include="IShellPage.cs" />
252251
<Compile Include="LocationsList.cs" />
253252
<Compile Include="Navigation\NavigationActions.cs" />

Files/Interacts/ItemInteractions.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

Files/MultilingualResources/Files.zh-Hans.xlf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</trans-unit>
4141
<trans-unit id="RecentItemOpenFileLocation.Text" translate="yes" xml:space="preserve">
4242
<source>Open file location</source>
43-
<target state="translated">打开文件位置</target>
43+
<target state="translated">打开文件所在的位置</target>
4444
</trans-unit>
4545
<trans-unit id="RecentItemRemove.Text" translate="yes" xml:space="preserve">
4646
<source>Remove this item</source>
@@ -52,7 +52,7 @@
5252
</trans-unit>
5353
<trans-unit id="SettingsAboutAppName.Text" translate="yes" xml:space="preserve">
5454
<source>Files UWP</source>
55-
<target state="translated">通用文件管理器</target>
55+
<target state="translated">文件管理器UWP</target>
5656
</trans-unit>
5757
<trans-unit id="SettingsAboutLicense.Text" translate="yes" xml:space="preserve">
5858
<source>License: </source>
@@ -68,7 +68,7 @@
6868
</trans-unit>
6969
<trans-unit id="SettingsAboutSubmitFeedbackDescription.Text" translate="yes" xml:space="preserve">
7070
<source>Send the developers an issue report with more information</source>
71-
<target state="translated">向开发者报告,并了解更多信息</target>
71+
<target state="translated">向开发者报告问题,并提供更多信息</target>
7272
</trans-unit>
7373
<trans-unit id="SettingsAboutThirdPartyLicenses.Text" translate="yes" xml:space="preserve">
7474
<source>Third Party Licenses</source>
@@ -424,7 +424,7 @@
424424
</trans-unit>
425425
<trans-unit id="WelcomeDialog.Title" translate="yes" xml:space="preserve">
426426
<source>Welcome to Files</source>
427-
<target state="translated">欢迎使用 通用文件管理器</target>
427+
<target state="translated">欢迎使用文件管理器UWP</target>
428428
</trans-unit>
429429
<trans-unit id="WelcomeDialog.PrimaryButtonText" translate="yes" xml:space="preserve">
430430
<source>Grant Permission</source>

Files/Strings/zh-Hans/Resources.resw

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<value>您以前访问过的文件和文件夹将显示在此处</value>
3838
</data>
3939
<data name="RecentItemOpenFileLocation.Text" xml:space="preserve">
40-
<value>打开文件位置</value>
40+
<value>打开文件所在的位置</value>
4141
</data>
4242
<data name="RecentItemRemove.Text" xml:space="preserve">
4343
<value>删除</value>
@@ -46,7 +46,7 @@
4646
<value>最近使用的文件</value>
4747
</data>
4848
<data name="SettingsAboutAppName.Text" xml:space="preserve">
49-
<value>通用文件管理器</value>
49+
<value>文件管理器UWP</value>
5050
</data>
5151
<data name="SettingsAboutLicense.Text" xml:space="preserve">
5252
<value>许可证:</value>
@@ -58,7 +58,7 @@
5858
<value>提交反馈</value>
5959
</data>
6060
<data name="SettingsAboutSubmitFeedbackDescription.Text" xml:space="preserve">
61-
<value>向开发者报告,并了解更多信息</value>
61+
<value>向开发者报告问题,并提供更多信息</value>
6262
</data>
6363
<data name="SettingsAboutThirdPartyLicenses.Text" xml:space="preserve">
6464
<value>第三方许可证</value>
@@ -325,7 +325,7 @@
325325
<value>大小</value>
326326
</data>
327327
<data name="WelcomeDialog.Title" xml:space="preserve">
328-
<value>欢迎使用 通用文件管理器</value>
328+
<value>欢迎使用文件管理器UWP</value>
329329
</data>
330330
<data name="WelcomeDialog.PrimaryButtonText" xml:space="preserve">
331331
<value>授权</value>

Files/UserControls/ModernNavigationToolbar.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@
826826
x:Uid="NavigationToolbarPaste"
827827
x:Load="{x:Bind local1:App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
828828
Click="{x:Bind local1:App.CurrentInstance.InteractionOperations.PasteItem_ClickAsync}"
829-
IsEnabled="{x:Bind local1:App.PS.IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
829+
IsEnabled="{x:Bind local1:App.InteractionViewModel.IsPasteEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
830830
Text="Paste">
831831
<MenuFlyoutItem.Icon>
832832
<FontIcon Glyph="&#xE77F;" />

Files/UserControls/YourHome.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
5757
instanceTabsView.SetSelectedTabInfo(parameters, null);
5858
instanceTabsView.TabStrip_SelectionChanged(null, null);
5959
App.CurrentInstance.NavigationToolbar.CanRefresh = false;
60-
App.PS.IsEnabled = false;
6160
App.CurrentInstance.NavigationToolbar.CanGoBack = App.CurrentInstance.ContentFrame.CanGoBack;
6261
App.CurrentInstance.NavigationToolbar.CanGoForward = App.CurrentInstance.ContentFrame.CanGoForward;
6362
App.CurrentInstance.NavigationToolbar.CanNavigateToParent = false;

Files/View Models/InteractionViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using GalaSoft.MvvmLight;
22
using System;
3-
using Windows.Storage;
43
using Windows.UI.Xaml;
54

65
namespace Files.Controls
@@ -39,6 +38,14 @@ public bool IsSelectedItemImage
3938
set => Set(ref _IsSelectedItemImage, value);
4039
}
4140

41+
private bool _isPasteEnabled = false;
42+
43+
public bool IsPasteEnabled
44+
{
45+
get => _isPasteEnabled;
46+
set => Set(ref _isPasteEnabled, value);
47+
}
48+
4249
public void CheckForImage()
4350
{
4451
//check if the selected item is an image file

Files/Views/InstanceTabsView.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Windows.UI.Xaml.Input;
2020
using Windows.UI.Xaml.Media;
2121
using Windows.UI.Xaml.Navigation;
22+
using Windows.ApplicationModel.DataTransfer;
2223

2324
namespace Files
2425
{
@@ -54,7 +55,8 @@ public InstanceTabsView()
5455
App.ExceptionDialogDisplay = new Dialogs.ExceptionDialog();
5556
// Turn on Navigation Cache
5657
this.NavigationCacheMode = NavigationCacheMode.Enabled;
57-
58+
Clipboard.ContentChanged += App.Clipboard_ContentChanged;
59+
App.Clipboard_ContentChanged(null, null);
5860
Window.Current.SizeChanged += Current_SizeChanged;
5961
Current_SizeChanged(null, null);
6062

Files/Views/LayoutModes/GenericFileBrowser.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
x:Name="PasteEmptySpace"
7777
x:Uid="BaseLayoutContextFlyoutPaste"
7878
Click="{x:Bind local:App.CurrentInstance.InteractionOperations.PasteItem_ClickAsync}"
79-
IsEnabled="{x:Bind local:App.PS.IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
79+
IsEnabled="{x:Bind local:App.InteractionViewModel.IsPasteEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
8080
Text="Paste">
8181
<MenuFlyoutItem.Icon>
8282
<FontIcon Glyph="&#xE77F;" />

0 commit comments

Comments
 (0)