Skip to content

Commit

Permalink
Photo Viewer position settings. v1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiNoel-osu committed Dec 19, 2022
1 parent 7e30bf4 commit fbc89e7
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 9 deletions.
19 changes: 19 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="FolderThumbnailExplorer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="FolderThumbnailExplorer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<FolderThumbnailExplorer.Properties.Settings>
Expand All @@ -12,4 +15,20 @@
</setting>
</FolderThumbnailExplorer.Properties.Settings>
</applicationSettings>
<userSettings>
<FolderThumbnailExplorer.Properties.Settings>
<setting name="PV_Width" serializeAs="String">
<value>480</value>
</setting>
<setting name="PV_Height" serializeAs="String">
<value>600</value>
</setting>
<setting name="PV_Left" serializeAs="String">
<value>0</value>
</setting>
<setting name="PV_Top" serializeAs="String">
<value>0</value>
</setting>
</FolderThumbnailExplorer.Properties.Settings>
</userSettings>
</configuration>
2 changes: 1 addition & 1 deletion FolderThumbnailExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
<IsPublishable>False</IsPublishable>
<SignAssembly>False</SignAssembly>
<Version>1.2.2</Version>
<Version>1.2.3</Version>
<Authors>Victor</Authors>
<Copyright>GNU AFFERO GENERAL PUBLIC LICENSE</Copyright>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
Expand Down
20 changes: 20 additions & 0 deletions Localization/Loc.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Localization/Loc.resx
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,12 @@ This flips that.</value>
<data name="PVPopUpSettingsScrViewTT" xml:space="preserve">
<value>By enabling this, Slideshow and Twin-Page viewing option will be ignored.</value>
</data>
<data name="PVPopUpSettingsSavePos" xml:space="preserve">
<value>Save window position &amp; size</value>
</data>
<data name="PVPopUpSettingsSavePosTT" xml:space="preserve">
<value>Save Photo Viewer's position &amp; size so it will be spawned at your desired location.
The setting file is in [%USERPROFILE%\AppData\Local\%USERNAME%].
Right click the button to reset 480*600@(0,0).</value>
</data>
</root>
8 changes: 8 additions & 0 deletions Localization/Loc.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,12 @@ Esc - 关闭图片浏览器.</value>
<data name="PVPopUpSettingsScrViewTT" xml:space="preserve">
<value>开启此项后, 幻灯片和双页浏览设置会被忽略.</value>
</data>
<data name="PVPopUpSettingsSavePos" xml:space="preserve">
<value>保存窗口位置和大小</value>
</data>
<data name="PVPopUpSettingsSavePosTT" xml:space="preserve">
<value>保存图片浏览器的位置和大小以让其在设定的方位打开.
你可以在[%USERPROFILE%\AppData\Local\%USERNAME%]中找到这些设置.
右键按钮可重置为480*600@(0,0).</value>
</data>
</root>
48 changes: 48 additions & 0 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,17 @@
<Setting Name="Locale" Type="System.String" Scope="Application">
<Value Profile="(Default)">zh-CN</Value>
</Setting>
<Setting Name="PV_Width" Type="System.Double" Scope="User">
<Value Profile="(Default)">480</Value>
</Setting>
<Setting Name="PV_Height" Type="System.Double" Scope="User">
<Value Profile="(Default)">600</Value>
</Setting>
<Setting Name="PV_Left" Type="System.Double" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="PV_Top" Type="System.Double" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
59 changes: 59 additions & 0 deletions View/ImageControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,65 @@
Style="{DynamicResource ToggleButtonTemplateStyle}" />
</DockPanel>
<!--#endregion-->
<!--#region Save viewer pos-->
<DockPanel>
<Label Content="{x:Static loc:Loc.PVPopUpSettingsSavePos}"
Foreground="White"
ToolTip="{x:Static loc:Loc.PVPopUpSettingsSavePosTT}">
<Label.Style>
<Style TargetType="{x:Type Label}">
<Style.Triggers>
<DataTrigger Binding="{Binding PosFlag}"
Value="1">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Foreground.(SolidColorBrush.Color)"
From="Lime"
To="White"
Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
<DataTrigger Binding="{Binding PosFlag}"
Value="-1">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Foreground.(SolidColorBrush.Color)"
From="Orange"
To="White"
Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<Button DockPanel.Dock="Right"
Background="Transparent"
Foreground="White"
HorizontalAlignment="Right"
Content="Save"
Height="16"
Width="32"
Margin="5,0"
Padding="0,-1,0,0"
Focusable="False"
Template="{DynamicResource ButtonTemplate1}">
<Button.InputBindings>
<MouseBinding Gesture="LeftClick"
Command="{Binding SavePosCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}, Mode=FindAncestor}}" />
<MouseBinding Gesture="RightClick"
Command="{Binding DefaultPosCommand}" />
</Button.InputBindings>
</Button>
</DockPanel>
<!--#endregion-->
</StackPanel>
</Border>
</Popup>
Expand Down
2 changes: 1 addition & 1 deletion View/ImageControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ private void AOTBtn_Changed(object sender, RoutedEventArgs e)
};
}
#endregion
}
}
}
4 changes: 2 additions & 2 deletions View/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
Command="{Binding MainPageViewModel.AddNewFavCommand}"
CommandParameter="{Binding RelativeSource={x:Static RelativeSource.Self}}">
<Button.Style>
<Style TargetType="Button">
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
Expand Down Expand Up @@ -216,7 +216,7 @@
Foreground="White"
Command="{Binding MainPageViewModel.ReGetContentCommand}">
<Button.Style>
<Style TargetType="Button">
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
Expand Down
11 changes: 8 additions & 3 deletions ViewModel/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public void SubfolderIconClicked(string folderName)
PATHtoShow = PATHtoShow.EndsWith('\\') ? string.Format("{0}{1}", PATHtoShow, folderName) : string.Format("{0}\\{1}", PATHtoShow, folderName);
}

