Initial commit

This commit is contained in:
Stone-Red-Code
2021-03-14 22:16:54 +01:00
commit aa0b56d0d7
662 changed files with 6758 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31019.35
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImgurAutoUploader", "ImgurAutoUploader\ImgurAutoUploader.csproj", "{5D9DDEF6-D737-4C9C-A5C4-F6F48CCE1540}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5D9DDEF6-D737-4C9C-A5C4-F6F48CCE1540}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D9DDEF6-D737-4C9C-A5C4-F6F48CCE1540}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D9DDEF6-D737-4C9C-A5C4-F6F48CCE1540}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D9DDEF6-D737-4C9C-A5C4-F6F48CCE1540}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9D0C0C67-6908-46E7-B2D9-F2A1C29EBE35}
EndGlobalSection
EndGlobal
+7
View File
@@ -0,0 +1,7 @@
<Application x:Class="ImgurAutoUploader.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
+11
View File
@@ -0,0 +1,11 @@
using System.Windows;
namespace ImgurAutoUploader
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
+10
View File
@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Imgur.API" Version="5.0.0" />
</ItemGroup>
</Project>
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>C:\Users\David\Google Drive\Programmieren\ImgurAutoUploader\ImgurAutoUploader\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Compile Update="Popup.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Popup.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>
+13
View File
@@ -0,0 +1,13 @@
<Window x:Class="ImgurAutoUploader.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ImgurAutoUploader"
mc:Ignorable="d"
WindowStyle="None"
Visibility="Hidden"
ShowInTaskbar="False"
Title="MainWindow" Height="0" Width="0">
<Grid />
</Window>
+45
View File
@@ -0,0 +1,45 @@
using Imgur.API.Authentication;
using System;
using System.Windows;
using System.Windows.Threading;
namespace ImgurAutoUploader
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private ApiClient apiClient;
private bool check = true;
private double width = 0;
private double height = 0;
public MainWindow()
{
InitializeComponent();
apiClient = new ApiClient(".");
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 1);
timer.Tick += Timer_Tick;
timer.Start();
}
private void Timer_Tick(object sender, EventArgs e)
{
if (Clipboard.ContainsImage() && check)
{
check = false;
var image = Clipboard.GetImage();
if (width != image.Width || height != image.Height)
{
width = image.Width;
height = image.Height;
new Popup(image, apiClient).ShowDialog();
}
check = true;
}
}
}
}
+32
View File
@@ -0,0 +1,32 @@
<Window x:Class="ImgurAutoUploader.Popup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ImgurAutoUploader"
mc:Ignorable="d"
Loaded="Window_Loaded"
WindowStyle="None"
ResizeMode="NoResize"
Topmost="True"
Title="Popup" Height="259" Width="419">
<Border BorderBrush="Gray" BorderThickness="0.5">
<Grid x:Name="grid" MouseEnter="Grid_MouseEnter" MouseLeave="Grid_MouseLeave" Background="#2C2C2C">
<Grid.RowDefinitions>
<RowDefinition Height="8*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Image x:Name="imageBox" Stretch="Uniform" Margin="1" />
<Grid Grid.Row="1" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<ProgressBar x:Name="UploadProgressBar" Visibility="Collapsed" IsIndeterminate="True" Grid.ColumnSpan="2" />
<TextBlock x:Name="LinkTextBlock" Visibility="Collapsed" Grid.ColumnSpan="2" TextAlignment="Center" VerticalAlignment="Center" Foreground="White" />
<Button x:Name="UploadButton" Content="Upload" Click="UploadButton_Click" />
<Button x:Name="SecretButton" Content="It's a secret" Grid.Column="1" Click="SecretButton_Click" />
</Grid>
</Grid>
</Border>
</Window>
+104
View File
@@ -0,0 +1,104 @@
using Imgur.API.Authentication;
using Imgur.API.Endpoints;
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
namespace ImgurAutoUploader
{
/// <summary>
/// Interaktionslogik für Popup.xaml
/// </summary>
public partial class Popup : Window
{
private BitmapSource bitmap;
private ApiClient apiClient;
private DispatcherTimer timer = new DispatcherTimer();
private bool upload = false;
public Popup(BitmapSource bitmapSource, ApiClient client)
{
InitializeComponent();
Rect desktopWorkingArea = SystemParameters.WorkArea;
Left = desktopWorkingArea.Right - Width;
Top = desktopWorkingArea.Bottom - Height;
imageBox.Source = bitmapSource;
bitmap = bitmapSource;
apiClient = client;
timer.Interval = TimeSpan.FromSeconds(5);
timer.Tick += TimerTick;
timer.Start();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
private void UploadButton_Click(object sender, RoutedEventArgs e)
{
timer.Stop();
using (var fileStream = new FileStream("img.png", FileMode.Create))
{
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
encoder.Save(fileStream);
}
Upload();
}
private void SecretButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
private async void Upload()
{
upload = true;
UploadProgressBar.Visibility = Visibility.Visible;
SecretButton.Visibility = Visibility.Collapsed;
UploadButton.Visibility = Visibility.Collapsed;
HttpClient httpClient = new();
string filePath = @"img.png";
using var fileStream = File.OpenRead(filePath);
ImageEndpoint imageEndpoint = new ImageEndpoint(apiClient, httpClient);
var imageUpload = await imageEndpoint.UploadImageAsync(fileStream);
string link = imageUpload?.Link ?? "Error";
Clipboard.SetText(link);
UploadProgressBar.Visibility = Visibility.Collapsed;
LinkTextBlock.Visibility = Visibility.Visible;
LinkTextBlock.Text = imageUpload.Link;
timer.Start();
}
private void TimerTick(object sender, EventArgs e)
{
DispatcherTimer timer = (DispatcherTimer)sender;
timer.Stop();
timer.Tick -= TimerTick;
Close();
}
private void Grid_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
if (!upload)
timer.Stop();
}
private void Grid_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
if (!upload)
timer.Start();
}
}
}
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net5.0-windows\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net5.0-windows</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
@@ -0,0 +1,52 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v5.0": {
"ImgurAutoUploader/1.0.0": {
"dependencies": {
"Imgur.API": "5.0.0"
},
"runtime": {
"ImgurAutoUploader.dll": {}
}
},
"Imgur.API/5.0.0": {
"dependencies": {
"System.Text.Json": "4.7.2"
},
"runtime": {
"lib/netstandard2.0/Imgur.API.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.0.0"
}
}
},
"System.Text.Json/4.7.2": {}
}
},
"libraries": {
"ImgurAutoUploader/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Imgur.API/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Iso2lol4tCvSQjyJ7PVVKyPb6k6FPf4ajRb0c6qUPTUV20nT5j9tyxHvHSiSU1uhRON4dZCK9VlfMtwumDQCOw==",
"path": "imgur.api/5.0.0",
"hashPath": "imgur.api.5.0.0.nupkg.sha512"
},
"System.Text.Json/4.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-TcMd95wcrubm9nHvJEQs70rC0H/8omiSGGpU4FQ/ZA1URIqD4pjmFJh2Mfv1yH1eHgJDWTi2hMDXwTET+zOOyg==",
"path": "system.text.json/4.7.2",
"hashPath": "system.text.json.4.7.2.nupkg.sha512"
}
}
}
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\David\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\David\\.nuget\\packages",
"C:\\Microsoft\\Xamarin\\NuGet"
]
}
}
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.WindowsDesktop.App",
"version": "5.0.0"
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

