コード例 #1
0
        /// <summary>
        /// Uses ("access_token") gained in performCodeExchange function to acces user infromation needed to extract his Avatar, Name, and also to get id needed in database
        /// </summary>
        /// <param name="access_token"></param>
        async void userinfoCall(string access_token)
        {
            // sends the request
            HttpWebRequest userinfoRequest = (HttpWebRequest)WebRequest.Create(userInfoEndpoint);

            userinfoRequest.Method = "GET";
            userinfoRequest.Headers.Add(string.Format("Authorization: Bearer {0}", access_token));
            userinfoRequest.ContentType = "application/x-www-form-urlencoded";
            userinfoRequest.Accept      = "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";

            // gets the response
            WebResponse userinfoResponse = await userinfoRequest.GetResponseAsync();

            using (StreamReader userinfoResponseReader = new StreamReader(userinfoResponse.GetResponseStream()))
            {
                // reads response body
                string userinfoResponseText = await userinfoResponseReader.ReadToEndAsync();

                char[] delimiterChars = { '"' };

                string[] words = userinfoResponseText.Split(delimiterChars);

                // gets needed informations
                int i = 0;
                foreach (var word in words)
                {
                    i++;
                    if (i == 4)
                    {
                        userSub = word;
                    }
                    if (i == 12)
                    {
                        userName         = word;
                        Witaj.Visibility = Visibility.Visible;
                        Witaj.Content    = "Hello there, " + userName;
                        LogIn.Visibility = Visibility.Collapsed;
                    }
                    if (i == 20)
                    {
                        BitmapImage bitmap = new BitmapImage();
                        bitmap.BeginInit();
                        bitmap.UriSource = new Uri(word, UriKind.Absolute);
                        bitmap.EndInit();
                        avatar.ImageSource = bitmap;
                        ActivateInterface();
                        Instructions.Text = "If you want to operate with tasks you have to use buttons bellow textboxes: “Add”, “Edit” and “Delete”. As it goes “Add” button let’s you to add task to table of your choose, if you want to edit content of the task input correct number in text box labeled “No.” and write correction to textbox and click “Edit”. If you want to delete content of table input correct number in text box labeled “No.” and click delete, it will disappear.";
                    }
                }



                SQLiteDA.CreateTables(userSub);


                Todo.ItemsSource       = SQLiteDA.GetData(userSub + "td", "todo", chosendate.Content.ToString()).DefaultView;
                Inprogress.ItemsSource = SQLiteDA.GetData(userSub + "ip", "inprogress", chosendate.Content.ToString()).DefaultView;
                Done.ItemsSource       = SQLiteDA.GetData(userSub + "d", "done", chosendate.Content.ToString()).DefaultView;
            }
        }
コード例 #2
0
 /// <summary>
 /// Deletes existing in database row based on entered by user number
 /// Every Delete button works the same with slight diffrence of proper tabels for each button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DeleteDone_Click(object sender, RoutedEventArgs e)
 {
     if (DoneNo.Text == "")
     {
         MessageBox.Show("Looks like something has gone wrong." + "\n" + "Be sure that entered data is correct");
     }
     else
     {
         SQLiteDA.Delete(userSub + "d", chosendate.Content.ToString(), DoneNo.Text.ToString());
         Done.ItemsSource = SQLiteDA.GetData(userSub + "d", "Done", chosendate.Content.ToString()).DefaultView;
     }
 }
コード例 #3
0
 /// <summary>
 /// Edits existing in database text, chooses row based on entered by user number
 /// Every Edit button works the same with slight diffrence of proper tabels for each button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EditInProgress_Click(object sender, RoutedEventArgs e)
 {
     if (InProgressNo.Text == "")
     {
         MessageBox.Show("Looks like something has gone wrong." + "\n" + "Be sure that entered data is correct");
     }
     else
     {
         SQLiteDA.Edit(userSub + "ip", "InProgress", chosendate.Content.ToString(), TextBoxInProgress.Text.ToString(), InProgressNo.Text.ToString());
         Inprogress.ItemsSource = SQLiteDA.GetData(userSub + "ip", "InProgress", chosendate.Content.ToString()).DefaultView;
     }
 }
コード例 #4
0
 /// <summary>
 /// Edits existing in database text, chooses row based on entered by user number
 /// Every Edit button works the same with slight diffrence of proper tabels for each button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EditToDo_Click(object sender, RoutedEventArgs e)
 {
     if (ToDoNo.Text == "")
     {
         MessageBox.Show("Looks like something has gone wrong." + "\n" + "Be sure that entered data is correct");
     }
     else
     {
         SQLiteDA.Edit(userSub + "td", "ToDo", chosendate.Content.ToString(), TexBoxToDo.Text.ToString(), ToDoNo.Text.ToString());
         Todo.ItemsSource = SQLiteDA.GetData(userSub + "td", "ToDo", chosendate.Content.ToString()).DefaultView;
     }
 }
コード例 #5
0
        /// <summary>
        /// Shows chosen date form calendar in chosendate label
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
        {
            // ... Get reference.
            var calendar = sender as Calendar;

            // ... See if a date is selected.
            if (calendar.SelectedDate.HasValue)
            {
                // ... Display SelectedDate in Title.
                DateTime date = calendar.SelectedDate.Value;
                chosendate.Content = date.ToShortDateString();
            }

            Todo.ItemsSource       = SQLiteDA.GetData(userSub + "td", "ToDo", chosendate.Content.ToString()).DefaultView;
            Inprogress.ItemsSource = SQLiteDA.GetData(userSub + "ip", "InProgress", chosendate.Content.ToString()).DefaultView;
            Done.ItemsSource       = SQLiteDA.GetData(userSub + "d", "Done", chosendate.Content.ToString()).DefaultView;
        }
コード例 #6
0
 /// <summary>
 /// Adds inserted by user text to database
 /// Every Add button works the same with slight diffrence of proper tabels for each button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AddDone_Click(object sender, RoutedEventArgs e)
 {
     SQLiteDA.Add(userSub + "d", "Done", chosendate.Content.ToString(), TextBoxDone.Text.ToString(), DoneNo.Text.ToString());
     Done.ItemsSource = SQLiteDA.GetData(userSub + "d", "Done", chosendate.Content.ToString()).DefaultView;
 }
コード例 #7
0
 /// <summary>
 /// Adds inserted by user text to database
 /// Every Add button works the same with slight diffrence of proper tabels for each button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AddInProgress_Click(object sender, RoutedEventArgs e)
 {
     SQLiteDA.Add(userSub + "ip", "InProgress", chosendate.Content.ToString(), TextBoxInProgress.Text.ToString(), InProgressNo.Text.ToString());
     Inprogress.ItemsSource = SQLiteDA.GetData(userSub + "ip", "InProgress", chosendate.Content.ToString()).DefaultView;
 }
コード例 #8
0
 /// <summary>
 /// Adds inserted by user text to database
 /// Every Add button works the same with slight diffrence of proper tabels for each button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AddToDo_Click(object sender, RoutedEventArgs e)
 {
     SQLiteDA.Add(userSub + "td", "ToDo", chosendate.Content.ToString(), TexBoxToDo.Text.ToString(), ToDoNo.Text.ToString());
     Todo.ItemsSource = SQLiteDA.GetData(userSub + "td", "ToDo", chosendate.Content.ToString()).DefaultView;
 }