Exemplo n.º 1
0
        internal void ShowPDMessage(GetPDListResult result)
        {
            if (App.Cards.Count == 0)
            {
                result = GetPDListResult.NoCheck;
            }

            switch (result)
            {
            case GetPDListResult.New:
            case GetPDListResult.Update:
                pdSuccess.Visibility = Visibility.Visible;
                pdError.Visibility   = Visibility.Collapsed;
                break;

            case GetPDListResult.NotFound:
            case GetPDListResult.Error:
            case GetPDListResult.Conflict:
                pdError.Visibility   = Visibility.Visible;
                pdSuccess.Visibility = Visibility.Collapsed;
                CardPrice.ClearPDLegalList();
                break;

            default:
                pdSuccess.Visibility = Visibility.Collapsed;
                pdError.Visibility   = Visibility.Collapsed;
                break;
            }
        }
Exemplo n.º 2
0
        private async void OnRetryPDList(object sender, RoutedEventArgs e)
        {
#if !OFFLINE
            imgLoading.Visibility = Visibility.Visible;

            var successPd = await CardPrice.GetOrOpenPDLegalFile(true);

            App.CurrentMainWindow?.ShowPDMessage(successPd);
            ViewModel.RefreshTab();
            UpdatePDRotationTime();

            imgLoading.Visibility = Visibility.Collapsed;
#endif
        }
Exemplo n.º 3
0
        private async void OnInitialized(object sender, EventArgs e)
        {
            var vm = ViewModel;

            imgLoading.Visibility = Visibility.Visible;

            await Task.Run(() =>
            {
#if !OFFLINE
                if (File.Exists(App.GetPath("cards.xml")))
                {
                    App.SetCardInfosFromXml(App.GetPath("cards.xml"));
                }

                if (CardPrice.EnableCardPrice)
                {
                    CardPrice.OpenCacheData();
                }
#else
                App.SetCardInfosFromResource();
#endif
            });

#if !OFFLINE
            if (vm.GetPDList)
            {
                var successPd = await CardPrice.GetOrOpenPDLegalFile(false);

                ShowPDMessage(successPd);
            }
#endif
            imgLoading.Visibility = Visibility.Hidden;
            vm.SetRefreshTimer(Dispatcher);

#if !OFFLINE
            if (vm.AutoVersionCheck && await App.IsOutdatedRelease(vm.AcceptsPrerelease))
            {
                notifier.Visibility = Visibility.Visible;
            }
#endif
        }
Exemplo n.º 4
0
        protected override void OnExit(ExitEventArgs e)
        {
#if !OFFLINE
            if (HttpClient.IsValueCreated)
            {
                HttpClient.Value.Dispose();
            }
#endif

            SettingsCache.Write();
            Settings.Default.Save();

#if !OFFLINE
            if (SettingsCache.GetCardPrice)
            {
                CardPrice.SaveCacheData();
            }
#endif
            Debug.WriteLine("Card.PropertyChanged = { " + string.Join(", ", Cards.Values.Where(card => card.IsObserved)) + " }");

            base.OnExit(e);
        }
Exemplo n.º 5
0
        /// <summary>
        /// カードテキストデータを XML に保存します。
        /// </summary>
        public static void SaveAsXml(string path)
        {
            var cardsElem = new XElement("cards");

            foreach (var card in Cards.Values.Where(c => !CardPrice.IsSpecialCard(c)).OrderBy(c => c.Name))
            {
                cardsElem.Add(card.ToXml());
            }

            foreach (var card in Cards.Values.Where(CardPrice.IsSpecialCard))
            {
                cardsElem.Add(card.ToXml());
            }

            foreach (var alt in AltCards.Values)
            {
                cardsElem.Add(alt.ToXml());
            }

            var doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), cardsElem);

            doc.Save(path);
        }
Exemplo n.º 6
0
        internal async void OnOption(object sender, RoutedEventArgs e)
        {
            var  vm       = ViewModel;
            bool oldPrice = vm.GetCardPrice;
            bool oldPd    = vm.GetPDList;

            var dlg = new OptionDialog(DataContext)
            {
                Owner = this
            };

            dlg.ShowDialog();

            Topmost = vm.TopMost;

            // Preview Pane の自動探索の設定を反映
            vm.SetRefreshTimer(Dispatcher);

#if !OFFLINE
            notifier.Visibility = vm.AutoVersionCheck &&
                                  await App.IsOutdatedRelease(vm.AcceptsPrerelease) ? Visibility.Visible : Visibility.Collapsed;

            // カード価格関連の変更を反映するために await
            imgLoading.Visibility = Visibility.Visible;

            if (vm.GetCardPrice != oldPrice)
            {
                if (CardPrice.EnableCardPrice)
                {
                    await Task.Run(CardPrice.OpenCacheData);
                }
                else
                {
                    CardPrice.ClearCacheData();
                }
            }

            if (vm.GetPDList != oldPd)
            {
                if (vm.GetPDList)
                {
                    var successPd = await CardPrice.GetOrOpenPDLegalFile(false);

                    ShowPDMessage(successPd);
                }
                else
                {
                    CardPrice.ClearPDLegalList();
                    pdSuccess.Visibility = Visibility.Collapsed;
                    pdError.Visibility   = Visibility.Collapsed;
                }
            }

            if (vm.GetCardPrice != oldPrice || vm.GetPDList != oldPd)
            {
                vm.RefreshTab();
            }

            imgLoading.Visibility = Visibility.Hidden;
#endif
        }