Skip to content

Commit

Permalink
Added ImageResizer page + sidepanel improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
niels9001 committed Mar 31, 2020
1 parent a8805b1 commit 75bc37a
Show file tree
Hide file tree
Showing 16 changed files with 349 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -63,6 +63,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ActivationService.cs" />
<Compile Include="Services\NavigationService.cs" />
<Compile Include="ViewModels\ImageResizerViewModel.cs" />
<Compile Include="ViewModels\GeneralViewModel.cs" />
<Compile Include="ViewModels\FancyZonesViewModel.cs" />
<Compile Include="ViewModels\PowerRenameViewModel.cs" />
Expand All @@ -72,13 +73,16 @@
<Compile Include="Views\GeneralPage.xaml.cs">
<DependentUpon>GeneralPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ImageResizerPage.xaml.cs">
<DependentUpon>ImageResizerPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PowerLauncherPage.xaml.cs">
<DependentUpon>PowerLauncherPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PowerPreviewPage.xaml.cs">
<DependentUpon>PowerPreviewPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\FancyZonesPage.xaml.cs">
<Compile Include="Views\FancyZonesPage.xaml.cs">
<DependentUpon>FancyZonesPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PowerRenamePage.xaml.cs">
Expand Down Expand Up @@ -160,6 +164,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ImageResizerPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\PowerLauncherPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,16 @@
<value>Shortcut Guide</value>
<comment>Navigation view item name for Shortcut Guide</comment>
</data>
<data name="Shell_PowerPreview.Content" xml:space="preserve">
<data name="Shell_PowerPreview.Content" xml:space="preserve">
<value>File Explorer Preview</value>
<comment>File Explorer Preview Settings</comment>
</data>
<comment>Navigation view item name for File Explorer Preview</comment>
</data>
<data name="Shell_FancyZones.Content" xml:space="preserve">
<value>FancyZones</value>
<comment>Navigation view item name for FancyZones</comment>
</data>
<data name="Shell_ImageResizer.Content" xml:space="preserve">
<value>Image Resizer</value>
<comment>Navigation view item name for Image Resizer</comment>
</data>
</root>
11 changes: 9 additions & 2 deletions src/core/Microsoft.PowerToys.Settings.UI/Styles/_Sizes.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@

<!-- Breakpoint for wide layout (side panel next to content) -->
<x:Double x:Key="WideLayoutMinWidth">1100</x:Double>

<!-- Breakpoint for small layout (side panel under content) -->
<x:Double x:Key="SmallLayoutMinWidth">480</x:Double>
</ResourceDictionary>

<!-- Column spacing between content and sidepanel -->
<x:Double x:Key="DefaultColumnSpacing">32</x:Double>

<!-- Row spacing between content and sidepanel (in small mode) -->
<x:Double x:Key="DefaultRowSpacing">32</x:Double>

</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

using Microsoft.PowerToys.Settings.UI.Helpers;

namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class ImageResizerViewModel : Observable
{
public ImageResizerViewModel()
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid ColumnSpacing="32" RowSpacing="32">
<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
Expand Down Expand Up @@ -131,8 +131,8 @@
Style="{StaticResource SettingsGroupTitleStyle}"
Margin="{StaticResource XSmallBottomMargin}"/>

<Image Source="https://user-images.githubusercontent.com/9866362/77859136-f04ae880-7207-11ea-8a7f-4295342fe319.gif" />
<HyperlinkButton Content="Module overview" NavigateUri="https://github.com/microsoft/PowerToys/blob/master/src/modules/fancyzones/README.md"/>
<HyperlinkButton Content="Video demo" NavigateUri="https://www.youtube.com/watch?v=rTtGzZYAXgY"/>
<HyperlinkButton Content="Give feedback"/>

<TextBlock Text="Contributors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid ColumnSpacing="32" RowSpacing="32">
<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
Expand Down Expand Up @@ -88,11 +88,11 @@



<TextBlock Text="Contributors" Style="{StaticResource SettingsGroupTitleStyle}"/>
<!--<TextBlock Text="Contributors" Style="{StaticResource SettingsGroupTitleStyle}"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>-->
</StackPanel>
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
// load run on start up ui settings value and update the ui state.
this.ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
}

ShellPage.ShellHandler.HideContributorsList();
ShellPage.ShellHandler.HideFeatureDetails();
}

/// <summary>
Expand Down
195 changes: 195 additions & 0 deletions src/core/Microsoft.PowerToys.Settings.UI/Views/ImageResizerPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
<Page
x:Class="Microsoft.PowerToys.Settings.UI.Views.ImageResizerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource WideLayoutMinWidth}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="SidePanel.(Grid.Column)" Value="1" />
<Setter Target="SidePanel.(Grid.Row)" Value="0" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="SmallLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource SmallLayoutMinWidth}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="SidePanel.(Grid.Column)" Value="0" />
<Setter Target="SidePanel.(Grid.Row)" Value="1" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock Text="Lets you resize images by right-clicking."
TextWrapping="Wrap"/>

<ToggleSwitch Header="Enable Image Resizer"
IsOn="True"
Margin="{StaticResource SmallTopMargin}" />

<TextBlock Text="Sizes"
Style="{StaticResource SettingsGroupTitleStyle}"/>

