示例#1
0
        static void InitBackend(string type)
        {
            Toolkit.EnterUserCode();
            if (type != null && LoadBackend(type))
            {
                return;
            }

            if (LoadBackend("Xwt.GtkBackend.GtkEngine, Xwt.Gtk, Version=1.0.0.0"))
            {
                return;
            }

            if (LoadBackend("Xwt.Mac.MacEngine, Xwt.Mac, Version=1.0.0.0"))
            {
                return;
            }

            if (LoadBackend("Xwt.WPFBackend.WPFEngine, Xwt.WPF, Version=1.0.0.0"))
            {
                return;
            }

            throw new InvalidOperationException("Xwt engine not found");
        }
示例#2
0
        /// <summary>
        /// Invokes an action in the GUI thread
        /// </summary>
        /// <param name='action'>
        /// The action to execute.
        /// </param>
        public static void Invoke(Action action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            engine.InvokeAsync(delegate {
                try {
                    toolkit.EnterUserCode();
                    action();
                    toolkit.ExitUserCode(null);
                } catch (Exception ex) {
                    toolkit.ExitUserCode(ex);
                }
            });
        }
示例#3
0
 public void DispatchPendingEvents()
 {
     try {
         toolkit.ExitUserCode(null);
         toolkit.Backend.DispatchPendingEvents();
     } finally {
         toolkit.EnterUserCode();
     }
 }
示例#4
0
 public static void DispatchPendingEvents()
 {
     try {
         Toolkit.ExitUserCode(null);
         engine.DispatchPendingEvents();
     } finally {
         Toolkit.EnterUserCode();
     }
 }
示例#5
0
        public static void Initialize(Toolkit toolkit)
        {
            engine   = toolkit.Backend;
            mainLoop = new UILoop(toolkit);

            UIThread = System.Threading.Thread.CurrentThread;

            toolkit.EnterUserCode();
        }
示例#6
0
 /// <summary>
 /// Invokes an action in the GUI thread
 /// </summary>
 /// <param name='action'>
 /// The action to execute.
 /// </param>
 public static void Invoke(Action action)
 {
     engine.Invoke(delegate {
         try {
             Toolkit.EnterUserCode();
             action();
             Toolkit.ExitUserCode(null);
         } catch (Exception ex) {
             Toolkit.ExitUserCode(ex);
         }
     });
 }
示例#7
0
        public static void Initialize(Toolkit tk)
        {
            if (toolkit == null)
            {
                toolkit = tk;
            }
            engine   = tk.Backend;
            mainLoop = new UILoop(tk);

            UIThread = System.Threading.Thread.CurrentThread;

            tk.EnterUserCode();
        }
示例#8
0
        public static void Initialize(string backendType)
        {
            if (engine != null)
            {
                return;
            }

            toolkit = Toolkit.Load(backendType, false);
            toolkit.SetActive();
            engine   = toolkit.Backend;
            mainLoop = new UILoop(toolkit);

            UIThread = System.Threading.Thread.CurrentThread;

            toolkit.EnterUserCode();
        }
示例#9
0
        /// <summary>
        /// Invokes an action in the GUI thread after the provided time span
        /// </summary>
        /// <returns>
        /// A timer object
        /// </returns>
        /// <param name='action'>
        /// The action to execute.
        /// </param>
        /// <remarks>
        /// This method schedules the execution of the provided function. The function
        /// must return 'true' if it has to be executed again after the time span, or 'false'
        /// if the timer can be discarded.
        /// The execution of the funciton can be canceled by disposing the returned object.
        /// </remarks>
        public static IDisposable TimeoutInvoke(TimeSpan timeSpan, Func <bool> action)
        {
            Timer t = new Timer();

            t.Id = engine.TimeoutInvoke(delegate {
                bool res = false;
                try {
                    Toolkit.EnterUserCode();
                    res = action();
                    Toolkit.ExitUserCode(null);
                } catch (Exception ex) {
                    Toolkit.ExitUserCode(ex);
                }
                return(res);
            }, timeSpan);
            return(t);
        }