Example #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            controls = new ControlsWindow();
            controls.Show();

            cascProgressBar = progressBar;

            ModelListBox.Visibility = Visibility.Hidden;
            FilterBox.Visibility    = Visibility.Hidden;
            tabs.Visibility         = Visibility.Hidden;

            cascWorker.RunWorkerAsync();
        }
Example #2
0
        public void SetCamera(Vector3 pos)
        {
            var worker = new BackgroundWorkerEx();

            worker.DoWork += (sender, e) =>
            {
                Camera = new Camera(pos, -Vector3.UnitZ);
                Camera.SetViewport(Control.Width, Control.Height);
                GL.Viewport(0, 0, Control.Width, Control.Height);
                Camera.OnMovement += () =>
                {
                    Renderer.Update();
                    Render();
                };
            };
            worker.RunWorkerAsync();
        }
Example #3
0
 private void Run()
 {
     ((MainWindow)ParentWindow).tabExecution.IsSelected = true;
     ((MainWindow)ParentWindow).tabParams.IsEnabled     = false;
     ((MainWindow)ParentWindow).tabMachines.IsEnabled   = false;
     ((MainWindow)ParentWindow).tabActions.IsEnabled    = false;
     ((MainWindow)ParentWindow).tabTasks.IsEnabled      = false;
     ((MainWindow)ParentWindow).m_actionVM.IsExecuting  = true;
     ((MainWindow)ParentWindow).m_machineVM.IsExecuting = true;
     ((MainWindow)ParentWindow).m_taskVM.IsExecuting    = true;
     ((MainWindow)ParentWindow).m_paramsVM.IsExecuting  = true;
     IsExecuting = true;
     runWorker   = new BackgroundWorkerEx();
     runWorker.WorkerSupportsCancellation = true;
     runWorker.DoWork             += this.Run_DoWork;
     runWorker.RunWorkerCompleted += this.Run_Completed;
     runWorker.RunWorkerAsync();
 }
Example #4
0
 public void LoadMap(string mapName)
 {
     _loader         = new BackgroundWorkerEx();
     _loader.DoWork += (sender, e) =>
     {
         _loader.ReportProgress(1, "Loading WDT...");
         Renderer?.Delete();
         var wdt = new WDT(string.Format(@"World\Maps\{0}\{0}.wdt", mapName));
         Renderer = new WDTRenderer(this, mapName, wdt);
         _loader.ReportProgress(100, "Map loaded");
     };
     _loader.ProgressChanged += (sender, args) =>
     {
         if (OnProgress != null)
         {
             OnProgress(args.ProgressPercentage, (string)args.UserState);
         }
     };
     _loader.RunWorkerCompleted += (sender, e) => InitializeView();
     _loader.RunWorkerAsync();
 }
        private void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            if ((string)exportButton.Content == "Crawl maptile for models")
            {
                var filterSplit = filterTextBox.Text.Remove(0, 8).Split('_');
                var filename    = "world\\maps\\" + filterSplit[0] + "\\" + filterSplit[0] + "_" + filterSplit[1] + "_" + filterSplit[2] + ".adt";

                fileworker.RunWorkerAsync(filename);
            }
            else
            {
                progressBar.Value       = 0;
                progressBar.Visibility  = Visibility.Visible;
                loadingLabel.Content    = "";
                loadingLabel.Visibility = Visibility.Visible;
                wmoCheckBox.IsEnabled   = false;
                m2CheckBox.IsEnabled    = false;
                exportButton.IsEnabled  = false;
                modelListBox.IsEnabled  = false;

                exportworker.RunWorkerAsync(modelListBox.SelectedItems);
            }
        }
 private void Window_ContentRendered(object sender, EventArgs e)
 {
     cascworker.RunWorkerAsync();
 }
