How can I add enevt to my custom calendar in outlook using Live SDK for .NET? In documentation you add event only to default calendar, not custom.
private async void btnCreateEvent_Click(object sender, RoutedEventArgs e)
{
try
{
var calEvent = new Dictionary<string, object>();
calEvent.Add("name", "Family Dinner");
calEvent.Add("description", "Dinner with Cynthia's family");
calEvent.Add("start_time", "2012-04-07T01:30:00-08:00");
calEvent.Add("end_time", "2012-04-07T03:00:00-08:00");
calEvent.Add("location", "Coho Vineyard and Winery, 123 Main St., Redmond WA 19532");
calEvent.Add("is_all_day_event", false);
calEvent.Add("availability", "busy");
calEvent.Add("visibility", "public");
LiveConnectClient liveClient = new LiveConnectClient(this.session);
LiveOperationResult operationResult = await liveClient.PostAsync("me/events", calEvent);
dynamic result = operationResult.Result;
this.infoTextBlock.Text = string.Join(" ", "Created event:", result.name, "ID:", result.id);
}
catch (LiveConnectException exception)
{
this.infoTextBlock.Text = "Error creating event: " + exception.Message;
}
}
I tried to replace path "me/events" by calendar id, but it doesnt work.
you said:
I tried to replace path "me/events" by calendar id, but it doesnt
work.
and you were one centimeter close !!
you should have replaced "me/events" by "CALENDAR_ID/events"
I came to this question after I asked here in SO and I answered it after reading the MSFT forum
Related
I'm trying to capture the item clicked on in a listview. Everything I've seen here deals with Xamarin Forms, I am NOT using Xamarin Forms. I build my listview and display it fine, but I cannot figure out how to capture the item click. My build code:
ListView PhoneNumberList;
PhoneNumberList = FindViewById<ListView>(Resource.Id.listViewNumbers);
ListOfPhoneNumbers = new List<string>();
if (PhoneNumberData.Tables[0].Rows.Count > 0)
{
foreach (DataRow MyDataRow in PhoneNumberData.Tables[0].Rows)
{
ListOfPhoneNumbers.Add(MyDataRow["FirstName"].ToString() + " " + MyDataRow["LastName"].ToString() + " " + MyDataRow["PhoneNumber"].ToString());
}
}
else
{
ListOfPhoneNumbers.Add("Currently there are no phone numbers available in this list
}
ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItemMultipleChoice, ListOfPhoneNumbers);
PhoneNumberList.Adapter = adapter;
This code displays the name and phone number as intended, but I cannot figure out how to detect when the Listview is clicked. I tried:
PhoneNumberList.ItemSelected += (sender, args) =>
{
var Sel = PhoneNumberList.SelectedItem;
};
But it never gets called on the click. I've also tried:
PhoneNumberList.ItemSelected += delegate (object sender, AdapterView.ItemSelectedEventArgs args) { PhoneNumberList_ItemSelected(); };
PhoneNumberList_ItemSelected never gets called either.
My Listview XML:
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="148.4dp"
android:id="#+id/listViewNumbers" />
So what am I doing wrong?
Ok, after slogging around the internet for a few hours, I was able to work it out. It was rather simple and I had already discovered the answer, I just formated one statement wrong and it sent me on a wild goose chase to find the answer. My updated code:
ListView PhoneNumberList;
PhoneNumberList = FindViewById<ListView>(Resource.Id.listViewNumbers);
ListOfPhoneNumbers = new List<string>();
if (PhoneNumberData.Tables[0].Rows.Count > 0)
{
foreach (DataRow MyDataRow in PhoneNumberData.Tables[0].Rows)
{
ListOfPhoneNumbers.Add(MyDataRow["FirstName"].ToString() + " " + MyDataRow["LastName"].ToString() + " " + MyDataRow["PhoneNumber"].ToString());
}
}
else
{
ListOfPhoneNumbers.Add("Currently there are no phone numbers available in this list
}
ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItemMultipleChoice, ListOfPhoneNumbers);
PhoneNumberList.Adapter = adapter;
Exactly the same, now I add the one line of code I just couldn't get right (duh):
PhoneNumberList.ItemClick += PhoneNumberList_ItemClick;
Originally I had used PhoneNumberList.ItemClick += PhoneNumberList_ItemClick(); and the error it generated sent me off on that aforementioned wild goose chase and there went several hours of my life I'll never get back, lol. The PhoneNumberList_ItemClick code:
void PhoneNumberList_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
// We now can write code here to set the checkbox in the listview to checked
// All I got to do now is figure out how to do THAT. Stay tuned ....
}
So, hopefully this will save someone the ordeal I put myself through.
**** Update ****
Didn't take long to figure out how to set the item clicked's checkbok, changes to PhoneNumberList_ItemClick code below:
void PhoneNumberList_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
ListView MyListView = (ListView)sender;
if (MyListView.IsItemChecked(e.Position))
{
MyListView.SetItemChecked(e.Position, true);
}
else
{
MyListView.SetItemChecked(e.Position, false);
}
}
.... And that's all folks ....
I am developing an Outlook plugin and faced with the problem when my callback NewMailEx is not called for a newly added storage.
My code looks like the next:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Application.ItemSend += Application_ItemSend;
Application.NewMailEx += Application_NewMailEx;
}
private void Application_NewMailEx(string EntryIDCollection)
{
logger.Debug("Received e-mail with ID: {0}", EntryIDCollection);
var outlook_namespace = Application.GetNamespace("MAPI");
dynamic item = outlook_namespace.GetItemFromID(EntryIDCollection);
if (!(item is Outlook.MailItem))
return;
// do some stuff with mail
}
I also tried to subscribe for a new storage:
{
Application.Session.Stores.StoreAdd += Stores_StoreAdd;
}
private void Stores_StoreAdd(Outlook.Store store)
{
logger.Info("New store is added: " + store.DisplayName);
Outlook.MAPIFolder rootFolder = store.GetRootFolder();
Outlook.MAPIFolder inbox = store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
inbox.Items.ItemAdd += items_ItemAdd;
}
private void items_ItemAdd(object item)
{
if (item is Outlook.MailItem)
{
Outlook.MailItem mail = item as Outlook.MailItem;
// do some stuff with mail
}
}
But ItemAdd is called only for items during the synchronization. For a new mails neither NewMailEx nor ItemAdd are called.
But after the restart everything works and NewMailEx works as usual.
Do you have any ideas how to fix it or some workaround?
Your items_ItemAdd event handler will never fire because you set up the event handler on an implicit variable created by the compiler on the line inbox.Items.ItemAdd += items_ItemAdd. You need to save Items object in a dedicated variabler (or event better a List<Items>) to make sure it stays alive and GC never releases it.
hi guys please i need to set up Admob interstitial on my windows 8 app, i have succesfully set up banners, but since downloads are not much i want to increase my earning by displaying interstitial instead. So please give my step by step guide and a sample code. thanks
You could use this code
private InterstitialAd interstitialAd;
void admobinterstitial()
{
interstitialAd = new InterstitialAd("YOUR AD UNIT ID");
AdRequest adRequest = new AdRequest();
interstitialAd.ReceivedAd += OnAdReceived;
interstitialAd.FailedToReceiveAd += interstitialAd_FailedToReceiveAd;
interstitialAd.LoadAd(adRequest);
}
void interstitialAd_FailedToReceiveAd(object sender, AdErrorEventArgs e)
{
interstitial = false;
System.Diagnostics.Debug.WriteLine("Interstitial failed");
}
private void OnAdReceived(object sender, AdEventArgs e)
{
interstitial = true;
System.Diagnostics.Debug.WriteLine("Interstitial received");
}
all. I am trying to develop an application for Windows Phone 7 using Visual Studio 2010. It is a music player that is supposed to be able to play music based on the current event.
I managed to extract the event but when I tried to combine it with the player, the entire player would just crash. Here are the codes.
void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
{
try
{
AppointmentResultsDataLINQ.DataContext =
from Appointment appt in e.Results
where appt.IsAllDayEvent == false
select appt;
}
catch (System.Exception)
{
//No results
}
}
private void button2_Click(object sender, RoutedEventArgs e)
{
if ((((Appointment)(AppointmentResultsDataLINQ.DataContext)).Subject).Equals("Meeting"))
{
mediaElement1.Source = new Uri("http://www.opendrive.com/files/NV8zNTMwNDYwX2hxRXZR/Crystallize.mp3", UriKind.Absolute);
}
else
{
mediaElement1.Source = new Uri("https://www.opendrive.com/files/NV8zMjAxODY0X0VBNDJY/Hetken%20tie%20on%20kevyt%20(piano%20cover)%20-%20YouTube.mp3", UriKind.Absolute);
}
mediaElement1.Play();
}
The problem is the cast. You are trying to cast the AppointmentResultsDataLINQ.DataContext to an Appointment. This does not make sense. You need to select one concrete appointment from using LINQ (similar to the code in your Appointments_SearchCompleted that imho does nothing)
I am trying to develop a pivot application for Windows Phone 7 using Visual Studio 2010. I got the data from the calendar with the following code.
void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
{
try
{
AppointmentResultsDataLINQ.DataContext =
from Appointment appt in e.Results
where appt.IsAllDayEvent == false
select appt;
}
catch (System.Exception)
{
//No results
}
}
The problem comes when I tried to connect to the next button.
private void button2_Click(object sender, RoutedEventArgs e)
{
if (AppointmentResultsDataLINQ.DataContext.ToString() == "Meeting")
{
mediaElement1.Source = new Uri("http://www.opendrive.com/files/NV8zNTMwNDYwX2hxRXZR/Crystallize.mp3", UriKind.Absolute);
}
else
{
mediaElement1.Source = new Uri("https://www.opendrive.com/files/NV8zMjAxODY0X0VBNDJY/Hetken%20tie%20on%20kevyt%20(piano%20cover)%20-%20YouTube.mp3", UriKind.Absolute);
}
mediaElement1.Play();
How can I convert the data to string so that it can play the two songs correctly? Because right now, even though I set the event to "Meeting" on the calendar, it still plays the second song.
You have binded the ListBox using the Appointment object, so the DataContext needs to be typecasted into the same. And by setting the event as Meeting if it means setting the Subject field of Appointment class as "Meeting" then this code should work fine.
if ((((Appointment)(AppointmentResultsDataLINQ.DataContext)).Subject).Equals("Meeting")))
{
mediaElement1.Source = new Uri("http://www.opendrive.com/files/NV8zNTMwNDYwX2hxRXZR/Crystallize.mp3", UriKind.Absolute);
}
When you are doing AppointmentResultsDataLINQ.DataContext.ToString() you are converting the DataContext object's address value to string and not getting the required string value. Also "==" doesn't work for string comparisons.