示例#1
0
 public void chkAutoRefreshTasks_Click(object sender, RoutedEventArgs e)
 {
     if (GTaskSettings.IsFree)
     {
         GTaskSettings.Upsell();
         chkAutoRefreshTasks.IsChecked = false;
     }
 }
示例#2
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            if (GTaskSettings.IsLoggedIn())
            {
                //Check to see if Reminder should be shown
                LoginHelper.Reminder();

                //Create Menu Bar
                BuildLocalizedApplicationBar();

                //hide login button
                btnLogin.Visibility = System.Windows.Visibility.Collapsed;

                //show TaskListBox
                TaskListBox.Visibility = System.Windows.Visibility.Visible;

                //add logout menu item
                ApplicationBarMenuItem appBarLogoutMenuItem = new ApplicationBarMenuItem(AppResources.AppBarLogoutMenuText);
                ApplicationBar.MenuItems.Add(appBarLogoutMenuItem);
                appBarLogoutMenuItem.Click += new EventHandler(Logout_Click);
            }
            else
            {
                //Set/Reset App Variables
                LoginHelper.SetVariables();

                //hide TaskListbox
                TaskListBox.Visibility = System.Windows.Visibility.Collapsed;
            }

            //Set Title
            txtTitle.Text = GTaskSettings.ApplicationTitle;

            //Turnoff Ads if not paid for
            if (GTaskSettings.IsFree)
            {
                AdControl.Visibility = System.Windows.Visibility.Visible;
                TaskListBox.Margin   = new Thickness(0, 0, 0, 80);
            }
            else
            {
                AdControl.Visibility = System.Windows.Visibility.Collapsed;
                TaskListBox.Margin   = new Thickness(0, 0, 0, 0);
            }
        }
示例#3
0
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            SystemTray.ProgressIndicator = new ProgressIndicator();

            //Get Data if logged in
            if (GTaskSettings.IsLoggedIn())
            {
                if (GTaskSettings.AutoRefreshLists)
                {
                    refresh(true, true);
                }
                else
                {
                    refresh();
                }
            }
        }
示例#4
0
        public Login()
        {
            InitializeComponent();

            //Login or Logout depending on current state
            if (GTaskSettings.IsLoggedIn())
            {
                try
                {
                    webBrowserGoogleLogin.Navigate(new Uri(GTaskSettings.LogOutURL, UriKind.RelativeOrAbsolute));

                    //Remove Stored Information
                    GTaskSettings.ClearSession();

                    //Remove LocalStorage (if exists)
                    string ApplicationDataFileName = "TaskListData.txt";

                    IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
                    if (storage.FileExists(ApplicationDataFileName))
                    {
                        storage.DeleteFile(ApplicationDataFileName);
                    }

                    //Remove LiveTiles
                    List <ShellTile> listST = new List <ShellTile>();
                    foreach (ShellTile shellTile in ShellTile.ActiveTiles)
                    {
                        if (shellTile.NavigationUri.ToString().Contains("/Views/TaskView.xaml?Id="))
                        {
                            shellTile.Delete();
                        }
                    }

                    MessageBoxResult msgbox = MessageBox.Show("You have successfully logged out.");
                    Dispatcher.BeginInvoke(() => NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute)));
                }
                catch (Exception)
                {
                    MessageBox.Show("[4] Take a screenshot and send it to @MattLoflin or [email protected]");
                }
            }
            else
            {
                webBrowserGoogleLogin.Navigate(LoginHelper.GetLoginUrl());
            }
        }
示例#5
0
        //If not logged it - take back to homepage where it will prompt
        //if logged in then pull in list, check to see if "Pinned" and show pin or unpin accordingly
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //If the user isn't logged in then go to the MainPage
            if (!GTaskSettings.IsLoggedIn())
            {
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
            }
            else
            {
                //Check to see if Reminder should be shown
                LoginHelper.Reminder();
            }



            //If there is an ID set it, else go to MainPage
            if (NavigationContext.QueryString.ContainsKey("Id"))
            {
                Id = NavigationContext.QueryString["Id"];

                //Check to see if the Id exists.
                Check_Id(Id);

                //Set Title
                txtTitle.Text = GTaskSettings.ApplicationTitle;
            }
            else
            {
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
            }

            //Create Menu Bar
            //BuildLocalizedApplicationBar();

            //Turnoff Ads if not paid for
            if (GTaskSettings.IsFree)
            {
                AdControl.Visibility = System.Windows.Visibility.Visible;
                //TasksView.Margin = new Thickness(0, 0, 0, 80);
            }
            else
            {
                AdControl.Visibility = System.Windows.Visibility.Collapsed;
                //TasksView.Margin = new Thickness(0, 0, 0, 0);
            }
        }
