public NewVersioInfo CheckNewAppVersionAvailable()
        {
            var requestErrorPolicy = Policy <NewVersioInfo>
                                     .Handle <System.Net.WebException>()
                                     .Fallback(new NewVersioInfo()
            {
                IsAvailable = false
            });

            string       url         = "https://raw.githubusercontent.com/MarioZG/elder-scrolls-legends-tracker/master/Build/versions.json";
            IHTTPService httpService = (IHTTPService)trackerFactory.GetService <IHTTPService>();

            return(requestErrorPolicy.Execute(() =>
            {
                string versionJSON = httpService.SendGetRequest(url);
                JObject versions = JObject.Parse(versionJSON);
                SerializableVersion latest = new SerializableVersion(new Version(versions["Application"].ToString()));
                IApplicationService appService = (IApplicationService)trackerFactory.GetService <IApplicationService>();

                return new NewVersioInfo()
                {
                    IsAvailable = latest > appService.GetAssemblyVersion(),
                    Number = latest.ToString(),
                    DownloadUrl = GetLatestDownladUrl()
                };
            }));
        }
 public CardInstance(Card card, ITrackerFactory trackerFactory)
 {
     this.Card           = card;
     this.trackerFactory = trackerFactory;
     if (cardImageService == null)
     {
         cardImageService = trackerFactory.GetService <ICardImageService>();
     }
     if (cardsDatabase == null)
     {
         cardsDatabase = trackerFactory.GetService <ICardsDatabase>();
     }
 }
        internal EditGameViewModel(ITrackerFactory trackerFactory)
        {
            this.trackerFactory = trackerFactory;

            messanger             = trackerFactory.GetService <IMessenger>();
            tracker               = trackerFactory.GetTracker();
            Game.PropertyChanged += Game_PropertyChanged;
            messanger.Register <ActiveDeckChanged>(this, ActiveDeckChanged);
            messanger.Register <EditGame>(this, EditGameStart, Utils.Messages.EditGame.Context.StartEdit);
            messanger.Register <NewDeckTagCreated>(this, RefreshTagsList);
            this.settings = trackerFactory.GetService <ISettings>();
            this.winApi   = trackerFactory.GetService <IWinAPI>();

            this.BeginEdit();
        }
        public DeckListViewModel(ITrackerFactory factory)
        {
            this.messanger = factory.GetService <IMessenger>();
            messanger.Register <DeckListFilterChanged>(this, DeckFilterChanged, ControlMessangerContext.DeckList_DeckFilterControl);
            messanger.Register <EditDeck>(this, EditDeckFinished, Utils.Messages.EditDeck.Context.EditFinished);
            messanger.Register <EditDeck>(this, CommandHideDeckExecute, Utils.Messages.EditDeck.Context.Hide);
            messanger.Register <EditDeck>(this, CommandUnHideDeckExecute, Utils.Messages.EditDeck.Context.UnHide);
            messanger.Register <EditDeck>(this, CommandDeleteDeckExecute, Utils.Messages.EditDeck.Context.Delete);

            this.trackerFactory = factory;
            this.tracker        = factory.GetTracker();
            FilteredDecks       = new ObservableCollection <Deck>(tracker.Decks);

            deckService = trackerFactory.GetService <IDeckService>();
            settings    = trackerFactory.GetService <ISettings>();
        }
        internal void AddCard(CardInstance value, int qty)
        {
            if (value == null)
            {
                return;
            }
            foreach (var ci in CardsCollection.Where(ci => ci.BorderBrush != null))
            {
                ci.BorderBrush = null;
            }
            var card = CardsCollection.Where(ci => ci.CardId == value.CardId).FirstOrDefault();

            if (card != null)
            {
                card.Quantity   += qty; //if already in deck, inc qty
                card.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 100, 15));
            }
            else
            {
                card             = value;
                card.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 100, 15));
                card.Quantity    = qty;
                CardsCollection.Add(card);
            }
            if (LimitCardCount)
            {
                trackerFactory.GetService <IDeckService>().EnforceCardLimit(card);
            }
            NewCard = null;
        }
Example #6
0
        public AddSingleRewardViewModel(ITrackerFactory trackerFactory)
        {
            this.trackerFactory = trackerFactory;
            cardsDatabase       = trackerFactory.GetService <ICardsDatabase>();

            CommandAddButtonPressed = new RelayCommand(new Action <object>(AddClicked));
            CommandDeleteClicked    = new RelayCommand(new Action <object>(DeleteClicked));
        }
