Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterX2000 committed Jul 11, 2016
1 parent e28699c commit aa62573
Show file tree
Hide file tree
Showing 16 changed files with 804 additions and 0 deletions.
Binary file added Icon/gfycat Random.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions gfycat Random.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gfycat Random", "gfycat Random\gfycat Random.csproj", "{6F877B85-9AA1-4236-8992-3F85B51DE494}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6F877B85-9AA1-4236-8992-3F85B51DE494}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F877B85-9AA1-4236-8992-3F85B51DE494}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F877B85-9AA1-4236-8992-3F85B51DE494}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F877B85-9AA1-4236-8992-3F85B51DE494}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
16 changes: 16 additions & 0 deletions gfycat Random/About.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Window x:Class="gfycat_Random.About"
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:gfycat_Random"
mc:Ignorable="d"
Title="About" Width="200" ResizeMode="NoResize" Height="140">
<Grid>
<TextBlock x:Name="textBlock" Margin="10" TextWrapping="Wrap">
<Hyperlink NavigateUri="http://misterx-hp.3server.de" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Homepage"/></Hyperlink><LineBreak/>
<Hyperlink NavigateUri="https://github.com/MisterX2000" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Github Profile"/></Hyperlink><LineBreak/>
<Hyperlink NavigateUri="https://github.com/MisterX2000/gfycat-Random" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="Github Project"/></Hyperlink>
<LineBreak/><Run/><LineBreak/><Run Text="Made by Mister X"/></TextBlock>
</Grid>
</Window>
23 changes: 23 additions & 0 deletions gfycat Random/About.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Windows;
using System.Diagnostics;
using System.Windows.Navigation;

namespace gfycat_Random
{
/// <summary>
/// Interaktionslogik für About.xaml
/// </summary>
public partial class About : Window
{
public About()
{
InitializeComponent();
}

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
}
}
6 changes: 6 additions & 0 deletions gfycat Random/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.5.2" />
</startup>
</configuration>
9 changes: 9 additions & 0 deletions gfycat Random/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="gfycat_Random.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:gfycat_Random"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions gfycat Random/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace gfycat_Random
{
/// <summary>
/// Interaktionslogik für "App.xaml"
/// </summary>
public partial class App : Application
{
}
}
29 changes: 29 additions & 0 deletions gfycat Random/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Window x:Class="gfycat_Random.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:gfycat_Random"
mc:Ignorable="d"
Title="gfycat Random" Height="350" Width="525">
<Grid>
<MediaElement x:Name="mediaElement" Margin="0,51,0,0" Volume="0" IsMuted="True" MediaEnded="mediaElement_MediaEnded" LoadedBehavior="Manual" MediaFailed="mediaElement_MediaFailed" MediaOpened="mediaElement_MediaOpened"/>
<Menu x:Name="menu" VerticalAlignment="Top" IsHitTestVisible="True">
<MenuItem Header="File">
<MenuItem x:Name="mi_save" Header="Save gfycat" Click="mi_save_Click" IsEnabled="False"/>
<MenuItem x:Name="mi_exit" Header="Exit" Click="mi_exit_Click"/>
</MenuItem>
<MenuItem Header="Settings">
<MenuItem Header="File Format">
<MenuItem x:Name="mi_mp4" Header="mp4" IsCheckable="True" IsChecked="True" Checked="mi_mp4_Checked"/>
<MenuItem x:Name="mi_webm" Header="webm" IsCheckable="True" Checked="mi_webm_Checked"/>
<MenuItem x:Name="mi_gif" Header="gif" IsCheckable="True" Checked="mi_gif_Checked" ToolTip="WARNING! Very long loading times."/>
</MenuItem>
</MenuItem>
<MenuItem x:Name="mi_about" Header="About" Click="mi_about_Click"/>
</Menu>
<Button x:Name="bt_random" Content="Random" HorizontalAlignment="Left" Margin="10,23,0,0" VerticalAlignment="Top" Click="bt_random_Click" Width="54"/>
<Label x:Name="l_link" Content="http://giant.gfycat.com/" HorizontalAlignment="Left" Margin="69,20,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.725,1.734"/>
<Button x:Name="bt_copylink" Content="Copy Link" Margin="0,23,10,0" VerticalAlignment="Top" HorizontalAlignment="Right" Click="bt_copylink_Click" Width="61"/>
</Grid>
</Window>
131 changes: 131 additions & 0 deletions gfycat Random/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows;

