<commit_before>﻿using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Forms;
using System.Windows.Media.Animation;
using System.Linq;
using System.ComponentModel;
using MahApps.Metro.Controls;
using CefSharp;
using CefSharp.Wpf;
using System.Threading.Tasks;
using System.Diagnostics;

namespace NotificationWebView
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow: Window, IDisposable
	{
		private Storyboard SlideUpStoryboard = null;
		private Storyboard SlideDownStoryboard  = null;

		private DoubleAnimation SlideUpAnimation = null;
		private DoubleAnimation SlideDownAnimation = null;

		private CefSettings WebViewSettings = null;

		private bool AllowFormClose = false;

		public MainWindow()
		{
			WebViewSettings = new CefSettings();
			WebViewSettings.UserAgent = String.Format("Mozilla/5.0 (Linux; 6.0;) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{0} Mobile Safari/537.36", Cef.ChromiumVersion);

			Cef.Initialize(WebViewSettings);

			InitializeComponent();		

			SlideUpStoryboard = (Storyboard)TryFindResource("SlideUpStoryboard");
			SlideDownStoryboard = (Storyboard)TryFindResource("SlideDownStoryboard");

			SlideUpAnimation = (DoubleAnimation)SlideUpStoryboard.Children.First();
			SlideDownAnimation = (DoubleAnimation)SlideDownStoryboard.Children.First();

			Loaded += new RoutedEventHandler(delegate (object sender, RoutedEventArgs e)
			{
				NavigateTo("https://www.google.com");
			});

			Closing += new CancelEventHandler(delegate (object sender, CancelEventArgs e)
			{
				if(!AllowFormClose)
				{
					e.Cancel = true;
				}				
				SlideDown();		
			});

			System.Windows.Application.Current.Exit += Current_Exit;

			SlideDownAnimation.Completed += new EventHandler(delegate (object o, EventArgs e)
			{
				Hide();
			});
		}

		private void Current_Exit(object sender, ExitEventArgs e)
		{
			Dispose();
		}

		public void SlideUp()
		{
			using (var dpiSettings = new DpiCalculator())
			{
				dpiSettings.LoadDpi();

				System.Drawing.Point cursor = Control.MousePosition;

				SlideUpAnimation.From = Top = Screen.PrimaryScreen.Bounds.Bottom;
				Show();

				Left = cursor.X / dpiSettings.ScalingFactorX - ActualWidth / 2;

				if ((Left + Width) * dpiSettings.ScalingFactorX > Screen.PrimaryScreen.Bounds.Right)
				{
					Left = Screen.PrimaryScreen.Bounds.Right / dpiSettings.ScalingFactorX - Width;
				}

				// The WPF form height is already adjusted for the DPI (software pixels) - WorkingArea.Bottom will report the physical pixels.
				SlideUpAnimation.To = Screen.PrimaryScreen.WorkingArea.Bottom / dpiSettings.ScalingFactorY - ActualHeight;
			}

			SlideUpStoryboard.Begin(this);
		}

		public void SlideDown()
		{
			if (!IsVisible) return;

			var dpiSettings = new DpiCalculator();
			dpiSettings.LoadDpi();

			SlideDownAnimation.From = Top;
			SlideDownAnimation.To = Screen.PrimaryScreen.Bounds.Bottom;
<commit_msg>Remained consistent with using ActualWidth for the window placement when moved from rendering offscreen.<commit_after>﻿using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Forms;
using System.Windows.Media.Animation;
using System.Linq;
using System.ComponentModel;
using MahApps.Metro.Controls;
using CefSharp;
using CefSharp.Wpf;
using System.Threading.Tasks;
using System.Diagnostics;

namespace NotificationWebView
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow: Window, IDisposable
	{
		private Storyboard SlideUpStoryboard = null;
		private Storyboard SlideDownStoryboard  = null;

		private DoubleAnimation SlideUpAnimation = null;
		private DoubleAnimation SlideDownAnimation = null;

		private CefSettings WebViewSettings = null;

		private bool AllowFormClose = false;

		public MainWindow()
		{
			WebViewSettings = new CefSettings();
			WebViewSettings.UserAgent = String.Format("Mozilla/5.0 (Linux; 6.0;) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{0} Mobile Safari/537.36", Cef.ChromiumVersion);

			Cef.Initialize(WebViewSettings);

			InitializeComponent();		

			SlideUpStoryboard = (Storyboard)TryFindResource("SlideUpStoryboard");
			SlideDownStoryboard = (Storyboard)TryFindResource("SlideDownStoryboard");

			SlideUpAnimation = (DoubleAnimation)SlideUpStoryboard.Children.First();
			SlideDownAnimation = (DoubleAnimation)SlideDownStoryboard.Children.First();

			Loaded += new RoutedEventHandler(delegate (object sender, RoutedEventArgs e)
			{
				NavigateTo("https://www.google.com");
			});

			Closing += new CancelEventHandler(delegate (object sender, CancelEventArgs e)
			{
				if(!AllowFormClose)
				{
					e.Cancel = true;
				}				
				SlideDown();		
			});

			System.Windows.Application.Current.Exit += Current_Exit;

			SlideDownAnimation.Completed += new EventHandler(delegate (object o, EventArgs e)
			{
				Hide();
			});
		}

		private void Current_Exit(object sender, ExitEventArgs e)
		{
			Dispose();
		}

		public void SlideUp()
		{
			using (var dpiSettings = new DpiCalculator())
			{
				dpiSettings.LoadDpi();

				System.Drawing.Point cursor = Control.MousePosition;

				SlideUpAnimation.From = Top = Screen.PrimaryScreen.Bounds.Bottom;
				Show();

				Left = cursor.X / dpiSettings.ScalingFactorX - ActualWidth / 2;

				if ((Left + ActualWidth) * dpiSettings.ScalingFactorX > Screen.PrimaryScreen.Bounds.Right)
				{
					Left = Screen.PrimaryScreen.Bounds.Right / dpiSettings.ScalingFactorX - ActualWidth;
				}

				// The WPF form height is already adjusted for the DPI (software pixels) - WorkingArea.Bottom will report the physical pixels.
				SlideUpAnimation.To = Screen.PrimaryScreen.WorkingArea.Bottom / dpiSettings.ScalingFactorY - ActualHeight;
			}

			SlideUpStoryboard.Begin(this);
		}

		public void SlideDown()
		{
			if (!IsVisible) return;

			var dpiSettings = new DpiCalculator();
			dpiSettings.LoadDpi();

			SlideDownAnimation.From = Top;
			SlideDownAnimation.To = Screen.PrimaryScreen.Bounds.Bottom;

{'fraction_non_alphanumeric': 0.10233096379566871, 'fraction_numerical': 0.00529013060009919, 'mean_word_length': 4.140186915887851, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '806789', 'n_tokens_mistral': 2172, 'n_tokens_neox': 1803, 'n_words': 399}