Exemple #1
0
 /// <summary>
 /// Unregister <paramref name="c"/> from the list of available windows.
 /// </summary>
 /// <param name="c">Window to unregister</param> 
 public static void UnregisterWindow(Window c)
 {
     lock (InternalWindows)
     {
         InternalWindows.Remove(c.SdlHandle);
     }
 }
Exemple #2
0
 /// <summary>
 /// Register <paramref name="c"/> to the list of available windows.
 /// </summary>
 /// <param name="c">Window to register</param>
 public static void RegisterWindow(Window c)
 {
     lock (InternalWindows)
     {
         InternalWindows.Add(c.SdlHandle, new WeakReference<Window>(c));
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WindowsMessageLoop"/> class.
 /// </summary>
 public SdlMessageLoop(Window control)
 {
     Control = control;
 }
        /// <summary>
        /// Runs the specified main loop for the specified windows form.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="renderCallback">The rendering callback.</param>
        /// <exception cref="System.ArgumentNullException">form
        /// or
        /// renderCallback</exception>
        public static void Run(Window form, RenderCallback renderCallback)
        {
            if(form == null) throw new ArgumentNullException(nameof(form));
            if(renderCallback == null) throw new ArgumentNullException(nameof(renderCallback));

            form.Show();
            using (var renderLoop = new SdlMessageLoop(form))
            {
                while(renderLoop.NextFrame())
                {
                    renderCallback();
                }
            }
        }