コード例 #1
0
        async private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (App.CardList.Where(c => c.Name == CardName.Text).Count() == 0)
            {
                Card newCard = new Card();
                newCard.Name = CardName.Text.Trim();
                newCard.Number = scanResult.Text.Trim();
                newCard.Format = scanResult.BarcodeFormat;
                App.CardList.Add(newCard);
                App.APP_SETTINGS.RewardCards = App.CardList;

                await App.Current.SaveAppSettings();
                if(App.APP_SETTINGS.SyncToOneDrive)
                    App.Current.PutAppSettingsToOneDrive();

                if (App.APP_SETTINGS.SyncToBand)
                {
                    BandIntegration b = new BandIntegration();
                    b.SyncToBand();
                }


                this.Frame.Navigate(typeof(MainPage));
            }
            else
            {
                CardName.Text = string.Empty;
                NameError.Visibility = Visibility.Visible;
                CardName.Focus(FocusState.Programmatic);
            }
        }
コード例 #2
0
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     theCard = (Card)e.Parameter;
     CardName.Text = theCard.Name;
     CardType.Text = theCard.Format.ToString();
     RenderCard();
 }
コード例 #3
0
         bool CanBeRenderedOnBand(Card card)
        {
            bool result = false;
            Regex exp = new Regex("^[a-zA-Z0-9$%+-/.]+$");

            switch (card.Format)
            {
                case ZXing.BarcodeFormat.EAN_13:
                case ZXing.BarcodeFormat.EAN_8:
                case ZXing.BarcodeFormat.UPC_EAN_EXTENSION:
                case ZXing.BarcodeFormat.UPC_A:                    
                    if (exp.IsMatch(card.Number) && (card.Number.Length - 1) <= 39)
                        result = true;
                    break;
                case ZXing.BarcodeFormat.PDF_417:
                    if (card.Number.All(char.IsDigit) && card.Number.Length <= 39)
                        result = true;
                    break;
                case ZXing.BarcodeFormat.CODE_128:
                    if (exp.IsMatch(card.Number) && card.Number.Length <= 39)
                        result = true;
                    break;
            }

            return result;
        }