Example #7
0
        public NewVersioInfo CheckNewAppVersionAvailable()
        {
            string url = settings.VersionCheck_VersionsUrl;

            var requestErrorPolicy = Policy <NewVersioInfo>
                                     .Handle <System.Net.WebException>()
                                     .Fallback(
                new NewVersioInfo()
            {
                IsAvailable = false
            }
                );

            IHTTPService httpService = (IHTTPService)trackerFactory.GetService <IHTTPService>();

            return(requestErrorPolicy.Execute(() =>
            {
                string versionJSON = httpService.SendGetRequest(url);
                JObject versions = JObject.Parse(versionJSON);
                SerializableVersion latest = new SerializableVersion(new Version(versions["Application"].ToString()));
                IApplicationService appService = (IApplicationService)trackerFactory.GetService <IApplicationService>();

                return new NewVersioInfo()
                {
                    IsAvailable = latest > appService.GetAssemblyVersion(),
                    Number = latest.ToString(),
                    DownloadUrl = GetLatestDownladUrl()
                };
            }));
        }
Example #8
0
        internal MainWindowViewModel(TrackerFactory trackerFactory)
        {
            this.trackerFactory = trackerFactory;
            tracker             = trackerFactory.GetTracker();
            messanger           = trackerFactory.GetMessanger();
            messanger.Register <Utils.Messages.EditDeck>(this, EditDeckStart, Utils.Messages.EditDeck.Context.StartEdit);
            messanger.Register <Utils.Messages.EditDeck>(this, EditDeckFinished, Utils.Messages.EditDeck.Context.EditFinished);
            messanger.Register <Utils.Messages.EditGame>(this, EditGameStart, Utils.Messages.EditGame.Context.StartEdit);
            messanger.Register <Utils.Messages.EditGame>(this, EditGameFinished, Utils.Messages.EditGame.Context.EditFinished);
            messanger.Register <Utils.Messages.EditSettings>(this, EditSettingsFinished, Utils.Messages.EditSettings.Context.EditFinished);

            deckService = trackerFactory.GetService <IDeckService>();
            settings    = trackerFactory.GetService <ISettings>();

            this.OverlayWindows.Add(new OverlayToolbar());
            this.OverlayWindows.Add(new DeckOverlay());
            this.OverlayWindows.CollectionChanged += (s, e) => RaisePropertyChangedEvent(nameof(OverlayWindows));
        }
Example #9
0
        public GameStatisticsViewModel(ITrackerFactory trackerFactory) : base(trackerFactory)
        {
            messenger = trackerFactory.GetService <IMessenger>();

            this.gameType   = GameType.PlayRanked;
            Formatter       = x => TotalGames > 0 ? Math.Round((double)x / TotalGames * 100, 0) + " %" : "- %";
            FormatterFirst  = x => OrderOfPlayFirst > 0 ? Math.Round((double)x / OrderOfPlayFirst * 100, 0) + " %" : "- %";
            FormatterSecond = x => OrderOfPlaySecond > 0 ? Math.Round((double)x / OrderOfPlaySecond * 100, 0) + " %" : "- %";
            HeatLabelPoint  = (x => ClassAttributesHelper.FindClassByAttribute(
                                   new DeckAttribute[] { (DeckAttribute)x.X, (DeckAttribute)x.Y }).First() + " : " + x.Weight + " % of games");
        }
        public async Task <object> CommandRunGameExecute(object parameter)
        {
            startingGame = true;
            CommandManager.InvalidateRequerySuggested();

            var proc = trackerFactory.GetService <ILauncherService>().StartGame(this.winApi, this.messanger);

            startingGame = false;
            CommandManager.InvalidateRequerySuggested();
            return(null);
        }
        public DeckClassSelectorViewModel(ITrackerFactory factory)
        {
            messenger         = factory.GetService <IMessenger>();
            FilterButtonState = new Dictionary <DeckAttribute, bool>();
            foreach (DeckAttribute a in Enum.GetValues(typeof(DeckAttribute)))
            {
                FilterButtonState.Add(a, false);
            }

            FilteredClasses = new ObservableCollection <DeckClass>();
            FilterCombo();
        }
        public void UpdateCardsDB(string newContent)
        {
            string         fileName      = ".\\Resources\\cards.json";
            IFileWrapper   fileWrapper   = trackerfactory.GetService <IFileWrapper>();
            ICardsDatabase cardsDatabase = trackerfactory.GetService <ICardsDatabase>();

            string backupFileName = string.Format("{0}_{1}{2}",
                                                  Path.GetFileNameWithoutExtension(fileName),
                                                  cardsDatabase.Version,
                                                  Path.GetExtension(fileName)); //includes .

            backupFileName = Path.Combine(Path.GetDirectoryName(fileName), backupFileName);

            if (fileWrapper.Exists(backupFileName))
            {
                fileWrapper.Delete(backupFileName);
            }
            fileWrapper.Move(fileName, backupFileName);

            fileWrapper.WriteAllText(fileName, newContent);
            trackerfactory.GetService <ICardsDatabase>().RealoadDB();
        }
        public DeckEditViewModel(ITrackerFactory trackerFactory)
        {
            this.trackerFactory = trackerFactory;
            this.messanger      = trackerFactory.GetService <IMessenger>();
            messanger.Register <EditDeck>(this, EditDeckStart, EditDeck.Context.StartEdit);

            CommandSave            = new RelayCommand(CommandSaveExecute);
            CommandCancel          = new RelayCommand(CommandCancelExecute);
            CommandImport          = new RealyAsyncCommand <object>(CommandImportExecute);
            CommandStartImportWeb  = new RelayCommand(CommandStartImportWebExecute, CommandStartImportWebCanExecute);
            CommandImportWebCancel = new RelayCommand(CommandImportWebCancelExecute);
            CommandImportWeb       = new RealyAsyncCommand <object>(CommandImportWebExecute, CommandImportWebCanExecute);
        }
