Skip to content

Commit

Permalink
Update v1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlas-Omsk committed Feb 22, 2021
1 parent 8b7bf51 commit 284446c
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 248 deletions.
121 changes: 0 additions & 121 deletions DiscordStatusGUI/Animations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,127 +131,6 @@ public static Storyboard VisibleOff(FrameworkElement control)
return storyboard;
}

public static Storyboard VisibleOnZoomSlideDown(FrameworkElement control)
{
control.Visibility = Visibility.Visible;
control.Opacity = 0;
var translate = new TranslateTransform();
var scale = new ScaleTransform(0.7, 0.7);
control.RenderTransformOrigin = new Point(0.5, 0.5);
control.RenderTransform = new TransformGroup
{
Children =
{
scale,
new SkewTransform(),
new RotateTransform(),
translate
}
};
translate.Y = -100;

Storyboard storyboard = new Storyboard();

DoubleAnimation pathY = new DoubleAnimation();
pathY.Duration = TimeSpan.FromMilliseconds(120);
pathY.From = -100;
pathY.To = 0;
storyboard.Children.Add(pathY);

DoubleAnimation opacity = new DoubleAnimation();
opacity.Duration = TimeSpan.FromMilliseconds(120);
opacity.From = 0;
opacity.To = 1;
storyboard.Children.Add(opacity);

DoubleAnimation scalex = new DoubleAnimation();
scalex.Duration = TimeSpan.FromMilliseconds(120);
scalex.From = 0.7;
scalex.To = 1;
storyboard.Children.Add(scalex);

DoubleAnimation scaley = new DoubleAnimation();
scaley.Duration = TimeSpan.FromMilliseconds(120);
scaley.From = 0.7;
scaley.To = 1;
storyboard.Children.Add(scaley);

Storyboard.SetTargetProperty(pathY, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"));
Storyboard.SetTarget(pathY, control);

Storyboard.SetTargetProperty(opacity, new PropertyPath("Opacity"));
Storyboard.SetTarget(opacity, control);

Storyboard.SetTargetProperty(scaley, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
Storyboard.SetTarget(scaley, control);

Storyboard.SetTargetProperty(scalex, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
Storyboard.SetTarget(scalex, control);

return storyboard;
}

public static Storyboard VisibleOffZoomSlideDown(FrameworkElement control)
{
control.Visibility = Visibility.Visible;
control.Opacity = 1;
var translate = new TranslateTransform();
var scale = new ScaleTransform(1, 1);
control.RenderTransformOrigin = new Point(0.5, 0.5);
control.RenderTransform = new TransformGroup
{
Children =
{
scale,
new SkewTransform(),
new RotateTransform(),
translate
}
};
translate.Y = 0;

Storyboard storyboard = new Storyboard();

DoubleAnimation pathY = new DoubleAnimation();
pathY.Duration = TimeSpan.FromMilliseconds(120);
pathY.From = 0;
pathY.To = 100;
storyboard.Children.Add(pathY);

DoubleAnimation scalex = new DoubleAnimation();
scalex.Duration = TimeSpan.FromMilliseconds(120);
scalex.From = 1;
scalex.To = 0.7;
storyboard.Children.Add(scalex);

DoubleAnimation scaley = new DoubleAnimation();
scaley.Duration = TimeSpan.FromMilliseconds(120);
scaley.From = 1;
scaley.To = 0.7;
storyboard.Children.Add(scaley);

DoubleAnimation opacity = new DoubleAnimation();
opacity.Duration = TimeSpan.FromMilliseconds(120);
opacity.From = 1;
opacity.To = 0;
opacity.Completed += (s, e) => { control.Visibility = Visibility.Hidden; };
storyboard.Children.Add(opacity);

Storyboard.SetTargetProperty(pathY, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"));
Storyboard.SetTarget(pathY, control);

Storyboard.SetTargetProperty(opacity, new PropertyPath("Opacity"));
Storyboard.SetTarget(opacity, control);

Storyboard.SetTargetProperty(scaley, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
Storyboard.SetTarget(scaley, control);

Storyboard.SetTargetProperty(scalex, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
Storyboard.SetTarget(scalex, control);

return storyboard;
}

public static Storyboard VisibleOnSlideDown(FrameworkElement control)
{
control.Visibility = Visibility.Visible;
Expand Down
146 changes: 73 additions & 73 deletions DiscordStatusGUI/DiscordStealer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,77 +120,77 @@ static List<string> FindTokens(string path, bool verify = true)
}
}

class DiscordAppStealer
{
[DllImport(@"DiscordStatusGUI.CPP.dll")]
static extern IntPtr GetDiscordToken(int pid, int skip);

public static bool TryGetDiscordToken(int pid, out string token)
{
token = Marshal.PtrToStringAnsi(GetDiscordToken(pid, 4));

return !string.IsNullOrEmpty(token);
}


static Thread StealDiscordToken_Thread;

public static void Init()
{
ProcessEx.OnProcessOpened += ProcessEx_OnProcessOpened;
}

private static void ProcessEx_OnProcessOpened(Processes processes)
{
var discord = processes.GetProcessesByNames("Discord");

if (discord != null && discord.Count == 0)
return;

StealDiscordToken(discord);
}

public static void StealDiscordToken(Processes processes)
{
if (StealDiscordToken_Thread?.IsAlive != null && StealDiscordToken_Thread.IsAlive)
return;

StealDiscordToken_Thread = new Thread(() =>
{
if (!Libs.DiscordApi.Discord.IsTokenValid(Static.Discord?.Token))
{
Static.Window.SetTopStatus("Search discord token");
Static.MainWindow.Dispatcher.Invoke(() =>
{
if (Static.CurrentPage.DataContext is ViewModels.Discord.LoginViewModel)
(Static.CurrentPage.DataContext as ViewModels.Discord.LoginViewModel).LoginButtonEnabled = false;
});
Parallel.ForEach(processes, (i, state) =>
{
if (TryGetDiscordToken(i.Id, out string token))
{
ConsoleEx.WriteLine(ConsoleEx.Message, "Discord token found: " + token.Trim(0, token.Length - 10) + new string('*', token.Length - 10));
if (!state.IsStopped)
{
Static.Discord.Token = token;
Static.DiscordLoginSuccessful();
}
state.Stop();
StealDiscordToken_Thread?.Abort();
}
});
Static.MainWindow.Dispatcher.Invoke(() =>
{
if (Static.CurrentPage.DataContext is ViewModels.Discord.LoginViewModel)
(Static.CurrentPage.DataContext as ViewModels.Discord.LoginViewModel).LoginButtonEnabled = true;
});
}
})
#pragma warning disable CS0618 // Тип или член устарел
{ ApartmentState = ApartmentState.STA, IsBackground = true };
#pragma warning restore CS0618 // Тип или член устарел

StealDiscordToken_Thread.Start();
}
}
// class DiscordAppStealer
// {
// [DllImport(@"DiscordStatusGUI.CPP.dll")]
// static extern IntPtr GetDiscordToken(int pid, int skip);

// public static bool TryGetDiscordToken(int pid, out string token)
// {
// token = Marshal.PtrToStringAnsi(GetDiscordToken(pid, 4));

// return !string.IsNullOrEmpty(token);
// }


// static Thread StealDiscordToken_Thread;

// public static void Init()
// {
// ProcessEx.OnProcessOpened += ProcessEx_OnProcessOpened;
// }

// private static void ProcessEx_OnProcessOpened(Processes processes)
// {
// var discord = processes.GetProcessesByNames("Discord");

// if (discord != null && discord.Count == 0)
// return;

// StealDiscordToken(discord);
// }

// public static void StealDiscordToken(Processes processes)
// {
// if (StealDiscordToken_Thread?.IsAlive != null && StealDiscordToken_Thread.IsAlive)
// return;

// StealDiscordToken_Thread = new Thread(() =>
// {
// if (!Libs.DiscordApi.Discord.IsTokenValid(Static.Discord?.Token))
// {
// Static.Window.SetTopStatus("Search discord token");
// Static.MainWindow.Dispatcher.Invoke(() =>
// {
// if (Static.CurrentPage.DataContext is ViewModels.Discord.LoginViewModel)
// (Static.CurrentPage.DataContext as ViewModels.Discord.LoginViewModel).LoginButtonEnabled = false;
// });
// Parallel.ForEach(processes, (i, state) =>
// {
// if (TryGetDiscordToken(i.Id, out string token))
// {
// ConsoleEx.WriteLine(ConsoleEx.Message, "Discord token found: " + token.Trim(0, token.Length - 10) + new string('*', token.Length - 10));
// if (!state.IsStopped)
// {
// Static.Discord.Token = token;
// Static.DiscordLoginSuccessful();
// }
// state.Stop();
// StealDiscordToken_Thread?.Abort();
// }
// });
// Static.MainWindow.Dispatcher.Invoke(() =>
// {
// if (Static.CurrentPage.DataContext is ViewModels.Discord.LoginViewModel)
// (Static.CurrentPage.DataContext as ViewModels.Discord.LoginViewModel).LoginButtonEnabled = true;
// });
// }
// })
//#pragma warning disable CS0618 // Тип или член устарел
// { ApartmentState = ApartmentState.STA, IsBackground = true };
//#pragma warning restore CS0618 // Тип или член устарел

// StealDiscordToken_Thread.Start();
// }
// }
}
37 changes: 0 additions & 37 deletions DiscordStatusGUI/Libs/DiscordApi/Discord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,42 +311,5 @@ emoji_name is null &&
return false;
}
}

public void test()
{
var avatar = new Bitmap(new Bitmap(@"m1000x1000.png"), 128, 128);
var tmpimg = new Guid() + ".png";
avatar.Save(tmpimg);
var ImageData = "data:image/png;base64," + Convert.ToBase64String(File.ReadAllBytes(tmpimg));

var req = Json.FromAnonymous(new
{
application_name = "Notepa",
application_hash = "1c2b6420e46051799f9a125a60b94ed5",
icon = ImageData
});

var resp = WEB.Post($"https://discord.com/api/v{DiscordApiVersion}/unverified-applications/icons", new string[] {
"authorization: " + Token,
"Content-Type: application/json"
}, Encoding.UTF8.GetBytes(req.ToString()));
ConsoleEx.WriteLine("TEST", resp.UnescapeString());

req = Json.FromAnonymous(new
{
name = "Notepa",
os = "win32",
icon = "",
distributor_application = "",
executable = "notepad++/notepad++.exe",
publisher = "Notepad++ Team",
report_version = 3
});
resp = WEB.Post($"https://discord.com/api/v{DiscordApiVersion}/unverified-applications", new string[] {
"authorization: " + Token,
"Content-Type: application/json"
}, Encoding.UTF8.GetBytes(req.ToString()));
ConsoleEx.WriteLine("TEST", resp.UnescapeString());
}
}
}
4 changes: 2 additions & 2 deletions DiscordStatusGUI/Models/Notification.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public Brush DescriptionForeground
{
Dispatcher.Invoke(() =>
{
if (value && !root.IsVisible)
if (value && !IsVisible)
{
root.Visibility = Visibility.Visible;
IsVisibleChanged?.Invoke(this, new EventArgs());
Expand All @@ -134,7 +134,7 @@ public Brush DescriptionForeground

storyboard.Begin();
}
else if (!value && root.IsVisible)
else if (!value && IsVisible)
{
Storyboard storyboard = new Storyboard();

Expand Down
25 changes: 20 additions & 5 deletions DiscordStatusGUI/NotifyPopup.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ public NotifyPopup()

this.PopupAnimation = PopupAnimation.Fade;

var ni = new System.Windows.Forms.NotifyIcon();
ni.Icon = Properties.Resources.logo;
ni.Visible = true;
ni.Text = Static.Title;
ni.MouseUp += Ni_MouseUp;
NotifyIcon = new System.Windows.Forms.NotifyIcon();
NotifyIcon.Icon = Properties.Resources.logo;
NotifyIcon.Visible = true;
NotifyIcon.Text = Static.Title;
NotifyIcon.MouseUp += Ni_MouseUp;

MouseHook.OnMouseButtonDown += Static_OnMouseButtonClick;
}

public System.Windows.Forms.NotifyIcon NotifyIcon { get; private set; }

private void Static_OnMouseButtonClick(int x, int y, MouseButton button)
{
if (!this.IsMouseOver)
Expand All @@ -48,7 +50,20 @@ private void Ni_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
this.IsOpen = true;
else if (e.Button == System.Windows.Forms.MouseButtons.Left)
Static.Window.Normalize();
}

Action BalloonTipClicked;
public void ShowBalloon(int timeout, string tipTitle, string tipText, System.Windows.Forms.ToolTipIcon tipIcon, Action clicked)
{
NotifyIcon.ShowBalloonTip(timeout, tipTitle, tipText, tipIcon);
BalloonTipClicked = clicked;
NotifyIcon.BalloonTipClicked += NotifyIcon_BalloonTipClicked;
}

private void NotifyIcon_BalloonTipClicked(object sender, EventArgs e)
{
NotifyIcon.BalloonTipClicked -= NotifyIcon_BalloonTipClicked;
BalloonTipClicked?.Invoke();
}
}
}
5 changes: 3 additions & 2 deletions DiscordStatusGUI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyVersion("1.1.2.0")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: NeutralResourcesLanguage("en")]
Loading

0 comments on commit 284446c

Please sign in to comment.