Exemplo n.º 1
0
        private async void saveNote()
        {
            if (client.Session == null)
            {
                statusTxt.Text = "You need to Sign In";
            }
            else
            {
                if (noteTitle.Text.Length == 0)
                {
                    statusTxt.Text = "Please provide a title";
                }
                else
                {
                    statusTxt.Text = "Saving " + noteTitle.Text;

                    UTF8Encoding enc    = new UTF8Encoding();
                    var          stream = new MemoryStream(enc.GetBytes(notesEditor.Text));

                    String filename = noteTitle.Text + ".txt";
                    try
                    {
                        LiveOperationResult uploadResult = await client.Upload(folderIds.Peek(), filename, stream, true);

                        statusTxt.Text = "File saved";

                        saveBtn.IsEnabled       = false;
                        addBtn.IsEnabled        = true;
                        deleteNoteBtn.IsEnabled = true;
                        cancelBtn.IsEnabled     = false;
                        needToSave = false;

                        findNoteList(folderIds.Peek());
                    }
                    catch (LiveConnectException e)
                    {
                        statusTxt.Text = e.Message;
                    }
                }
            }
        }