public static async Task RaiseWindowResizeEvent(int width, int height) { WindowWidth = width; WindowHeight = height; bool canRaiseEvent = true; try { if (WindowResize?.Target == null) { canRaiseEvent = false; } else { _ = WindowResize.Target.ToString(); } } catch (Exception ex) { canRaiseEvent = false; } if (canRaiseEvent) { await WindowResize?.Invoke(); } }
/// <summary> /// Set media window /// </summary> /// <param name="MediaWindow">Media window</param> /// <param name="Width">Floating window width</param> /// <param name="Height">Floating window height</param> /// <param name="Position">Floating window position</param> /// <param name="TitleBar">Floating window title bar</param> /// <param name="Resize">Floating window resize</param> /// <param name="Title">Floating window title</param> /// <remarks> /// <para> /// All optional arguments are applicable to floating window only. /// </para> /// </remarks> public void SetMediaWindow ( MediaWindow MediaWindow, Int32 Width = 0, Int32 Height = 0, WindowPosition Position = WindowPosition.Center, WindowTitleBar TitleBar = WindowTitleBar.TitleBarWithCloseButton, WindowResize Resize = WindowResize.KeepAspectRatio, String Title = null ) { // set media play window code MediaScreenParamBE.AddInteger("/W", (Int32)MediaWindow); // all choices but floating window if (MediaWindow != MediaWindow.Floating) { MediaScreenParamBE.Remove("/F"); return; } // play rendition in floating window // Table 9.19 page 774 PdfDictionary FloatingWindow = new PdfDictionary(this); MediaScreenParamBE.AddDictionary("/F", FloatingWindow); // window's dimensions if (Width == 0 || Height == 0) { Width = 320; Height = 180; } FloatingWindow.AddFormat("/D", "[{0} {1}]", Width, Height); FloatingWindow.AddInteger("/P", (Int32)Position); FloatingWindow.AddBoolean("/T", TitleBar != WindowTitleBar.NoTitleBar); if (TitleBar == WindowTitleBar.NoTitleBar) { return; } FloatingWindow.AddInteger("/R", (Int32)Resize); if (Title != null) { // if(Document.Encryption == null) // { // FloatingWindow.AddFormat("/TT", "[() ({0})]", Title); // } // else // { FloatingWindow.AddFormat("/TT", "[{0} {1}]", Document.TextToPdfString(String.Empty, this), Document.TextToPdfString(Title, this)); // } } return; }
} // OnPrepareGraphicsDevice #endregion #region On Screen Size Changed /// <summary> /// Raised when the window size changes. /// </summary> private static void OnScreenSizeChanged(object sender, System.EventArgs e) { if (WindowResize != null) WindowResize.Invoke(null, new ResizeEventArgs(EngineManager.Device.PresentationParameters.BackBufferWidth, EngineManager.Device.PresentationParameters.BackBufferHeight, oldScreenWidth, oldScreenHeight)); oldScreenWidth = EngineManager.Device.PresentationParameters.BackBufferWidth; oldScreenHeight = EngineManager.Device.PresentationParameters.BackBufferHeight; } // OnScreenSizeChanged
public static async Task RaiseWindowResizeEvent(int width, int height) { WindowWidth = width; WindowHeight = height; try { await WindowResize?.Invoke(); } catch { } }
/* * private void PopulateScreens() * { * settings.Screens = Screen.AllScreens.Select(s => * { * string friendlyName = s.DeviceName; * if (settings.ScreenFriendlyName) * { * try * { * string friendlyNameStr = s.DeviceFriendlyName(); * if (!String.IsNullOrEmpty(friendlyNameStr)) * { * friendlyName = friendlyNameStr; * } * } * catch { } * } * return new ScreenInfo(s.DeviceName, friendlyName); * }).ToList(); * * if (string.IsNullOrWhiteSpace(settings.Screen) && settings.Screens.Count > 0) * { * settings.Screen = settings.Screens[0].DeviceName; * } * Logger.Instance.LogMessage(TracingLevel.INFO, $"Populated {settings.Screens.Count} screens"); * }*/ private async Task MoveApplication() { if (String.IsNullOrWhiteSpace(settings.Screen)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Screen not specified."); await Connection.ShowAlert(); return; } if (settings.AppSpecific && String.IsNullOrWhiteSpace(settings.ApplicationName)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Application not specified."); await Connection.ShowAlert(); return; } if (String.IsNullOrWhiteSpace(settings.XPosition) || String.IsNullOrWhiteSpace(settings.YPosition)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"X or Y position not specified."); await Connection.ShowAlert(); return; } if (!int.TryParse(settings.XPosition, out int xPosition)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid X position: {settings.XPosition}"); await Connection.ShowAlert(); return; } if (!int.TryParse(settings.YPosition, out int yPosition)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid Y position: {settings.YPosition}"); await Connection.ShowAlert(); return; } WindowSize windowSize = null; WindowResize windowResize = WindowResize.NoResize; if (settings.ResizeWindow) { windowResize = WindowResize.ResizeWindow; if (String.IsNullOrWhiteSpace(settings.Height) || String.IsNullOrWhiteSpace(settings.Width)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Height or Width position not specified."); await Connection.ShowAlert(); return; } if (!int.TryParse(settings.Height, out int height)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid height: {settings.Height}"); await Connection.ShowAlert(); return; } if (!int.TryParse(settings.Width, out int width)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid width: {settings.Width}"); await Connection.ShowAlert(); return; } windowSize = new WindowSize(height, width); } else if (settings.MaximizeWindow) { windowResize = WindowResize.Maximize; } else if (settings.MinimizeWindow) { windowResize = WindowResize.Minimize; } else if (settings.OnlyTopmost) { windowResize = WindowResize.OnlyTopmost; } Screen screen = MonitorManager.Instance.GetScreenFromUniqueValue(settings.Screen); if (screen == null) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"Could not find screen {settings.Screen}"); await Connection.ShowAlert(); return; } var processCount = WindowPosition.MoveProcess(new MoveProcessSettings() { AppSpecific = settings.AppSpecific, Name = settings.ApplicationName, DestinationScreen = screen, Position = new System.Drawing.Point(xPosition, yPosition), WindowResize = windowResize, WindowSize = windowSize, MakeTopmost = settings.TopmostWindow, LocationFilter = settings.ShouldFilterLocation ? settings.LocationFilter : null, TitleFilter = settings.ShouldFilterTitle ? settings.TitleFilter : null }); if (processCount > 0) { tmrRetryProcess.Stop(); } else if (processCount == 0 && !tmrRetryProcess.Enabled) { if (!Int32.TryParse(settings.RetryAttempts, out retryAttempts)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"Invalid RetryAttempts: {settings.RetryAttempts}"); return; } tmrRetryProcess.Start(); } }
internal void OnWindowResize(object Wb, object Wn) { WindowResize?.Invoke(GetWorkbook(Wb), GetWindow(Wn)); }
/// <summary> /// Set media window /// </summary> /// <param name="MediaWindow">Media window</param> /// <param name="Width">Floating window width</param> /// <param name="Height">Floating window height</param> /// <param name="Position">Floating window position</param> /// <param name="TitleBar">Floating window title bar</param> /// <param name="Resize">Floating window resize</param> /// <param name="Title">Floating window title</param> /// <remarks> /// <para> /// All optional arguments are applicable to floating window only. /// </para> /// </remarks> public void SetMediaWindow( MediaWindow MediaWindow, Int32 Width = 0, Int32 Height = 0, WindowPosition Position = WindowPosition.Center, WindowTitleBar TitleBar = WindowTitleBar.TitleBarWithCloseButton, WindowResize Resize = WindowResize.KeepAspectRatio, String Title = null ) { // set media play window code MediaScreenParamBE.AddInteger("/W", (Int32) MediaWindow); // all choices but floating window if(MediaWindow != MediaWindow.Floating) { MediaScreenParamBE.Remove("/F"); return; } // play rendition in floating window // Table 9.19 page 774 PdfDictionary FloatingWindow = new PdfDictionary(this); MediaScreenParamBE.AddDictionary("/F", FloatingWindow); // window's dimensions if(Width == 0 || Height == 0) { Width = 320; Height = 180; } FloatingWindow.AddFormat("/D", "[{0} {1}]", Width, Height); FloatingWindow.AddInteger("/P", (Int32) Position); FloatingWindow.AddBoolean("/T", TitleBar != WindowTitleBar.NoTitleBar); if(TitleBar == WindowTitleBar.NoTitleBar) return; FloatingWindow.AddInteger("/R", (Int32) Resize); if(Title != null) { // if(Document.Encryption == null) // { // FloatingWindow.AddFormat("/TT", "[() ({0})]", Title); // } // else // { FloatingWindow.AddFormat("/TT", "[{0} {1}]", Document.TextToPdfString(String.Empty, this), Document.TextToPdfString(Title, this)); // } } return; }
internal static void InvokeWindowRezie(KauWindow window) => WindowResize?.Invoke(window);
private void Awake() { Instance = this; }