Example #14
0
        public DeckStatsViewModel(ITrackerFactory trackerFactory)
        {
            this.messanger = trackerFactory.GetService <IMessenger>();
            tracker        = trackerFactory.GetTracker();

            if (tracker.ActiveDeck != null)
            {
                //load data for active deck from settigs
                RefreshData();
            }

            messanger.Register <EditDeck>(this, GameAdded, EditDeck.Context.StatsUpdated);
            messanger.Register <ActiveDeckChanged>(this, ActiveDeckChanged);
        }
Example #15
0
        internal EditGameViewModel(ITrackerFactory trackerFactory)
        {
            this.trackerFactory = trackerFactory;

            messanger             = trackerFactory.GetMessanger();
            tracker               = trackerFactory.GetTracker();
            Game.PropertyChanged += Game_PropertyChanged;
            messanger.Register <ActiveDeckChanged>(this, ActiveDeckChanged);
            messanger.Register <EditGame>(this, EditGameStart, Utils.Messages.EditGame.Context.StartEdit);

            this.settings = trackerFactory.GetService <ISettings>();

            this.BeginEdit();
        }
        public DeckTypeSelectorViewModel(ITrackerFactory trackerFactory)
        {
            this.trackerFactory = trackerFactory;
            messanger           = trackerFactory.GetService <IMessenger>();
            FilterButtonState   = new Dictionary <DeckType, bool>();
            foreach (DeckType a in Enum.GetValues(typeof(DeckType)))
            {
                FilterButtonState.Add(a, false);
            }
            messanger.Register <DeckListResetFilters>(this, ResetFilter, ControlMessangerContext.DeckList_DeckFilterControl);

            //init filters (so checkbox for hiding completed arena runs is applied
            messanger.Send(new DeckListFilterChanged(DeckListFilterChanged.Source.TypeFilter, FilteredTypes, showCompletedArenaRuns, showHiddenDecks, null, null), ControlMessangerContext.DeckList_DeckFilterControl);
        }
        private async Task <object> CommandImportExecute(object obj)
        {
            this.ShowImportPanel = true;

            DeckImporter deckImporter = obj as DeckImporter;
            var          tcs          = new TaskCompletionSource <bool>();

            deckImporter.ImportFinished(tcs);

            await tcs.Task;

            bool succeed = tcs.Task.Result;

            if (succeed)
            {
                if (deckImporter.DeltaImport)
                {
                    foreach (var importedCard in deckImporter.Cards)
                    {
                        var instance = deck.SelectedVersion.Cards.Where(ci => ci.Card.Id == importedCard.CardId).FirstOrDefault();
                        if (instance != null)
                        {
                            instance.Quantity += importedCard.Quantity;
                            if (instance.Quantity <= 0)
                            {
                                deck.SelectedVersion.Cards.Remove(instance);
                            }
                            if (LimitCardCount)
                            {
                                trackerFactory.GetService <IDeckService>().EnforceCardLimit(instance);
                            }
                        }
                        else if (importedCard.Quantity > 0)
                        {
                            deck.SelectedVersion.Cards.Add(importedCard);
                        }
                    }
                }
                else
                {
                    deck.SelectedVersion.Cards = new PropertiesObservableCollection <CardInstance>(deckImporter.Cards);
                    //curr version shour equal deck.selected version, attch change to reflect clink for remove in deck history
                    CurrentVersion.Cards.CollectionChanged += (s, e) => { RaisePropertyChangedEvent(nameof(ChangesFromCurrentVersion)); };
                    RaisePropertyChangedEvent(String.Empty);
                }
            }
            this.ShowImportPanel = false;
            return(null);
        }
        public bool CanDelete(Deck deck)
        {
            if (deck == null)
            {
                return(false);
            }
            DeckDeleteMode deleteMode = trackerFactory.GetService <ISettings>().DeckDeleteMode;

            switch (deleteMode)
            {
            case DeckDeleteMode.Forbidden:
                return(false);

            case DeckDeleteMode.OnlyEmpty:
                return(GetDeckGames(deck).Count() == 0);

            case DeckDeleteMode.Any:
                return(true);

            default:
                throw new NotImplementedException("Unknown delete mode");
            }
        }
 public DeckEditViewModel(ITrackerFactory trackerFactory)
 {
     this.trackerFactory = trackerFactory;
     this.messanger      = trackerFactory.GetService <IMessenger>();
     messanger.Register <EditDeck>(this, EditDeckStart, EditDeck.Context.StartEdit);
 }
