示例#1
0
        private void post_Tap(object sender, EventArgs e)
        {
            statusString = textbox.Text;
            statusString = statusString.Replace("\r", "\n");

            if (App.finalStartTime.CompareTo(DateTime.Now) <= 0 && App.finalExpTime.CompareTo(DateTime.Now) >= 0)
            {
                if (App.NetworkCheckEventFlag)
                {
                    NetworkInformationUtility.GetNetworkTypeCompleted += GetNetworkTypeCompleted;
                    App.NetworkCheckEventFlag = false;
                }

                NetworkInformationUtility.GetNetworkTypeAsync(3000); // Timeout of 3 seconds
            }
            else
            {
                if (App.finalExpTime.CompareTo(DateTime.Now) < 0)
                {
                    MessageBox.Show("Check the expiry time !");
                    return;
                }
                else
                {
                    CustomMessageBox();
                }
            }

            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));

            //MessageBox.Show("Post button was clicked !");
        }
        protected override void OnInvoke(ScheduledTask task)
        {
            Task             = task;
            scheduledUpdates = 0;
            completedUpdates = 0;
            statusUpdateDb   = new StatusUpdateDataContext(StatusUpdateDataContext.DBConnectionString);
            // Define the query to gather all of the to-do items.
            var statusItemsInDB = from statusUpdateItem statusItem in statusUpdateDb.StatusUpdateItems
                                  select statusItem;

            NetworkInformationUtility.GetNetworkTypeCompleted += GetNetworkTypeCompleted;

            NetworkInformationUtility.GetNetworkTypeAsync(3000); // Timeout of 3 seconds
            // Execute the query and place the results into a collection.
            StatusUpdateItems = new ObservableCollection <statusUpdateItem>(statusItemsInDB);
            //TODO: Add code to perform your task in background
            string     toastMessage = "Started";
            ShellToast toast        = new ShellToast();

            toast.Title   = "Started";
            toast.Content = toastMessage;
            toast.Show();
            //var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(10) };
            //timer.Tick += (sender2, args) => { stopPosting(); timer.Stop(); };
            //timer.Start();
            //var timer2 = new DispatcherTimer { Interval = TimeSpan.FromSeconds(24) };
            //timer2.Tick += (sender3, args3) => { notify(); timer2.Stop(); };
            //timer2.Start();


            //postOnFb();
            //postOnLinkedin();
            //postOnTwitter();
            //NotifyComplete();
        }
示例#3
0
        private void LoadUserInfo()
        {
            SetProgressIndicator("Connecting to Facebook", true);
            try
            {
                var fb = new FacebookClient(this.loginButton.CurrentSession.AccessToken);
                MessageBox.Show("If connect too long, let logout and login again!");

                NetworkInformationUtility.GetNetworkTypeAsync(3000); // Timeout of 3 seconds

                if (Bool_Connect != true)
                {
                    //Dispatcher.BeginInvoke(() => MessageBox.Show(message));
                    return;
                }
                fb.GetCompleted += (o, e) =>
                {
                    if (e.Error != null)
                    {
                        //MessageBox.Show(e.Error.Message);
                        return;
                    }

                    var result = (IDictionary <string, object>)e.GetResultData();

                    Dispatcher.BeginInvoke(() =>
                    {
                        try
                        {
                            var profilePictureUrl    = string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", loginButton.CurrentUser.Id, "square", this.loginButton.CurrentSession.AccessToken);
                            this.MyImage.ImageSource = new BitmapImage(new Uri(profilePictureUrl));
                            this.MyName.Text         = String.Format("{0} {1}", (string)result["first_name"], (string)result["last_name"]);
                            Bool_Load_Complete       = true;
                            SetProgressIndicator("", false);
                        }
                        catch
                        {
                            SetProgressIndicator("", false);
                        }
                    });
                };

                fb.GetTaskAsync("me");
            }
            catch (Exception ex)
            {
                SetProgressIndicator("", true);
                MessageBox.Show(ex.ToString());
            }
        }
 void Load_NextQuestion(Question ques)
 {
     try
     {
         Str_Question = "- - - Waiting the question - - -";
         if (Global.Current_Question > 10)
         {
             return;
         }
         NumberQues = "Question: " + (Global.Current_Question + 1).ToString() + "/10";
         Score      = Global.Total_Score.ToString();
         NetworkInformationUtility.GetNetworkTypeAsync(30);
         WClient_MoreInfo.DownloadStringAsync(new Uri(ques.URL));
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }