private void SetPosition() { if (TaskButton == null || TaskButton.ParentTaskbar == null) { return; } Point taskButtonPoint = TaskButton.GetThumbnailAnchor(); if (Settings.Instance.TaskbarPosition == 1) { // taskbar on top Top = taskButtonPoint.Y + TaskButton.ActualHeight; } else { Top = taskButtonPoint.Y - ActualHeight; } double desiredLeft = taskButtonPoint.X - ((ActualWidth - TaskButton.ActualWidth) / 2); if (desiredLeft < TaskButton.ParentTaskbar.Left) { Left = TaskButton.ParentTaskbar.Left; } else if (desiredLeft + ActualWidth > TaskButton.ParentTaskbar.Left + TaskButton.ParentTaskbar.ActualWidth) { double bump = desiredLeft + ActualWidth - (TaskButton.ParentTaskbar.Left + TaskButton.ParentTaskbar.ActualWidth); Left = desiredLeft - bump; } else { Left = desiredLeft; } }
private void Window_SourceInitialized(object sender, EventArgs e) { // hide from alt-tab WindowInteropHelper helper = new WindowInteropHelper(this); handle = helper.Handle; Shell.HideWindowFromTasks(handle); // get anchor point Point taskButtonPoint = taskButton.GetThumbnailAnchor(); if (Configuration.Settings.Instance.TaskbarPosition == 1) { // taskbar on top Top = taskButtonPoint.Y + taskButton.ActualHeight; bdrThumb.Style = Application.Current.FindResource("TaskThumbWindowBorderTopStyle") as Style; bdrThumbInner.Style = Application.Current.FindResource("TaskThumbWindowInnerBorderTopStyle") as Style; bdrTranslate.Y *= -1; ToolTipService.SetPlacement(this, System.Windows.Controls.Primitives.PlacementMode.Bottom); } else { Top = taskButtonPoint.Y - ActualHeight; } Left = taskButtonPoint.X - ((ActualWidth - taskButton.ActualWidth) / 2); if (isDwmEnabled) { // set up thumbnail dwmThumbnail.DpiScale = taskButton.ParentTaskbar.dpiScale; dwmThumbnail.ThumbnailOpacity = 0; dwmThumbnail.SourceWindowHandle = taskButton.Window.Handle; // set up animation isAnimating = true; System.Windows.Media.CompositionTarget.Rendering += CompositionTarget_Rendering; } }