Download a Sharepoint File with GraphServiceClient (Microsoft Graph API)

Demons protect a PowerPoint presentation from developers trying to access it.

There is a stunningly simple way to get a file out of sharepoint and I'll get to that soon (or just skip to the very end of the post).

I have been automating the shit out of a lot of routine work in Microsoft Teams recently. Teams is the result of Skype and Sharepoint having too much to drink at the Microsoft holiday party. It often shows. One annoyance is that channel threads are ordered by the time that someone last responded. Useful for quickly seeing the latest gossip but a pain when you need to keep an eye on each individual thread. After listlessly scrolling around trying to keep up with the flow I came up with a dumb solution - I sync the channel to Obsidian (my choice of note app, could be anything) and then I can just check there for new threads. It's a small convenience but has meaningully improved my life.

Unfortunately I got greedy. These messages usually have a PowerPoint presentation attached to them and so why not have an LLM summarize this while updating my notes?

It doesn't look like Copilot has a useful API yet. You can build plug-ins, but I don't want to talk to Copilot about presentations, I just want it to do the heavy lifting while I sleep so I can read the summary in the morning. Hopefully in the future there will be a simple way to say hey, Copilot, summarize this PPTX. Not yet.

So the outline of a solution here is download the presentation, send it ChatGPT, generate a summary and stick that in Obsidian. This felt like a half hour type of project. And it should have been - getting GPT4 Turbo to summarize a PPTX file took about ten minutes. Downloading the file has taken days and sent my self esteem back to primary school.

You would think that downloading a file would be the Graph API's bread and butter. Especially as I have a ChatMessage from the channel that includes attachments and links. The link is for a logged in human, but it must be easy to translate from this to an API call, right?

It turns out that all you need is the site ID, the drive ID and the item ID.

These IDs are not in the attachment URL or the ChatMessageAttachment. It would be pretty RESTful to include the obvious next resource I'm going to need in that return type. No dice though.

I tried ChatGPT which helpfully suggested API calls that looked really plausible and helpful but that did not in fact exist. So I then read probably hundreds of blogs and forum posts from equally confused and desperate developers. Here is a typical example:

"Now how can I upload and download files to this library with the help of Graph API (GraphServiceClient)."

To which Microsoft, terrifyingly, reply:

"We are currently looking into this issue and will give you an update as soon as possible."

Before eventually suggesting:

"await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Content.GetAsync();"

Ignoring the sharepoint part and glossing over where that drive ID is coming from. Other documentation suggests that you can lookup your site by the URL, and then download a list of drives to go looking for the right one. Well, the first page in paginated drive collection anyway implying that just finding the ID might get you a call from the quota police.

I know Microsoft is looking after a lot of files for a lot of organizations, but how can it be this hard?

It isn't. It's just hidden. I eventually found this post from Alex Terentiev that points out that you just need to base64 encode the sharing url, swap some characters around and then call:

"GET https://graph.microsoft.com/v1.0/shares/{sharing-url}/driveItem"

If Google was doing its job right this would be the top result. I should be grateful they're still serving results at all and not just telling me that my pastimes are all harmful.

The documentation is here and Microsoft should link to it on every page that discusses drives and DriveItems. For GraphServiceClient the call to get to an actual stream is:

"graphClient.Shares[encodedUrl].DriveItem.Content.GetAsync()"

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: Download a Sharepoint File with GraphServiceClient (Microsoft Graph API) #code #ml #graph #sharepoint #c# Everyone developing applications with the Graph API should know about the shares endpoint that allows you to download files easily. )

Migrating a C# Integration from GA3 to GA4

Updated on Saturday, May 6, 2023

GA4

This blog has a couple of Google Analytics integrations - the popular posts list is pulled from GA, and the unnecessarily accurate count of non visitors in the footer. I just migrated from the GA3 API to the GA4 API. The backend for this blog is ASP.NET MVC with .NET 4.8. One day I might catch up with the cool kids and try to get on .NET Core, but not today.

Here's where I stubbed my toe:

