Skip to content

Commit daa5c48

Browse files
committed
Improve UI scaling in smaller window sizes
1 parent acbe485 commit daa5c48

9 files changed

+65
-33
lines changed

ClipboardCanvas/Dialogs/FileSystemAccessDialog.xaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
mc:Ignorable="d">
1313

1414
<StackPanel Spacing="24">
15-
<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" />
15+
<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" />
1616

1717
<StackPanel>
18-
<TextBlock Text="You can grant this permission by heading to settings, after which the app will be closed." TextWrapping="WrapWholeWords" />
18+
<TextBlock Text="You can grant this permission by heading to settings, whereupon the app will be closed." TextWrapping="WrapWholeWords" />
1919
<HyperlinkButton
2020
Padding="0,4,0,4"
2121
Command="{x:Bind ViewModel.OpenSettingsCommand}"

ClipboardCanvas/Helpers/CollectionsHelpers.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Linq;
1+
using System.Collections.Generic;
22
using ClipboardCanvas.ViewModels.UserControls;
33

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

2020
public static void UpdateSavedCollectionLocationsSetting()
2121
{
22-
App.AppSettings.CollectionLocationsSettings.SavedCollectionLocations = CollectionsControlViewModel.Items.Where((item) => !item.isDefault).Select((item) => item.CollectionFolderPath).ToList();
22+
List<string> paths = new List<string>();
23+
foreach (var item in CollectionsControlViewModel.Items)
24+
{
25+
if (!item.isDefault)
26+
{
27+
paths.Add(item.CollectionFolderPath);
28+
}
29+
}
30+
31+
App.AppSettings.CollectionLocationsSettings.SavedCollectionLocations = paths;
2332
}
2433
}
2534
}

ClipboardCanvas/Helpers/Filesystem/StorageHelpers.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using ClipboardCanvas.Helpers.SafetyHelpers;
2-
using ClipboardCanvas.UnsafeNative;
3-
using System;
1+
using System;
42
using System.Threading.Tasks;
53
using Windows.Storage;
64
using Windows.Storage.FileProperties;
5+
76
using ClipboardCanvas.Enums;
8-
using static ClipboardCanvas.UnsafeNative.UnsafeNativeDataModels;
7+
using ClipboardCanvas.Helpers.SafetyHelpers;
8+
using ClipboardCanvas.UnsafeNative;
99

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

3535
// Check if exists

ClipboardCanvas/Models/ICollectionsContainerModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public interface ICollectionsContainerModel
4343
/// <summary>
4444
/// Checks whether can open collection and updates UI and <see cref="CanOpenCollection"/> if necessary
4545
/// </summary>
46-
void CheckCollectionAvailability();
46+
bool CheckCollectionAvailability();
4747

4848
/// <summary>
4949
/// Sets index of currently selected canvas

ClipboardCanvas/Pages/CanvasPage.xaml

+12-7
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,21 @@
8383
</Grid.RowDefinitions>
8484

8585
<!-- Title text -->
86-
<TextBlock
87-
x:Name="TitleText"
88-
Grid.Row="0"
86+
<Viewbox
87+
x:Name="TitleTextViewBox"
88+
MaxWidth="680"
89+
MaxHeight="150"
8990
HorizontalAlignment="Center"
9091
VerticalAlignment="Center"
9192
x:Load="{x:Bind ViewModel.TitleTextLoad, Mode=OneWay}"
92-
AllowDrop="True"
93-
FontSize="32"
94-
FontWeight="Bold"
95-
Text="{x:Bind ViewModel.TitleText, Mode=OneWay}" />
93+
StretchDirection="Both">
94+
<Grid Padding="20">
95+
<TextBlock
96+
AllowDrop="True"
97+
FontWeight="Bold"
98+
Text="{x:Bind ViewModel.TitleText, Mode=OneWay}" />
99+
</Grid>
100+
</Viewbox>
96101

