Skip to content

Commit

Permalink
Misc Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Aug 28, 2019
1 parent 0923192 commit 98657b0
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 51 deletions.
2 changes: 1 addition & 1 deletion PicView/Configs/Styles/Menu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Border BorderBrush="{StaticResource BorderBrushAlt}" BorderThickness="2" />
<Border BorderBrush="#FF2B2727" BorderThickness="2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
47 changes: 32 additions & 15 deletions PicView/File Logic/Copy_Paste.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,41 @@ internal static void Paste()
{
var files = Clipboard.GetFileDropList().Cast<string>().ToArray();

if (!string.IsNullOrWhiteSpace(PicPath) &&
Path.GetDirectoryName(files[0]) == Path.GetDirectoryName(PicPath))
Pic(Pics.IndexOf(files[0]));
else
Pic(files[0]);

if (files.Length > 0)
if (files != null)
{
Parallel.For(1, files.Length, x =>
if (files.Length >= 1)
{
var myProcess = new Process
var x = files[0];

// If from same folder
if (!string.IsNullOrWhiteSpace(PicPath) && Path.GetDirectoryName(x) == Path.GetDirectoryName(PicPath))
{
StartInfo = { FileName = Assembly.GetExecutingAssembly().Location, Arguments = files[x] }
};
myProcess.Start();
});
if (!Preloader.Contains(x))
{
PreloadCount = 4;
Preloader.Add(x);
}

Pic(Pics.IndexOf(x));
}
else
Pic(x);

if (files.Length > 1)
{
for (int i = 1; i < files.Length; i++)
{
using (var n = new Process ())
{
n.StartInfo.FileName = Assembly.GetExecutingAssembly().Location;
n.StartInfo.Arguments = files[i];
n.Start();
}
}
}
}
return;
}

return;
}

// Clipboard Image
Expand Down Expand Up @@ -152,6 +168,7 @@ internal static void Cut(string path)
Clipboard.Clear();
Clipboard.SetDataObject(data, true);

// Force Preloader to add new images, to minimize slowdown errors
PreloadCount = 4;

