Skip to content

Commit 9f6b8fa

Browse files
Luke BlevinsLuke Blevins
authored andcommitted
Paste Button Now Changes Enabled Property When Needed
1 parent 65e568b commit 9f6b8fa

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

GenericFileBrowser.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
xmlns:local="using:Files"
2222
xmlns:local1="using:Navigation"
2323
xmlns:local2="using:ItemListPresenter"
24+
xmlns:local3="using:Interact"
2425
Name="GenericItemView"
2526
mc:Ignorable="d" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Auto">
2627

@@ -160,7 +161,7 @@
160161
<TextBlock TextWrapping="WrapWholeWords" VerticalAlignment="Bottom" Text="Add Item" HorizontalAlignment="Center" TextAlignment="Center" Width="60"/>
161162
</StackPanel>
162163
<StackPanel Orientation="Vertical" Margin="2">
163-
<AppBarButton HorizontalAlignment="Center" x:Name="Paste" Style="{ThemeResource AppBarButtonRevealStyle}" Content="&#xE77F;" FontFamily="Segoe MDL2 Assets" FontSize="20" VerticalAlignment="Center" Width="50" Height="50" />
164+
<AppBarButton IsEnabled="{x:Bind local3:Interaction.PS.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" x:Name="Paste" Style="{ThemeResource AppBarButtonRevealStyle}" Content="&#xE77F;" FontFamily="Segoe MDL2 Assets" FontSize="20" VerticalAlignment="Center" Width="50" Height="50" />
164165
<TextBlock TextWrapping="WrapWholeWords" VerticalAlignment="Bottom" Text="Paste" HorizontalAlignment="Center" TextAlignment="Center" Width="60"/>
165166
</StackPanel>
166167
<StackPanel Orientation="Vertical" Margin="2">

GenericFileBrowser.xaml.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,22 @@ public GenericFileBrowser()
6969
Refresh.Click += Navigation.NavigationActions.Refresh_Click;
7070
AllView.DoubleTapped += Interact.Interaction.List_ItemClick;
7171
Paste.Click += Interact.Interaction.PasteItem_ClickAsync;
72+
Clipboard.ContentChanged += Clipboard_ContentChanged;
7273

7374
}
7475

75-
76+
private void Clipboard_ContentChanged(object sender, object e)
77+
{
78+
DataPackageView packageView = Clipboard.GetContent();
79+
if (packageView.Contains(StandardDataFormats.StorageItems))
80+
{
81+
Interact.Interaction.PS.isEnabled = true;
82+
}
83+
else
84+
{
85+
Interact.Interaction.PS.isEnabled = false;
86+
}
87+
}
7688

7789
public static UniversalPath p = new UniversalPath();
7890
public static UniversalPath P { get { return GenericFileBrowser.p; } }

ItemInteractions.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using Windows.UI.Xaml.Media;
3030
using System.Collections.ObjectModel;
3131
using Windows.UI.Xaml.Media.Animation;
32+
using System.ComponentModel;
3233

3334
namespace Interact
3435
{
@@ -37,8 +38,9 @@ namespace Interact
3738

3839
public class Interaction
3940
{
40-
4141

42+
private static PasteState ps = new PasteState();
43+
public static PasteState PS { get { return ps; } }
4244

4345
public static Page page;
4446
public Interaction(Page p)
@@ -452,5 +454,31 @@ private static async void CloneDirectoryAsync(string SourcePath, string Destinat
452454
}
453455
}
454456

457+
public class PasteState : INotifyPropertyChanged
458+
{
459+
public bool _isEnabled;
460+
public bool isEnabled
461+
{
462+
get
463+
{
464+
return _isEnabled;
465+
}
466+
467+
set
468+
{
469+
if (value != _isEnabled)
470+
{
471+
_isEnabled = value;
472+
NotifyPropertyChanged("isEnabled");
473+
}
474+
}
475+
}
476+
public event PropertyChangedEventHandler PropertyChanged;
477+
478+
private void NotifyPropertyChanged(string info)
479+
{
480+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info));
481+
}
482+
}
455483

456484
}

NavigationSystem.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public bool isEnabled
113113
{
114114
_isEnabled = value;
115115
NotifyPropertyChanged("isEnabled");
116-
Debug.WriteLine("NotifyPropertyChanged was called successfully");
117116
}
118117
}
119118
}
@@ -144,7 +143,6 @@ public bool isEnabled
144143
{
145144
_isEnabled = value;
146145
NotifyPropertyChanged("isEnabled");
147-
Debug.WriteLine("NotifyPropertyChanged was called successfully");
148146
}
149147
}
150148
}

0 commit comments

Comments
 (0)