I got the solution, here is the code
public void RunImpl(object state)
{
if (authToken == "your developer token")
{
ShowMessage("Please fill in your devleoper token in Sample.cs");
return;
}
// Instantiate the libraries to connect the service
TTransport userStoreTransport = new THttpClient(new Uri(UserStoreUrl));
TProtocol userStoreProtocol = new TBinaryProtocol(userStoreTransport);
UserStore.Client userStore = new UserStore.Client(userStoreProtocol);
// Check that the version is correct
//bool versionOK =
// userStore.checkVersion("Evernote EDAMTest (WP7)",
// Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MAJOR,
// Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MINOR);
//InvokeOnUIThread(() => ViewModel.TheViewModel.VersionOK = versionOK);
//Debug.WriteLine("Is my Evernote API version up to date? " + versionOK);
//if (!versionOK)
//{
// return;
//}
// Get the URL used to interact with the contents of the user's account
// When your application authenticates using OAuth, the NoteStore URL will
// be returned along with the auth token in the final OAuth request.
// In that case, you don't need to make this call.
String noteStoreUrl = userStore.getNoteStoreUrl(authToken);
TTransport noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
TProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
NoteStore.Client noteStore = new NoteStore.Client(noteStoreProtocol);
// Listing all the user's notebook
List<Notebook> notebooks = noteStore.listNotebooks(authToken);
// Debug.WriteLine("Found " + notebooks.Count + " notebooks:");
InvokeOnUIThread(() => notebooks.ForEach(notebook => ViewModel.TheViewModel.Notebooks.Add(notebook)));
// Find the default notebook
Notebook defaultNotebook = notebooks.Single(notebook => notebook.DefaultNotebook);
// Printing the names of the notebooks
//foreach (Notebook notebook in notebooks)
//{
// radListPicker1.Items.Add(notebook.Name);
//}
// Listing the first 10 notes in the default notebook
NoteFilter filter = new NoteFilter { NotebookGuid = defaultNotebook.Guid };
NoteList notes = noteStore.findNotes(authToken, filter, 0, 10);
InvokeOnUIThread(() => notes.Notes.ForEach(note1 => ViewModel.TheViewModel.Notes.Add(note1)));
foreach (Note note1 in notes.Notes)
{
Debug.WriteLine(" * " + note1.Title);
}
Note mynote1 = new Note();
// Uri uri = null;
// uri = new Uri(String.Format("/DiaryKuliner;component/Images/makanan.jpg"), UriKind.Relative);
MemoryStream ms = new MemoryStream();
MemoryStream ms1 = new MemoryStream();
byte[] imagesBytes;
byte[] hash;
byte[] imagesBytes1;
byte[] hash1;
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
wb = new WriteableBitmap(450, 344);
wb.Render(map1, new MatrixTransform());
wb.Invalidate();
wb1 = new WriteableBitmap(450, 344);
wb1.Render(image, new MatrixTransform());
wb1.Invalidate();
});
Thread.Sleep(500);
wb.SaveJpeg(ms, wb.PixelWidth, wb.PixelHeight, 0, 100);
wb1.SaveJpeg(ms1, wb1.PixelWidth, wb1.PixelHeight, 0, 100); //untuk hasil dari camera
imagesBytes = ms.ToArray();
imagesBytes1 = ms1.ToArray();
hash = new MD5CryptoServiceProvider().ComputeHash(imagesBytes);
hash1 = new MD5CryptoServiceProvider().ComputeHash(imagesBytes1);
Data data = new Data();
data.Size = imagesBytes.Length;
data.BodyHash = hash;
data.Body = imagesBytes;
Data data1 = new Data();
data1.Size = imagesBytes1.Length;
data1.Body = hash1;
data1.Body = imagesBytes1;
Resource resource = new Resource();
resource.Mime = "image/jpeg";
resource.Data = data;
Resource resource1 = new Resource();
resource1.Mime = "image/jpeg";
resource1.Data = data1;
mynote1.Resources = new List<Resource>();
mynote1.Resources.Add(resource);
mynote1.Resources.Add(resource1);
// To display the Resource as part of the note1's content, include an <en-media>
// tag in the note1's ENML content. The en-media tag identifies the corresponding
// Resource using the MD5 hash.
string hashHex = BitConverter.ToString(hash).Replace("-", "").ToLower();
string hashHex1 = BitConverter.ToString(hash1).Replace("-", "").ToLower();
// The content of an Evernote note1 is represented using Evernote Markup Language
// (ENML). The full ENML specification can be found in the Evernote API Overview
// at http://dev.evernote.com/documentation/cloud/chapters/ENML.php
mynote1.Title = curTitle;
mynote1.Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">" +
"<en-note>" + curContent + "<br/>" +
"Lokasi : <br/> <en-media type=\"image/png\" hash=\"" + hashHex + "\"/>" + "<br/>" +
"Gambarnya :<br/> <en-media type=\"image/png\" hash=\"" + hashHex1 + "\"/>" + "<br/>" +
"<br/><br/><br/><br/> © DiaryKuliner 2012 -- Syncs with Evernote®" +
"</en-note>";
// Finally, send the new note1 to Evernote using the createNote method
// The new Note object that is returned will contain server-generated
// attributes such as the new note1's unique GUID.
Note createdNote1 = noteStore.createNote(authToken, mynote1);
//Note ambilNote = noteStore.getNote(authToken, createdNote1.Guid, true, true, true, true);
ShowMessage("Successfully created new note1 with Title : " + createdNote1.Title);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
txtContent.Text = "";
txtTitle.Text = "";
mypivot.SelectedIndex = 0;
});
}
The explanation is, this code
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
wb = new WriteableBitmap(450, 344);
wb.Render(map1, new MatrixTransform());
wb.Invalidate();
wb1 = new WriteableBitmap(450, 344);
wb1.Render(image, new MatrixTransform());
wb1.Invalidate();
});
is use to generate writeable bitmap "in background", if don't use
Deployment.Current.Dispatcher.BeginInvoke(( will raise an error, after create writeablebitmap, add Resouces and attach, almost the same with Evernote C# Client (windows form) sample.
Hope my explanation clear.. if need help, please send mail to rgunawans@gmail.com,