Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WindowsMessageLoop"/> class.
 /// </summary>
 public SdlMessageLoop(Window control)
 {
     Control = control;
 }
Ejemplo n.º 4
0
        /// <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();
                }
            }
        }