I'm following this code sample to make my first GA4 call. After installing the NuGet package I couldn't find BetaAnalyticsDataClient anywhere. It turns out that there is a Google.Apis.AnalyticsData.v1beta package and a Google.Analytics.Data.V1Beta which is only available if you check 'Include prerelease' when searching. You want the second one. I'm not in love with BetaAnalyticsDataClient as a class name, it suggests all sorts of breaking changes are coming. My GA3 integration has ticked over for years with no changes. Maybe GA4 is going to be more like Google Ads and shank you with breaking changes every few months. Moving on...

Wow the error messages are good. Kudos to the API team. I'm so used to cryptic bullshit but this API tells you what you're doing wrong and sends back helpful pointers and even URLs. Every API should be this friendly. I got through the remaining problems fairly quickly because of this.

The code sample passes the property ID as 'property/nnnnnnn' but the API is expecting 'properties/nnnnnnn'.

I'd been using a ServiceAccountCredential created from a .p12 file for GA3. This doesn't seem to be supported for BetaAnalyticsDataClient but I was able to generate a new credential with a .json serialization of the credentials and passing this to BetaAnalyticsDataClient worked fine. I had a permission denied error, this was because I hadn't added the service account email address to the property and doing so got me some data.

The client library is pretty classy (as in too many classes). Creating a filter to exclude internal users involves four nested classes - a FilterExpression that has another FilterExpression for a not condition and then this needs a Filter and the Filter needs a StringFilter. Tedious. And including enums for metrics and dimensions is too much trouble so adding those now requires Metric and Dimension classes but these are just initialized with a string. The list is here.

Lastly when it comes to running the thing the site won't start and says:

"CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'."

Presumably due to some NuGet horror or other. Adding that reference indeed fixes the problem and hopefully doesn't create a new one.

I am now technically if not emotionally prepared for GA3 to be switched off.

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: Migrating a C# Integration from GA3 to GA4 #code #ga4 #ithcwy #c# Some tips on avoiding pitfalls when migrating a C# application from Google Analytics 3 to Google Analytics 4. )

Outlook/Office iCal feed 400 bad request error with C# WebClient

Updated on Tuesday, June 21, 2022

400

Just in case it helps someone else I was able to fetch an Outlook iCal feed using C#'s WebClient for years until it stopped working in June, 2022 with a 400 / bad request error. I was downloading a set of calendars and the fix was just to use a new WebClient for each calendar so it must be some kind of state thing in WebClient.

To regain around 1% of sanity I have a task that pulls the various calendars that life throws at me and combines them into a single, de-duplicated calendar. The Google Calendar on my phone is gorgeous as a result. My primary calendar is orange and then all of the miscellanea are teal and unique. It would be great if Google Calendar could do this without help, but it was worth the effort not to have some random soccer match repeated five times in different colors.

Last week one calendar, an Outlook feed, started failing with 400 bad request.

Naturally I assumed that the server had started to suddenly care about some header or other and I started playing around with setting User-Agent and various Accept headers without any luck. To make debugging slightly easier I moved the Outlook calendar out of a loop (where I was iterating through a list of iCal feeds that I need to be aware of) and then it magically started working. The magic in this case must be a fresh WebClient and so the fix was to use a new WebClient for each calendar instead of reusing a single instance. It looks like WebClient is deprecated in .NET 6 and one is supposed to start using HttpClient instead so that's probably another fix but not one I'm going to wrestle with today.

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: Outlook/Office iCal feed 400 bad request error with C# WebClient #code #c# #outlook How to fix a 400 / bad request error with the C# WebClient when downloading an Office iCal feed. )

Catfood Earth

Updated on Saturday, January 20, 2024

Catfood Earth

Catfood Earth uses satellite imagery and data feeds to create live wallpaper for Windows and Android. Earth shows you the current extent of day and night combined with global cloud cover (clouds updated every hour). You can also choose to display time zones, places, earthquakes, volcanoes and weather radar. The Windows version includes a screen saver. Catfood Earth was first released in 2003. Version 4 was fully remastered to support 4K resolution on both platforms.