97102
<!-- Content Loading progress ring -->
98103
<ProgressRing

ClipboardCanvas/UserControls/NavigationToolBarControl.xaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
<ResourceDictionary x:Key="Dark">
3838
<AcrylicBrush
3939
x:Key="NavigationBarBackground"
40-
Windows10version1903:TintLuminosityOpacity="0.30"
40+
Windows10version1903:TintLuminosityOpacity="0.40"
4141
BackgroundSource="HostBackdrop"
4242
FallbackColor="{ThemeResource SolidBackgroundAcrylic}"
4343
TintColor="{ThemeResource SolidBackgroundAcrylic}"
44-
TintOpacity="0.30" />
44+
TintOpacity="0.40" />
4545
</ResourceDictionary>
4646
</ResourceDictionary.ThemeDictionaries>
4747
</ResourceDictionary>
@@ -50,7 +50,7 @@
5050
<!-- Toolbar size modes -->
5151

5252
<!-- Medium size mode -->
53-
<DataTemplate x:Key="ToolBar_Medium_SizeMode" x:DataType="vm:NavigationToolBarControlViewModel">
53+
<DataTemplate x:Key="ToolBar_Small_SizeMode" x:DataType="vm:NavigationToolBarControlViewModel">
5454
<Border>
5555
<!-- Navigation -->
5656
<uc:NavigationControl
@@ -126,7 +126,7 @@
126126
<AdaptiveTrigger MinWindowWidth="{StaticResource MediumWindowThreshold}" />
127127
</VisualState.StateTriggers>
128128
<VisualState.Setters>
129-
<Setter Target="MainContentPresenter.ContentTemplate" Value="{StaticResource ToolBar_Medium_SizeMode}" />
129+
<Setter Target="MainContentPresenter.ContentTemplate" Value="{StaticResource ToolBar_Large_SizeMode}" />
130130
</VisualState.Setters>
131131
</VisualState>
132132
<!-- Small window -->
@@ -135,7 +135,7 @@
135135
<AdaptiveTrigger MinWindowWidth="{StaticResource SmallWindowThreshold}" />
136136
</VisualState.StateTriggers>
137137
<VisualState.Setters>
138-
<Setter Target="MainContentPresenter.ContentTemplate" Value="{StaticResource ToolBar_Medium_SizeMode}" />
138+
<Setter Target="MainContentPresenter.ContentTemplate" Value="{StaticResource ToolBar_Small_SizeMode}" />
139139
</VisualState.Setters>
140140
</VisualState>
141141
</VisualStateGroup>

ClipboardCanvas/UserControls/WindowTitleBarControl.xaml

+17-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
d:DesignWidth="400"
1010
mc:Ignorable="d">
1111

12-
<Grid x:Name="CustomTitleBar" Padding="15,0,15,0">
12+
<Grid
13+
x:Name="CustomTitleBar"
14+
Padding="15,0,15,0"
15+
HorizontalAlignment="Stretch"
16+
ColumnSpacing="8">
1317

1418
<Grid.ColumnDefinitions>
1519
<!-- Title text -->
16-
<ColumnDefinition />
20+
<ColumnDefinition Width="Auto" />
1721
<!-- Restricted Access -->
18-
<ColumnDefinition />
22+
<ColumnDefinition Width="Auto" />
1923
<!-- Compact overlay -->
2024
<ColumnDefinition />
2125
</Grid.ColumnDefinitions>
@@ -40,14 +44,17 @@
4044
<Grid
4145
Grid.Column="0"
4246
Padding="0,8,0,0"
47+
HorizontalAlignment="Left"
48+
VerticalAlignment="Center"
4349
Canvas.ZIndex="1">
4450
<TextBlock
4551
x:Name="StandardTitleBar"
4652
VerticalAlignment="Center"
4753
x:Load="{x:Bind ViewModel.StandardTitleBarLoad, Mode=OneWay}"
4854
FontSize="16"
4955
FontWeight="SemiLight"
50-
Text="{x:Bind ViewModel.StandardTitleBarText, Mode=OneWay}" />
56+
Text="{x:Bind ViewModel.StandardTitleBarText, Mode=OneWay}"
57+
TextTrimming="CharacterEllipsis" />
5158

