Skip to content

Commit

Permalink
Basic start
Browse files Browse the repository at this point in the history
-All wanted pictures will be copied.
-Sort by ratio
-Selectable directory
-Function to start with Windows
  • Loading branch information
Daniel Gerdes committed Jan 20, 2019
0 parents commit 324f4c2
Show file tree
Hide file tree
Showing 12 changed files with 639 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.vs
/bin
/obj
*.pfx
6 changes: 6 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
</startup>
</configuration>
133 changes: 133 additions & 0 deletions BilderGui.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CCB650DE-752E-4505-A099-16D2F1606A5B}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>BilderGui</RootNamespace>
<AssemblyName>BilderGui</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>C:\Users\Daniel\OneDrive - ruhr-uni-bochum.de\Projekte\C#\BilderGui\publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ProductName>Bilder</ProductName>
<PublisherName>Daniel Gerdes</PublisherName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>0FFB961A8817186516CB89197CC3697EC3CD9DA7</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>BilderGui_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>BilderGui_TemporaryKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="BilderGui_TemporaryKey.pfx" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.1 %28x86 und x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
21 changes: 21 additions & 0 deletions BilderGui.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<RemoteDebugEnabled>false</RemoteDebugEnabled>
<StartArguments>
</StartArguments>
</PropertyGroup>
<PropertyGroup>
<PublishUrlHistory>C:\Users\Daniel\OneDrive - ruhr-uni-bochum.de\Projekte\C#\BilderGui\publish\|/publish/|ftp://valendia.bplaced.net/bild/|ftp://valendia.bplaced.net/|publish\</PublishUrlHistory>
<InstallUrlHistory>http://valendia.bplaced.net/bild/</InstallUrlHistory>
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>de-DE</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
<PropertyGroup>
<EnableSecurityDebugging>false</EnableSecurityDebugging>
</PropertyGroup>
</Project>
25 changes: 25 additions & 0 deletions BilderGui.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2018
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BilderGui", "BilderGui.csproj", "{CCB650DE-752E-4505-A099-16D2F1606A5B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CCB650DE-752E-4505-A099-16D2F1606A5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCB650DE-752E-4505-A099-16D2F1606A5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCB650DE-752E-4505-A099-16D2F1606A5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCB650DE-752E-4505-A099-16D2F1606A5B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {701CEBCE-4476-4DC3-8307-A717FAA3B0EE}
EndGlobalSection
EndGlobal
119 changes: 119 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using System;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
using Microsoft.Win32;

namespace BilderGui
{
static class Program
{

static string config = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Remove(0, 6) + "\\config.dat";

[STAThread]
static void Main(string[] args)
{
string folder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Remove(0, 6) + "\\Bilder";
string user = Environment.UserName;
string bilder = "C:\\Users\\" + user + "\\AppData\\Local\\Packages\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\LocalState\\Assets\\";
bool force = false;

if (args.Length > 0)
{
if (args[0].Equals("startup"))
{
StartUp();
return;
}
else if (args[0].Equals("nostartup"))
{
RemoveStartUp();
return;
}
else if (args[0].Equals("-s")) force = true;
}

folder = Init(folder, force);

Copy(bilder, folder);
}

static void StartUp()
{
RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
key.SetValue("Bilder", Directory.GetCurrentDirectory() + "\\BilderGui.exe");
}

static void RemoveStartUp()
{
RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
key.DeleteValue("Bilder", false);
}

static string Init(string folder, bool force)
{
if (File.Exists(config))
{
StreamReader sr = new StreamReader(File.OpenRead(config));
string read = sr.ReadLine();
if (!read.Trim().Equals("")) folder = read;
sr.Close();
}
if(!File.Exists(config)||force||!Directory.Exists(folder))
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.ShowNewFolderButton = true;
fbd.RootFolder = Environment.SpecialFolder.Desktop;

if (fbd.ShowDialog() == DialogResult.OK)
{
folder = fbd.SelectedPath;
}
else if (!Directory.Exists(folder)) folder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Remove(0, 6) + "\\Bilder";

StreamWriter sw = new StreamWriter(File.Create(config));
sw.Write(folder);
sw.Close();
}
if (!folder.EndsWith("\\")) folder += "\\";

if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
if (!Directory.Exists(folder + "Horizontal")) Directory.CreateDirectory(folder + "Horizontal");
if (!Directory.Exists(folder + "Vertikal")) Directory.CreateDirectory(folder + "Vertikal");
return folder;
}

static void Copy(string bilder, string folder)
{
string[] files = Directory.GetFiles(bilder);
foreach (string file in files)
{
FileInfo fi = new FileInfo(file);
if (fi.Length > 100 * 1024)
{
string pathHo = folder + "Horizontal\\";
string pathVer = folder + "Vertikal\\";
if (!File.Exists(pathVer + fi.Name + ".jpg")&& !File.Exists(pathHo + fi.Name + ".jpg"))
{
Image img = Image.FromFile(file);
if (img.Width > img.Height)
{
File.Copy(file, pathHo + fi.Name + ".jpg");
Console.WriteLine("Copied: " + fi.Name + " to " + pathHo + "\nwith " + fi.Length / 1024 + "kb\n");
}
else if(img.Width < img.Height)
{
File.Copy(file, pathVer + fi.Name + ".jpg");
Console.WriteLine("Copied: " + fi.Name + " to " + pathVer + "\nwith " + fi.Length / 1024 + "kb\n");
}
else
{
Console.WriteLine("Not copied: " + fi.Name + " is probably not the type of image you want!\n");
}
}
}
}
}
}
}
36 changes: 36 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("BilderGui")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BilderGui")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("ccb650de-752e-4505-a099-16d2f1606a5b")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 324f4c2

Please sign in to comment.