diff --git a/App.config b/App.config
index 9012c58..e883482 100644
--- a/App.config
+++ b/App.config
@@ -14,7 +14,7 @@
False
-
+ .image_temp
True
diff --git a/Class/Convert.cs b/Class/Convert.cs
index c00bd96..d8b0ecc 100644
--- a/Class/Convert.cs
+++ b/Class/Convert.cs
@@ -1,46 +1,131 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ImageMagick;
+using NReco.VideoConverter;
namespace Mr_Squirrely_Converters.Class
{
class Converter
{
+
+ #region Video Converters
+ internal static void ConvertWebM(List files) {
+ try {
+
+ // Currently disabled
+ //FFMpegConverter video = new FFMpegConverter();
+ //foreach (string file in files) {
+ // string fileName = Path.GetFileNameWithoutExtension(file);
+ // string fileLocation = Path.GetDirectoryName(file);
+ // string fileType = Path.GetExtension(file);
+ // video.ConvertMedia(file, $"{fileLocation}\\{fileName}.webm", Format.webm);
+ //}
+
+ }
+ catch (Exception) {
+
+ }
+ }
+
+ internal static void ConvertMP4(List files) {
+
+ }
+ #endregion
+
+ #region Image Converters
//If alpha true = remove else = set
internal static void ConvertWebP(List files) {
foreach (string file in files) {
string fileName = Path.GetFileNameWithoutExtension(file);
+ string fullName = Path.GetFileName(file);
string fileLocation = Path.GetDirectoryName(file);
+ string fullLocation = Path.GetFullPath(file);
MagickImage image = new MagickImage(file);
- image.Settings.SetDefine(MagickFormat.WebP, "lossless", true);
- image.Settings.SetDefine(MagickFormat.WebP, "emulate-jpeg-size", false);
+ image.Settings.SetDefine(MagickFormat.WebP, "-lossless", Options.WebPLossless);
+ image.Settings.SetDefine(MagickFormat.WebP, "-emulate-jpeg-size", Options.WebPEmulateJPEG);
+ image.Settings.SetDefine(MagickFormat.WebP, "-alpha", Options.GetWebPRemoveAlpha());
+ image.Settings.SetDefine(MagickFormat.WebP, "-quality", Options.WebPQuality.ToString());
image.Format = MagickFormat.WebP;
image.Write($"{fileLocation}\\{fileName}.webp");
+ //I need help on this. There has to be a better way to do this?!
+ foreach (NewFile newFile in Utils._Images) {
+ int index = Utils._Images.IndexOf(newFile);
+ if (Utils._Images[index].Location == fullLocation) {
+ Utils._Images[index].Converted = "Converted";
+ }
+ }
+ Utils._MainPage.Dispatcher.Invoke(() => { Utils._MainPage.ImageFiles.Items.Refresh(); }, System.Windows.Threading.DispatcherPriority.Background);
+ if (Options.CreateTemp) {
+ if (!Directory.Exists($"{Utils._WorkingDir}\\image_temp")) Directory.CreateDirectory($"{Utils._WorkingDir}\\image_temp");
+ File.Copy(file, $"{Utils._WorkingDir}\\image_temp\\{fullName}");
+ }
+ DeleteFile(file);
}
}
internal static void ConvertJPEG(List files) {
foreach (string file in files) {
string fileName = Path.GetFileNameWithoutExtension(file);
+ string fullName = Path.GetFileName(file);
string fileLocation = Path.GetDirectoryName(file);
+ string fullLocation = Path.GetFullPath(file);
MagickImage image = new MagickImage(file);
+ image.Settings.SetDefine(MagickFormat.Jpeg, "-quality", Options.WebPQuality.ToString());
image.Format = MagickFormat.Jpeg;
image.Write($"{fileLocation}\\{fileName}.Jpeg");
+ //I need help on this. There has to be a better way to do this?!
+ foreach (NewFile newFile in Utils._Images) {
+ int index = Utils._Images.IndexOf(newFile);
+ if (Utils._Images[index].Location == fullLocation) {
+ Utils._Images[index].Converted = "Converted";
+ }
+ }
+ Utils._MainPage.Dispatcher.Invoke(() => { Utils._MainPage.ImageFiles.Items.Refresh(); }, System.Windows.Threading.DispatcherPriority.Background);
+ if (Options.CreateTemp) {
+ if (!Directory.Exists($"{Utils._WorkingDir}\\image_temp")) Directory.CreateDirectory($"{Utils._WorkingDir}\\image_temp");
+ File.Copy(file, $"{Utils._WorkingDir}\\image_temp\\{fullName}");
+ }
+ DeleteFile(file);
}
}
internal static void ConvertPNG(List files) {
foreach (string file in files) {
string fileName = Path.GetFileNameWithoutExtension(file);
+ string fullName = Path.GetFileName(file);
string fileLocation = Path.GetDirectoryName(file);
+ string fullLocation = Path.GetFullPath(file);
MagickImage image = new MagickImage(file);
+ image.Settings.SetDefine(MagickFormat.Png, "-lossless", Options.WebPLossless);
+ image.Settings.SetDefine(MagickFormat.Png, "-alpha", Options.GetWebPRemoveAlpha());
+ image.Settings.SetDefine(MagickFormat.Png, "-quality", Options.WebPQuality.ToString());
image.Format = MagickFormat.Png;
image.Write($"{fileLocation}\\{fileName}.Png");
+ //I need help on this. There has to be a better way to do this?!
+ foreach (NewFile newFile in Utils._Images) {
+ int index = Utils._Images.IndexOf(newFile);
+ if (Utils._Images[index].Location == fullLocation) {
+ Utils._Images[index].Converted = "Converted";
+ }
+ }
+ Utils._MainPage.Dispatcher.Invoke(() => { Utils._MainPage.ImageFiles.Items.Refresh(); }, System.Windows.Threading.DispatcherPriority.Background);
+ if (Options.CreateTemp) {
+ if (!Directory.Exists($"{Utils._WorkingDir}\\image_temp")) Directory.CreateDirectory($"{Utils._WorkingDir}\\image_temp");
+ File.Copy(file, $"{Utils._WorkingDir}\\image_temp\\{fullName}");
+ }
+ DeleteFile(file);
}
}
+ #endregion
+
+ private static void DeleteFile(string file) {
+ if (Options.ImagesDelete) File.Delete(file);
+ }
+
}
}
diff --git a/Class/Enum.cs b/Class/Enum.cs
index 84326d5..2c243c6 100644
--- a/Class/Enum.cs
+++ b/Class/Enum.cs
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
diff --git a/Class/Options.cs b/Class/Options.cs
new file mode 100644
index 0000000..46fc0f7
--- /dev/null
+++ b/Class/Options.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Mr_Squirrely_Converters.Class {
+ class Options {
+
+ internal static bool CreateTemp { get { return Properties.Settings.Default.Create_Temp; } set { Properties.Settings.Default.Create_Temp = value; } }
+ internal static string TempLocation { get { return Properties.Settings.Default.Temp_Location; } set { Properties.Settings.Default.Temp_Location = value; } }
+ internal static bool ImagesDelete { get { return Properties.Settings.Default.Images_Delete; } set { Properties.Settings.Default.Images_Delete = value; } }
+ internal static bool WebPLossless { get { return Properties.Settings.Default.WebP_Lossess; } set { Properties.Settings.Default.WebP_Lossess = value; } }
+ internal static bool WebPEmulateJPEG { get { return Properties.Settings.Default.WebP_Emulate_JPEG; } set { Properties.Settings.Default.WebP_Emulate_JPEG = value; } }
+ internal static double WebPQuality { get { return Properties.Settings.Default.WebP_Quality; } set { Properties.Settings.Default.WebP_Quality = value; } }
+ internal static bool WebPRemoveAlpha { get { return Properties.Settings.Default.WebP_RemoveAlpha; } set { Properties.Settings.Default.WebP_RemoveAlpha = value; } }
+ internal static double JPEGQuality { get { return Properties.Settings.Default.JPEG_Quality; } set { Properties.Settings.Default.JPEG_Quality = value; } }
+ internal static bool PNGLossless { get { return Properties.Settings.Default.PNG_Lossess; } set { Properties.Settings.Default.PNG_Lossess = value; } }
+ internal static double PNGQuality { get { return Properties.Settings.Default.PNG_Quality; } set { Properties.Settings.Default.PNG_Quality = value; } }
+ internal static bool PNGRemoveAlpha { get { return Properties.Settings.Default.PNG_RemoveAlpha; } set { Properties.Settings.Default.PNG_RemoveAlpha = value; } }
+
+ internal static void Save() => Properties.Settings.Default.Save();
+
+ internal static string GetWebPRemoveAlpha() {
+ if (WebPRemoveAlpha) return "remove"; else return "set";
+ }
+
+ internal static string GetPNGRemoveAlpha() {
+ if (PNGRemoveAlpha) return "remove"; else return "set";
+ }
+ }
+}
diff --git a/Class/Toast.cs b/Class/Toast.cs
index f31e0bb..a909fbc 100644
--- a/Class/Toast.cs
+++ b/Class/Toast.cs
@@ -11,23 +11,28 @@
namespace Mr_Squirrely_Converters.Class
{
class Toast {
- private static Notifier notifier;
+ private static Notifier _Notifier;
- internal static void CreateNotifier() =>
- notifier = new Notifier(cfg => {
- cfg.PositionProvider = new PrimaryScreenPositionProvider(corner: Corner.BottomRight, offsetX: 10, offsetY: 10);
- cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(notificationLifetime: TimeSpan.FromSeconds(5), maximumNotificationCount: MaximumNotificationCount.FromCount(5));
- cfg.Dispatcher = App.Current.Dispatcher;
- });
+ internal static void CreateNotifier() {
+ _Notifier = new Notifier(cfg => {
+ cfg.PositionProvider = new WindowPositionProvider(parentWindow: Utils._MainWindow, corner: Corner.BottomRight, offsetX: 10, offsetY: 10);
+ cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(notificationLifetime: TimeSpan.FromSeconds(10), maximumNotificationCount: MaximumNotificationCount.FromCount(5));
+ cfg.Dispatcher = App.Current.Dispatcher;
+ });
+ }
#region Messages
- internal static void NoUpdate() => notifier.ShowSuccess("There is no update!");
- internal static void Update() => notifier.ShowInformation($"There is an update. Your version: {Utils._CurrentVersion} Updated version: {Utils._UpdateVerstion}"); //This message shows when there is an update
- internal static void UpdateCheckFail() => notifier.ShowWarning("Failed to check for update. Please try again."); //In case checking for the update fails
- internal static void BetaRelease() => notifier.ShowInformation("This is a beta release so some things are not finished."); //Beta release notice
- internal static void ConvertFinished() => notifier.ShowInformation("Finished Converting"); //Finished message
- internal static void AlreadyConverting() => notifier.ShowWarning("Already Converting"); //Already converting message
+ internal static void NoUpdate() => _Notifier.ShowSuccess("There is no update!");// Shows if there is no update
+ internal static void Update() => _Notifier.ShowInformation($"There is an update. Your version: {Utils._CurrentVersion} Updated version: {Utils._UpdateVerstion}"); //This message shows when there is an update
+ internal static void UpdateCheckFail() => _Notifier.ShowWarning("Failed to check for update. Please try again."); //In case checking for the update fails
+ internal static void BetaRelease() => _Notifier.ShowInformation("This is a beta release so some things are not finished."); //Beta release notice
+ internal static void ConvertFinished() => _Notifier.ShowInformation("Finished Converting"); //Finished message
+ internal static void AlreadyConverting() => _Notifier.ShowWarning("Already Converting"); //Already converting message
+ internal static void SettingsSaved() => _Notifier.ShowSuccess("Settings were saved!"); //Settings saved message
+ internal static void SettingsReset() => _Notifier.ShowInformation("Settings reset, make sure you save them!"); //Reset message and a reminder to save them
+ internal static void VideoMessage() => _Notifier.ShowWarning("Video conversion can take a long time to finish. Currently I do not show progress. It is not recommended that you convert multiple videos at once.");//Message for video
+ internal static void VideoMessage2() => _Notifier.ShowWarning("Currently converting of videos is disabled.");
#endregion
- internal static void Dispose() => notifier.Dispose(); //Dispose when we are done
+ internal static void Dispose() => _Notifier.Dispose(); //Dispose when we are done
}
}
diff --git a/Class/Utils.cs b/Class/Utils.cs
index a4f5924..eb526e4 100644
--- a/Class/Utils.cs
+++ b/Class/Utils.cs
@@ -8,10 +8,11 @@
using System.Windows.Controls;
using System.IO;
using System.Collections.ObjectModel;
-using System.Collections.Immutable;
using System.Threading;
using System.Net;
using MahApps.Metro.Controls;
+using MaterialDesignThemes.Wpf;
+using System.Security.Cryptography;
namespace Mr_Squirrely_Converters.Class {
class Utils {
@@ -21,8 +22,10 @@ class Utils {
internal static List _Dirs = new List();
internal static ObservableCollection _Images = new ObservableCollection(); // I'm keeping both for a reason that might come later.
internal static ObservableCollection _Videos = new ObservableCollection();
- internal static string _CurrentVersion = "2018.1b";
+ internal static string _CurrentVersion = "1.0rc1";
internal static string _UpdateVerstion { get; set; }
+ internal static bool _FirstClicked = true;
+ internal static MD5 _MD5Hash = MD5.Create();
internal static string _WorkingDir { get; set; }
internal static bool _IsFolder { get; set; }
@@ -30,9 +33,7 @@ class Utils {
internal static ListView _ImageItems;
internal static ListView _VideoItems;
- internal static MetroWindow _MainWindow;
- internal static MainPage _MainPage = new MainPage();
- internal static SettingsPage _SettingsPage = new SettingsPage();
+ internal static DialogHost _VideoDialog;
internal static WebClient _WebClient = new WebClient();
private static string _VERSION_URL = "https://raw.githubusercontent.com/MrSquirrelyNet/SquirrelyConverter/master/current.version";
@@ -41,45 +42,12 @@ class Utils {
private readonly static string _README_FILENAME = "README.md";
#region Windows
- private static About _Aboutwindow;
- private static Settings _SettingsWindow;
private static String _Github = "https://github.com/MrSquirrelyNet/SquirrelyConverter/issues";
-
- internal static void OpenSettings() {
- _SettingsWindow = new Settings();
- _SettingsWindow.Show();
- }
-
- internal static void CloseSettings() {
- try {
- _SettingsWindow.Close();
- }
- catch (Exception) {
-
- }
-
- }
-
- internal static void OpenAbout() {
- _Aboutwindow = new About();
- _Aboutwindow.Show();
- }
-
- internal static void CloseAbout() {
- try {
- _Aboutwindow.Close();
- }
- catch (Exception) {
- }
-
- }
-
- internal static void CloseWindows() {
- CloseSettings();
- CloseAbout();
- Toast.Dispose();
- }
-
+ internal static MetroWindow _MainWindow;
+ internal static MainPage _MainPage = new MainPage();
+ internal static SettingsPage _SettingsPage;
+ internal static void OpenSettings() => _SettingsPage = new SettingsPage();
+ internal static void Dispose() => Toast.Dispose();
internal static void OpenGithub() => Process.Start(_Github);
#endregion
@@ -92,20 +60,26 @@ class Utils {
break;
case 1:
_MainWindow.Title = "Mr. Squirrely's Video Converter";
+ if (_FirstClicked == true) {
+ Toast.VideoMessage2();
+ _FirstClicked = false;
+ }
break;
}
}
internal static void DownloadFiles() {
try {
- if (File.Exists(Utils._README_FILENAME)) File.Delete(Utils._README_FILENAME);
- _WebClient.DownloadFile(Utils._README_URL, Utils._README_FILENAME);
if (File.Exists(@"current.version")) File.Delete(@"current.version");
_WebClient.DownloadFile(_VERSION_URL, _VERSION_FILENAME);
}
- catch (Exception) {
+ catch (Exception ex) {
+ Console.WriteLine("versions not found");
+ Console.WriteLine(ex.Source);
+ Console.WriteLine(ex.Message);
}
}
+
internal static void CheckForUpdate(bool ShowSuccess) {
try {
StreamReader streamReader = new StreamReader(@"current.version");
@@ -167,7 +141,59 @@ class Utils {
}
private static void ConvertVideo(int selectedIndex) {
- //Add a switch case here for videos
+ switch (selectedIndex) {
+ case 0:
+ ConvertWebM();
+ break;
+ case 1:
+ ConvertMP4();
+ break;
+ }
+ }
+ #endregion
+
+ #region Video Converters
+ private static void StartConvertWebM() => Converter.ConvertWebM(_Files);
+ private static void StartConvertMP4() => Converter.ConvertMP4(_Files);
+
+ private static void ConvertWebM() {
+ if (_DroppedFiles == null) return;
+ if (_IsWorking) {
+ Toast.AlreadyConverting();
+ return;
+ }
+ _IsWorking = true;
+ Thread _ThreadEncode;
+ ThreadStart _Starter = StartConvertWebM;
+ _Starter += () => {
+ Toast.ConvertFinished();
+ _IsWorking = false;
+ };
+
+ _ThreadEncode = new Thread(_Starter);
+ _ThreadEncode.SetApartmentState(ApartmentState.STA);
+ _ThreadEncode.IsBackground = true;
+ _ThreadEncode.Start();
+ }
+
+ private static void ConvertMP4() {
+ if (_DroppedFiles == null) return;
+ if (_IsWorking) {
+ Toast.AlreadyConverting();
+ return;
+ }
+ _IsWorking = true;
+ Thread _ThreadEncode;
+ ThreadStart _Starter = StartConvertMP4;
+ _Starter += () => {
+ Toast.ConvertFinished();
+ _IsWorking = false;
+ };
+
+ _ThreadEncode = new Thread(_Starter);
+ _ThreadEncode.SetApartmentState(ApartmentState.STA);
+ _ThreadEncode.IsBackground = true;
+ _ThreadEncode.Start();
}
#endregion
@@ -298,7 +324,7 @@ class Utils {
string fileLocation = Path.GetFullPath(file);
FileAttributes fileAttributes = File.GetAttributes(file);
if (Types.ImageFormats.Contains(fileType)) {
- _Images.Add(new NewFile { Name = fileName, Type = fileType, Converted = "Queued", Location = fileLocation });
+ _Images.Add(new NewFile { Name = fileName, Type = fileType, Converted = "Queued", Location = fileLocation});
_Files.Add(file);
}
if (scanDir == true) {
diff --git a/FodyWeavers.xml b/FodyWeavers.xml
index 6965121..189b345 100644
--- a/FodyWeavers.xml
+++ b/FodyWeavers.xml
@@ -16,6 +16,8 @@
System.Windows.Interactivity
ToastNotifications
ToastNotifications.Messages
+ System.Collections.Immutable
+ NReco.VideoConverter
\ No newline at end of file
diff --git a/Mr Squirrely Converters.csproj b/Mr Squirrely Converters.csproj
index 42c8d7d..0af1cfc 100644
--- a/Mr Squirrely Converters.csproj
+++ b/Mr Squirrely Converters.csproj
@@ -85,6 +85,9 @@
..\packages\MaterialDesignThemes.2.4.0.1044\lib\net45\MaterialDesignThemes.Wpf.dll
+
+ ..\packages\NReco.VideoConverter.1.1.2\lib\net20\NReco.VideoConverter.dll
+
@@ -118,25 +121,16 @@
+
-
- About.xaml
-
MainPage.xaml
-
- Settings.xaml
-
SettingsPage.xaml
-
- Designer
- MSBuild:Compile
-
Designer
MSBuild:Compile
@@ -153,10 +147,6 @@
MainWindow.xaml
Code
-
- Designer
- MSBuild:Compile
-
Designer
MSBuild:Compile
@@ -186,6 +176,7 @@
SettingsSingleFileGenerator
Settings.Designer.cs
+
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 90ffb81..27d964b 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -37,7 +37,7 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("")]
+ [global::System.Configuration.DefaultSettingValueAttribute(".image_temp")]
public string Temp_Location {
get {
return ((string)(this["Temp_Location"]));
@@ -86,9 +86,9 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("80")]
- public int WebP_Quality {
+ public double WebP_Quality {
get {
- return ((int)(this["WebP_Quality"]));
+ return ((double)(this["WebP_Quality"]));
}
set {
this["WebP_Quality"] = value;
@@ -110,9 +110,9 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("80")]
- public int JPEG_Quality {
+ public double JPEG_Quality {
get {
- return ((int)(this["JPEG_Quality"]));
+ return ((double)(this["JPEG_Quality"]));
}
set {
this["JPEG_Quality"] = value;
@@ -134,9 +134,9 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("80")]
- public int PNG_Quality {
+ public double PNG_Quality {
get {
- return ((int)(this["PNG_Quality"]));
+ return ((double)(this["PNG_Quality"]));
}
set {
this["PNG_Quality"] = value;
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 90ab3a0..1b3cb83 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -6,7 +6,7 @@
False
-
+ .image_temp
True
@@ -17,19 +17,19 @@
False
-
+
80
False
-
+
80
True
-
+
80
diff --git a/TODO.cs b/TODO.cs
deleted file mode 100644
index 3a4acf6..0000000
--- a/TODO.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Mr_Squirrely_Converters {
- class TODO {
-
- /*
- * These are coming in the next update:
- * I'm going to try and change all the publics to internal.
- * Adding settings.
- *
- * These are still to come:
- * Adding Video Support
- *
- *
- * Bug Testing!
- */
-
- }
-}
diff --git a/Views/About.xaml b/Views/About.xaml
deleted file mode 100644
index 3bae115..0000000
--- a/Views/About.xaml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/Views/About.xaml.cs b/Views/About.xaml.cs
deleted file mode 100644
index eb9fc95..0000000
--- a/Views/About.xaml.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-using System.Xaml;
-using XamlReader = System.Windows.Markup.XamlReader;
-using Mr_Squirrely_Converters.Class;
-using Markdig;
-using Markdig.Wpf;
-using System.Reflection;
-using System.Diagnostics;
-
-namespace Mr_Squirrely_Converters.Views {
- ///
- /// Interaction logic for About.xaml
- ///
- public partial class About {
- public About() {
- InitializeComponent();
- }
-
- private static MarkdownPipeline BuildPipeline() {
- return new MarkdownPipelineBuilder()
- .UseSupportedExtensions().
- Build();
- }
-
- private void OnLoad(object sender, RoutedEventArgs e) {
- StreamReader streamReader = new StreamReader(@"README.md");
- string Markdown = streamReader.ReadToEnd();
- string XAML = Markdig.Wpf.Markdown.ToXaml(Markdown, BuildPipeline());
- using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(XAML))) {
- XamlXmlReader reader = new XamlXmlReader(stream, new MyXamlSchemaContext());
- FlowDocument document = XamlReader.Load(reader) as FlowDocument;
- if (document != null) {
- Viewer.Document = document;
- }
- }
- streamReader.Dispose();
- }
-
- private void OpenHyperlink(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) {
- Process.Start(e.Parameter.ToString());
- }
- }
-
-
-
- class MyXamlSchemaContext : XamlSchemaContext {
- public override bool TryGetCompatibleXamlNamespace(string xamlNamespace, out string compatibleNamespace) {
- if (xamlNamespace.Equals("clr-namespace:Markdig.Wpf")) {
- compatibleNamespace = $"clr-namespace:Markdig.Wpf;assembly={Assembly.GetAssembly(typeof(Markdig.Wpf.Styles)).FullName}";
- return true;
- }
- return base.TryGetCompatibleXamlNamespace(xamlNamespace, out compatibleNamespace);
- }
- }
-}
diff --git a/Views/MainPage.xaml b/Views/MainPage.xaml
index 4060759..dfa47d0 100644
--- a/Views/MainPage.xaml
+++ b/Views/MainPage.xaml
@@ -7,13 +7,16 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
Title="MainPage">
-
+
-
-
+
+
+
+
@@ -41,7 +44,7 @@
-
+
@@ -56,11 +59,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/Views/MainPage.xaml.cs b/Views/MainPage.xaml.cs
index 286721b..111fdd4 100644
--- a/Views/MainPage.xaml.cs
+++ b/Views/MainPage.xaml.cs
@@ -29,10 +29,10 @@ public MainPage()
Utils.CheckForUpdate(false);
}
- private void RightWindowSettings_Click(object sender, RoutedEventArgs e) => Utils.OpenSettings();
- private void RightWindowAbout_Click(object sender, RoutedEventArgs e) => Utils.OpenAbout();
+ private void RightWindowSettings_Click(object sender, RoutedEventArgs e) { }
+ private void RightWindowAbout_Click(object sender, RoutedEventArgs e) { }
private void RightWindowGithub_Click(object sender, RoutedEventArgs e) => Utils.OpenGithub();
- private void MetroWindow_Closed(object sender, EventArgs e) => Utils.CloseWindows();
+ private void MetroWindow_Closed(object sender, EventArgs e) => Utils.Dispose();
private void ImageFiles_Drop(object sender, DragEventArgs e) => Utils.PopulateList(e.Data.GetData(DataFormats.FileDrop) as string[], Types.Images());
private void VideoFiles_Drop(object sender, DragEventArgs e) => Utils.PopulateList(e.Data.GetData(DataFormats.FileDrop) as string[], Types.Videos());
@@ -40,9 +40,8 @@ public MainPage()
private void ImageConvertButton_Click(object sender, RoutedEventArgs e) => Utils.Convert(ImageFormatSelector.SelectedIndex, Types.Images());
private void VideoConvertButton_Click(object sender, RoutedEventArgs e) => Utils.Convert(ImageFormatSelector.SelectedIndex, Types.Videos());
- //private void HamburgerButton_Click(object sender, RoutedEventArgs e) => HamburgerButton.ContextMenu.IsOpen = true;
- private void SettingsMenu_Click(object sender, RoutedEventArgs e) => Utils.OpenSettings();
- private void AboutMenu_Click(object sender, RoutedEventArgs e) => Utils.OpenAbout();
+ private void SettingsMenu_Click(object sender, RoutedEventArgs e) { }
+ private void AboutMenu_Click(object sender, RoutedEventArgs e) { }
private void ClearMenu_Click(object sender, RoutedEventArgs e) => Utils.Clear();
private void UpdateMenu_Click(object sender, RoutedEventArgs e) => Utils.CheckForUpdate(true);
diff --git a/Views/MainWindow.xaml b/Views/MainWindow.xaml
index 0ae2df5..b7bf982 100644
--- a/Views/MainWindow.xaml
+++ b/Views/MainWindow.xaml
@@ -13,16 +13,13 @@
TextElement.FontWeight="Medium"
TextElement.FontSize="14"
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
- Title="Mr. Squirrely's Image Converter" Height="450" Width="800" Closed="MetroWindow_Closed">
+ Title="Mr. Squirrely's Image Converter" Height="720" Width="1280" Closed="MetroWindow_Closed" MinWidth="1000" MinHeight="600">
-
-
@@ -33,7 +30,6 @@
-
@@ -44,60 +40,5 @@
-
diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs
index 51fea2d..15247ef 100644
--- a/Views/MainWindow.xaml.cs
+++ b/Views/MainWindow.xaml.cs
@@ -14,44 +14,33 @@
using System.Windows.Shapes;
using Mr_Squirrely_Converters.Views;
using Mr_Squirrely_Converters.Class;
+using System.IO;
namespace Mr_Squirrely_Converters {
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow {
-
-
public MainWindow() {
InitializeComponent();
Toast.CreateNotifier();
Utils.DownloadFiles();
- //Utils._ImageItems = ImageFiles;
- //Utils._VideoItems = VideoFiles;
+ Utils.OpenSettings();
Utils._MainWindow = this;
- //Utils.CheckForUpdate(false);
Utils._MainWindow.Content = Utils._MainPage;
+ Utils._WorkingDir = Directory.GetCurrentDirectory();
}
private void RightWindowSettings_Click(object sender, RoutedEventArgs e) => Utils._MainWindow.Content = Utils._SettingsPage;
- private void RightWindowAbout_Click(object sender, RoutedEventArgs e) => Utils.OpenAbout();
private void RightWindowGithub_Click(object sender, RoutedEventArgs e) => Utils.OpenGithub();
- private void MetroWindow_Closed(object sender, EventArgs e) => Utils.CloseWindows();
-
- //private void ImageFiles_Drop(object sender, DragEventArgs e) => Utils.PopulateList(e.Data.GetData(DataFormats.FileDrop) as string[], Types.Images());
- //private void VideoFiles_Drop(object sender, DragEventArgs e) => Utils.PopulateList(e.Data.GetData(DataFormats.FileDrop) as string[], Types.Videos());
-
- //private void ImageConvertButton_Click(object sender, RoutedEventArgs e) => Utils.Convert(ImageFormatSelector.SelectedIndex, Types.Images());
- //private void VideoConvertButton_Click(object sender, RoutedEventArgs e) => Utils.Convert(ImageFormatSelector.SelectedIndex, Types.Videos());
+ private void MetroWindow_Closed(object sender, EventArgs e) => Utils.Dispose();
private void HamburgerButton_Click(object sender, RoutedEventArgs e) => HamburgerButton.ContextMenu.IsOpen = true;
- private void SettingsMenu_Click(object sender, RoutedEventArgs e) => Utils.OpenSettings();
- private void AboutMenu_Click(object sender, RoutedEventArgs e) => Utils.OpenAbout();
+ private void SettingsMenu_Click(object sender, RoutedEventArgs e) => Utils._MainWindow.Content = Utils._SettingsPage;
private void ClearMenu_Click(object sender, RoutedEventArgs e) => Utils.Clear();
private void UpdateMenu_Click(object sender, RoutedEventArgs e) => Utils.CheckForUpdate(true);
- //private void ConverterTabs_SelectionChanged(object sender, SelectionChangedEventArgs e) => Utils.UpdateTitle(ConverterTabs.SelectedIndex);
}
}
diff --git a/Views/Settings.xaml b/Views/Settings.xaml
deleted file mode 100644
index 6246b5c..0000000
--- a/Views/Settings.xaml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
diff --git a/Views/Settings.xaml.cs b/Views/Settings.xaml.cs
deleted file mode 100644
index e6fbd57..0000000
--- a/Views/Settings.xaml.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-
-namespace Mr_Squirrely_Converters.Views {
- ///
- /// Interaction logic for Settings.xaml
- ///
- public partial class Settings {
- public Settings() {
- InitializeComponent();
- }
- }
-}
diff --git a/Views/SettingsPage.xaml b/Views/SettingsPage.xaml
index 9f82648..8e181e5 100644
--- a/Views/SettingsPage.xaml
+++ b/Views/SettingsPage.xaml
@@ -5,43 +5,59 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Mr_Squirrely_Converters.Views"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
- mc:Ignorable="d"
- d:DesignHeight="450" d:DesignWidth="800"
- Title="SettingsPage">
+ TextElement.Foreground="{DynamicResource MaterialDesignBody}"
+ Background="{DynamicResource MaterialDesignPaper}"
+ TextElement.FontWeight="Medium"
+ TextElement.FontSize="14"
+ FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
+ mc:Ignorable="d"
+ Title="SettingsPage" MinWidth="800" MinHeight="400">
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/Views/SettingsPage.xaml.cs b/Views/SettingsPage.xaml.cs
index bc266d6..2f03a20 100644
--- a/Views/SettingsPage.xaml.cs
+++ b/Views/SettingsPage.xaml.cs
@@ -21,13 +21,63 @@ namespace Mr_Squirrely_Converters.Views
///
public partial class SettingsPage : Page
{
+ //I need to work on this a little bit.
+ //Currently it sets the view and even if you cancel it never goes back. only a Restart would fix it.
public SettingsPage()
{
InitializeComponent();
+ SetValues();
}
- private void Button_Click(object sender, RoutedEventArgs e) {
+ private void SetValues() {
+ TempCreate.IsChecked = Options.CreateTemp;
+ LocationTemp.Text = Options.TempLocation;
+ DeleteImages.IsChecked = Options.ImagesDelete;
+ LosslessWebP.IsChecked = Options.WebPLossless;
+ RemoveAlphaWebP.IsChecked = Options.WebPRemoveAlpha;
+ EmulateJPEGWebP.IsChecked = Options.WebPEmulateJPEG;
+ QualityWebP.Value = Options.WebPQuality;
+ LosslessPNG.IsChecked = Options.PNGLossless;
+ RemoveAlphaPNG.IsChecked = Options.PNGRemoveAlpha;
+ QualityPNG.Value = Options.PNGQuality;
+ QualityJPEG.Value = Options.JPEGQuality;
+ }
+
+ private void SaveButton_Click(object sender, RoutedEventArgs e) {
+ Options.CreateTemp = TempCreate.IsChecked.Value;
+ Options.TempLocation = LocationTemp.Text;
+ Options.ImagesDelete = DeleteImages.IsChecked.Value;
+ Options.WebPLossless = LosslessWebP.IsChecked.Value;
+ Options.WebPRemoveAlpha = RemoveAlphaWebP.IsChecked.Value;
+ Options.WebPEmulateJPEG = EmulateJPEGWebP.IsChecked.Value;
+ Options.WebPQuality = QualityWebP.Value;
+ Options.PNGLossless = LosslessPNG.IsChecked.Value;
+ Options.PNGRemoveAlpha = RemoveAlphaPNG.IsChecked.Value;
+ Options.PNGQuality = QualityPNG.Value;
+ Options.JPEGQuality = QualityJPEG.Value;
+
+ Toast.SettingsSaved();
+
+ Options.Save();
Utils._MainWindow.Content = Utils._MainPage;
}
+
+ private void ResetButton_Click(object sender, RoutedEventArgs e) {
+ Options.CreateTemp = false;
+ Options.TempLocation = ".image_temp";
+ Options.ImagesDelete = true;
+ Options.WebPLossless = false;
+ Options.WebPRemoveAlpha = false;
+ Options.WebPEmulateJPEG = false;
+ Options.WebPQuality = 80;
+ Options.PNGLossless = true;
+ Options.PNGRemoveAlpha = false;
+ Options.PNGQuality = 80;
+ Options.JPEGQuality = 80;
+ SetValues();
+ Toast.SettingsReset();
+ }
+
+ private void CancelButton_Click(object sender, RoutedEventArgs e) => Utils._MainWindow.Content = Utils._MainPage;
}
}
diff --git a/current.version b/current.version
index e071f0a..4fa52a5 100644
--- a/current.version
+++ b/current.version
@@ -1 +1 @@
-2018.1b
\ No newline at end of file
+1.0rc1
\ No newline at end of file
diff --git a/packages.config b/packages.config
index e634bf4..6bf12da 100644
--- a/packages.config
+++ b/packages.config
@@ -11,6 +11,7 @@
+
\ No newline at end of file