예제 #1
0
 public bool Save(Notes note)
 {
     try
     {
         using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
         {
             db.Notes.InsertOnSubmit(note);
             db.SubmitChanges();
         }
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
예제 #2
0
 public bool Destroy(Notes note)
 {
     try
     {
         using (DataBaseContext db = new DataBaseContext(DataBaseContext.ConnectionString))
         {
             var excluir = db.Notes.Where(t => t.id == note.id).First();
             db.Notes.DeleteOnSubmit(excluir);
             db.SubmitChanges();
         }
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
예제 #3
0
        //ToDo implement note detail page
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            note = new Notes();
            base.OnNavigatedTo(e);
            int id = Int32.Parse(NavigationContext.QueryString["parameter"]);
            if (id > 0)
            {
                note = note.GetNote(id);
            }
            else
            {
                note.note = String.Empty;
                note.date = DateTime.Now;
            }

            ContentPanel.DataContext = note;
            BoxNoteDetail.Text = note.note;
            BlockNoteDate.Text = note.date.ToString();
        }
예제 #4
0
        /// <summary>
        /// We found a note command, so we save it
        /// </summary>
        /// <param name="note"></param>
        private void HandleNoteCommands(string text)
        {
            noting = true;

            note = new Notes();
            note.date = DateTime.Now;
            note.note = text;
            bool verify = StorageHelper.GetSetting("VERIFY_INPUT", true);
            if (verify)
            {
                CortanaOverlay("I heard you say:", note.note, "Should i note it?");
            }
            else
            {
                note.Save();
                NotesList.ItemsSource = note.GetAllNotes();
            }
        }
예제 #5
0
        private void HandleAskCommands(string question)
        {
            noting = false;
            question = question.Replace("?", String.Empty);
            string[] words = question.Split(' ');
            List<Notes> results = new List<Notes>();
            Notes note = new Notes();

            for (int i = 0; i < words.Length; i++)
            {
                if (!phrases.Contains(words[i]))
                {
                    results.AddRange(note.GetSimilarNotes(" " + words[i] + " "));
                }
            }

            if (results.Count > 0)
            {
                //Here is where is the magic, selecting the most frequent note found using the users given keywords
                Notes mostFrequent = results.GroupBy(id => id).OrderByDescending(g => g.Count()).Take(1).Select(g => g.Key).First();
                mostFrequent.note = mostFrequent.note.Replace("my ", "your ");
                mostFrequent.note = mostFrequent.note.Replace("i ", "You ");
                mostFrequent.note = mostFrequent.note.Replace("I am ", "You are");
                if (mostFrequent != null || !String.IsNullOrEmpty(mostFrequent.note))
                {
                    if (!mostFrequent.note.StartsWith("You"))
                    {
                        mostFrequent.note = "You " + mostFrequent.note;
                    }
                    try
                    {
                        CortanaOverlay("Here is what i found:", mostFrequent.note, String.Empty);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error when trying to use Text to speech", "Error", MessageBoxButton.OK);
                    }
                }
                else
                {
                    CortanaOverlay("Sorry, i couldn't find anything", String.Empty, String.Empty);
                }
            }
            else
            {
                CortanaOverlay("Sorry, i couldn't find anything", String.Empty, String.Empty);
            }
        }
예제 #6
0
        /// <summary>
        /// We need to check if the app called by Cortana and then handle the voice commands, else whe install the voice commands
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.NavigationMode == NavigationMode.New)
            {
                string voiceCommandName;
                if (NavigationContext.QueryString.TryGetValue("voiceCommandName", out voiceCommandName))
                {
                    HandleVoiceCommand(voiceCommandName);
                }
                else
                {
                    Task.Run(() => InstallVoiceCommands());
                }
            }

            bool delete = StorageHelper.GetSetting("AUTO_DELETE", false);
            int days = StorageHelper.GetSetting("MAXIMUM_DATE", 1);

            Notes notes = new Notes();
            notes.DestroyOldNotes(days, delete);
            NotesList.ItemsSource = notes.GetAllNotes();
        }