@@ -0,0 +1,59 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.1": {
"ImgurAutoUploader/1.0.0": {
"dependencies": {
"Imgur.API": "5.0.0"
},
"runtime": {
"ImgurAutoUploader.dll": {}
}
},
"Imgur.API/5.0.0": {
"dependencies": {
"System.Text.Json": "4.7.2"
},
"runtime": {
"lib/netstandard2.0/Imgur.API.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.0.0"
}
}
},
"System.Text.Json/4.7.2": {
"runtime": {
"lib/netcoreapp3.0/System.Text.Json.dll": {
"assemblyVersion": "4.0.1.2",
"fileVersion": "4.700.20.21406"
}
}
}
}
},
"libraries": {
"ImgurAutoUploader/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Imgur.API/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Iso2lol4tCvSQjyJ7PVVKyPb6k6FPf4ajRb0c6qUPTUV20nT5j9tyxHvHSiSU1uhRON4dZCK9VlfMtwumDQCOw==",
"path": "imgur.api/5.0.0",
"hashPath": "imgur.api.5.0.0.nupkg.sha512"
},
"System.Text.Json/4.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-TcMd95wcrubm9nHvJEQs70rC0H/8omiSGGpU4FQ/ZA1URIqD4pjmFJh2Mfv1yH1eHgJDWTi2hMDXwTET+zOOyg==",
"path": "system.text.json/4.7.2",
"hashPath": "system.text.json.4.7.2.nupkg.sha512"
}
}
}
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\David\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\David\\.nuget\\packages",
"C:\\Microsoft\\Xamarin\\NuGet"
]
}
}
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.WindowsDesktop.App",
"version": "3.1.0"
}
}
}
@@ -0,0 +1,52 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v5.0": {
"ImgurAutoUploader/1.0.0": {
"dependencies": {
"Imgur.API": "5.0.0"
},
"runtime": {
"ImgurAutoUploader.dll": {}
}
},
"Imgur.API/5.0.0": {
"dependencies": {
"System.Text.Json": "4.7.2"
},
"runtime": {
"lib/netstandard2.0/Imgur.API.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.0.0"
}
}
},
"System.Text.Json/4.7.2": {}
}
},
"libraries": {
"ImgurAutoUploader/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Imgur.API/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Iso2lol4tCvSQjyJ7PVVKyPb6k6FPf4ajRb0c6qUPTUV20nT5j9tyxHvHSiSU1uhRON4dZCK9VlfMtwumDQCOw==",
"path": "imgur.api/5.0.0",
"hashPath": "imgur.api.5.0.0.nupkg.sha512"
},
"System.Text.Json/4.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-TcMd95wcrubm9nHvJEQs70rC0H/8omiSGGpU4FQ/ZA1URIqD4pjmFJh2Mfv1yH1eHgJDWTi2hMDXwTET+zOOyg==",
"path": "system.text.json/4.7.2",
"hashPath": "system.text.json.4.7.2.nupkg.sha512"
}
}
}
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\David\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\David\\.nuget\\packages",
"C:\\Microsoft\\Xamarin\\NuGet"
]
}
}
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.WindowsDesktop.App",
"version": "5.0.0"
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

File diff suppressed because it is too large Load Diff
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\David\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\David\\.nuget\\packages",
"C:\\Microsoft\\Xamarin\\NuGet"
]
}
}
@@ -0,0 +1,15 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "5.0.4"
},
{
"name": "Microsoft.WindowsDesktop.App",
"version": "5.0.4"
}
]
}
}

Some files were not shown because too many files have changed in this diff Show More