示例#6
0
        private async void save_Click(object sender, EventArgs e)
        {
            SetProgressIndicator(true);
            SystemTray.ProgressIndicator.Text = "Saving Task";

            if (!string.IsNullOrEmpty(txtbxTitle.Text.Trim()))
            {
                //Disable buttons
                ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = false;
                ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = false;
                ((ApplicationBarIconButton)ApplicationBar.Buttons[2]).IsEnabled = false;

                if (!_id.Equals("new"))
                {
                    var s = from p in App.TaskViewModel.TaskItem
                            where p.id == _id
                            select p;

                    //Set the variables
                    var taskItem = s.First();

                    string oldNotes = null;
                    string newNotes = null;
                    if (taskItem.notes != null)
                    {
                        oldNotes = taskItem.notes;
                    }
                    if (txtNotes.Text.Trim() != null && txtNotes.Text.Trim() != "")
                    {
                        newNotes = txtNotes.Text.Trim();
                    }

                    string oldDue = null;
                    string newDue = null;
                    if (taskItem.due != null)
                    {
                        oldDue = Convert.ToDateTime(Universal.ConvertToUniversalDate(taskItem.due)).ToString("yyyy-MM-dd'T'hh:mm:ss.00Z");
                    }
                    if (txtDueDate.Value.ToString() != null)
                    {
                        newDue = GetReminderDateTime();
                    }

                    //check for changes before submitting to google
                    if (taskItem.title != txtbxTitle.Text.Trim() || oldNotes != newNotes || oldDue != newDue)
                    {
                        taskItem.title = txtbxTitle.Text.Trim();
                        taskItem.notes = newNotes;
                        taskItem.due   = newDue;

                        //Update the task
                        bool result = await taskItem.Update(GetResponse);

                        // Update the task locally
                        List <TaskListItem> lists = await TaskListHelper.GetTaskListFromApplicationStorage();

                        foreach (TaskListItem list in lists)
                        {
                            foreach (TaskItem task in list.taskList.Where(x => x.id == _id))
                            {
                                task.title   = taskItem.title;
                                task.notes   = taskItem.notes;
                                task.due     = taskItem.due;
                                task.updated = DateTime.UtcNow.ToString("yyyy-MM-dd'T'hh:mm:ss.00Z"); //DateTime.UtcNow.ToString();
                            }
                        }

                        // Resubmit the list to local storage
                        await TaskListHelper.SubmitToLocalStorage(lists);

                        if (result)
                        {
                            if (GTaskSettings.MsgUpdateTask)
                            {
                                MessageBoxResult m = MessageBox.Show("Complete.", "Update Task", MessageBoxButton.OK);
                            }
                        }
                        else
                        {
                            MessageBoxResult m = MessageBox.Show("This task was updated while offline, please sync once back online.", "Offline Mode", MessageBoxButton.OK);
                        }
                    }

                    NavigationService.Navigate(new Uri("/Views/TaskView.xaml?Id=" + _listId, UriKind.RelativeOrAbsolute));
                }
                else //if it is new
                {
                    var t = new TaskItem {
                    };
                    t.title = txtbxTitle.Text.Trim();
                    t.notes = txtNotes.Text.Trim();

                    if (!string.IsNullOrEmpty(txtDueDate.Value.ToString()))
                    {
                        t.due = GetReminderDateTime();
                    }
                    else
                    {
                        t.due = null;
                    }

                    //Create the Task
                    TaskItem result = await TaskHelper.AddTask(t, GetResponse, _listId);

                    if (result != null)
                    {
                        // Refresh the data
                        await GTaskSettings.RefreshData(false, _listId, true);

                        if (GTaskSettings.MsgCreateTask)
                        {
                            MessageBoxResult n = MessageBox.Show("Complete.", "Create Task", MessageBoxButton.OK);
                        }
                    }
                    else
                    {
                        // Create a random ID
                        t.id       = Guid.NewGuid().ToString();
                        t.status   = "needsAction";
                        t.updated  = DateTime.UtcNow.ToString("yyyy-MM-dd'T'hh:mm:ss.00Z");
                        t.kind     = "tasks#task";
                        t.selfLink = "https://www.googleapis.com/tasks/v1/lists/" + _listId + "/tasks/" + t.id;

                        // Add a setting to flag the list
                        var settings = IsolatedStorageSettings.ApplicationSettings;
                        settings.Add("Task_" + t.id + "_Action", "added");
                        settings.Add("Task_" + t.id + "_Timestamp", DateTime.UtcNow.ToString());

                        // Get local storage
                        List <TaskListItem> list = await TaskListHelper.GetTaskListFromApplicationStorage();

                        // Set the position
                        // Check if there are items in the current list
                        if (list.Where(x => x.id == _listId).First().taskList.Count() > 0)
                        {
                            t.position = (double.Parse(list.Where(x => x.id == _listId).First().taskList.OrderBy(x => x.position).First().position) - 1).ToString();
                        }
                        else
                        {
                            t.position = "10000";
                        }

                        // Add the task to the list
                        list.Where(x => x.id == _listId).First().taskList.Insert(0, t);

                        // Resubmit the list to local storage
                        await TaskListHelper.SubmitToLocalStorage(list);

                        MessageBoxResult m = MessageBox.Show("This task was created while offline, please sync once back online.", "Offline Mode", MessageBoxButton.OK);
                    }

                    //Navigate back to TaskView if "New"
                    //Given we don't know the TaskID of this item yet, if you don't return it will create multiple identical tasks
                    NavigationService.Navigate(new Uri("/Views/TaskView.xaml?Id=" + _listId, UriKind.RelativeOrAbsolute));
                }
            }
            else
            {
                MessageBoxResult o = MessageBox.Show("Well, hello there! Do you mind including a Title?", "Title?", MessageBoxButton.OK);
            }

            //re-enable buttons
            ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
            ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true;
            ((ApplicationBarIconButton)ApplicationBar.Buttons[2]).IsEnabled = true;

            SetProgressIndicator(false);
        }