private void ThumbnailMouseUpHandler(object sender, MouseButtonEventArgs e)
private void ThumbnailMouseUpHandler(object sender, MouseButtonEventArgs e) //Open Photo Viewer or advance path.
{
string imageFolder = ((Image)sender).ToolTip.ToString();
if (e.ChangedButton == MouseButton.Left)
Expand All @@ -258,8 +258,13 @@ private void ThumbnailMouseUpHandler(object sender, MouseButtonEventArgs e)
{ //Image found, start Photo Viewer.
string imagePath = ((FileStream)((BitmapImage)((Image)sender).Source).StreamSource).Name;
imagePath = imagePath.Remove(imagePath.LastIndexOf('\\'));
PhotoViewer photoViewer = new PhotoViewer(imagePath);
photoViewer.Left = 0; photoViewer.Top = 0; //Spawns window at top left corner.
PhotoViewer photoViewer = new PhotoViewer(imagePath)
{
Width = Properties.Settings.Default.PV_Width,
Height = Properties.Settings.Default.PV_Height,
Left = Properties.Settings.Default.PV_Left,
Top = Properties.Settings.Default.PV_Top
};
wnds.Add(photoViewer); //Add this to opened windows list to close it when mainwindow closes
photoViewer.Show();
}
Expand Down
28 changes: 26 additions & 2 deletions ViewModel/PhotoViewerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public int Compare(string left, string right)
}
public partial class PhotoViewerViewModel : ObservableObject, IDataErrorInfo
{
private readonly string path;
private bool closing = false;
readonly string path;
bool closing = false;

[ObservableProperty]
ushort _ListSelectedIndex; //Shared between PhotoViewer & ImageControl, and they need to be in the same DataContext.
Expand All @@ -57,6 +57,8 @@ public partial class PhotoViewerViewModel : ObservableObject, IDataErrorInfo
bool _ScrollView = false;
[ObservableProperty]
ObservableCollection<Image> _ScrollImg = new ObservableCollection<Image>();
[ObservableProperty]
sbyte _PosFlag = 0;

public bool DoubleTurn { get; set; } = false;

Expand Down Expand Up @@ -151,6 +153,28 @@ public void LoadScrollView()
});
}
}
[RelayCommand]
public void SavePos(Window wnd)
{
PosFlag = 0;
Properties.Settings.Default.PV_Width = wnd.Width;
Properties.Settings.Default.PV_Height = wnd.Height;
Properties.Settings.Default.PV_Left = wnd.Left;
Properties.Settings.Default.PV_Top = wnd.Top;
Properties.Settings.Default.Save();
PosFlag = 1;
}
[RelayCommand]
public void DefaultPos()
{
PosFlag = 0;
Properties.Settings.Default.PV_Width = 480;
Properties.Settings.Default.PV_Height = 600;
Properties.Settings.Default.PV_Left = 0;
Properties.Settings.Default.PV_Top = 0;
Properties.Settings.Default.Save();
PosFlag = -1;
}

#region IDataErrorInfo members
public string Error => throw new NotImplementedException();
Expand Down

0 comments on commit fbc89e7

Please sign in to comment.