コード例 #1
0
        public CardViewModel(IReporter reporter, ArtworkPreferences artPreferences, Card card, BitmapSource cardImage, int quantity, double zoomPercent, bool isFront = true)
        {
            Reporter       = reporter;
            ArtPreferences = artPreferences;
            CardImage      = cardImage;
            Quantity       = quantity;

            if (card.IsToken)
            {
                IsLegal = true;
            }
            else
            {
                PropertyInfo specificFormatPropInfo = card.Legalities.GetType().GetProperty(Settings.Default.SavedFormat.ToString()) ?? throw new ArgumentOutOfRangeException(nameof(Settings.Default.SavedFormat));
                IsLegal = specificFormatPropInfo.GetValue(card.Legalities).ToString() == "legal";
            }

            _isFront         = isFront;
            UpdateImageTimer = new Timer(100)
            {
                AutoReset = false
            };
            UpdateImageTimer.Elapsed += UpdateImageTimerOnElapsed;

            ScaleToPercent(zoomPercent);
            LoadPrints(card);

            Settings.Default.SettingsSaving += DefaultOnSettingsSaving;
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModelLocator"/> class.
        /// </summary>
        public ViewModelLocator()
        {
            // Initialize other
            DialogService = new DialogService.DialogService();
            Reporter      = new ReporterNoLog();

            // Initialize large/serialized objects
            CardCatalog        = CardCatalog.CreateFromFile();
            ArtworkPreferences = ArtworkPreferences.CreateFromFile();

            // Initialize container dependencies.
            DialogService.Register <MessageDialogViewModel, MessageDialogView>();
            DialogService.Register <YesNoDialogViewModel, YesNoDialogView>();
            DialogService.Register <SettingsDialogViewModel, SettingsDialogView>();
            DialogService.Register <ChooseCardDialogViewModel, ChooseCardDialogView>();

            // Initialize View Models
            MainVm = new MainViewModel(DialogService, Reporter, CardCatalog, ArtworkPreferences);
        }
コード例 #3
0
ファイル: MainViewModel.cs プロジェクト: bodines1/Boxy
        /// <summary>
        /// Creates a new instance of <see cref="MainViewModel"/>.
        /// </summary>
        /// <param name="dialogService">Service for resolving and showing dialog windows from viewmodels.</param>
        /// <param name="reporter">Reports status and progress events to subscribers.</param>
        /// <param name="cardCatalog">Holds a queryable set of all oracle cards (no duplicate printings) to prevent excess queries to ScryfallAPI.</param>
        /// <param name="artworkPreferences">Holds a mapping of Oracle Ids to Card Ids to store and retrieve a user's preferred printing of a card.</param>
        public MainViewModel(IDialogService dialogService, IReporter reporter, CardCatalog cardCatalog, ArtworkPreferences artworkPreferences)
        {
            DialogService  = dialogService;
            Reporter       = reporter;
            OracleCatalog  = cardCatalog;
            ArtPreferences = artworkPreferences;
            ZoomPercent    = Settings.Default.ZoomPercent;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                Version version = ApplicationDeployment.CurrentDeployment.CurrentVersion;
                SoftwareVersion = $"{version.Major}.{version.Minor}.{version.Build}";
            }
            else
            {
                SoftwareVersion = "Debug";
            }

            Reporter.StatusReported   += (sender, args) => LastStatus = args;
            Reporter.ProgressReported += (sender, args) => LastProgress = args;
        }