<!-- TO DO: Don't know if a listview with these items is the best solution here. Maybe a data grid is better? -->
<!--<ListView Margin="{StaticResource SmallTopMargin}" Padding="-12,0,0,0" SelectionMode="None" ItemsSource="{x:Bind Sizes, Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:ResizeSize">
<StackPanel Orientation="Horizontal" Spacing="4">
<TextBox Text="{x:Bind Title}" Width="68"/>
<ComboBox SelectedIndex="1" Width="88">
<ComboBoxItem>Fill</ComboBoxItem>
<ComboBoxItem>Fit</ComboBoxItem>
<ComboBoxItem>Stretch</ComboBoxItem>
</ComboBox>
<muxc:NumberBox Value="{x:Bind Width}"/>
<TextBlock Text="x" FontWeight="SemiBold" Margin="0,4,0,0"/>
<muxc:NumberBox Value="{x:Bind Height}"/>
<ComboBox SelectedIndex="3">
<ComboBoxItem>Centimeters</ComboBoxItem>
<ComboBoxItem>Inches</ComboBoxItem>
<ComboBoxItem>Percent</ComboBoxItem>
<ComboBoxItem>Pixels</ComboBoxItem>
</ComboBox>
<Button x:Name="RemoveButton" Background="Transparent" Click="RemoveButton_Click">
<Button.Content>
<FontIcon Opacity="0.8" Glyph="&#xE74D;"/>
</Button.Content>
</Button>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>-->

<Button x:Name="AddSizeButton" Content="Add new size" Margin="{StaticResource SmallTopMargin}"/>

<TextBlock Text="Encoding"
Style="{StaticResource SettingsGroupTitleStyle}"/>

<ComboBox Header="Fallback encoder"
SelectedIndex="1"
MinWidth="240"
Margin="{StaticResource SmallTopMargin}">
<ComboBoxItem>BMP Encoder</ComboBoxItem>
<ComboBoxItem>GIF Encoder</ComboBoxItem>
<ComboBoxItem>JPEG Encoder</ComboBoxItem>
<ComboBoxItem>PNG Encoder</ComboBoxItem>
<ComboBoxItem>TIFF Encoder</ComboBoxItem>
<ComboBoxItem>WMPhoto Encoder</ComboBoxItem>
</ComboBox>

<muxc:NumberBox Header="JPEG Quality level"
Minimum="0"
Maximum="100"
Value="90"
MinWidth="240"
SpinButtonPlacementMode="Inline"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}" />

<ComboBox Header="PNG interlacing"
SelectedIndex="0"
MinWidth="240"
Margin="{StaticResource SmallTopMargin}">
<ComboBoxItem>Default</ComboBoxItem>
<ComboBoxItem>On</ComboBoxItem>
<ComboBoxItem>Off</ComboBoxItem>
</ComboBox>

<ComboBox Header="TIFF Compression"
SelectedIndex="0"
MinWidth="240"
Margin="{StaticResource SmallTopMargin}">
<ComboBoxItem>Default</ComboBoxItem>
<ComboBoxItem>None</ComboBoxItem>
<ComboBoxItem>CCITT3</ComboBoxItem>
<ComboBoxItem>CCITT4</ComboBoxItem>
<ComboBoxItem>LZW</ComboBoxItem>
<ComboBoxItem>RLE</ComboBoxItem>
<ComboBoxItem>Zip</ComboBoxItem>
</ComboBox>

<TextBlock Text="File"
Style="{StaticResource SettingsGroupTitleStyle}"/>


<TextBox Header="Filename format"
Text="%1 (%2)"
HorizontalAlignment="Left"
MinWidth="240"
Margin="{StaticResource SmallTopMargin}"/>

<TextBlock Text="The following parameters can be used:"
Margin="{StaticResource SmallTopBottomMargin}"/>

<TextBlock FontSize="12">
<Run FontWeight="Bold">%1</Run>
<Run> - Original filename</Run>
</TextBlock>
<TextBlock FontSize="12">
<Run FontWeight="Bold">%2</Run>
<Run> - Size name</Run>
</TextBlock>
<TextBlock FontSize="12">
<Run FontWeight="Bold">%3</Run>
<Run> - Selected width</Run>
</TextBlock>
<TextBlock FontSize="12">
<Run FontWeight="Bold">%4</Run>
<Run> - Selected height</Run>
</TextBlock>
<TextBlock FontSize="12">
<Run FontWeight="Bold">%5</Run>
<Run> - Actual height</Run>
</TextBlock>
<TextBlock FontSize="12">
<Run FontWeight="Bold">%6</Run>
<Run> - Actual width</Run>
</TextBlock>

<CheckBox Content="Use original date modified"
Margin="{StaticResource SmallTopMargin}"/>
</StackPanel>

<StackPanel x:Name="SidePanel"
Orientation="Vertical"
HorizontalAlignment="Left"
Width="{StaticResource SidePanelWidth}"
Grid.Column="1">

<TextBlock Text="About this feature"
Style="{StaticResource SettingsGroupTitleStyle}"
Margin="{StaticResource XSmallBottomMargin}"/>

<HyperlinkButton Content="Module overview"/>
<HyperlinkButton Content="Give feedback"/>

<TextBlock Text="Contributors"
Style="{StaticResource SettingsGroupTitleStyle}"/>

<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
<HyperlinkButton Content="Contributor name"/>
</StackPanel>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.PowerToys.Settings.UI.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace Microsoft.PowerToys.Settings.UI.Views
{
public sealed partial class ImageResizerPage : Page
{
public ImageResizerViewModel ViewModel { get; } = new ImageResizerViewModel();

public ImageResizerPage()
{
this.InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid ColumnSpacing="32" RowSpacing="32">
<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
Expand Down
Loading

0 comments on commit 75bc37a

Please # to comment.