mohabouje / WinToast

WinToast is a lightly library written in C++ which brings a complete integration of the modern toast notifications of Windows 8 & Windows 10. Toast notifications allows your app to inform the users about relevant information and timely events that they should see and take action upon inside your app, such as a new instant message, a new friend request, breaking news, or a calendar event.
MIT License
704 stars 130 forks source link

Add Custom XML #25

Closed sraboy closed 6 years ago

sraboy commented 6 years ago

Do you know how to add new elements and or add attributes to an element? I cannot for the life of me figure that out.

I resorted to using IXmlDocumentIO::LoadXml("[xmlhere]") and its ComPtr::CopyTo([the IXmlDocument]) but that makes using all your helpers to set text/image impossible.

For now, I've hacked in two new WinToastTemplateType values (CustomXmlText and CustomXmlImageAndText) but, if you know how to add new elements and attributes to existing elements, it would be a great feature add.

Here's an example XML template I'm using:

<toast duration="short">
   <audio silent="true" />
   <visual>
      <binding template="ToastGeneric">
         <image placement="appLogoOverride" hint-crop="circle" src="" />
         <text hint-maxLines="1" />
         <text placement="attribution">via SMS</text>
      </binding>
   </visual>
</toast>

Side note, if you do start messing with this, putting XML in the command-line arguments in VS' project settings results in single quotes being swapped for double quotes and an xmlns attribute being added to the first element once you hit "Apply". After it edits it, you have to manually escape the double quotes and leave in the xmlns attribute.

sraboy commented 6 years ago

Aha, finally figured it out. If I can get it cleaned up, would you want a PR to add audio options and attribution text?

mohabouje commented 6 years ago

Yeah, definitely . It will be nice as a new feature :) When you get something ready to test, just do the PR.

On 21 Jan 2018 11:26 pm, "Steve Lavoie" notifications@github.com wrote:

Aha, finally figured it out. If I can get it cleaned up, would you want a PR to add audio options and attribution text?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mohabouje/WinToast/issues/25#issuecomment-359286964, or mute the thread https://github.com/notifications/unsubscribe-auth/AGhXmvAwknd2ochbAKIoHFFpmE2BdzpDks5tM7mfgaJpZM4Rl6Uz .

mohabouje commented 6 years ago

Let's review the PR and close this one then.