コード例 #1
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            // Specify the local database connection string.
            string DBConnectionString = "Data Source=isostore:/Stats.sdf";

            using (DataBaseContext db = new DataBaseContext(DBConnectionString))
            {
                if (db.DatabaseExists() == false)
                {
                    // Create the local database.
                    db.CreateDatabase();
                }
            }
            DB = new DataBaseContext(DBConnectionString);
        }
コード例 #2
0
        //Create and adds a few ItemViewModel objects into the Items collection
        public void LoadData()
        {
            //Create DataBase
            DataB = new DataBaseContext("Data Source=isostore:/DB.sdf");

            using (DataB)
            {
                if (!DataB.DatabaseExists())
                {
                    DataB.CreateDatabase();
                    DataB.SubmitChanges();
                }
                else
                {
                    int last = 0;
                    foreach (var item in DataB.Tile)
                    {
                        if (last <= item.TileUpdateId)
                        {
                            last = item.TileUpdateId;

                            TileUpdate.idTile       = item.TileUpdateId;
                            TileUpdate.modelTile    = item.ModelTile;
                            TileUpdate.currencyTile = item.CurrencyTile;
                            TileUpdate.seeTile      = item.SeeTile;
                            TileUpdate.updateTile   = item.UpdateTile;
                            TileUpdate.valueTile    = item.ValueTile;

                            DataB.SubmitChanges();
                        }
                    }
                }
            }

            //if (this.IsDataLoaded == false)
            //{

            this.Items.Clear();
            id = 0;

            //this.Items.Add(new ItemViewModel() { ID = "0", LineOne = "Please Wait...", LineTwo = "Please wait while the catalog is downloaded from the server.", LineThree = null });

            //Load Web Api

            WebClient webClientMtGox = new WebClient();

            webClientMtGox.Headers["Accept"]        = "application/json";
            webClientMtGox.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadCatalogCompletedMtGox);
            webClientMtGox.DownloadStringAsync(new Uri(urlMtGox));

            WebClient webClientBtcE = new WebClient();

            webClientBtcE.Headers["Accept"]        = "application/json";
            webClientBtcE.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadCatalogCompletedBtcE);
            webClientBtcE.DownloadStringAsync(new Uri(urlBtcE));

            WebClient webClientBitstamp = new WebClient();

            webClientBitstamp.Headers["Accept"]        = "application/json";
            webClientBitstamp.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadCatalogCompletedBitstamp);
            webClientBitstamp.DownloadStringAsync(new Uri(urlBitstamp));

            WebClient webClientCoinBase = new WebClient();

            webClientCoinBase.Headers["Accept"]        = "application/json";
            webClientCoinBase.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadCatalogCompletedCoinBase);
            webClientCoinBase.DownloadStringAsync(new Uri(urlCoinBase));

            //WebClient webClientCampBX = new WebClient();
            //webClientCampBX.Headers["Accept"] = "application/json";
            //webClientCampBX.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadCatalogCompletedCampBX);
            //webClientCampBX.DownloadStringAsync(new Uri(urlCampBX));

            WebClient webClientLocalbitcoins = new WebClient();

            webClientLocalbitcoins.Headers["Accept"]        = "application/json";
            webClientLocalbitcoins.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadCatalogCompletedLocalbitcoins);
            webClientLocalbitcoins.DownloadStringAsync(new Uri(urlLocalbitcoins));
            //}

            //IsDataLoaded = false;
        }
コード例 #3
0
ファイル: LoginPage.xaml.cs プロジェクト: tymiles003/FindMe
        private async void loginButton_Click(object sender, EventArgs e)
        {
            this.Pivot.IsHitTestVisible = false;
            this.Pivot.Opacity          = 0.6;
            uiHelper.ShowProgressIndicator("Logging in......", this);
            string userName = userNameText.Text;
            string password = passwordText.Password;

            try
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                {
                    serverHelper = new ServerHelper();
                    Token token = await serverHelper.GetToken(userName, password);

                    AppSettings settings = new AppSettings();
                    if (token != null)
                    {
                        if (token.Error == null)
                        {
                            settings.AddOrUpdateValue("token", token.AccessToken);
                            settings.AddOrUpdateValue("issued", token.Issued);
                            settings.AddOrUpdateValue("expires", token.Expires);
                            settings.AddOrUpdateValue("isLogin", true);
                            settings.Save();
                            serverHelper = new ServerHelper();
                            uiHelper.ShowProgressIndicator("Getting user information......", this);
                            UserInfo userInfo = await serverHelper.GetUserInfo();

                            userInfo.ProfilePic = await serverHelper.GetProfilePic(userInfo.ProfilePicUrl);

                            using (DataBaseContext db = new DataBaseContext(DataBaseContext.DBConnectionString))
                            {
                                if (!db.DatabaseExists())
                                {
                                    //Create the database
                                    db.CreateDatabase();
                                }
                                db.UserInfo.InsertOnSubmit(userInfo);
                                db.SubmitChanges();
                            }
                            uiHelper.ShowProgressIndicator("Getting friends list......", this);
                            appHelper = new AppHelper();
                            await appHelper.UpdateFriends();

                            await ConnectionHelper.Connect();

                            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                        }
                        else
                        {
                            settings.AddOrUpdateValue("isLogin", false);
                            settings.Save();
                            Dispatcher.BeginInvoke(() =>
                            {
                                MessageBox.Show(token.Error);
                            });
                        }
                    }
                    else
                    {
                        settings.AddOrUpdateValue("isLogin", false);
                        settings.Save();
                        Dispatcher.BeginInvoke(() =>
                        {
                            MessageBox.Show("Sorry, unable to contact the server.");
                        });
                    }
                }
                else
                {
                    Dispatcher.BeginInvoke(() =>
                    {
                        MessageBox.Show("Sorry, no network found. Please check your connection settings.");
                    });
                }
            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(ex.Message);
                });
            }
            this.Pivot.IsHitTestVisible = true;
            this.Pivot.Opacity          = 1;
            uiHelper.HideProgressIndicator(this);
        }