211 lines
7.7 KiB
C#
211 lines
7.7 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Raton.Windows.Notification
|
|
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
|
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
|
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
|
|
|
using System;
|
|
using System.CodeDom.Compiler;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Markup;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Animation;
|
|
using System.Windows.Threading;
|
|
|
|
#nullable disable
|
|
namespace Raton.Windows;
|
|
|
|
public partial class Notification : Window
|
|
{
|
|
private static Notification _instance;
|
|
|
|
public static void Show(string message, string iconGlyph = null, Color? iconColor = null)
|
|
{
|
|
Application.Current.Dispatcher.Invoke((Action) (() =>
|
|
{
|
|
if (Notification._instance == null || !Notification._instance.IsLoaded)
|
|
{
|
|
Notification._instance = new Notification();
|
|
Notification._instance.PositionWindow();
|
|
Notification._instance.Show();
|
|
}
|
|
Notification._instance.AddEntry(message, iconGlyph, iconColor);
|
|
Notification._instance.Activate();
|
|
}));
|
|
}
|
|
|
|
public Notification()
|
|
{
|
|
this.InitializeComponent();
|
|
this.Closed += new EventHandler(this.OnClosed);
|
|
}
|
|
|
|
private void OnClosed(object sender, EventArgs e) => Notification._instance = (Notification) null;
|
|
|
|
private void PositionWindow()
|
|
{
|
|
Rect workArea = SystemParameters.WorkArea;
|
|
this.Left = workArea.Right - this.Width - 16.0;
|
|
this.Top = workArea.Bottom - 10.0;
|
|
}
|
|
|
|
protected override void OnRenderSizeChanged(SizeChangedInfo info)
|
|
{
|
|
base.OnRenderSizeChanged(info);
|
|
if (!this.IsLoaded)
|
|
return;
|
|
Rect workArea = SystemParameters.WorkArea;
|
|
this.Left = workArea.Right - this.ActualWidth - 16.0;
|
|
this.Top = workArea.Bottom - this.ActualHeight - 16.0;
|
|
}
|
|
|
|
private void AddEntry(string message, string iconGlyph, Color? iconColor)
|
|
{
|
|
if (this.NotifStack.Children.Count > 0)
|
|
{
|
|
Border element = new Border();
|
|
element.Height = 1.0;
|
|
element.Background = (Brush) new SolidColorBrush(Color.FromRgb((byte) 42, (byte) 42, (byte) 42));
|
|
element.Margin = new Thickness(14.0, 0.0, 14.0, 0.0);
|
|
element.IsHitTestVisible = false;
|
|
this.NotifStack.Children.Add((UIElement) element);
|
|
}
|
|
Grid grid = new Grid();
|
|
grid.Margin = new Thickness(16.0, 14.0, 14.0, 14.0);
|
|
Grid row = grid;
|
|
row.ColumnDefinitions.Add(new ColumnDefinition()
|
|
{
|
|
Width = GridLength.Auto
|
|
});
|
|
row.ColumnDefinitions.Add(new ColumnDefinition()
|
|
{
|
|
Width = new GridLength(1.0, GridUnitType.Star)
|
|
});
|
|
row.ColumnDefinitions.Add(new ColumnDefinition()
|
|
{
|
|
Width = GridLength.Auto
|
|
});
|
|
bool flag = !string.IsNullOrWhiteSpace(iconGlyph);
|
|
if (flag)
|
|
{
|
|
TextBlock textBlock = new TextBlock();
|
|
textBlock.Text = iconGlyph;
|
|
textBlock.FontFamily = new FontFamily("Segoe MDL2 Assets");
|
|
textBlock.FontSize = 18.0;
|
|
textBlock.Foreground = (Brush) new SolidColorBrush(iconColor ?? Color.FromRgb((byte) 187, (byte) 187, (byte) 187));
|
|
textBlock.VerticalAlignment = VerticalAlignment.Top;
|
|
textBlock.Margin = new Thickness(0.0, 1.0, 12.0, 0.0);
|
|
textBlock.TextAlignment = TextAlignment.Center;
|
|
TextBlock element = textBlock;
|
|
Grid.SetColumn((UIElement) element, 0);
|
|
row.Children.Add((UIElement) element);
|
|
}
|
|
TextBlock textBlock1 = new TextBlock();
|
|
textBlock1.Text = message;
|
|
textBlock1.Foreground = (Brush) new SolidColorBrush(Color.FromRgb((byte) 204, (byte) 204, (byte) 204));
|
|
textBlock1.FontSize = 12.5;
|
|
textBlock1.FontFamily = new FontFamily("Segoe UI");
|
|
textBlock1.TextWrapping = TextWrapping.Wrap;
|
|
textBlock1.VerticalAlignment = VerticalAlignment.Center;
|
|
textBlock1.LineHeight = 18.0;
|
|
TextBlock element1 = textBlock1;
|
|
Grid.SetColumn((UIElement) element1, 1);
|
|
if (!flag)
|
|
Grid.SetColumnSpan((UIElement) element1, 1);
|
|
row.Children.Add((UIElement) element1);
|
|
Button button = new Button();
|
|
button.VerticalAlignment = VerticalAlignment.Top;
|
|
button.HorizontalAlignment = HorizontalAlignment.Right;
|
|
button.Margin = new Thickness(8.0, 0.0, 0.0, 0.0);
|
|
button.Style = (Style) this.Resources[(object) "CloseBtn"];
|
|
Button element2 = button;
|
|
Grid.SetColumn((UIElement) element2, 2);
|
|
row.Children.Add((UIElement) element2);
|
|
DispatcherTimer timer = new DispatcherTimer()
|
|
{
|
|
Interval = TimeSpan.FromSeconds(10.0)
|
|
};
|
|
bool isHovered = false;
|
|
bool timerFired = false;
|
|
timer.Tick += (EventHandler) ((s, e) =>
|
|
{
|
|
timer.Stop();
|
|
timerFired = true;
|
|
if (isHovered)
|
|
return;
|
|
this.RemoveEntryFade(row);
|
|
});
|
|
row.MouseEnter += (MouseEventHandler) ((s, e) =>
|
|
{
|
|
isHovered = true;
|
|
row.BeginAnimation(UIElement.OpacityProperty, (AnimationTimeline) null);
|
|
row.Opacity = 1.0;
|
|
});
|
|
row.MouseLeave += (MouseEventHandler) ((s, e) =>
|
|
{
|
|
isHovered = false;
|
|
if (!timerFired)
|
|
return;
|
|
this.RemoveEntryFade(row);
|
|
});
|
|
Grid capturedRow = row;
|
|
element2.Click += (RoutedEventHandler) ((s, e) =>
|
|
{
|
|
timer.Stop();
|
|
this.RemoveEntryInstant(capturedRow);
|
|
});
|
|
row.Opacity = 0.0;
|
|
row.RenderTransform = (Transform) new TranslateTransform(0.0, 6.0);
|
|
row.RenderTransformOrigin = new Point(0.5, 0.5);
|
|
this.NotifStack.Children.Add((UIElement) row);
|
|
DoubleAnimation doubleAnimation1 = new DoubleAnimation(0.0, 1.0, (Duration) TimeSpan.FromMilliseconds(220.0));
|
|
CubicEase cubicEase1 = new CubicEase();
|
|
cubicEase1.EasingMode = EasingMode.EaseOut;
|
|
doubleAnimation1.EasingFunction = (IEasingFunction) cubicEase1;
|
|
DoubleAnimation animation1 = doubleAnimation1;
|
|
DoubleAnimation doubleAnimation2 = new DoubleAnimation(6.0, 0.0, (Duration) TimeSpan.FromMilliseconds(220.0));
|
|
CubicEase cubicEase2 = new CubicEase();
|
|
cubicEase2.EasingMode = EasingMode.EaseOut;
|
|
doubleAnimation2.EasingFunction = (IEasingFunction) cubicEase2;
|
|
DoubleAnimation animation2 = doubleAnimation2;
|
|
row.BeginAnimation(UIElement.OpacityProperty, (AnimationTimeline) animation1);
|
|
row.RenderTransform.BeginAnimation(TranslateTransform.YProperty, (AnimationTimeline) animation2);
|
|
timer.Start();
|
|
}
|
|
|
|
private void RemoveEntryFade(Grid row)
|
|
{
|
|
DoubleAnimation doubleAnimation = new DoubleAnimation(1.0, 0.0, (Duration) TimeSpan.FromSeconds(10.0));
|
|
CubicEase cubicEase = new CubicEase();
|
|
cubicEase.EasingMode = EasingMode.EaseIn;
|
|
doubleAnimation.EasingFunction = (IEasingFunction) cubicEase;
|
|
DoubleAnimation animation = doubleAnimation;
|
|
animation.Completed += (EventHandler) ((s, e) => this.RemoveRowFromStack(row));
|
|
row.BeginAnimation(UIElement.OpacityProperty, (AnimationTimeline) animation);
|
|
}
|
|
|
|
private void RemoveEntryInstant(Grid row) => this.RemoveRowFromStack(row);
|
|
|
|
private void RemoveRowFromStack(Grid row)
|
|
{
|
|
int num1 = this.NotifStack.Children.IndexOf((UIElement) row);
|
|
if (num1 < 0)
|
|
return;
|
|
if (num1 > 0 && this.NotifStack.Children[num1 - 1] is Border child2 && child2.Height == 1.0)
|
|
{
|
|
this.NotifStack.Children.RemoveAt(num1 - 1);
|
|
int num2 = num1 - 1;
|
|
}
|
|
else if (num1 < this.NotifStack.Children.Count - 1 && this.NotifStack.Children[num1 + 1] is Border child1 && child1.Height == 1.0)
|
|
this.NotifStack.Children.RemoveAt(num1 + 1);
|
|
this.NotifStack.Children.Remove((UIElement) row);
|
|
if (this.NotifStack.Children.Count != 0)
|
|
return;
|
|
this.Close();
|
|
}
|
|
}
|