5259
<StackPanel
5360
x:Name="TwoSideTitleBar"
@@ -65,14 +72,16 @@
6572
VerticalAlignment="Center"
6673
FontSize="16"
6774
FontWeight="SemiBold"
68-
Text="{x:Bind ViewModel.TitleBarSecondSideText, Mode=OneWay}" />
75+
Text="{x:Bind ViewModel.TitleBarSecondSideText, Mode=OneWay}"
76+
TextTrimming="CharacterEllipsis" />
6977
</StackPanel>
7078
</Grid>
7179

7280
<!-- Restricted Access title text -->
7381
<TextBlock
7482
x:Name="RestrictedAccess"
75-
Grid.Column="1"
83+
Grid.Column="0"
84+
Grid.ColumnSpan="3"
7685
Padding="0,8,0,0"
7786
HorizontalAlignment="Center"
7887
VerticalAlignment="Center"
@@ -95,7 +104,8 @@
95104
HorizontalAlignment="Left"
96105
x:Load="{x:Bind ViewModel.ShowTitleUnderline, Mode=OneWay}"
97106
BorderBrush="{ThemeResource TitleBarSeparatorColor}"
98-
BorderThickness="0,0,0,0.5" />
107+
BorderThickness="0,0,0,0.5"
108+
Canvas.ZIndex="1" />
99109

100110
<!-- TODO: For now the button is hidden -->
101111
<!-- Compact overlay button -->

ClipboardCanvas/ViewModels/UserControls/CollectionsContainerViewModel.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private async Task EditBoxLostFocus(RoutedEventArgs e)
281281

282282
#region ICollectionContainerModel
283283

284-
public void CheckCollectionAvailability()
284+
public bool CheckCollectionAvailability()
285285
{
286286
if (App.IsInRestrictedAccessMode && !isDefault)
287287
{
@@ -290,11 +290,14 @@ public void CheckCollectionAvailability()
290290
else if (StorageHelpers.Exists(CollectionFolderPath))
291291
{
292292
SetCollectionError(SafeWrapperResult.S_SUCCESS);
293+
return true;
293294
}
294295
else
295296
{
296297
SetCollectionError(s_CollectionFolderNotFound);
297298
}
299+
300+
return false;
298301
}
299302

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

585588
public async Task<bool> InitializeInnerStorageFolder()
586589
{
587-
if (_innerStorageFolder != null && StorageHelpers.Exists(_innerStorageFolder?.Path))
590+
if (!CheckCollectionAvailability())
591+
{
592+
return false;
593+
}
594+
595+
if (_innerStorageFolder != null)
588596
{
589597
// Make sure to update the state if collection path was repaired
590598
SetCollectionError(SafeWrapperResult.S_SUCCESS);

ClipboardCanvas/ViewModels/UserControls/CollectionsControlViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public static void RemoveCollection(CollectionsContainerViewModel container)
364364

365365
public static async Task<bool> AddCollection(CollectionsContainerViewModel container, bool suppressSettingsUpdate = false)
366366
{
367-
if (Items.Any((item) => item.DangerousGetCollectionFolder()?.Path == container.DangerousGetCollectionFolder()?.Path))
367+
if (Items.Any((item) => item.DangerousGetCollectionFolder()?.Path == container.CollectionFolderPath))
368368
{
369369
return false;
370370
}
@@ -390,7 +390,7 @@ public static async Task<bool> AddCollection(CollectionsContainerViewModel conta
390390
{
391391
CollectionsHelpers.UpdateSavedCollectionLocationsSetting();
392392
}
393-
393+
394394
return true;
395395
}
396396

0 commit comments

Comments
 (0)