namespace gfycat_Random
{
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private string format = "mp4";

private void mediaElement_MediaEnded(object sender, RoutedEventArgs e)
{
mediaElement.Position = new TimeSpan(0, 0, 0);
}

private void bt_random_Click(object sender, RoutedEventArgs e)
{
DoStuff();
}

private void DoStuff()
{
mediaElement.Source = new Uri(GetRandomLink());
mediaElement.Play();
l_link.Content = mediaElement.Source.AbsoluteUri;
}

private string GetRandomLink()
{
var adj = File.ReadAllLines(@"adjectives.txt");
var ani = File.ReadAllLines(@"animals.txt");
var r = new Random();

var word1 = UppercaseFirst(adj[r.Next(0, adj.Count() - 1)]);
var word2 = UppercaseFirst(adj[r.Next(0, adj.Count() - 1)]);
var word3 = UppercaseFirst(ani[r.Next(0, ani.Count() - 1)]);

var link = string.Format("http://giant.gfycat.com/{0}.{1} ", word1 + word2 + word3, format);

return link;
}

static string UppercaseFirst(string s)
{
if (string.IsNullOrEmpty(s))
return string.Empty;
return char.ToUpper(s[0]) + s.Substring(1);
}

private void bt_copylink_Click(object sender, RoutedEventArgs e)
{
Clipboard.SetText(mediaElement.Source.AbsoluteUri);
}

private void mi_exit_Click(object sender, RoutedEventArgs e)
{
Close();
}

private void mediaElement_MediaFailed(object sender, ExceptionRoutedEventArgs e)
{
DoStuff();

mi_save.IsEnabled = false;
}

private void mi_save_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = mediaElement.Source.LocalPath.Substring(1);
dlg.DefaultExt = "." + format;
dlg.Filter = "Video|*.mp4;*.webm;*.gif";

// Show save file dialog box
Nullable<bool> result = dlg.ShowDialog();

// Process save file dialog box results
if (result == true)
{
// Save document
string filename = dlg.FileName;
new WebClient().DownloadFile(mediaElement.Source.AbsoluteUri, filename);
}
}

private void mediaElement_MediaOpened(object sender, RoutedEventArgs e)
{
mi_save.IsEnabled = true;
}

private void mi_mp4_Checked(object sender, RoutedEventArgs e)
{
format = "mp4";
if (mi_webm != null || mi_gif != null)
{
mi_webm.IsChecked = false;
mi_gif.IsChecked = false;
}

}

private void mi_webm_Checked(object sender, RoutedEventArgs e)
{
format = "webm";
mi_mp4.IsChecked = false;
mi_gif.IsChecked = false;
}

private void mi_gif_Checked(object sender, RoutedEventArgs e)
{
format = "gif";
mi_mp4.IsChecked = false;
mi_webm.IsChecked = false;
}

private void mi_about_Click(object sender, RoutedEventArgs e)
{
new About().ShowDialog();
}
}
}
55 changes: 55 additions & 0 deletions gfycat Random/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// 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("gfycat Random")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("gfycat Random")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. 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)]

//Um mit dem Erstellen lokalisierbarer Anwendungen zu beginnen, legen Sie
//<UICulture>ImCodeVerwendeteKultur</UICulture> in der .csproj-Datei
//in einer <PropertyGroup> fest. Wenn Sie in den Quelldateien beispielsweise Deutsch
//(Deutschland) verwenden, legen Sie <UICulture> auf \"de-DE\" fest. Heben Sie dann die Auskommentierung
//des nachstehenden NeutralResourceLanguage-Attributs auf. Aktualisieren Sie "en-US" in der nachstehenden Zeile,
//sodass es mit der UICulture-Einstellung in der Projektdatei übereinstimmt.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
//(wird verwendet, wenn eine Ressource auf der Seite
// oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
//(wird verwendet, wenn eine Ressource auf der Seite, in der Anwendung oder einem
// designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
)]


// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// ü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 aa62573

Please sign in to comment.