Download Catfood Earth

Catfood Earth Themes

Catfood Earth can be quickly configured with three different themes. After installing, run Catfood Earth Settings and click one of the buttons to activate a theme. If you want to customize further then visit the layers and advanced tabs of the settings app, described in detail below. The themes are:

Natural Theme

Natural is the default theme. This combines day, night and cloud cover. The day image uses NASA's blue marble next generation monthly global composite. combined daily so you can see changes in snow, ice and even vegetation throughout the year. Next, global cloud cover is blended on top of the day image (updated hourly). Finally Catfood Earth computes the extent of day and night and blends in NASA's city lights image. You can update the image as frequently as every minute and watch the terminator between day and night move across the planet and change shape with the passing seasons. The video below shows how all three components of the natural theme change over the course of a year:

Time Zones Theme

The time zones theme shows the current time zone in each country and optionally international zones as well. This theme is highly configurable, you can choose to show borders, pick colors, show hours or hours and minutes and control transparency. Catfood Earth can also show the local time for anywhere on Earth, see the places layer for more details. The video below shows how the time zones change by country from May 2021 to June 2022:

Earthquakes Theme

The final theme, earthquakes, uses a different daytime map with a more geological look and adds earthquakes for the past 24 hours. Size is proportional to magnitude and the quakes fade out over 24 hours so the most recent are highly visible. Again it's possible to customize extensively via layers. You can show active volcanoes and control the colors used, transparency and which magnitudes to plot. The video below shows a month of earthquakes as seen in Catfood Earth:

Catfood Earth Layers

The layers tab is where you can fully customize Catfood Earth. Use the checkboxes to activate layers and then click each layer to access detailed settings. Layers are listed in the order that they are drawn (i.e. clouds are drawn on top of the day map, and then night is drawn on top of the clouds and so on).

Day Map

The first layer is the daytime map. Catfood Earth ships with two defaults. The first uses NASA's blue marble 2 monthly images, merged with a more attractive ocean image. Catfood Earth interpolates these images daily so the extent of snow/ice and vegetation will change in a subtle way throughout the year. The other default is a less colorful map that I feel works well with earthquakes and volcanoes. You can also browse to and select a different image if you don't like the defaults.

All the images and data layers in Catfood Earth use an equirectangular projection so if you are using custom images you should make sure that they use the expected projection.

Clouds

Clouds come from the Space Science and Engineering Center at the University of Wisconsin-Madison. These images are web mercator by default, my website downloads the global composite every hour and transforms the image to equirectangular for Catfood Earth. If you have a different source for clouds you can enter a custom URL. You can also set the color and transparency of the clouds layer. The defaults are designed to make the clouds fairly subtle.

Night Map

The last natural layer is the nighttime map. Catfood Earth ships with NASA's 2016 update to city lights. This layer is drawn on top of daytime and clouds where it is currently nighttime (updated as often as every minute, see advanced options below). You can set the transparency of the layer and also the width used to blend the terminator between day and night (in degrees). It's also possible to select a different nighttime image if you prefer.

Time Zones

The time zones layer is based on the IANA time zone database. You can change the colors used to show the time zones and control the transparency of national and international zones. You can also choose if minutes are displayed with the time zone legends at the top of the screen. This is a good layer to use in combination with the Places layer and the Political Borders layer (both described below).

Political Borders

This layer displays political borders in a configurable color.

Places

The places layer shows a list of places optionally combined with the local time for each place. I've used this to show office locations around the world (handy to know if it's a good time to call someone) and also to track my geographically dispersed family. Catfood Earth ships with a default list of major cities. You can add to this, or remove everything and start from scratch. You can even export and import the list to make it easy to share between different devices. For each place you just need to provide the latitude, longitude and time zone (from the same source as the time zones layer).

Earthquakes