Example #7
0
        private void Initialize()
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Loading local CASC storage...please wait");
            Console.ResetColor();

            TextWriter console = Console.Out;

            var time = new Stopwatch();

            BackgroundWorker.DoWork += (_, e) =>
            {
                Console.SetOut(TextWriter.Null); // suppress output
                CASCConfig config = CASCConfig.LoadLocalStorageConfig(StoragePath);
                CASCHandler = CASCHandler.OpenStorage(config, BackgroundWorker);

                LocaleFlags locale = LocaleFlags.All;

                Console.SetOut(console); // enable output
                CASCHandler.Root.LoadListFile(Path.Combine(Environment.CurrentDirectory, "listfile.txt"), BackgroundWorker);

                Console.SetOut(TextWriter.Null); // suppress output
                CASCFolderRoot = CASCHandler.Root.SetFlags(locale);
            };

            BackgroundWorker.ProgressChanged += (_, e) =>
            {
                // main thread is blocked, so push it on another thread
                Task.Run(() => { DrawProgressBar(e.ProgressPercentage, 100, 72, '#'); });
            };

            BackgroundWorker.RunWorkerCompleted += (_, e) =>
            {
                time.Stop();
                Console.SetOut(console); // enable output
                Console.Write("\r");
                DrawProgressBar(100, 100, 72, '#');

                Console.WriteLine();
                Console.WriteLine($"Finished in {time.Elapsed.TotalSeconds} seconds");
                Console.WriteLine();

                ResetEvent.Set();
            };

            try
            {
                // use backgroundworker for progress reporting since it is provided by CASCLib
                // the main thread is blocked until the background process is completed
                time.Start();
                BackgroundWorker.RunWorkerAsync();
                ResetEvent.WaitOne();
            }
            catch (Exception ex)
            {
                ResetEvent.Set();
                Console.SetOut(console);
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine();
                Console.WriteLine("Error while opening storage");
                Console.WriteLine(ex.Message);

                Console.ResetColor();
                Environment.Exit(1);
            }
        }
Example #8
0
        private void Window_ContentRendered(object sender, EventArgs e)
        {
            outdir = ConfigurationManager.AppSettings["outdir"];

            cascworker.RunWorkerAsync();
        }
Example #9
0
        private void OnLoad(object obj, EventArgs ea)
        {
            _cascAction         = new BackgroundWorkerEx();
            _cascAction.DoWork += (sender, e) =>
            {
                if (string.IsNullOrEmpty(_localCascPath))
                {
                    CASC.InitializeOnline(_cascAction);
                }
                else
                {
                    try
                    {
                        CASC.Initialize(_localCascPath, _cascAction);
                    }
                    catch (Exception /* ex */)
                    {
                        MessageBox.Show("Path '" + _localCascPath + "/Data' was not found.", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            };
            _cascAction.ProgressChanged += (sender, e) =>
            {
                if (e.UserState != null && !string.IsNullOrEmpty((string)e.UserState))
                {
                    _feedbackText.Text = (string)e.UserState;
                }
                _backgroundTaskProgress.Style   = ProgressBarStyle.Continuous;
                _backgroundTaskProgress.Maximum = 100;
                _backgroundTaskProgress.Value   = e.ProgressPercentage;
            };
            _cascAction.RunWorkerCompleted += (sender, e) =>
            {
                if (CASC.Initialized)
                {
                    _dbcAction.RunWorkerAsync();
                }
            };

            _dbcAction         = new BackgroundWorkerEx();
            _dbcAction.DoWork += (sender, e) =>
            {
                switch (_dbcIndex)
                {
                case 0:
                    _mapRecords = new DBC <MapRecord>(@"DBFilesClient\Map.dbc", _dbcAction);
                    break;

                case 1:
                    _areaTableRecords = new DBC <AreaTableRecord>(@"DBFilesClient\AreaTable.dbc", _dbcAction);
                    break;

                case 2:
                    // _areaAssignmentRecords = new DB2<AreaAssignmentRecord>(@"DBFilesClient\AreaAssignment.db2");
                    break;
                }
            };
            _dbcAction.ProgressChanged += (sender, e) =>
            {
                _feedbackText.Text              = string.Format(@"Loading {0} ...", (new[] { "maps", "areas" })[_dbcIndex]);
                _backgroundTaskProgress.Style   = ProgressBarStyle.Continuous;
                _backgroundTaskProgress.Maximum = 100;
                _backgroundTaskProgress.Value   = e.ProgressPercentage;

                switch (_dbcIndex)
                {
                case 0:
                    var mapEntry = (MapRecord)e.UserState;
                    _mapListBox.Items.Add(new MapListBoxEntry
                    {
                        Name      = mapEntry.MapNameLang,
                        Directory = mapEntry.Directory,
                        MapID     = mapEntry.ID
                    });
                    break;

                case 1:
                    // Don't populate yet
                    break;
                }
            };
            _dbcAction.RunWorkerCompleted += (sender, e) =>
            {
                _feedbackText.Text = string.Format(@"{0} loaded.", (new[] { "Maps", "Areas" })[_dbcIndex]);
                ++_dbcIndex;
                if (_dbcIndex < 2)
                {
                    _dbcAction.RunWorkerAsync();
                }
            };
        }
Example #10
0
 private void LoadOnlineCASC(object sender, EventArgs e)
 {
     _localCascPath = string.Empty;
     _cascAction.RunWorkerAsync();
 }