Example #20
0
 public ImportTextViewModel(ITrackerFactory trackerFactory)
 {
     this.trackerFactory = trackerFactory;
     DeckImporter        = trackerFactory.GetService <IDeckImporter>();
 }
 public CardListEditorViewModel(ITrackerFactory trackerFactory)
 {
     this.trackerFactory = trackerFactory;
     this.cardsDatabase  = trackerFactory.GetService <ICardsDatabase>();
 }
 public DeckImporter(ITrackerFactory trackerFactory)
 {
     this.trackerFactory = trackerFactory;
     this.cardsDatabase  = trackerFactory.GetService <ICardsDatabase>();
 }
        public Task SaveScreenShot(string fileName)
        {
            IntPtr?eslHandle = trackerfactory.GetService <IWinAPI>().GetEslProcess()?.MainWindowHandle;

            if (eslHandle.HasValue)
            {
                var rect = new WinAPI.Rect();
                WinAPI.GetWindowRect(eslHandle.Value, ref rect);

                int width  = rect.right - rect.left;
                int height = rect.bottom - rect.top;

                var      bmp    = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                Graphics gfxBmp = Graphics.FromImage(bmp);

                List <Window> hiddenWindows = new List <Window>();
                Application.Current.Dispatcher.Invoke(() =>
                {
                    foreach (Window w in Application.Current.Windows)
                    {
                        // System.Diagnostics.Debugger.Log(1, "", "w"+ w.Title);
                        // System.Diagnostics.Debugger.Log(1, "", "  w.IsActive" + w.IsActive);
                        // System.Diagnostics.Debugger.Log(1, "", "   w.Topmost" + w.Topmost);
                        // System.Diagnostics.Debugger.Log(1, "", Environment.NewLine) ;
                        if (w.IsActive) //if other if visible - cannot do anything; otherwise if it was in back, it would be show at the top:/...
                        {
                            w.Hide();
                            hiddenWindows.Add(w);
                        }
                    }
                });
                WinAPI.SetForegroundWindow(eslHandle.Value);
                gfxBmp.CopyFromScreen(
                    rect.left,
                    rect.top,
                    0,
                    0,
                    new System.Drawing.Size(width, height),
                    CopyPixelOperation.SourceCopy);

                foreach (Window w in hiddenWindows)
                {
                    w.Dispatcher.Invoke(() => w.Show());
                }

                string path = Path.Combine(
                    DataPath,
                    ScreenShotFolder,
                    Path.ChangeExtension(fileName, "png")
                    );
                if (!Directory.Exists(Path.GetDirectoryName(path)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                }
                bmp.Save(path, System.Drawing.Imaging.ImageFormat.Png);

                gfxBmp.Dispose();
            }

            return(Task.FromResult <object>(null));
        }
 public CardImageService(ITrackerFactory trackerFactory)
 {
     resourceService = trackerFactory.GetService <IResourcesService>();
 }
Example #25
0
 public VersionService(ITrackerFactory trackerFactory)
 {
     this.trackerFactory = trackerFactory;
     this.settings       = trackerFactory.GetService <ISettings>();
 }
 public FileManager(ITrackerFactory trackerfactory)
 {
     this.trackerfactory = trackerfactory;
     this.settings       = trackerfactory.GetService <ISettings>();
 }
 public ScreenshotNameProvider(ITrackerFactory trackerFactory)
 {
     this.trackerFactory = trackerFactory;
     this.settings       = trackerFactory.GetService <ISettings>();
 }
 public AddSingleRewardViewModel(ITrackerFactory trackerFactory)
 {
     this.trackerFactory = trackerFactory;
     cardsDatabase       = trackerFactory.GetService <ICardsDatabase>();
 }
 public FilterDateViewModel(ITrackerFactory trackerFactory)
 {
     this.trackerFactory           = trackerFactory;
     this.settings                 = trackerFactory.GetService <ISettings>();
     this.FilterDateSelectedOption = settings.GamesFilter_SelectedPredefinedDateFilter;
 }
 public DeckPreviewViewModel(ITrackerFactory trackerFactory)
 {
     this.trackerFactory = trackerFactory;
     this.messanger      = trackerFactory.GetService <IMessenger>();
     this.tracker        = trackerFactory.GetTracker();
 }