Beispiel #1
0
        /// <summary>
        /// Schedule asynchronous texture loading.
        /// </summary>
        private void LoadAsync()
        {
            TextureQueue.CompletionCallback callback = (file, image, actualLocation, result) =>
            {
                Debug.Assert(_file == file);
                SetImage(image, result);

                _actualLocation = actualLocation;

                if (_callback != null)
                {
                    _callback(_file, _image, actualLocation, result);
                }
            };

            lock (_lock)
            {
                State = TextureState.LoadingPending;
                if (_dataSource != null)
                {
                    TextureQueue.Enqueue(_dataSource, _file, callback);
                    return;
                }

                TextureQueue.Enqueue(_file, _baseDir, callback);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            MainWindow mainWindow = null;

            RunOnceGuard.Guard("open3mod_global_app",

                               // what to do if this is the first instance of the application
                               () =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                mainWindow = new MainWindow();
                if (args.Length > 0)
                {
                    mainWindow.AddTab(args[0]);
                }
                Application.Run(mainWindow);
                mainWindow = null;

                TextureQueue.Terminate();
            },

                               // what do invoke if this is the first instance of the application,
                               // and another (temporary) instance messages it to open a new tab
                               (String absPath) =>
            {
                if (mainWindow != null)
                {
                    mainWindow.BeginInvoke(new MethodInvoker(() =>
                    {
                        mainWindow.Activate();
                        mainWindow.AddTab(absPath);
                    }));
                }
            },

                               // what to send to the first instance of the application if the
                               // current instance is only temporary.
                               () =>
            {
                if (args.Length == 0)
                {
                    return(null);
                }
                // note: have to get absolute path because the working dirs
                // of the instances may be different.
                return(Path.GetFullPath(args[0]));
            }
                               );
        }