Пример #1
0
        private void DownloadSingleMap(string mapStr)
        {
            var ssVm = new ServerSelectionViewModel();

            if (!ssVm.AvaliableServers.Any())
            {
                MessageBox.Show("There are no servers avaliable", "Server not found", MessageBoxButton.OK, MessageBoxImage.Error);
                Current.Shutdown();
                return;
            }

            // find server
            DownloadMapsViewModel  dmVmSelected = null;
            IEnumerable <MapModel> mapsSelected = null;

            foreach (var server in ssVm.AvaliableServers)
            {
                var dmVm = new DownloadMapsViewModel();
                dmVm.BindServerObject(server);

                var mapsFound = dmVm.Maps?.Where(x => x.Name.Contains(mapStr));
                if (mapsFound.Any())
                {
                    mapsSelected = mapsFound;
                    dmVmSelected = dmVm;
                    break;
                }
            }

            if (dmVmSelected == null)
            {
                MessageBox.Show("Map not found in servers", "Map not found", MessageBoxButton.OK, MessageBoxImage.Error);
                Current.Shutdown();
                return;
            }

            // select map
            foreach (var map in dmVmSelected.Maps)
            {
                if (mapsSelected.Contains(map))
                {
                    map.SkipOnDownload = false;
                    continue;
                }

                map.SkipOnDownload = true;
            }

            // show progress
            var win        = new WinDownloadMapsView();
            var vmDownload = win.FindResource(nameof(DownloadMapsViewModel)) as DownloadMapsViewModel;

            vmDownload.ForceRebind(dmVmSelected);
            vmDownload.AppendToLog("Automated map download...");
            win.Show();
            vmDownload.StartDownload();
            Thread.Sleep(300);
            win.Close();
        }
Пример #2
0
        public ActionResult ServerSelection(int?categoryID)
        {
            var viewModel = new ServerSelectionViewModel();

            viewModel.Categories = context.Categories;
            if (categoryID.HasValue)
            {
                viewModel.Products = ProductsByCategory(categoryID.Value);
            }

            return(View(viewModel));
        }
Пример #3
0
 public SelectServerContextCommand(ServerSelectionViewModel vm)
 {
     _vm = vm;
 }