mirror of
https://github.com/Stone-Red-Code/ImgurAutoUploader.git
synced 2026-09-04 09:06:13 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a16de4dfc | ||
|
|
bd944e273f | ||
|
|
bc6e41ab01 | ||
|
|
4fa7fb9597 | ||
|
|
ad3d58b967 | ||
|
|
c0503c6f89 | ||
|
|
8ccf553893 | ||
|
|
a2ed708f34 |
+390
@@ -1 +1,391 @@
|
||||
ImgurAutoUploader/bin/Release/net5.0-windows/publish
|
||||
ImgurAutoUploader/bin/Debug/net5.0-windows/img.png
|
||||
*.png
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Nuget personal access tokens and Credentials
|
||||
nuget.config
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
<Window x:Class="ImgurAutoUploader.EditWindow"
|
||||
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"
|
||||
SizeChanged="Window_SizeChanged"
|
||||
Title="EditWindow" Height="450" Width="800">
|
||||
<Grid Background="#2C2C2C">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="30px" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Viewbox x:Name="viewBox" Stretch="Uniform">
|
||||
<InkCanvas x:Name="inkCanvas" PreviewMouseWheel="InkCanvas_PreviewMouseWheel" PreviewMouseLeftButtonDown="InkCanvas_PreviewMouseLeftButtonDown" PreviewMouseLeftButtonUp="InkCanvas_PreviewMouseLeftButtonUp" PreviewMouseRightButtonDown="InkCanvas_PreviewMouseRightButtonDown" PreviewMouseRightButtonUp="InkCanvas_PreviewMouseRightButtonUp" Background="Transparent">
|
||||
<InkCanvas.DefaultDrawingAttributes>
|
||||
<DrawingAttributes x:Name="attribute" Width="10" Height="10" Color="Red" />
|
||||
</InkCanvas.DefaultDrawingAttributes>
|
||||
</InkCanvas>
|
||||
</Viewbox>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ProgressBar x:Name="UploadProgressBar" Visibility="Collapsed" IsIndeterminate="True" Grid.ColumnSpan="2" />
|
||||
<Button x:Name="SecretButton" Content="Upload" Grid.Column="0" Click="UploadButton_Click" />
|
||||
<Button x:Name="UploadButton" Content="Save" Grid.Column="1" Click="SaveButton_Click" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,162 @@
|
||||
using Imgur.API.Authentication;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace ImgurAutoUploader
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für EditWindow.xaml
|
||||
/// </summary>
|
||||
public partial class EditWindow : Window
|
||||
{
|
||||
private BitmapSource bitmap;
|
||||
private ApiClient apiClient;
|
||||
|
||||
private struct OriginalSize
|
||||
{
|
||||
public OriginalSize(double x, double y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
}
|
||||
|
||||
private OriginalSize originalSize = new OriginalSize(10, 10);
|
||||
|
||||
public EditWindow(BitmapSource bitmapSource, ApiClient client)
|
||||
{
|
||||
InitializeComponent();
|
||||
bitmap = bitmapSource;
|
||||
apiClient = client;
|
||||
|
||||
inkCanvas.Width = bitmap.Width;
|
||||
inkCanvas.Height = bitmap.Height;
|
||||
|
||||
ImageBrush ib = new ImageBrush();
|
||||
ib.ImageSource = bitmapSource;
|
||||
inkCanvas.Background = ib;
|
||||
}
|
||||
|
||||
private void InkCanvas_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (e.Delta > 0)
|
||||
{
|
||||
originalSize.X++;
|
||||
originalSize.Y++;
|
||||
}
|
||||
else if (originalSize.X > 1)
|
||||
{
|
||||
originalSize.X--;
|
||||
originalSize.Y--;
|
||||
}
|
||||
|
||||
UpdateScale();
|
||||
}
|
||||
|
||||
private void InkCanvas_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
|
||||
}
|
||||
|
||||
private void InkCanvas_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||
}
|
||||
|
||||
private void InkCanvas_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
inkCanvas.DefaultDrawingAttributes.Height = originalSize.Y;
|
||||
inkCanvas.DefaultDrawingAttributes.Width = originalSize.X;
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(inkCanvas.DefaultDrawingAttributes.Width, inkCanvas.DefaultDrawingAttributes.Height);
|
||||
}
|
||||
|
||||
private void InkCanvas_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
UpdateScale();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.IsEnabled = false;
|
||||
this.Cursor = Cursors.Wait;
|
||||
Clipboard.SetImage(ControlToImage(inkCanvas));
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private async void UploadButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.IsEnabled = false;
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
|
||||
UploadProgressBar.Visibility = Visibility.Visible;
|
||||
SecretButton.Visibility = Visibility.Collapsed;
|
||||
UploadButton.Visibility = Visibility.Collapsed;
|
||||
|
||||
string link = await UploadManager.Upload(bitmap, apiClient);
|
||||
|
||||
Clipboard.SetText(link);
|
||||
UploadProgressBar.Visibility = Visibility.Collapsed;
|
||||
this.Close();
|
||||
|
||||
Mouse.OverrideCursor = null;
|
||||
}
|
||||
|
||||
public BitmapImage ControlToImage(FrameworkElement control)
|
||||
{
|
||||
RenderTargetBitmap rtb = new RenderTargetBitmap((int)control.ActualWidth, (int)control.ActualHeight, 96, 96, PixelFormats.Pbgra32);
|
||||
rtb.Render(control);
|
||||
|
||||
BitmapImage bitmapImage = new BitmapImage();
|
||||
PngBitmapEncoder bitmapEncoder = new PngBitmapEncoder();
|
||||
bitmapEncoder.Frames.Add(BitmapFrame.Create(rtb));
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
bitmapEncoder.Save(stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
bitmapImage.BeginInit();
|
||||
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmapImage.StreamSource = stream;
|
||||
bitmapImage.EndInit();
|
||||
}
|
||||
return bitmapImage;
|
||||
}
|
||||
|
||||
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
UpdateScale();
|
||||
}
|
||||
|
||||
private void UpdateScale()
|
||||
{
|
||||
double a = originalSize.Y * viewBox.GetScaleFactor() + 1;
|
||||
double b = originalSize.X * viewBox.GetScaleFactor() + 1;
|
||||
inkCanvas.DefaultDrawingAttributes.Height = a;
|
||||
inkCanvas.DefaultDrawingAttributes.Width = b;
|
||||
inkCanvas.EraserShape = new EllipseStylusShape(inkCanvas.DefaultDrawingAttributes.Width, inkCanvas.DefaultDrawingAttributes.Height);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ViewBoxExtensions
|
||||
{
|
||||
public static double GetScaleFactor(this Viewbox viewbox)
|
||||
{
|
||||
if (viewbox.Child == null ||
|
||||
(viewbox.Child is FrameworkElement) == false)
|
||||
{
|
||||
return double.NaN;
|
||||
}
|
||||
FrameworkElement child = viewbox.Child as FrameworkElement;
|
||||
return viewbox.ActualWidth / child.ActualWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Imgur.API" Version="5.0.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -9,11 +9,17 @@
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="EditWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Popup.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="EditWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="MainWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
|
||||
@@ -9,5 +9,7 @@
|
||||
Visibility="Hidden"
|
||||
ShowInTaskbar="False"
|
||||
Title="MainWindow" Height="0" Width="0">
|
||||
<Grid />
|
||||
<Grid>
|
||||
<!-- Currently empty but i may use this as an option window-->
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -5,28 +5,50 @@
|
||||
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" />
|
||||
|
||||
<Window.Resources>
|
||||
<Style x:Key="FancyButton" TargetType="Button">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Name="border" BorderThickness="0" BorderBrush="Black" Background="{TemplateBinding Background}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid x:Name="grid" MouseEnter="Grid_MouseEnter" MouseLeave="Grid_MouseLeave" Background="#2C2C2C">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="8*" />
|
||||
<RowDefinition Height="1*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Button Style="{StaticResource FancyButton}" MouseEnter="EditButton_MouseEnter" MouseLeave="EditButton_MouseLeave" Click="EditButton_Click" Cursor="Hand">
|
||||
<Button.Background>
|
||||
<ImageBrush />
|
||||
</Button.Background>
|
||||
<Grid>
|
||||
<Image x:Name="imageBox" Stretch="Uniform" />
|
||||
<Label x:Name="editLabel" Content="EDIT" Visibility="Collapsed" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="36" FontWeight="Bold" FontFamily="Myanmar Text" />
|
||||
</Grid>
|
||||
</Button>
|
||||
<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>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,9 +1,5 @@
|
||||
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;
|
||||
@@ -18,7 +14,7 @@ namespace ImgurAutoUploader
|
||||
private BitmapSource bitmap;
|
||||
private ApiClient apiClient;
|
||||
private DispatcherTimer timer = new DispatcherTimer();
|
||||
private bool upload = false;
|
||||
private bool allowHide = true;
|
||||
|
||||
public Popup(BitmapSource bitmapSource, ApiClient client)
|
||||
{
|
||||
@@ -35,59 +31,29 @@ namespace ImgurAutoUploader
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
private async void UploadButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
}
|
||||
this.IsEnabled = false;
|
||||
|
||||
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()
|
||||
{
|
||||
string link = "";
|
||||
|
||||
upload = true;
|
||||
allowHide = false;
|
||||
UploadProgressBar.Visibility = Visibility.Visible;
|
||||
SecretButton.Visibility = Visibility.Collapsed;
|
||||
UploadButton.Visibility = Visibility.Collapsed;
|
||||
|
||||
try
|
||||
{
|
||||
using HttpClient httpClient = new();
|
||||
string link = await UploadManager.Upload(bitmap, apiClient);
|
||||
|
||||
string filePath = @"img.png";
|
||||
using var fileStream = File.OpenRead(filePath);
|
||||
|
||||
ImageEndpoint imageEndpoint = new ImageEndpoint(apiClient, httpClient);
|
||||
var imageUpload = await imageEndpoint.UploadImageAsync(fileStream);
|
||||
|
||||
link = imageUpload?.Link ?? "Error";
|
||||
}
|
||||
catch
|
||||
{
|
||||
link = "Error";
|
||||
}
|
||||
Clipboard.SetText(link);
|
||||
|
||||
LinkTextBlock.Text = link;
|
||||
UploadProgressBar.Visibility = Visibility.Collapsed;
|
||||
LinkTextBlock.Visibility = Visibility.Visible;
|
||||
timer.Start();
|
||||
System.Collections.Hashtable a;
|
||||
}
|
||||
|
||||
private void SecretButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void TimerTick(object sender, EventArgs e)
|
||||
@@ -100,14 +66,34 @@ namespace ImgurAutoUploader
|
||||
|
||||
private void Grid_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
{
|
||||
if (!upload)
|
||||
if (allowHide)
|
||||
timer.Stop();
|
||||
}
|
||||
|
||||
private void Grid_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
{
|
||||
if (!upload)
|
||||
if (allowHide)
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void EditButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
{
|
||||
editLabel.Visibility = Visibility.Visible;
|
||||
imageBox.Opacity = 0.5;
|
||||
}
|
||||
|
||||
private void EditButton_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
{
|
||||
editLabel.Visibility = Visibility.Collapsed;
|
||||
imageBox.Opacity = 1;
|
||||
}
|
||||
|
||||
private void EditButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
allowHide = false;
|
||||
this.Hide();
|
||||
new EditWindow(bitmap, apiClient).ShowDialog();
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using Imgur.API.Authentication;
|
||||
using Imgur.API.Endpoints;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace ImgurAutoUploader
|
||||
{
|
||||
internal class UploadManager
|
||||
{
|
||||
static public async Task<string> Upload(BitmapSource bitmap, ApiClient apiClient)
|
||||
{
|
||||
string link = "";
|
||||
|
||||
using (var fileStream = new FileStream("img.png", FileMode.Create))
|
||||
{
|
||||
BitmapEncoder encoder = new PngBitmapEncoder();
|
||||
encoder.Frames.Add(BitmapFrame.Create(bitmap));
|
||||
encoder.Save(fileStream);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using 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);
|
||||
|
||||
link = imageUpload?.Link ?? "Error";
|
||||
}
|
||||
catch
|
||||
{
|
||||
link = "Error";
|
||||
}
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@
|
||||
".NETCoreApp,Version=v5.0": {
|
||||
"ImgurAutoUploader/1.0.0": {
|
||||
"dependencies": {
|
||||
"Imgur.API": "5.0.0"
|
||||
"Imgur.API": "5.0.0",
|
||||
"System.Drawing.Common": "5.0.2"
|
||||
},
|
||||
"runtime": {
|
||||
"ImgurAutoUploader.dll": {}
|
||||
@@ -25,6 +26,37 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/5.0.0": {},
|
||||
"Microsoft.Win32.SystemEvents/5.0.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Platforms": "5.0.0"
|
||||
}
|
||||
},
|
||||
"System.Drawing.Common/5.0.2": {
|
||||
"dependencies": {
|
||||
"Microsoft.Win32.SystemEvents": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.0/System.Drawing.Common.dll": {
|
||||
"assemblyVersion": "5.0.0.2",
|
||||
"fileVersion": "5.0.421.11614"
|
||||
}
|
||||
},
|
||||
"runtimeTargets": {
|
||||
"runtimes/unix/lib/netcoreapp3.0/System.Drawing.Common.dll": {
|
||||
"rid": "unix",
|
||||
"assetType": "runtime",
|
||||
"assemblyVersion": "5.0.0.2",
|
||||
"fileVersion": "5.0.421.11614"
|
||||
},
|
||||
"runtimes/win/lib/netcoreapp3.0/System.Drawing.Common.dll": {
|
||||
"rid": "win",
|
||||
"assetType": "runtime",
|
||||
"assemblyVersion": "5.0.0.2",
|
||||
"fileVersion": "5.0.421.11614"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Text.Json/4.7.2": {}
|
||||
}
|
||||
},
|
||||
@@ -41,6 +73,27 @@
|
||||
"path": "imgur.api/5.0.0",
|
||||
"hashPath": "imgur.api.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ==",
|
||||
"path": "microsoft.netcore.platforms/5.0.0",
|
||||
"hashPath": "microsoft.netcore.platforms.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Win32.SystemEvents/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-Bh6blKG8VAKvXiLe2L+sEsn62nc1Ij34MrNxepD2OCrS5cpCwQa9MeLyhVQPQ/R4Wlzwuy6wMK8hLb11QPDRsQ==",
|
||||
"path": "microsoft.win32.systemevents/5.0.0",
|
||||
"hashPath": "microsoft.win32.systemevents.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Drawing.Common/5.0.2": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-rvr/M1WPf24ljpvvrVd74+NdjRUJu1bBkspkZcnzSZnmAUQWSvanlQ0k/hVHk+cHufZbZfu7vOh/vYc0q5Uu/A==",
|
||||
"path": "system.drawing.common/5.0.2",
|
||||
"hashPath": "system.drawing.common.5.0.2.nupkg.sha512"
|
||||
},
|
||||
"System.Text.Json/4.7.2": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 5.9 KiB |
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -8,7 +8,8 @@
|
||||
".NETCoreApp,Version=v5.0": {
|
||||
"ImgurAutoUploader/1.0.0": {
|
||||
"dependencies": {
|
||||
"Imgur.API": "5.0.0"
|
||||
"Imgur.API": "5.0.0",
|
||||
"System.Drawing.Common": "5.0.2"
|
||||
},
|
||||
"runtime": {
|
||||
"ImgurAutoUploader.dll": {}
|
||||
@@ -25,6 +26,37 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/5.0.0": {},
|
||||
"Microsoft.Win32.SystemEvents/5.0.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Platforms": "5.0.0"
|
||||
}
|
||||
},
|
||||
"System.Drawing.Common/5.0.2": {
|
||||
"dependencies": {
|
||||
"Microsoft.Win32.SystemEvents": "5.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netcoreapp3.0/System.Drawing.Common.dll": {
|
||||
"assemblyVersion": "5.0.0.2",
|
||||
"fileVersion": "5.0.421.11614"
|
||||
}
|
||||
},
|
||||
"runtimeTargets": {
|
||||
"runtimes/unix/lib/netcoreapp3.0/System.Drawing.Common.dll": {
|
||||
"rid": "unix",
|
||||
"assetType": "runtime",
|
||||
"assemblyVersion": "5.0.0.2",
|
||||
"fileVersion": "5.0.421.11614"
|
||||
},
|
||||
"runtimes/win/lib/netcoreapp3.0/System.Drawing.Common.dll": {
|
||||
"rid": "win",
|
||||
"assetType": "runtime",
|
||||
"assemblyVersion": "5.0.0.2",
|
||||
"fileVersion": "5.0.421.11614"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Text.Json/4.7.2": {}
|
||||
}
|
||||
},
|
||||
@@ -41,6 +73,27 @@
|
||||
"path": "imgur.api/5.0.0",
|
||||
"hashPath": "imgur.api.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ==",
|
||||
"path": "microsoft.netcore.platforms/5.0.0",
|
||||
"hashPath": "microsoft.netcore.platforms.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Win32.SystemEvents/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-Bh6blKG8VAKvXiLe2L+sEsn62nc1Ij34MrNxepD2OCrS5cpCwQa9MeLyhVQPQ/R4Wlzwuy6wMK8hLb11QPDRsQ==",
|
||||
"path": "microsoft.win32.systemevents/5.0.0",
|
||||
"hashPath": "microsoft.win32.systemevents.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Drawing.Common/5.0.2": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-rvr/M1WPf24ljpvvrVd74+NdjRUJu1bBkspkZcnzSZnmAUQWSvanlQ0k/hVHk+cHufZbZfu7vOh/vYc0q5Uu/A==",
|
||||
"path": "system.drawing.common/5.0.2",
|
||||
"hashPath": "system.drawing.common.5.0.2.nupkg.sha512"
|
||||
},
|
||||
"System.Text.Json/4.7.2": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 8.2 KiB |
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
-9
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"additionalProbingPaths": [
|
||||
"C:\\Users\\David\\.dotnet\\store\\|arch|\\|tfm|",
|
||||
"C:\\Users\\David\\.nuget\\packages",
|
||||
"C:\\Microsoft\\Xamarin\\NuGet"
|
||||
]
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net5.0",
|
||||
"includedFrameworks": [
|
||||
{
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "5.0.4"
|
||||
},
|
||||
{
|
||||
"name": "Microsoft.WindowsDesktop.App",
|
||||
"version": "5.0.4"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user