示例#7
0
        private async void speech_Click(object sender, EventArgs eventArgs)
        {
            string message   = "Excuse me, what did you say?!";
            string txtbxType = string.Empty;

            if (GTaskSettings.IsFree)
            {
                GTaskSettings.Upsell();
            }
            else
            {
                try
                {
                    //If no textbox is selected, there is no where to put the text
                    if (focusedTextbox == null)
                    {
                        MessageBoxResult o = MessageBox.Show("Please select the text box you want to use and try again.", "Which Text Box?", MessageBoxButton.OK);
                        return;
                    }

                    // Create an instance of SpeechRecognizerUI.
                    this.recoWithUI = new SpeechRecognizerUI();
                    recoWithUI.Settings.ReadoutEnabled   = false;
                    recoWithUI.Settings.ShowConfirmation = false;

                    if (focusedTextbox.Name == "txtbxTitle")
                    {
                        recoWithUI.Settings.ListenText  = "Listening for Task Title...";
                        recoWithUI.Settings.ExampleText = "Ex. 'Mow the lawn'";
                        txtbxType = "Title";
                    }
                    else
                    {
                        recoWithUI.Settings.ListenText  = "Listening for Tasks Notes...";
                        recoWithUI.Settings.ExampleText = "Ex. 'This needs to be done by Tuesday.'";
                        txtbxType = "Notes";
                    }

                    // Start recognition (load the dictation grammar by default).
                    SpeechRecognitionUIResult recoResult = await recoWithUI.RecognizeWithUIAsync();

                    // Do something with the recognition result.
                    string txtbxText       = focusedTextbox.Text;
                    string SpeakResult     = (recoResult.RecognitionResult == null) ? string.Empty : recoResult.RecognitionResult.Text;
                    string FinalText       = string.Empty;
                    int    SelectionStart  = focusedTextbox.SelectionStart;
                    int    SelectionLength = focusedTextbox.SelectionLength;
                    int    SelectionEnd    = SelectionStart + SelectionLength;

                    if (SpeakResult == string.Empty) //If nothing in speech result, don't do anything
                    {
                        return;
                    }

                    FinalText = SpeechHelper.FormatSpeech(SelectionStart, txtbxText, SelectionEnd, SpeakResult, txtbxType);

                    if (FinalText != String.Empty) //Results are returned
                    {
                        if (SelectionLength == 0)  //0 means it is an insert
                        {
                            focusedTextbox.Text = focusedTextbox.Text.Insert(SelectionStart, FinalText);
                            focusedTextbox.Select(SelectionStart + FinalText.Length, 0); //Set the cursor location to where the start was previously
                        }
                        else //greater than 0 means it is a replace
                        {
                            focusedTextbox.SelectedText = FinalText;
                            focusedTextbox.Select(SelectionStart + FinalText.Length, 0); //Set the cursor location to where the start was previously
                        }
                    }
                }
                catch
                {
                    if (GTaskSettings.MsgError)
                    {
                        MessageBox.Show(message);
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// Refresh the data on the page
        /// </summary>
        /// <param name="refreshLocalStorage">Refresh local storage</param>
        public async void refresh(bool refresh = false, bool hidden = false)
        {
            //Start Progress Indicator
            SetProgressIndicator(true);

            if (refresh)
            {
                SystemTray.ProgressIndicator.Text = "Syncing with Google";
            }
            else
            {
                SystemTray.ProgressIndicator.Text = "Getting Data";
            }

            //Check to see if the Id exists.
            Check_Id(Id);

            // Get the settings
            var settings = IsolatedStorageSettings.ApplicationSettings;

            // Check to see if the list currently being viewed was added
            if (settings.Contains("List_" + Id + "_Action") && settings["List_" + Id + "_Action"].ToString() == "added")
            {
                settings["GetNewListId"] = Id;
            }

            //If hidden = true then we need to reload all the data, else we don't
            if (hidden == false)
            {
                await GTaskSettings.RefreshData(true, Id, refresh);
            }
            else
            {
                await GTaskSettings.RefreshData(true, null, refresh);
            }

            if (refresh)
            {
                SystemTray.ProgressIndicator.Text = "Data Synced, Finishing up";
            }


            // Update the ID value
            if (settings.Contains("GetNewListId"))
            {
                Id = settings["GetNewListId"].ToString();

                // Remove the setting
                settings.Remove("GetNewListId");
            }

            //Load the Tasks
            await App.TaskViewModel.LoadData(Id);

            //Set DataContext to TaskList(s)
            DataContext = App.TaskViewModel;

            //Update Title
            SetTitle();

            //Stop Progress Indicator
            SetProgressIndicator(false);

            //Build menu bar
            BuildLocalizedApplicationBar();
        }
示例#9
0
        //Speech
        private async void speech_Click(object sender, EventArgs eventArgs)
        {
            string message   = "Excuse me, what did you say?!";
            string txtbxType = "Title";

            if (GTaskSettings.IsFree)
            {
                GTaskSettings.Upsell();
            }
            else
            {
                try
                {
                    // Create an instance of SpeechRecognizerUI.
                    this.recoWithUI = new SpeechRecognizerUI();
                    recoWithUI.Settings.ReadoutEnabled   = false;
                    recoWithUI.Settings.ShowConfirmation = false;

                    recoWithUI.Settings.ListenText  = "Listening for Task List Title...";
                    recoWithUI.Settings.ExampleText = "Ex. 'Grocery List'";

                    // Start recognition (load the dictation grammar by default).
                    SpeechRecognitionUIResult recoResult = await recoWithUI.RecognizeWithUIAsync();

                    // Do something with the recognition result.
                    string txtbxText       = txtbxTitle.Text;
                    string FinalText       = string.Empty;
                    int    SelectionStart  = txtbxTitle.SelectionStart;
                    int    SelectionLength = txtbxTitle.SelectionLength;
                    int    SelectionEnd    = SelectionStart + SelectionLength;
                    string SpeakResult     = (recoResult.RecognitionResult == null) ? string.Empty : recoResult.RecognitionResult.Text;

                    if (SpeakResult == string.Empty) //If nothing in speech result, don't do anything
                    {
                        return;
                    }

                    FinalText = SpeechHelper.FormatSpeech(SelectionStart, txtbxText, SelectionEnd, SpeakResult, txtbxType);

                    if (FinalText != String.Empty) //Results are returned
                    {
                        if (SelectionLength == 0)  //0 means it is an insert
                        {
                            txtbxTitle.Text = txtbxTitle.Text.Insert(SelectionStart, FinalText);
                            txtbxTitle.Select(SelectionStart + FinalText.Length, 0); //Set the cursor location to where the start was previously
                        }
                        else //greater than 0 means it is a replace
                        {
                            txtbxTitle.SelectedText = FinalText;
                            txtbxTitle.Select(SelectionStart + FinalText.Length, 0); //Set the cursor location to where the start was previously
                        }
                    }
                }
                catch
                {
                    if (GTaskSettings.MsgError)
                    {
                        MessageBox.Show(message);
                    }
                }
            }
        }