ToolTipStyle("Added Image to move clipboard");
Expand Down
22 changes: 11 additions & 11 deletions PicView/Image Logic/Resize_and_Zoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,17 @@ internal static void Zoom(int i, bool zoomMode)
internal static void ZoomFit(double width, double height)
{
double maxWidth, maxHeight;
var interfaceHeight = 85; /// TopBar + mainWindow.LowerBar height + extra padding
var interfaceHeight = 90; /// TopBar + mainWindow.LowerBar height + extra padding

if (FitToWindow)
{
/// Get max width and height, based on user's screen
// Get max width and height, based on user's screen
if (Properties.Settings.Default.ShowInterface)
{
maxWidth = Math.Min(MonitorInfo.Width - ComfySpace, width);
maxHeight = Math.Min((MonitorInfo.Height - interfaceHeight), height);
}
/// - 2 for window border
// - 2 for window border
else
{
maxWidth = Math.Min(MonitorInfo.Width - 2, width - 2);
Expand All @@ -301,7 +301,7 @@ internal static void ZoomFit(double width, double height)
}
else
{
/// Get max width and height, based on window size
// Get max width and height, based on window size
maxWidth = Math.Min(mainWindow.Width, width);

if (Properties.Settings.Default.ShowInterface)
Expand All @@ -314,26 +314,26 @@ internal static void ZoomFit(double width, double height)

if (IsScrollEnabled)
{
/// Calculate height based on width
// Calculate height based on width
mainWindow.img.Width = maxWidth;
mainWindow.img.Height = maxWidth * height / width;

/// Set mainWindow.Scroller height to aspect ratio calculation
// Set mainWindow.Scroller height to aspect ratio calculation
mainWindow.Scroller.Height = (height * AspectRatio);

/// Update values
// Update values
xWidth = mainWindow.img.Width;
xHeight = mainWindow.Scroller.Height;
}
else
{
/// Reset mainWindow.Scroller's height to auto
// Reset mainWindow.Scroller's height to auto
mainWindow.Scroller.Height = double.NaN;

/// Fit image by aspect ratio calculation
/// and update values
mainWindow.img.Height = xHeight = (height * AspectRatio);
// Fit image by aspect ratio calculation
// and update values
mainWindow.img.Width = xWidth = (width * AspectRatio);
mainWindow.img.Height = xHeight = (height * AspectRatio);
}

if (FitToWindow)
Expand Down
1 change: 0 additions & 1 deletion PicView/Image Logic/Rotate_and_Flip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace PicView
{
internal static class Rotate_and_Flip
{
// Rotate and flip
/// <summary>
/// Rotates the image the specified degrees and updates imageSettingsMenu value
/// </summary>
Expand Down
28 changes: 24 additions & 4 deletions PicView/Interface Logic/Instantiate/ContextMenus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ internal static class ContextMenus
{
internal static void AddContextMenus()
{
#region Add ContextMenus

// Add main contextmenu
cm = new ContextMenu();
var scbf = (SolidColorBrush)Application.Current.Resources["MainColorFadedBrush"];
Expand Down Expand Up @@ -247,6 +245,14 @@ internal static void AddContextMenus()
{
Header = "Setings"
};
var settingscmIcon = new System.Windows.Shapes.Path
{
Data = Geometry.Parse(SVGiconWrench),
Stretch = Stretch.Fill
};
settingscmIcon.Width = settingscmIcon.Height = 12;
settingscmIcon.Fill = scbf;
settingscm.Icon = settingscmIcon;
cm.Items.Add(settingscm);

///////////////////////////
Expand Down Expand Up @@ -337,6 +343,14 @@ internal static void AddContextMenus()
InputGestureText = "F3",
ToolTip = "Opens the current image on your drive"
};
var lcdcmIcon = new System.Windows.Shapes.Path
{
Data = Geometry.Parse(SVGiconSearch),
Stretch = Stretch.Fill
};
lcdcmIcon.Width = lcdcmIcon.Height = 12;
lcdcmIcon.Fill = scbf;
lcdcm.Icon = lcdcmIcon;
lcdcm.Click += (s, x) => Open_In_Explorer();
cm.Items.Add(lcdcm);

Expand All @@ -351,6 +365,14 @@ internal static void AddContextMenus()
Header = "File Details",
InputGestureText = "Ctrl + I"
};
var fildecmIcon = new System.Windows.Shapes.Path
{
Data = Geometry.Parse(SVGiconPaperDetails),
Stretch = Stretch.Fill
};
fildecmIcon.Width = fildecmIcon.Height = 12;
fildecmIcon.Fill = scbf;
fildecm.Icon = fildecmIcon;
fildecm.Click += (s, x) => NativeMethods.ShowFileProperties(PicPath);
cm.Items.Add(fildecm);
cm.Items.Add(new Separator());
Expand Down Expand Up @@ -554,8 +576,6 @@ internal static void AddContextMenus()
break;
}

#endregion Add ContextMenus

cm.Opened += (tt, yy) => Recentcm_MouseEnter(recentcm);
}
}
Expand Down
4 changes: 4 additions & 0 deletions PicView/Interface Logic/SvgIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ internal static class SvgIcons
internal const string SVGiconPrint = "M448 1536h896v-256h-896v256zm0-640h896v-384h-160q-40 0-68-28t-28-68v-160h-640v640zm1152 64q0-26-19-45t-45-19-45 19-19 45 19 45 45 19 45-19 19-45zm128 0v416q0 13-9.5 22.5t-22.5 9.5h-224v160q0 40-28 68t-68 28h-960q-40 0-68-28t-28-68v-160h-224q-13 0-22.5-9.5t-9.5-22.5v-416q0-79 56.5-135.5t135.5-56.5h64v-544q0-40 28-68t68-28h672q40 0 88 20t76 48l152 152q28 28 48 76t20 88v256h64q79 0 135.5 56.5t56.5 135.5z";
internal const string SVGiconPaper = "M288,48H136c-22.092,0-40,17.908-40,40v336c0,22.092,17.908,40,40,40h240c22.092,0,40-17.908,40-40V176L288,48z M272,192 V80l112, 112H272z";
internal const string SVGiconSort = "M666 481q-60 92-137 273-22-45-37-72.5t-40.5-63.5-51-56.5-63-35-81.5-14.5h-224q-14 0-23-9t-9-23v-192q0-14 9-23t23-9h224q250 0 410 225zm1126 799q0 14-9 23l-320 320q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-192q-32 0-85 .5t-81 1-73-1-71-5-64-10.5-63-18.5-58-28.5-59-40-55-53.5-56-69.5q59-93 136-273 22 45 37 72.5t40.5 63.5 51 56.5 63 35 81.5 14.5h256v-192q0-14 9-23t23-9q12 0 24 10l319 319q9 9 9 23zm0-896q0 14-9 23l-320 320q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-192h-256q-48 0-87 15t-69 45-51 61.5-45 77.5q-32 62-78 171-29 66-49.5 111t-54 105-64 100-74 83-90 68.5-106.5 42-128 16.5h-224q-14 0-23-9t-9-23v-192q0-14 9-23t23-9h224q48 0 87-15t69-45 51-61.5 45-77.5q32-62 78-171 29-66 49.5-111t54-105 64-100 74-83 90-68.5 106.5-42 128-16.5h256v-192q0-14 9-23t23-9q12 0 24 10l319 319q9 9 9 23z";
internal const string SVGiconWrench = "M474.1 398.2L289.1 212c18.3-47 8.1-102.3-30.5-141.1C217.9 30 156.9 21.8 108.1 44.3l87.4 88-61 61.4-89.5-88c-24.3 49-14.1 110.4 26.5 151.3 38.6 38.9 93.5 49.1 140.3 30.7l185 186.2c8.1 8.2 20.3 8.2 28.5 0l46.8-47c10.2-8.3 10.2-22.6 2-28.7z";
internal const string SVGiconSearch = "M442,386.7l-84.8-85.9c13.8-24.1,21-50.9,21-77.9c0-87.6-71.2-158.9-158.6-158.9C135.2,64,64,135.3,64,222.9 c0,87.6,71.2,158.9,158.6,158.9c27.9,0,55.5-7.7,80.1-22.4l84.4,85.6c1.9,1.9,4.6,3.1,7.3,3.1c2.7,0,5.4-1.1,7.3-3.1l43.3-43.8 C449,397.1,449,390.7,442,386.7z M222.6,125.9c53.4,0,96.8,43.5,96.8,97c0,53.5-43.4,97-96.8,97c-53.4,0-96.8-43.5-96.8-97 C125.8,169.4,169.2,125.9,222.6,125.9z";
internal const string SVGiconPaperDetails = "M398.6,169.2c-0.9-2.2-2-4.3-3.5-6.1l-83.8-91.7c-1.9-2.1-4.2-3.6-6.7-4.9c-2.9-1.5-6.1-2.1-9.5-2.1H135.2 c-12.4,0-22.7,10.6-22.7,23.9v335.2c0,13.4,10.3,24.9,22.7,24.9h243.1c12.4,0,22.2-11.5,22.2-24.9V179.4 C400.5,175.8,400,172.3,398.6,169.2z M160.5,178.6c0-1.5,1.8-2.1,3.4-2.1h70.8c1.6,0,2.8,0.6,2.8,2.1v10.8c0,1.4-1.1,3.1-2.8,3.1 h-70.8c-1.6,0-3.4-1.7-3.4-3.1V178.6z M160.5,306.6c0-1.5,1.8-2.1,3.4-2.1h122.2c1.6,0,2.4,0.6,2.4,2.1v10.8c0,1.4-0.7,3.1-2.4,3.1 H163.9c-1.6,0-3.4-1.7-3.4-3.1V306.6z M320.5,381.4c0,1.4-0.7,3.1-2.4,3.1H163.9c-1.6,0-3.4-1.7-3.4-3.1v-10.8 c0-1.5,1.8-2.1,3.4-2.1h154.2c1.6,0,2.4,0.6,2.4,2.1V381.4z M352.5,253.4c0,1.4-0.7,3.1-2.4,3.1H163.9c-1.6,0-3.4-1.7-3.4-3.1 v-10.8c0-1.5,1.8-2.1,3.4-2.1h186.2c1.6,0,2.4,0.6,2.4,2.1V253.4z M305.6,177.5c-5.6,0-11.1-5.2-11.1-11.3v-66l71.2,77.3H305.6";


}
}
30 changes: 14 additions & 16 deletions PicView/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,6 @@ public MainWindow()
InitializeComponent();
Loaded += (s, e) => MainWindow_Loaded(s, e);
ContentRendered += MainWindow_ContentRendered;

