Skip to content

Commit

Permalink
Improve UI scaling in smaller window sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
d2dyno1 committed Jun 23, 2021
1 parent acbe485 commit daa5c48
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 33 deletions.
4 changes: 2 additions & 2 deletions ClipboardCanvas/Dialogs/FileSystemAccessDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
mc:Ignorable="d">

<StackPanel Spacing="24">
<TextBlock Text="Clipboard Canvas requires permission to access the file system to be able to save items to Collections anywhere on the drive." TextWrapping="WrapWholeWords" />
<TextBlock Text="Clipboard Canvas requires permission to access the file system to be able to save items to Collections anywhere on your drive." TextWrapping="WrapWholeWords" />

<StackPanel>
<TextBlock Text="You can grant this permission by heading to settings, after which the app will be closed." TextWrapping="WrapWholeWords" />
<TextBlock Text="You can grant this permission by heading to settings, whereupon the app will be closed." TextWrapping="WrapWholeWords" />
<HyperlinkButton
Padding="0,4,0,4"
Command="{x:Bind ViewModel.OpenSettingsCommand}"
Expand Down
13 changes: 11 additions & 2 deletions ClipboardCanvas/Helpers/CollectionsHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Collections.Generic;
using ClipboardCanvas.ViewModels.UserControls;

namespace ClipboardCanvas.Helpers
Expand All @@ -19,7 +19,16 @@ public static void UpdateLastSelectedCollectionSetting(CollectionsContainerViewM

public static void UpdateSavedCollectionLocationsSetting()
{
App.AppSettings.CollectionLocationsSettings.SavedCollectionLocations = CollectionsControlViewModel.Items.Where((item) => !item.isDefault).Select((item) => item.CollectionFolderPath).ToList();
List<string> paths = new List<string>();
foreach (var item in CollectionsControlViewModel.Items)
{
if (!item.isDefault)
{
paths.Add(item.CollectionFolderPath);
}
}

App.AppSettings.CollectionLocationsSettings.SavedCollectionLocations = paths;
}
}
}
10 changes: 5 additions & 5 deletions ClipboardCanvas/Helpers/Filesystem/StorageHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using ClipboardCanvas.Helpers.SafetyHelpers;
using ClipboardCanvas.UnsafeNative;
using System;
using System;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.FileProperties;

using ClipboardCanvas.Enums;
using static ClipboardCanvas.UnsafeNative.UnsafeNativeDataModels;
using ClipboardCanvas.Helpers.SafetyHelpers;
using ClipboardCanvas.UnsafeNative;

