Beispiel #1
0
        public BpViewModel(ViewModelFactory viewModelFactory, IEventAggregator eventAggregator, ISecurityProvider securityProvider, IRestApi restApi, IToastService toastService)
        {
            _viewModelFactory = viewModelFactory;
            _restApi          = restApi;
            _eventAggregator  = eventAggregator;
            _toastService     = toastService;
            _securityProvider = securityProvider;
            _eventAggregator.Subscribe(this);
            _scanningCancellationToken = new CancellationTokenSource();

            try
            {
                var folder        = @".\hashlist.json";
                var sourceContent = File.ReadAllText(folder);

                AllHero.HeroInfo = JsonConvert.DeserializeObject <List <EachHero> >(sourceContent);

                OcrUtil = new OcrUtil();
                OcrUtil.Initialize();
                OcrAvailable = true;
            }
            catch (Exception)
            {
                // ignored
            }

            var unitPos = App.AppSetting.Position.BpHelperPosition.ToUnitPoint();

            Left = unitPos.X;
            Top  = unitPos.Y;

            _heroSelectorWindowViewModel = _viewModelFactory.CreateViewModel <HeroSelectorWindowViewModel>();

            var filePath = @Path.Combine(App.AppPath, Const.LOCAL_WEB_FILE_DIR, "index.html#") + App.Language;

            LocalFileUri = filePath;

            WebCallbackListener.PresetRequested += WebCallbackListenerOnPresetRequested;
        }
Beispiel #2
0
        public void InitializeAllHeroSelector()
        {
            // unspoiled cache, no need to re-initialize
            if (!HeroSelectorViewModels.Any() && _cachedHeroSelectorViewModels.Any())
            {
                return;
            }

            if (_cachedHeroSelectorViewModels.Any())
            {
                CloseHeroSelectorWindows();
            }

            _heroSelectorWindowViewModel = _viewModelFactory.CreateViewModel <HeroSelectorWindowViewModel>();
            WindowManager.ShowWindow(_heroSelectorWindowViewModel);
            ((Window)_heroSelectorWindowViewModel.View).Owner = (Window)View;

            for (var i = 0; i <= 13; ++i)
            {
                var vm = _viewModelFactory.CreateViewModel <HeroSelectorViewModel>();
                _cachedHeroSelectorViewModels.Add(vm);
                vm.Id = i;
                vm.InitializeUnselect();
                var position = _listPositions[i];
                if (i < 7)
                {
                    vm.SetLeftAndTop(position);
                }
                else
                {
                    vm.SetRightAndTop(position);
                }
                vm.InteractionVisible = false;
                vm.LayerVisible       = false;
                vm.Refresh();
            }
        }