// If normal window style
if (!Properties.Settings.Default.FitToWindow)
{
Top = Properties.Settings.Default.Top;
Left = Properties.Settings.Default.Left;
Height = Properties.Settings.Default.Height;
Width = Properties.Settings.Default.Width;

if (Properties.Settings.Default.Maximized)
{
WindowState = WindowState.Maximized;
}
FitToWindow = false;
}
else FitToWindow = true;
}

#region Loaded and Rendered
Expand All @@ -70,6 +54,20 @@ private void MainWindow_Loaded(object sender, RoutedEventArgs e)
RightBorderRectangle.Visibility
= Visibility.Collapsed;
}
// If normal window style
if (!Properties.Settings.Default.FitToWindow)
{
Top = Properties.Settings.Default.Top;
Left = Properties.Settings.Default.Left;
Height = Properties.Settings.Default.Height;
Width = Properties.Settings.Default.Width;

if (Properties.Settings.Default.Maximized)
WindowState = WindowState.Maximized;

FitToWindow = false;
}
else FitToWindow = true;
}

private void MainWindow_ContentRendered(object sender, EventArgs e)
Expand Down
3 changes: 3 additions & 0 deletions PicView/Navigation/Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ internal static async void Pic(string path)

if (File.Exists(Pics[FolderIndex]))
{
if (!freshStartup)
Preloader.Clear();

// Navigate to picture using obtained index
Pic(FolderIndex);
}
Expand Down
2 changes: 1 addition & 1 deletion PicView/UserControls/Menus/ImageSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
BorderBrush="{x:Null}"
FontWeight="Bold"
Foreground="{x:Null}"
ToolTip="Flip image">
ToolTip="Flip image [F]">
<CheckBox.Background>
<SolidColorBrush x:Name="FlipButtonBrush" Color="{StaticResource BackgroundColorAlt}" />
</CheckBox.Background>
Expand Down
4 changes: 2 additions & 2 deletions PicView/UserControls/Menus/ImageSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public ImageSettings()
// Change FlipButton's icon when (un)checked
private void FlipButton_Unchecked(object sender, System.Windows.RoutedEventArgs e)
{
FlipButton.ToolTip = "Flip image";
FlipButton.ToolTip = "Flip image [F]";
FlipPath.Data = Geometry.Parse("M192,96v64h248c4.4,0,8,3.6,8,8v240c0,4.4-3.6,8-8,8H136c-4.4,0-8-3.6-8-8v-48c0-4.4,3.6-8,8-8h248V224H192v64L64,192 L192, 96z");
}

private void FlipButton_Checked(object sender, System.Windows.RoutedEventArgs e)
{
FlipButton.ToolTip = "Unflip image";
FlipButton.ToolTip = "Unflip image [F]";
FlipPath.Data = Geometry.Parse("M448,192l-128,96v-64H128v128h248c4.4,0,8,3.6,8,8v48c0,4.4-3.6,8-8,8H72c-4.4,0-8-3.6-8-8V168c0-4.4,3.6-8,8-8h248V96 L448, 192z");
}

Expand Down

0 comments on commit 98657b0

Please sign in to comment.