namespace ClipboardCanvas.Helpers.Filesystem
{
Expand All @@ -29,7 +29,7 @@ public static async Task<SafeWrapper<TOut>> ToStorageItemWithError<TOut>(string
// Check if path is to .lnk or .url file
if (path.ToLower().EndsWith(".lnk") || path.ToLower().EndsWith(".url"))
{
throw new UnauthorizedAccessException("Function ToStorageItem<TOut>() does not support converting from .lnk nor .url files.");
return new SafeWrapper<TOut>(default, OperationErrorCode.InvalidOperation, new InvalidOperationException(), "Function ToStorageItem<TOut>() does not support converting from .lnk nor .url files.");
}

// Check if exists
Expand Down
2 changes: 1 addition & 1 deletion ClipboardCanvas/Models/ICollectionsContainerModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public interface ICollectionsContainerModel
/// <summary>
/// Checks whether can open collection and updates UI and <see cref="CanOpenCollection"/> if necessary
/// </summary>
void CheckCollectionAvailability();
bool CheckCollectionAvailability();

/// <summary>
/// Sets index of currently selected canvas
Expand Down
19 changes: 12 additions & 7 deletions ClipboardCanvas/Pages/CanvasPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,21 @@
</Grid.RowDefinitions>

<!-- Title text -->
<TextBlock
x:Name="TitleText"
Grid.Row="0"
<Viewbox
x:Name="TitleTextViewBox"
MaxWidth="680"
MaxHeight="150"
HorizontalAlignment="Center"
VerticalAlignment="Center"
x:Load="{x:Bind ViewModel.TitleTextLoad, Mode=OneWay}"
AllowDrop="True"
FontSize="32"
FontWeight="Bold"
Text="{x:Bind ViewModel.TitleText, Mode=OneWay}" />
StretchDirection="Both">
<Grid Padding="20">
<TextBlock
AllowDrop="True"
FontWeight="Bold"
Text="{x:Bind ViewModel.TitleText, Mode=OneWay}" />
</Grid>
</Viewbox>

<!-- Content Loading progress ring -->
<ProgressRing
Expand Down
10 changes: 5 additions & 5 deletions ClipboardCanvas/UserControls/NavigationToolBarControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
<ResourceDictionary x:Key="Dark">
<AcrylicBrush
x:Key="NavigationBarBackground"
Windows10version1903:TintLuminosityOpacity="0.30"
Windows10version1903:TintLuminosityOpacity="0.40"
BackgroundSource="HostBackdrop"
FallbackColor="{ThemeResource SolidBackgroundAcrylic}"
TintColor="{ThemeResource SolidBackgroundAcrylic}"
TintOpacity="0.30" />
TintOpacity="0.40" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
Expand All @@ -50,7 +50,7 @@
<!-- Toolbar size modes -->

<!-- Medium size mode -->
<DataTemplate x:Key="ToolBar_Medium_SizeMode" x:DataType="vm:NavigationToolBarControlViewModel">
<DataTemplate x:Key="ToolBar_Small_SizeMode" x:DataType="vm:NavigationToolBarControlViewModel">
<Border>
<!-- Navigation -->
<uc:NavigationControl
Expand Down Expand Up @@ -126,7 +126,7 @@
<AdaptiveTrigger MinWindowWidth="{StaticResource MediumWindowThreshold}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MainContentPresenter.ContentTemplate" Value="{StaticResource ToolBar_Medium_SizeMode}" />
<Setter Target="MainContentPresenter.ContentTemplate" Value="{StaticResource ToolBar_Large_SizeMode}" />
</VisualState.Setters>
</VisualState>
<!-- Small window -->
Expand All @@ -135,7 +135,7 @@
<AdaptiveTrigger MinWindowWidth="{StaticResource SmallWindowThreshold}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MainContentPresenter.ContentTemplate" Value="{StaticResource ToolBar_Medium_SizeMode}" />
<Setter Target="MainContentPresenter.ContentTemplate" Value="{StaticResource ToolBar_Small_SizeMode}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
Expand Down
24 changes: 17 additions & 7 deletions ClipboardCanvas/UserControls/WindowTitleBarControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
d:DesignWidth="400"
mc:Ignorable="d">

<Grid x:Name="CustomTitleBar" Padding="15,0,15,0">
<Grid
x:Name="CustomTitleBar"
Padding="15,0,15,0"
HorizontalAlignment="Stretch"
ColumnSpacing="8">

<Grid.ColumnDefinitions>
<!-- Title text -->
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<!-- Restricted Access -->
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<!-- Compact overlay -->
<ColumnDefinition />
</Grid.ColumnDefinitions>
Expand All @@ -40,14 +44,17 @@
<Grid
Grid.Column="0"
Padding="0,8,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Canvas.ZIndex="1">
<TextBlock
x:Name="StandardTitleBar"
VerticalAlignment="Center"
x:Load="{x:Bind ViewModel.StandardTitleBarLoad, Mode=OneWay}"
FontSize="16"
FontWeight="SemiLight"
Text="{x:Bind ViewModel.StandardTitleBarText, Mode=OneWay}" />
Text="{x:Bind ViewModel.StandardTitleBarText, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />

<StackPanel
x:Name="TwoSideTitleBar"
Expand All @@ -65,14 +72,16 @@
VerticalAlignment="Center"
FontSize="16"
FontWeight="SemiBold"
Text="{x:Bind ViewModel.TitleBarSecondSideText, Mode=OneWay}" />
Text="{x:Bind ViewModel.TitleBarSecondSideText, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
</StackPanel>
</Grid>

<!-- Restricted Access title text -->
<TextBlock
x:Name="RestrictedAccess"
Grid.Column="1"
Grid.Column="0"
Grid.ColumnSpan="3"
Padding="0,8,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Expand All @@ -95,7 +104,8 @@
HorizontalAlignment="Left"
x:Load="{x:Bind ViewModel.ShowTitleUnderline, Mode=OneWay}"
BorderBrush="{ThemeResource TitleBarSeparatorColor}"
BorderThickness="0,0,0,0.5" />
BorderThickness="0,0,0,0.5"
Canvas.ZIndex="1" />

<!-- TODO: For now the button is hidden -->
<!-- Compact overlay button -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private async Task EditBoxLostFocus(RoutedEventArgs e)

#region ICollectionContainerModel

public void CheckCollectionAvailability()
public bool CheckCollectionAvailability()
{
if (App.IsInRestrictedAccessMode && !isDefault)
{
Expand All @@ -290,11 +290,14 @@ public void CheckCollectionAvailability()
else if (StorageHelpers.Exists(CollectionFolderPath))
{
SetCollectionError(SafeWrapperResult.S_SUCCESS);
return true;
}
else
{
SetCollectionError(s_CollectionFolderNotFound);
}

return false;
}

public void DangerousSetIndex(int newIndex)
Expand Down Expand Up @@ -584,7 +587,12 @@ public async Task<bool> InitializeItems()

public async Task<bool> InitializeInnerStorageFolder()
{
if (_innerStorageFolder != null && StorageHelpers.Exists(_innerStorageFolder?.Path))
if (!CheckCollectionAvailability())
{
return false;
}

if (_innerStorageFolder != null)
{
// Make sure to update the state if collection path was repaired
SetCollectionError(SafeWrapperResult.S_SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public static void RemoveCollection(CollectionsContainerViewModel container)

public static async Task<bool> AddCollection(CollectionsContainerViewModel container, bool suppressSettingsUpdate = false)
{
if (Items.Any((item) => item.DangerousGetCollectionFolder()?.Path == container.DangerousGetCollectionFolder()?.Path))
if (Items.Any((item) => item.DangerousGetCollectionFolder()?.Path == container.CollectionFolderPath))
{
return false;
}
Expand All @@ -390,7 +390,7 @@ public static async Task<bool> AddCollection(CollectionsContainerViewModel conta
{
CollectionsHelpers.UpdateSavedCollectionLocationsSetting();
}

return true;
}

Expand Down

0 comments on commit daa5c48

Please sign in to comment.