Earthquake data is downloaded from the USGS feed and can show global quakes from magnitude 2.5 up. There is a lot you can fine tune for this layer - The fill and accent colors, number of past hours to show (up to 24), the transparency range (older earthquakes are more transparent) and the minimum magnitude to plot. You can also choose whether to show descriptions or not and the order in which to plot the quakes (time based, or size based which makes it easier to see what's going on when a lot of quakes hit a small area).

Volcanoes

Volcano data comes from the Smithsonian Institution's Global Volcanism Program. This shows currently active volcanoes around the world. You can set the fill and accent colors, the transparency to use and whether to show descriptions or not.

Weather Radar

The final layer shows weather radar from the National Weather Service. This layer is US only. Enter a list of one or more radar stations to display, separated by commas. You can find your local station(s) at the NWS web site.

Catfood Earth Advanced

The advanced tab of Catfood Earth Settings controls how the final image is displayed and also allows you to render sequences of images (this is how I made most of the videos above).

Set how often the image is updated in minutes, as frequently as every minute which is handy if you're displaying the local time for places. You can also skip the first update when Catfood Earth loads (potentially useful at boot time when Windows is starting a lot of programs).

There are some settings relating to text display: a global font size and an option to use drop shadows.

Earth can be centered to a specific longitude (default 0) or to a specific time. If you choose a time then the image will rotate throughout the day to keep that local time at the center of the screen.

It is also possible to set a specific output size and location for the wallpaper. The default is to fill the screen.

Click Render Images to output a sequence of images. If you use a proxy server click Proxy Settings to configure.

Finally there are some troubleshooting options that you might be asked to use if you need help with the product.

Render Images

Render Images allows you to create frames from Catfood Earth based on current settings. This is useful for making animations based on how the Earth image changes over time. Set a start date/time (UTC), how to increment time between frames, the number of frames to generate, the size and an output folder. Earth will then create a sequence of JPEGs. This works well with computed layers like day/night and time zones. It will not work well with live data like clouds and earthquakes. I have made videos from live data as well, but this involves storing many images and/or data points and is not currently supported in Catfood Earth.

Catfood Earth for Android

Catfood Earth is a little different on Android. Because phones are mostly used in a portrait orientation the wallpaper shows the full range of latitude but only a segment of longitude depending on the screen size of the device. The wallpaper is the same as the natural theme in Catfood Earth for Windows (blue marble 2 day map, clouds, city lights night map) with the optional addition of earthquakes.

Run Catfood Earth and click Settings to configure. The slice of Earth displayed is based on a central longitude. By default this will update to your phone's current location. You can also set a manual location. -90 degrees works well to center North America. In addition to the central longitude you can opt to show recent earthquakes, control cloud and night transparency and the width of the terminator between day and night. There are advanced options to ignore screen size changes and reuse the most recent image, and to paint black under the menu bar which is useful on some devices.

After configuring Catood Earth just select it as your current wallpaper. You can do this from device settings or tap the Set Wallpaper button in the Catfood Earth app.

Catfood Earth for Android is optimized for battery life. It will update around every ten minutes and so it might take that long to see any changes to settings. Clouds are downloaded every hour. If using your phone location it accesses the last location fix established by other apps.

Installation and Support for Catfood Earth

Catfood Earth for Windows requires version 4.8 of the .NET Framework. You almost certainly have this already and the installer will download if necessary. The installer for Catfood Earth is digitally signed. You may get a warning about it being infrequently used which you will need to ignore to install.

For support please visit this post, check to see if your issue has already been addressed and if not leave a new comment.

Customer Reviews

Updates

Catfood Earth 4.40

Most of the layers enabled in Catfood Earth 4.40.

Catfood Earth 4.40 is now available to download.

With this release Catfood Earth is 20 years old! This update includes version 2023c of the Time Zone Database and the following bug fixes.

The National Weather Service changed one letter in the URL of their one hour precipitation weather radar product. It needs to be BOHA instead of BOHP. Presumably just checking that data consumers are paying attention? Weather radar is working again.

Not to be left out the Smithsonian Institution Global Vulcanism Program has decided to drop the www from their web site. The convention here is to redirect but they're content with just being unavailable at the former address. Recent volcanoes are working again as well.

The final fix is to the locations layer. Editing a location was crashing. This was due to a new format in the zoneinfo database that was not contemplated by the library that I use. As far as I can tell this isn't maintained any more since the death of CodePlex. While working on this update I started using GitHub Copilot, their AI assistant based on GPT 3.5. I was amazed at how helpful it was figuring out and then fixing this rather fiddly bug. The locations layer is back to normal, and I have regenerated all the time zone mapping as well.

Catfood Earth for Android 4.30

Catfood Earth for Android 4.30

Catfood Earth for Android now supports random locations. The slice of Earth displayed will change periodically throughout the day. You can still set a manual location or have Catfood Earth use your current location. Install from Google Play, existing users will get this update over the next few days.

Catfood Earth 4.30

Catfood Earth Satellite Composite Image of Earth including Volcanoes and Earthquakes

Catfood Earth 4.30 is available to download.

This update fixes a couple of problems with the screensaver. It now has improved support for multiple monitors (the image will repeat rather than stretch). There was a problem with the screensaver not starting in some cases. This should now be fixed. After upgrading to 4.30 please find and run the 'Catfood Earth Screensaver Settings' shortcut to configure the screensaver.

4.30 also includes version 2022d of the time zone database.

Catfood Earth for Android 4.20

Catfood Earth for Android 4.20

Catfood Earth for Android 4.20 adds support for Material You, the custom color scheme introduced in Android 12. By default every wallpaper update will also subtly change your system color palette. You can override this from settings -> Wallpaper & style and switch back to basic colors if you don't like the Catfood Earth colors. This update was surprisingly painful. You can install Catfood Earth from Google Play, or for existing users it will automatically update in the next day or so.

Catfood Earth 4.20

Catfood Earth 4.20

Catfood Earth 4.20 is available to download.

This update includes the 2021d time zone database.

After procrastinating for far too long I have also migrated to .net 4.8 and renewed my code signing certificate. You'll get at least one less warning when installing and you no longer need to enable .net 3.5 on Windows 10 which was a pain. This shouldn't make any difference but please let me know if you have any trouble installing or running this version.

Catfood Earth 4.10

Catfood Earth 4.10

Catfood Earth 4.10 is available for download.

The National Weather Service updated their weather radar API. The weather radar layer has changed a bit, you can enter one or more (comma separated) weather station IDs and Earth will show one hour precipitation for all of them. You used to be limited to a single station but with more options for the rader layer to display. Let me know if you love or hate the new version.

4.10 also includes the latest 2021a time zone database.

(I'm sure there are great reasons for it, but the 'new' NWS API is an XML document per station that links to a HTML folder listing of images where you can enjoy parsing out the latest only to download a TINY GZIPPED TIFF file FFS).

Catfood Earth 4.01

Catfood Earth 4.01 is available for download.

The timezone database has been updated to 2020a. There is also a small fix to a problem with screensaver installation on recent versions of Windows 10.

Catfood Earth for Android 4.00

Catfood Earth for Android 4.00

Catfood Earth for Android 4.00 is available for download and is updating through the Google Play Store.

As with the 4.00 update for Windows all images have been remastered to 4K resolution. Earth for Android has also been updated to better support Android 10 (updates are faster and the settings layout looks much better). You'll need to grant location permission in settings to have Earth automatically center on your current location. It's also possible to set a center longitude manually (I find -90 works well for centering most of the Americas).

Catfood Earth 4.00

Image from Catfood Earth 4.00

Catfood Earth 4.00 is available for download.

The main change is that all of the images shipped with Catfood Earth have been remastered to 4K resolution. This includes NASA Blue Marble 2 monthly images (which Catfood Earth interpolates daily) and the 2016 version of Black Marble (city lights at night). The Catfood Earth clouds service has been updated to full 4K resolution as well.

Earth 4.00 also includes an update to the 2019c version of the Time Zone Database.

As well as providing desktop wallpaper and a screensaver, Catfood Earth can render frames for any time and date. To celebrate the release of 4.00 I created the 4K video below which shows all of 2019, 45 minutes per frame, 9,855 frames. You'll see the shape of the terminator change over the course of the year (I always post the seasonal changes here: Spring Equinox, Summer SolsticeAutumnal Equinox, and Winter Solstice). If you watch closely you'll also see changes in snow and ice cover and even vegetation over the course of the year.

Catfood Earth 3.46

Improved clouds in Catfood Earth

Catfood Earth 3.46 is now available for download. Catfood Earth for Android 1.70 is available in the Google Play Store and will update automatically if you already have it installed.

This follows hot on the heels of the last release as the new clouds layer service running on this blog can update far more frequently than the source used prior to 3.45. You will now get a fresh helping of clouds every hour! Unrelated to this release I've improved the quality of the clouds image as well. If you're interested you can read about this in exhaustive detail here.

Catfood Earth 3.45

New cloud layer image in Catfood Earth

Catfood Earth 3.45 is now available to download. Catfood Earth for Android 1.60 is available on Google Play and will update automatically if you have it installed.

I only just released 3.44 with some timezone updates but in the past week the location I had been using for global cloud cover abruptly shut down. If you like up to date clouds you'll want to install the new versions as soon as possible. With this update I'm building a cloud image every three hours and serving through this blog (and thankfully CloudFlare) so any further changes should not require a code release.

Catfood Earth 3.44

Updated timezones in Catfood Earth 3.44

Catfood Earth 3.44 is now available to download.

The timezone database has been updated to 2018i.

Eric Muller's shapefile map of timezones is no longer maintained and so Catfood Earth has switched to Evan Siroky's timezone boundary builder version.

A bug that could cause all volcanoes to be plotted at 0,0 depending on your system locale has been fixed.

Download Catfood Earth.

(Previously)

Catfood Earth 3.43

North Korea moves back to UTC +09 on May 5, 2018

Catfood Earth 3.43 updates the timezone database to 2018e. The big change is that North Korea is moving back to UTC +09 today (May 5, 2018). The time zones layer in Catfood Earth shows the current time in each zone at the top of your screen and color codes each country and region. You can also display a list of specific places (either an included list of major cities or your own custom locations).

Catfood Earth is dynamic desktop wallpaper for Windows that includes day and night time satellite imagery, the terminator between daytime and nighttime, global cloud cover, time zones, political borders, places, earthquakes, volcanoes and weather radar. You can choose which layers to display an how often the wallpaper updates.

Download Catfood Earth.

(Previously, Previously)

Catfood Earth 3.42

Catfood Earth 3.42

Catfood Earth 3.42 is a small update to the latest (2016d) timezone database and the latest timezone world and countries maps from Eric Muller. If you use the political borders, places or time zones layers in Catfood Earth then you'll want to install this version.

Download the latest Catfood Earth.

(Previously)

Catfood Earth 3.41

Catfood Earth 3.41

Catfood Earth 3.41 fixes a problem that was preventing the weather radar layer from loading.

I've also updated to the latest (2015g) time zone database and the latest time zone map from Eric Muller.

Download the latest Catfood Earth.

(Previously)

Catfood Earth 3.40

Catfood Earth 3.40

I've just released Catfood Earth 3.40 for Windows and 1.50 for Android.

Both updates fix a problem with the clouds layer not updating. The Android update also adds compatibility for Android 5 / Lollipop.

Also, Catfood Earth for Android is now free. I had been charging $0.99 for the Android version but I've reached the conclusion that I'm never going to retire based on this (or even buy more than a couple of beers) so it's not worth the hassle. Catfood Earth for Windows has been free since 3.20.

Enjoy!

Volcanoes Back (Catfood Earth 3.30)

Volcanoes Back (Catfood Earth 3.30)

Catfood Earth fans will want to download Catfood Earth 3.30. This update fixes a problem where volcanoes were all plotted in the middle of the screen.

Catfood Earth for Android 1.40

Catfood Earth for Android 1.40

Catfood Earth for Android now includes the option to display earthquakes (magnitude 5.0 or higher) from the USGS feed.

Catfood Earth 3.20

Catfood Earth 3.20

Catfood Earth 3.20 for Windows is now available for download. This update fixes a change in the feed address for the earthquakes layer. I've also switched to using the new NASA Black Marble night-time image and 3.20 includes the latest time zone and political border data.

Earth for Android has been updated to 1.30. This includes the new Black Marble image.

Catfood Earth for Android 1.20

Catfood Earth for Android 1.20

I recently upgraded to the HTC One which has a transparent notification bar. This makes it hard to see notification icons when using Catfood Earth as your wallpaper, at least in the summer when it's always light at high latitudes and your white icons are displayed on top of polar ice and clouds.

Catfood Earth for Android 1.20 fixes this with an option to paint black under the notification bar. That's the only update other than the latest Xamarin runtime.

Catfood: Earth for Android 1.10

Catfood Earth for Android 1.10

I’ve just released Catfood Earth for Android 1.10. You can control the center of the screen manually (the most requested new feature) and also tweak the transparency of each layer and the width of the terminator between day and night. It also starts a lot faster and has fewer update glitches. Grab it from Google Play if this looks like your sort of live wallpaper.

Catfood: Earth for Android

EarthForAndroid

I’ve just released Catfood Earth for Android. It’s my second app created with Xamarin’s excellent toolkit. Being able to develop in C# allowed me to reuse a lot of code from the Windows version of Catfood Earth. The Android version doesn’t include all the same layers (yet) but it’s got the main ones – daytime (twelve different satellite images included, based on NASA’s Blue Marble Next Generation but with some special processing to make them look better), nighttime (city lights, shaded to show nighttime and the terminator between day and night) and a clouds layer that is downloaded every three hours.

My main worry had been that this would suck the phone battery dry, but after a fair amount of optimization it doesn’t even register on the battery consumption list. Grab it now from Google Play ($3.99, Android 2.2 or better).

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: Catfood Earth #code #earth #catfood #android #c# #xamarin #monodroid #volcanoes #software #windows #weather #radar #timezone #clouds #video #screensaver Live wallpaper for Windows and Android that combines Blue Marble 2 NASA satellite imagery with live feeds of clouds, earthquakes, volcanoes and more. )

Catfood: Earth for Android

Updated on Monday, May 31, 2021

EarthForAndroid

I’ve just released Catfood Earth for Android. It’s my second app created with Xamarin’s excellent toolkit. Being able to develop in C# allowed me to reuse a lot of code from the Windows version of Catfood Earth. The Android version doesn’t include all the same layers (yet) but it’s got the main ones – daytime (twelve different satellite images included, based on NASA’s Blue Marble Next Generation but with some special processing to make them look better), nighttime (city lights, shaded to show nighttime and the terminator between day and night) and a clouds layer that is downloaded every three hours.

My main worry had been that this would suck the phone battery dry, but after a fair amount of optimization it doesn’t even register on the battery consumption list. Grab it now from Google Play ($3.99, Android 2.2 or better).

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

Share a picture in MonoDroid

Updated on Sunday, November 6, 2022

Here’s how to share a picture to Facebook, Twitter and so forth from MonoDroid:

A fun mix of Java and C#. The directory got me to start with so check to see if the ExternalCacheDir is available and if not fall back to the internal CacheDir. Frustratingly Facebook doesn’t pick up on the text associated with an image regardless of the intent ExtraWhatever specified.

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

Catfood: WebCams for Android

Updated on Sunday, September 5, 2021

Catfood WebCams for Android

I’ve just released a WebCam app for Android. It’s based on WebCamSaver but allows you to control the webcam – you tap the edges of the screen to pan, pinch to zoom in and out. A fun little time waster.

This is the first app I’ve released using Xamarin’s MonoDroid framework. This integrates nicely into Visual Studio and allows you to program an Android app in C#. This is fantastic for productivity and code reuse and I enjoyed the process a lot more than previous work I’ve done in Java / Eclipse. The main drawback is that the framework adds around 5MB (significant for mobile) and the documentation isn’t always the best, especially when you search for something and find out you’ve been dumped into iOS reference material. Digging around the sample code and cross-referencing the official Android documentation helps a lot. I’m going to take a stab at something a little more ambitious next…

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

Catfood.Shapefile 1.40

Updated on Monday, September 19, 2022

I’ve just released a small update to Catfood.Shapefile. Stephan Stapel, who implemented PolyLineM support, has contributed a patch that improves the class hierarchy. CodePlex user originSH suggested supporting the ACE driver for 64-bit systems. I’ve added a constructor overload that allows you to use predefined Jet and ACE connection strings or provide your own templates if necessary. Thanks to Stephan and originSH.

Catfood.Shapefile is a .NET library for enumerating ESRI shapefiles. I originally wrote the library to help me build some complex layers in Catfood Earth. Since then it’s picked up thousands of users and some really valuable suggestions and patches from the CodePlex community. I’m very glad a took a couple of hours to open source the library back in 2009.

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

Convert BlogML comments to WXR for Disqus

Updated on Thursday, November 12, 2015

I’ve just moved ITHCWY comments over to Disqus. BlogEngine.NET now supports Disqus out of the box, but doesn’t export comments to anything that Disqus is willing to eat. I’ve knocked up a quick converter that takes a full BlogML export from BlogEngine.NET (and at least in theory any other source of BlogML) and converts the comments to WXR. You can import the WXR file under the Generic option in Disqus.

The tool is a Windows console application that takes two parameters, the BlogML import file and the WXR output, i.e.:

BlogMLtoDisqus.exe C:\BlogML.xml C:\ForDisqus.wxr

It isn’t fancy and there is no error checking so it will either work or die horribly. If the latter, leave a comment and I’ll try to fix it for you.

Download BlogMLtoDisqus.exe. You’ll need to install .NET 4.0 as well if you don’t already have it.

Updated 2011-04-22: Added an optional third parameter that specifies the XML namespace for BlogML in case you need to override the default.

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: Convert BlogML comments to WXR for Disqus #code #blogengine.net #c# #.net #blogml #wxr #disqus A command line tool to convert BlogML comments to WXR (i.e. for Disqus). )

Merging Resource Dictionaries for fun and profit

Updated on Thursday, April 29, 2021

Merging Resource Dictionaries for fun and profit

Here are two scenarios where merged ResourceDictionary objects are the way forward.

I’m working on a WPF project that needs to be single instance. Heaven forbid that the WPF team should pollute the purity of their framework with support for this kind of thing (or NotifyIcon support but that’s another story) so I’m using the code recommended by Arik Poznanski: WPF Single Instance Application. I like this because it both enforces a single instance and provides an interface that reports the command line passed to any attempt to launch another instance.

An issue with using this code is that you need to write a Main function and so App.xaml is set to Page instead of Application Definition. Once you’ve done this the program works fine but the Visual Studio designer fails to load resources in UserControls (and in Windows containing those UserControls).

The fix is to factor all of the application level resources out into a separate ResourceDictionary (i.e. MergedResources.xaml). Once you’ve done this merge the new ResourceDictionary into App.xaml as follows:

Next, in each Window or UserControl reference the same ResourceDictionary:

The designer will now be able to find the correct resources for each UserControl and Window.

The second scenario is factoring resources and other Xaml into a DLL. To pull resources in from a referenced assembly you just need to use a Pack Uri when merging in the remote ResourceDictionary:

If you’re putting Windows and UserControls in the DLL use exactly the same approach to reference the resources using ResourceDictionary.MergedDictionaries and you’ll get designer support for these as well.

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: Merging Resource Dictionaries for fun and profit #code #.net #c# #wpf #xaml Get designer support for XAML loaded from a DLL by merging resource dictionaries in .NET WPF. )