Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
2.0rc1
Browse files Browse the repository at this point in the history
This is release canidate 1 for 2.0
  • Loading branch information
MrSquirrely committed Jun 29, 2018
1 parent 6b412f3 commit ef2ab0f
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 116 deletions.
1 change: 0 additions & 1 deletion ConverterUtilities/CUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.IO;
using System.Windows.Threading;
using static ConverterUtilities.Enums;
using MahApps.Metro.Controls;
using System.Net;
using System.Diagnostics;
using System.Windows;
Expand Down
3 changes: 2 additions & 1 deletion ConverterUtilities/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public enum FileExtension { Yes, No }
".jfif",
".jfi",
".tiff",
".tif"
".tif",
".webp"
};

public static readonly List<string> VideoFormats = new List<string>{
Expand Down
1 change: 0 additions & 1 deletion ConverterUtilities/Toast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public static class Toast {

public static void CreateNotifier() {
_notifier = new Notifier(cfg => {
//cfg.PositionProvider = new PrimaryScreenPositionProvider( corner: Corner.BottomRight, offsetX: 10, offsetY: 10);
cfg.PositionProvider = new WindowPositionProvider(parentWindow: CUtilities.MainWindow, corner:Corner.BottomRight, offsetX:10, offsetY:10);
cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(notificationLifetime: TimeSpan.FromSeconds(5), maximumNotificationCount: MaximumNotificationCount.FromCount(5));
cfg.Dispatcher = CUtilities.Dispatcher;
Expand Down
30 changes: 11 additions & 19 deletions ImageConverter/Class/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,17 @@ public static void ConvertPng(List<string> files) {
}

private static void Finish(string file) {
CopyFile(file);
DeleteFile(file);
if (Options.GetCreateTemp()) {
if (!Directory.Exists($"{CUtilities.GetTempDir(Options.GetCreateTemp(), Options.GetTempLocation())}")) {
Directory.CreateDirectory($"{CUtilities.GetTempDir(Options.GetCreateTemp(), Options.GetTempLocation())}");
}
File.Copy(file, $"{CUtilities.GetTempDir(Options.GetCreateTemp(), Options.GetTempLocation())}");
}
File.Delete(file);

if (Options.GetDeleteTemp() && Directory.Exists(Options.GetTempLocation())) {
Directory.Delete(Options.GetTempLocation());
}
}

private static void UpdateView() {
Expand All @@ -146,22 +155,5 @@ private static void UpdateView() {
}
}

private static void CopyFile(string file) {
if (Options.GetCreateTemp()) {
if (!Directory.Exists($"{CUtilities.GetTempDir(Options.GetCreateTemp(), Options.GetTempLocation())}")) {
Directory.CreateDirectory($"{CUtilities.GetTempDir(Options.GetCreateTemp(), Options.GetTempLocation())}");
}
File.Copy(file, $"{CUtilities.GetTempDir(Options.GetCreateTemp(), Options.GetTempLocation())}");
}
}

private static void DeleteFile(string file) {
File.Delete(file);

if (Options.GetDeleteTemp() && Directory.Exists(Options.GetTempLocation())) {
Directory.Delete(Options.GetTempLocation());
}
}

}
}
7 changes: 5 additions & 2 deletions ImageConverter/Class/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ private static void GetImages(string file, bool scanDirectory) {
}
}

public static void UpdateViews() {
public static void Clear() {
ImageListView.Items.Refresh();

DroppedFiles.Clear();
Files.Clear();
Directories.Clear();
ImagesCollection.Clear();
}
}
}
4 changes: 2 additions & 2 deletions ImageConverter/View/ImageView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
</ListView.ContextMenu>
<ListView.View>
<GridView x:Name="ImageFilesList">
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Name" Width="200"/>
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Name" Width="400"/>
<GridViewColumn DisplayMemberBinding="{Binding Type}" Header="Type"/>
<GridViewColumn DisplayMemberBinding="{Binding Converted}" Header="Converted"/>
<GridViewColumn DisplayMemberBinding="{Binding Location}" Header="Location"/>
</GridView>
</ListView.View>
</ListView>
<Button Content="Convert" x:Name="ImageConvertButton" Height="Auto" Margin="0,0,10,10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="ImageConvertButton_Click"/>
<ComboBox x:Name="ImageFormatSelector" Margin="0,0,97,10" VerticalAlignment="Bottom" Width="55" HorizontalAlignment="Right" SelectedIndex="0">
<ComboBox x:Name="ImageFormatSelector" Margin="0,0,97,10" VerticalAlignment="Bottom" Width="64" HorizontalAlignment="Right" SelectedIndex="0">
<ComboBoxItem Content="WebP"/>
<ComboBoxItem Content="PNG"/>
<ComboBoxItem Content="JPEG"/>
Expand Down
5 changes: 1 addition & 4 deletions ImageConverter/View/ImageView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Windows;
using ImageConverter.Class;
using ConverterUtilities;

namespace ImageConverter.View {
/// <summary>
Expand All @@ -10,13 +9,11 @@ public partial class ImageView {
public ImageView() {
InitializeComponent();
ImageUtilities.ImageListView = ImageFiles;
CUtilities.ImageView = ImageFiles;
ImageUtilities.ImageView = this;
}

private void ImageConvertButton_Click(object sender, RoutedEventArgs e) => ImageUtilities.Convert(ImageFormatSelector.SelectedIndex);

private void ClearMenu_Click(object sender, RoutedEventArgs e) => ImageFiles.Items.Clear();
private void ClearMenu_Click(object sender, RoutedEventArgs e) => ImageUtilities.Clear();
private void ImageFiles_Drop(object sender, DragEventArgs e) => ImageUtilities.PopulateList(e.Data.GetData(DataFormats.FileDrop) as string[]);
}
}
45 changes: 29 additions & 16 deletions SquirrelyConverter/Class/Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows.Controls;
using System;
using System.Windows.Controls;
using ConverterUtilities;
using Dragablz;
using ImageConverter.View;
Expand All @@ -7,27 +8,39 @@
namespace Mr_Squirrely_Converters.Class {
internal static class Utilities {

private static int Tabs { get; set; }
private static int Tabs = 0;
public static TabablzControl ConverterTabs { get; set; }

public static void AddImageTab() {
Logger.LogDebug("Adding Image Tab");
Tabs = ConverterTabs.Items.Count;
TabItem imageTab = new TabItem {
Content = new ImageView(),
Header = "Image Converter"
};
ConverterTabs.Items.Insert(Tabs, imageTab);
try {
Logger.LogDebug("Adding Image Tab");
Tabs = ConverterTabs.Items.Count;
TabItem imageTab = new TabItem {
Content = new ImageView(),
Header = "Image Converter"
};
ConverterTabs.Items.Insert(Tabs, imageTab);
}
catch (Exception ex) {
Logger.LogError(ex);
}

}

public static void AddVideoTab() {
Logger.LogDebug("Adding Video Tab");
Tabs = ConverterTabs.Items.Count;
TabItem videoTab = new TabItem {
Content = new VideoView(),
Header = "Video Converter"
};
ConverterTabs.Items.Insert(Tabs, videoTab);
try {
Logger.LogDebug("Adding Video Tab");
Tabs = ConverterTabs.Items.Count;
TabItem videoTab = new TabItem {
Content = new VideoView(),
Header = "Video Converter"
};
ConverterTabs.Items.Insert(Tabs, videoTab);
}
catch (Exception ex) {
Logger.LogError(ex);
}

}
}
}
5 changes: 1 addition & 4 deletions SquirrelyConverter/Todo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
// This is just a list of things that need to be done
// Todo Change all options code to Converter Utilities code
// Todo make the converter classes for Images and Videos equal (EX: ImageConverter.Finish(file) | VideoConverter.Copy(file))
// Todo Create the settings page
// Todo Clean Code
// Nothing
2 changes: 1 addition & 1 deletion SquirrelyConverter/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<materialDesign:PackIcon Kind="Settings" />
</Button>
<Button Name="RightWindowGithub" ToolTip="Report Bugs and Request Features" Click="RightWindowGithub_Click">
<materialDesign:PackIcon Kind="GithubFace" />
<materialDesign:PackIcon Kind="Bug" />
</Button>
</metro:WindowCommands>
</metro:MetroWindow.RightWindowCommands>
Expand Down
15 changes: 8 additions & 7 deletions SquirrelyConverter/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public MainWindow() {

Logger.LogDebug($"{CUtilities.GetWorkdingDir()}");

//CUtilities.CheckVersion(true,true,true); Todo do this better
}

private SettingsWindow _settingsWindow;
private SettingsPage _settingsPage;

private void LoadViews() {
if (File.Exists($"{CUtilities.GetWorkdingDir()}\\ImageConverter.dll")) {
Utilities.AddImageTab();
Options.StartImageSettings();
Expand All @@ -39,15 +46,8 @@ public MainWindow() {
Options.StartVideoSettings();
CUtilities.IsVideoLoaded = true;
}

//CUtilities.CheckVersion(true,true,true); Todo do this better

//Toast.PreviewRelease();
}

private SettingsWindow _settingsWindow;
private SettingsPage _settingsPage;

private void RightWindowSettings_Click(object sender, RoutedEventArgs e) {
CUtilities.MainWindow.IsEnabled = false;
_settingsPage = new SettingsPage();
Expand All @@ -68,6 +68,7 @@ private void ConverterTabs_OnSelectionChanged(object sender, SelectionChangedEve
}

private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) {
LoadViews();
Toast.PreviewRelease();
}
}
Expand Down
15 changes: 7 additions & 8 deletions SquirrelyConverter/Views/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
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"
xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
Expand All @@ -22,7 +21,7 @@
</Page.Resources>
<Grid>
<!-- dragablz:TabablzControl -->
<TabControl Width="850" Name="Control">
<dragablz:TabablzControl Width="850" Name="Control">
<TabItem Header="Default" Name="DefaultTab">
<Grid>
<CheckBox Name="CreateTemp" Content="Backup Files" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
Expand All @@ -36,7 +35,7 @@
</TabItem>
<TabItem Header="Images" Name="ImageTab">
<Grid>
<TabControl>
<dragablz:TabablzControl>
<TabItem Header="WebP">
<Grid>
<CheckBox Name="WebPLossess" Content="Lossless" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
Expand All @@ -60,21 +59,21 @@
<Label Content="Quality:" HorizontalAlignment="Left" Margin="10,33.8,0,0" VerticalAlignment="Top"/>
</Grid>
</TabItem>
</TabControl>
</dragablz:TabablzControl>
</Grid>
</TabItem>
<TabItem Header="Videos" Name="VideoTab">
<Grid>
<Label Content="VideoWidth:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
<TextBox Name="VideoWidth" HorizontalAlignment="Left" Height="23" Margin="67.2,11,0,0" TextWrapping="Wrap" Text="800" VerticalAlignment="Top" Width="60" MaxLines="1" TextAlignment="Center" PreviewTextInput="PreviewTextInput"/>
<Label Content="VideoHeight:" HorizontalAlignment="Left" Margin="132.2,10,0,0" VerticalAlignment="Top"/>
<TextBox Name="VideoHeight" HorizontalAlignment="Left" Height="23" Margin="193.61,11,0,0" TextWrapping="Wrap" Text="450" VerticalAlignment="Top" Width="60" MaxLines="1" TextAlignment="Center" PreviewTextInput="PreviewTextInput"/>
<TextBox Name="VideoWidth" HorizontalAlignment="Left" Height="23" Margin="104.073,11,0,0" TextWrapping="Wrap" Text="800" VerticalAlignment="Top" Width="60" MaxLines="1" TextAlignment="Center" PreviewTextInput="PreviewTextInput"/>
<Label Content="VideoHeight:" HorizontalAlignment="Left" Margin="168.626,10,0,0" VerticalAlignment="Top"/>
<TextBox Name="VideoHeight" HorizontalAlignment="Left" Height="23" Margin="266.91,11,0,0" TextWrapping="Wrap" Text="450" VerticalAlignment="Top" Width="60" MaxLines="1" TextAlignment="Center" PreviewTextInput="PreviewTextInput"/>
<CheckBox Name="ChangeSize" Content="Change VideoWidth and VideoHeight of video" HorizontalAlignment="Left" Margin="10,41.8,0,0" VerticalAlignment="Top"/>
</Grid>
</TabItem>


</TabControl>
</dragablz:TabablzControl>

<Button Content="Save" Name="SaveButton" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="76" Click="SaveButton_Click" Grid.Column="1"/>
<Button Content="Reset" Name="ResetButton" HorizontalAlignment="Right" Margin="0,0,90,10" VerticalAlignment="Bottom" Width="76" Click="ResetButton_Click" Grid.Column="1"/>
Expand Down
21 changes: 2 additions & 19 deletions SquirrelyConverter/Views/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
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;
using ConverterUtilities;

namespace Mr_Squirrely_Converters.Views {
/// <summary>
/// Interaction logic for SettingsWindow.xaml
/// </summary>
public partial class SettingsWindow {
public SettingsWindow() {
InitializeComponent();
}

private void SettingsWindow_OnClosed(object sender, EventArgs e) {
CUtilities.MainWindow.IsEnabled = true;
}
public SettingsWindow() => InitializeComponent();
private void SettingsWindow_OnClosed(object sender, EventArgs e) => CUtilities.MainWindow.IsEnabled = true;
}
}
Loading

0 comments on commit ef2ab0f

Please sign in to comment.