Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5388248
commit 5549165
Showing
6 changed files
with
221 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<mah:MetroWindow x:Class="AUCapture_WPF.Contributors" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" | ||
xmlns:dialogs="http://metro.mahapps.com/winfx/xaml/controls" | ||
xmlns:li="http://github.com/zeluisping/loadingIndicators/xaml/controls" | ||
xmlns:converters="clr-namespace:AUCapture_WPF.Converters" | ||
xmlns:controls="clr-namespace:AUCapture_WPF.Controls" | ||
xmlns:wpf="clr-namespace:LoadingIndicators.WPF;assembly=LoadingIndicators.WPF" | ||
xmlns:hc="https://handyorg.github.io/handycontrol" | ||
xmlns:local="clr-namespace:AUCapture_WPF" | ||
Style="{DynamicResource MahApps.Styles.MetroWindow.Clean}" | ||
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" | ||
xmlns:b="http://schemas.microsoft.com/xaml/behaviors" | ||
mc:Ignorable="d" | ||
Title="Contributors" Height="450" Width="450"> | ||
<mah:MetroWindow.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/clean/Controls.xaml" /> | ||
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! --> | ||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> | ||
<!-- Theme setting --> | ||
<hc:Theme Name="HandyTheme"/> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</mah:MetroWindow.Resources> | ||
<Grid> | ||
<GroupBox Header="The special people that make capture possible"> | ||
<Border Background="{DynamicResource RegionBrush}" CornerRadius="4,4,0,0" Width="{Binding Width, RelativeSource={RelativeSource AncestorType=GroupBox}}" Height="{Binding Height, RelativeSource={RelativeSource AncestorType=GroupBox}}"> | ||
<Viewbox Stretch="Uniform"> | ||
<ListBox BorderThickness="0" Style="{StaticResource ListBoxCustom}" ItemsSource="{Binding }"> | ||
|
||
|
||
<ListBox.ItemTemplate> | ||
<DataTemplate> | ||
<hc:Gravatar Source="{Binding AvatarUrl}" Style="{StaticResource GravatarCircleImg}" ToolTip="{Binding Login}" MouseDown="Gravatar_MouseDown" Cursor="Hand"/> | ||
</DataTemplate> | ||
</ListBox.ItemTemplate> | ||
<ListBox.ItemsPanel> | ||
<ItemsPanelTemplate> | ||
<hc:HoneycombPanel IsItemsHost="True" Margin="10" hc:PanelElement.FluidMoveBehavior="{StaticResource BehaviorXY400}"/> | ||
</ItemsPanelTemplate> | ||
</ListBox.ItemsPanel> | ||
</ListBox> | ||
|
||
|
||
</Viewbox> | ||
</Border> | ||
|
||
</GroupBox> | ||
|
||
</Grid> | ||
</mah:MetroWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
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 System.Windows.Threading; | ||
using HandyControl.Controls; | ||
using HandyControl.Data; | ||
using HandyControl.Themes; | ||
using HandyControl.Tools; | ||
using MahApps.Metro.Controls; | ||
using Octokit; | ||
|
||
namespace AUCapture_WPF | ||
{ | ||
/// <summary> | ||
/// Interaction logic for Contributors.xaml | ||
/// </summary> | ||
public partial class Contributors | ||
{ | ||
public Queue<RepositoryContributor> RepoContributorsToBeAdded = new(); | ||
public ObservableCollection<RepositoryContributor> CurrentContributors = new(); | ||
public Contributors(bool dark) | ||
{ | ||
InitializeComponent(); | ||
if (dark) | ||
{ | ||
SharedResourceDictionary.SharedDictionaries.Clear(); | ||
ResourceHelper.GetTheme("HandyTheme", Resources).Skin = SkinType.Dark; | ||
|
||
} | ||
|
||
DataContext = CurrentContributors; | ||
AddContributors(); | ||
|
||
} | ||
|
||
public async void AddContributors() | ||
{ | ||
GitHubClient client = new GitHubClient(new ProductHeaderValue("AmongUsCapture")); | ||
IReadOnlyList<RepositoryContributor> repoContribs = await client.Repository.GetAllContributors("automuteus", "amonguscapture"); | ||
var tempList = repoContribs.Where(x => x.Id != 49699333).ToList(); | ||
tempList.Shuffle(); | ||
RepoContributorsToBeAdded = new Queue<RepositoryContributor>(tempList); | ||
CurrentContributors.Add(RepoContributorsToBeAdded.Dequeue()); | ||
|
||
System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); | ||
dispatcherTimer.Tick += dispatcherTimer_Tick; | ||
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(100); | ||
dispatcherTimer.Start(); | ||
} | ||
private void dispatcherTimer_Tick(object sender, EventArgs e) | ||
{ | ||
|
||
if (RepoContributorsToBeAdded.Count != 0) | ||
{ | ||
var c = RepoContributorsToBeAdded.Dequeue(); | ||
CurrentContributors.Add(c); | ||
Console.WriteLine(c.Login); | ||
|
||
|
||
} | ||
else | ||
{ | ||
var timer = sender as DispatcherTimer; | ||
timer.Stop(); | ||
} | ||
|
||
|
||
} | ||
public static void OpenBrowser(string url) | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); | ||
} | ||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
{ | ||
Process.Start("xdg-open", url); | ||
} | ||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | ||
{ | ||
Process.Start("open", url); | ||
} | ||
else | ||
{ | ||
// throw | ||
} | ||
} | ||
private void Gravatar_MouseDown(object sender, MouseButtonEventArgs e) | ||
{ | ||
var tar = sender as Gravatar; | ||
var tarContext = tar.DataContext as RepositoryContributor; | ||
OpenBrowser(tarContext.HtmlUrl); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace AUCapture_WPF | ||
{ | ||
public static class ThreadSafeRandom | ||
{ | ||
[ThreadStatic] private static Random Local; | ||
|
||
public static Random ThisThreadsRandom | ||
{ | ||
get { return Local ?? (Local = new Random(unchecked(Environment.TickCount * 31 + Thread.CurrentThread.ManagedThreadId))); } | ||
} | ||
} | ||
|
||
static class MyExtensions | ||
{ | ||
public static void Shuffle<T>(this IList<T> list) | ||
{ | ||
int n = list.Count; | ||
while (n > 1) | ||
{ | ||
n--; | ||
int k = ThreadSafeRandom.ThisThreadsRandom.Next(n + 1); | ||
T value = list[k]; | ||
list[k] = list[n]; | ||
list[n] = value; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters