public static void Main(string[] args) { //System.Diagnostics.Debug.WriteLine( // typeof(Microsoft.FSharp.Core.Operators).AssemblyQualifiedName //); #if DEBUG var Spawn = default(Action<Action<Window>>); var Session = new List<ApplicationCanvas>(); Spawn = WindowCreated => { var c = new ApplicationCanvas(); Session.Add(c); c.ConnectToSession(Session.Except(new[] { c })); var w = c.ToWindow(); w.Title += " | F2 - Spawn, F11 - Fullscreen"; w.Closing += delegate { Session.Remove(c); }; w.KeyUp += (s, e) => { if (e.Key == Key.F2) Spawn(k => k.Show()); }; w.KeyDown += (s, e) => { if (e.Key == Key.Escape || e.Key == Key.F11) if (w.WindowState == WindowState.Maximized) { w.WindowState = WindowState.Normal; return; } if (e.Key == Key.F11) if (w.WindowState == WindowState.Normal) { w.WindowStyle = WindowStyle.None; w.WindowState = WindowState.Maximized; return; } }; w.StateChanged += (s, e) => { w.WindowStyle = w.WindowState == WindowState.Maximized ? WindowStyle.None : WindowStyle.SingleBorderWindow; }; w.Loaded += delegate { w.SizeToContent = SizeToContent.Manual; w.Focus(); }; w.SizeChanged += (s, e) => { if (e.PreviousSize.Width == 0) return; // Content dictates its size. Yet when we resize the window we want the content to know it has more room. // http://stackoverflow.com/questions/1081580/how-to-set-wpf-windows-startup-clientsize var horizontalBorderHeight = SystemParameters.ResizeFrameHorizontalBorderHeight; var verticalBorderWidth = SystemParameters.ResizeFrameVerticalBorderWidth; var captionHeight = SystemParameters.CaptionHeight; var Width = e.NewSize.Width; var Height = e.NewSize.Height; Width -= 2 * verticalBorderWidth; Height -= 2 * horizontalBorderHeight; if (w.WindowStyle != WindowStyle.None) { Height -= captionHeight; } // where is this function documented? c.SizeTo(Width, Height); }; if (WindowCreated != null) WindowCreated(w); }; Spawn(w => w.ShowDialog()); #else RewriteToUltraApplication.AsProgram.Launch(typeof(Application)); #endif }
public static void Main(string[] args) { //System.Diagnostics.Debug.WriteLine( // typeof(Microsoft.FSharp.Core.Operators).AssemblyQualifiedName //); #if DEBUG var Spawn = default(Action <Action <Window> >); var Session = new List <ApplicationCanvas>(); Spawn = WindowCreated => { var c = new ApplicationCanvas(); Session.Add(c); c.ConnectToSession(Session.Except(new[] { c })); var w = c.ToWindow(); w.Title += " | F2 - Spawn, F11 - Fullscreen"; w.Closing += delegate { Session.Remove(c); }; w.KeyUp += (s, e) => { if (e.Key == Key.F2) { Spawn(k => k.Show()); } }; w.KeyDown += (s, e) => { if (e.Key == Key.Escape || e.Key == Key.F11) { if (w.WindowState == WindowState.Maximized) { w.WindowState = WindowState.Normal; return; } } if (e.Key == Key.F11) { if (w.WindowState == WindowState.Normal) { w.WindowStyle = WindowStyle.None; w.WindowState = WindowState.Maximized; return; } } }; w.StateChanged += (s, e) => { w.WindowStyle = w.WindowState == WindowState.Maximized ? WindowStyle.None : WindowStyle.SingleBorderWindow; }; w.Loaded += delegate { w.SizeToContent = SizeToContent.Manual; w.Focus(); }; w.SizeChanged += (s, e) => { if (e.PreviousSize.Width == 0) { return; } // Content dictates its size. Yet when we resize the window we want the content to know it has more room. // http://stackoverflow.com/questions/1081580/how-to-set-wpf-windows-startup-clientsize var horizontalBorderHeight = SystemParameters.ResizeFrameHorizontalBorderHeight; var verticalBorderWidth = SystemParameters.ResizeFrameVerticalBorderWidth; var captionHeight = SystemParameters.CaptionHeight; var Width = e.NewSize.Width; var Height = e.NewSize.Height; Width -= 2 * verticalBorderWidth; Height -= 2 * horizontalBorderHeight; if (w.WindowStyle != WindowStyle.None) { Height -= captionHeight; } // where is this function documented? c.SizeTo(Width, Height); }; if (WindowCreated != null) { WindowCreated(w); } }; Spawn(w => w.ShowDialog()); #else RewriteToUltraApplication.AsProgram.Launch(typeof(Application)); #endif }