From 36d1edb4f9cc4fbd9c134d3b387bcfec05424537 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 8 Jul 2018 17:55:46 +0300 Subject: Doing some work on PPC + Mirta integration. --- .../Controls/AsyncAdornerControl.cs | 48 ++++------------------ 1 file changed, 8 insertions(+), 40 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/AsyncAdornerControl.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/AsyncAdornerControl.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/AsyncAdornerControl.cs index b20e93ff9..36779c571 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/AsyncAdornerControl.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/AsyncAdornerControl.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -23,39 +24,11 @@ namespace Tango.PPC.Common.Controls public partial class AsyncAdornerControl : ContentControl { private bool _loaded; - - public enum GWL - { - ExStyle = -20 - } - - public enum WS_EX - { - Transparent = 0x20, - Layered = 0x80000 - } - - public enum LWA - { - ColorKey = 0x1, - Alpha = 0x2 - } - - [DllImport("user32.dll", EntryPoint = "GetWindowLong")] - public static extern int GetWindowLong(IntPtr hWnd, GWL nIndex); - - [DllImport("user32.dll", EntryPoint = "SetWindowLong")] - public static extern int SetWindowLong(IntPtr hWnd, GWL nIndex, int dwNewLong); - - [DllImport("user32.dll", EntryPoint = "SetLayeredWindowAttributes")] - public static extern bool SetLayeredWindowAttributes(IntPtr hWnd, int crKey, byte alpha, LWA dwFlags); - private Window _window; public AsyncAdornerControl() { Loaded += AsyncAdornerControl_Loaded; - LayoutUpdated += AsyncAdornerControl_LayoutUpdated; IsVisibleChanged += AsyncAdornerControl_IsVisibleChanged; } @@ -71,11 +44,6 @@ namespace Tango.PPC.Common.Controls } } - private void AsyncAdornerControl_LayoutUpdated(object sender, EventArgs e) - { - SyncBounds(); - } - public Type ViewType { get { return (Type)GetValue(ViewTypeProperty); } @@ -94,6 +62,8 @@ namespace Tango.PPC.Common.Controls { if (!this.IsInDesignMode()) { + var startTime = Process.GetCurrentProcess().StartTime; + if (_loaded) return; _loaded = true; @@ -111,6 +81,11 @@ namespace Tango.PPC.Common.Controls Thread thread = new Thread(() => { + if (DateTime.Now < startTime.AddSeconds(5)) + { + Thread.Sleep(5000); + } + _window = new Window(); _window.WindowStyle = WindowStyle.None; _window.ResizeMode = ResizeMode.NoResize; @@ -129,8 +104,6 @@ namespace Tango.PPC.Common.Controls _window.ShowActivated = false; - //FrameworkElement element = Activator.CreateInstance(type) as FrameworkElement; - var cloned = FrameworkElementSerializer.Deserialize(xaml); cloned.DataContext = dc; @@ -138,11 +111,6 @@ namespace Tango.PPC.Common.Controls _window.Show(); - int wl = GetWindowLong(handle, GWL.ExStyle); - wl = wl | 0x80000 | 0x20; - SetWindowLong(handle, GWL.ExStyle, wl); - SetLayeredWindowAttributes(handle, 0, 128, LWA.Alpha); - SyncBounds(); System.Windows.Threading.Dispatcher.Run(); -- cgit v1.3.1