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

Bugfixes and basic Drag & Drop #33

Open
wants to merge 3 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
24 changes: 21 additions & 3 deletions src/BuildCast/Helpers/TitleBarHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using System;
using System.ComponentModel;
using Windows.ApplicationModel.Core;
using Windows.UI.Xaml;

using Windows.UI.Xaml.Controls;

namespace BuildCast.Helpers
{
public class TitleBarHelper : INotifyPropertyChanged
Expand All @@ -22,6 +24,7 @@ public class TitleBarHelper : INotifyPropertyChanged
private static CoreApplicationViewTitleBar _coreTitleBar;
private Thickness _titlePosition;
private Visibility _titleVisibility;
private int _extraPadding;

/// <summary>
/// Initializes a new instance of the <see cref="TitleBarHelper"/> class.
Expand Down Expand Up @@ -103,7 +106,22 @@ private Thickness CalculateTilebarOffset(double leftPosition, double height)
// top position should be 6 pixels for a 32 pixel high titlebar hence scale by actual height
var correctHeight = height / 32 * 6;

return new Thickness(leftPosition + 12, correctHeight, 0, 0);
}
return new Thickness(leftPosition + 12 + _extraPadding, correctHeight, 0, 0);
}

internal void NavDisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
{
switch (args.DisplayMode)
{
case NavigationViewDisplayMode.Compact:
_extraPadding = 50;
break;
default:
_extraPadding = 0;
break;
}

TitlePosition = CalculateTilebarOffset(_coreTitleBar.SystemOverlayLeftInset, _coreTitleBar.Height);
}
}
}
2 changes: 1 addition & 1 deletion src/BuildCast/Views/NavigationRoot.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Fill="{StaticResource NavigationViewDefaultPaneBackground}"
HorizontalAlignment="Left" Height="1000" Width="48"/>

<RS3:NavigationView IsSettingsVisible="True" x:Name="navview" AlwaysShowHeader="False" ItemInvoked="Navview_ItemInvoked">
<RS3:NavigationView IsSettingsVisible="True" x:Name="navview" AlwaysShowHeader="False" ItemInvoked="Navview_ItemInvoked" DisplayModeChanged="navview_DisplayModeChanged">
<RS3:NavigationView.MenuItems>
<RS3:NavigationViewItem Content="Browse videos" IsSelected="True">
<RS3:NavigationViewItem.Icon>
Expand Down
5 changes: 5 additions & 0 deletions src/BuildCast/Views/NavigationRoot.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,10 @@ public static string ShortDate(DateTime d)
return d.ToString("d");
}
#endregion

private void navview_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
{
TitleBarHelper.Instance.NavDisplayModeChanged(sender, args);
}
}
}
2 changes: 2 additions & 0 deletions src/BuildCast/Views/Notes.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@
ItemClick="NotesListView_Tapped"
IsItemClickEnabled="True"
SelectionMode="None"
CanDragItems="True"
animations:Implicit.ShowAnimations="{StaticResource DefaultListShowAnimations}"
animations:Implicit.HideAnimations="{StaticResource DefaultListHideAnimations}"
DragItemsStarting="notesListView_DragItemsStarting"
>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
Expand Down
30 changes: 25 additions & 5 deletions src/BuildCast/Views/Notes.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
// ******************************************************************

using BuildCast.DataModel;
using BuildCast.Helpers;
using BuildCast.Services.Navigation;
using BuildCast.ViewModels;
using Windows.ApplicationModel.DataTransfer;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Hosting;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;

namespace BuildCast.Views
{
public sealed partial class Notes : Page, IPageWithViewModel<NotesViewModel>
Expand Down Expand Up @@ -168,6 +166,28 @@ private void MenuFlyout_Opening(object sender, object e)
private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
{
ReLoadNotes();
}
}

private async void notesListView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
{
// Set the content of the DataPackage
if (e.Items.Count > 0)
{
var noteParameter = e.Items[0] as dynamic;

if (noteParameter != null)
{
switch (noteParameter.Type)
{
case "Bookmark":
e.Data.SetText($"{noteParameter.Time}\t{noteParameter.Episode}\t{noteParameter.NoteText}\n");
break;
}
}
}

// As we want our Reference list to say intact, we only allow Copy
e.Data.RequestedOperation = DataPackageOperation.Copy;
}
}
}
2 changes: 1 addition & 1 deletion src/BuildCast/Views/PopupPlayer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" x:Name="theGrid">
<Rectangle x:Name="gl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></Rectangle>
<Rectangle SizeChanged="PlayerHolder_SizeChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="playerHolder" Margin="0,0,0,0"></Rectangle>
<Button x:Name="btnexit" Click="Btnexit_LeaveCompactMode" VerticalAlignment="Bottom" HorizontalAlignment="Center">Exit</Button>
<Button x:Name="btnexit" Click="Btnexit_LeaveCompactMode" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10,0,0">Exit</Button>
</Grid>
</Page>