Qudos .NET Meetup Newcastle - September 2024

Qudos .NET Meetup Newcastle - September 2024

Writing Windows 11 Widgets - Peter Bull

Introduction

Recently awarded Microsoft MVP for .NET and Windows Development thanks to presenting at events like this .NET Meetup. write posts and articles including this event along with hosting a Podcast including an episode on Windows 11 Widgets at rogueplanetoid.com along with Tutorials, Talks and Workshops at tutorialr.com or connect with them on LinkedIn

Windows 11 & Widgets

Windows 11 is Microsoft's latest most powerful Windows operating system helping you to get things done with many thousands of applications, it is optimised for productivity with snap assist to organise windows and Dev Home which is a central hub for developer features. Windows 11 gaming is elevated with improved reality-rivalling game visuals and elevated entertainment experience and is enhanced with an AI-powered Copilot to help kickstart creativity or act as an intelligent assistant. You can find out more about Windows 11 at windows.com.

Windows 11 Widgets enable quick access to features or information at-a-glance without needing to open an app or website. Widgets Board is the central hub to stay organised and save time with widgets for calendar, news, weather and more with widgets that can be customised with your own interests and preferences or be personalised for what is important to you. Widgets can be interactive to engage with content directly and dynamic with real-time updates to text or graphics and are updated to include features and functionality all from a click or a swipe of the Widgets Board.

Design Widgets with Adaptive Cards

Adaptive Cards are platform-agnostic UI snippets in JSON used by Microsoft Teams, Viva Connections and Widgets in Windows 11 or Dev Home. Exchange at-a-glance content templates using text and images and create interactive experiences with actions in Adaptive Cards. Create templates using the drag-and-drop Designer for elements, structure and properties for the Schema of Adaptive Cards and Preview using the Widgets Board host including small, medium and large sizes along with light and dark themes. You can find out more about Adaptive Cards including the designer, documentation and samples at adaptivecards.io.

Adaptive Cards use a Schema that defines the JSON structure including CardElements, Containers, Actions, Inputs and Types. Card Elements include TextBlock, Image for text or graphics along with Media and MediaSource for displaying video. Containers for arranging information include Columns, Table, FactSet and Facts for displaying key / value pairs. Actions to enable interactivity include ToggleVisiblity of a TargetElement or Submit any Inputs to a client. Inputs that can be Submitted from an Action to a Client include Text, Number, Date and Time. Types include BackgroundImage and other Types supported by hosts using Adaptive Cards. Windows 11 Widgets using Adaptive Cards can supports small, medium or large sizes along with light and dark themes and developers delivering Windows 11 Widgets with Adaptive Cards from apps can support any or all sizes and themes.

Adaptive Cards can be designed and output using ChatGPT's AI you just need to ask Create an Adaptive Card for a visually interesting Windows 11 Widget. ChatGPT can help you create content and implement ideas you want for an Adaptive Card to be used for a Windows 11 Widget. ChatGPT can help you create content and implement ideas you want for an Adaptive Card to be used for a Windows 11 Widget. You can craft your prompt to create your ideal Adaptive Card from ChatGPT including any actions or even add emoji. You can output your Adaptive Card easily by adding Do not return any non-JSON text or numbering to the prompt. You can try creating your own Adaptive Card for a Windows 11 Widget wit ChatGPT at chatgpt.com.

Develop Widgets with Windows App SDK

Windows App SDK enables you to build modern native Windows apps using WinUI 3 targeting Windows 10RS5 or 1809 to latest the Windows 11. Windows App SDK is decoupled from Windows updates and delivered via NuGet with a new version every six months with the latest being 1.6 and supports WinRT APIs or native Windows APIs and implements Microsoft's Fluent Design System for modern controls. Windows App SDK can be installed with the Windows application development workload to create WinUI 3 in Desktop apps. You can find out how to get started with it using C++ with Win32 or C# with .NET at aka.ms/winappsdk.

.NET is a free and modern open-source developer framework from Microsoft that enables developers to create powerful applications for cloud, mobile, web and desktop. .NET and C# provide a platform and programming language that evolves to meet the needs of developers with yearly releases to add new features or functionality. Windows App SDK developers can leverage the latest .NET & C# capabilities to create applications and use world-class developer tooling with Visual Studio where developers can create cross-platform applications in .NET & C# sharing a common core on platforms including iOS, Android, Linux, Mac OS and Windows. You can find the latest SDK and C# along with documentation and information at dot.net.

Windows App SDK applications can become a Widget Provider by implementing the six key methods from the IWidgetProvider interface. IWidgetProvider includes CreateWidget and Delete Widget when Widgets are added or removed from the Widgets Board, OnActionInvoked when an Action has occurred and OnWidgetContextChanged when the Size has changed. Activate and Deactivate when the Widget Board is interested or not in updates from a Widget Provider. Applications can also implement the IWidgetProvider2 interface which adds a seventh key method OnCustomizationRequested, which is used when the Widgets Board when a Widget accepts Customisation and is enabled with IsCustomizable for the Widget in the Application Package Manifest. You can find out more about developing Windows 11 Widgets at aka.ms/widgetdevdocs

Windows App SDK packaged applications must register their Widget Provider in the package manifest for the application for any Windows 11 Widgets to be able to be added to the Widgets Board. Package.appxmanifest needs to be modified to add AppExtension including Name which must be com.microsoft.windows.widgets and Properties to include details of the Widget Provider. WidgetProvider defines ProviderIcons to be shown in Add Widgets for the Widgets Board and Activation must include the Class Id of the Widget Provider and Definitions for the Widgets. Definition of a Widget includes the Id and Display Name along with options such as IsCustomizable along with Capabilities and ThemeResources for the Widget. Capability is Size supported by a Widget being served by the application which can include any or all sizes available including small, medium or large. ThemeResources are the Icons and Screenshots for the Widget which can be localised assets and for both Light and Dark themes.

Modifying the manifest should be the most complex thing when developing Widgets with Windows App SDK but there's lots of code too but that's where you need Comentsys.Toolkit.WindowsAppSdk which is a package offering useful features for Windows App SDK developers such as controls and extensions including support for Widget functionality. This package wraps all the classes and methods developed by Microsoft to implement Windows 11 Widgets with Windows App SDK making them easier to use. Developers can inherit WidgetProviderBase with a simple lightweight class to create a Widget Provider by just providing the Guid attribute with a Class Id and inherit WidgetBase to implement method needed including returning Adaptive Card-based template and JSON data for a Widget. Windows App SDK developers can install Comentsys.Toolkit.WindowsAppSdk from NuGet or get source code and an example Widget on GitHub. Comentsys.Toolkit.WindowsAppSdk offers a WidgetProviderBase which includes all seven key methods along with Update and Add methods for managing or registering Widgets. WidgetBase allows Widgets to be easily implemented with echoed methods from Widget Provider and methods for returning Adaptive Card based Template and JSON Data. You can find details of Comentsys.Toolkit.WindowsAppSdk at comentsys.com/packages/toolkits

When developing Windows 11 Widgets things may go wrong and you may see some potential issues but don't panic there are some solutions to get back on track! If you encounter any problems adding or removing your Widget or it doesn't work correctly you can Uninstall your app using Add or Remove Programs, then once uninstalled you can Deploy your application from Visual Studio 2022 to get back running or you may need to restart your computer. If your Widget is blank and Uninstalling and Deploying doesn't work, you then you may have to Uninstall then Install the Widgets Board. You can Uninstall the Widgets Board by running the winget uninstall --id 9MSSGKG348SP command in a PowerShell Terminal running as Administrator and then Install the Widgets Board again with the winget install --id 9MSSGKG348SP from PowerShell to restore it back to normal.

Overview

Windows 11 is Microsoft's latest and most powerful operating system that supports Widgets with at-a-glance information that help you save time, stay organised and stay in your flow. Design amazing Adaptive Cards with the Designer or refer to the Schema to customise and create the results you want with the actions you need to use in your Windows 11 Widget. Quickly and easily create Adaptive Cards for your Windows 11 Widgets with ChatGPT to produce the output you want with the information and actions you need using prompts. Develop your own Windows 11 Widgets using Windows App SDK and .NET by implementing a Widget Provider to deliver your Widgets with Templates using Adaptive Cards which is helped by using Comentsys.Toolkit.WindowsAppSdk making it simple to create a Widget Provider in your Windows App SDK app so you can focus on your Widget functionality. You can get all the slides along with code for a demo on Writing Windows 11 Widgets at github.com/rogueplanetoid/writingwindows11widgets

ADHD in a Software Development Environment - Andy Morrell

Introduction

Andy has ADHD but only realised in the past four years, he is a former Microsoft MVP and has been a professional developer for twenty-ish years and been a developer for thirty-three years since they were eight when they got a ZX Spectrum.

ADHD

5% of Children between 5-16 had ADHD but 30% ADHD in Software Engineers. ADHD is Attentional Deficit Hyperactivity Disorder. They discovered their ADHD between 2020-2024 during lockdown, they never looked into it before. Changes they have made is being honest about it but haven't had a diagnosis but there may be symptoms you may diagnose in yourself.

1. Hyper Fixation

They had an idea and spent six hours developing it and finished at 2am. Hyper Fixation can involve forgetting to eat, drink and take breaks and get frustrated with any kind of interaction. If you get distracted it is the end of your hyper fixation. Interruptions try not to when you can see those with ADHD are in focus mode.

2. Doom scenarios

"Can we have a catch up later" - messages like this often in a work environment, this creates a massive fear complex in someone with ADHD, they will go through all the scenarios possible and always feel like it is the worst scenario possible e.g. HR have booked a meeting with you at 10am tomorrow. So, tell them what is about don't book something which just says talk but scheduled meetings, 1-2-1s and standups are fine, and a good example is "New meeting from manager - handover from holiday" is perfect as will know what is about.

3. Information underload (not Overload)

"Can you spare five minutes to help with this" - they get those sorts of messages all the time which comes from being a team leader, but if don't get enough information will be somewhat ignored. Big messages are allowed, include as much information as possible but don't expect an immediate reply but if it is important then send another message or interrupt them if they are hyper fixated.

4. Last minute

"If you know you know" - ADHDers are very good at doing everything last minute including packing for trips, development, this talk and getting to places on time (sometimes). Understand you may see some progress in the first three days of a project on a five-day delivery, you will see the most progress in the last few hours. Don't be hard on yourself if you haven't seen any progress, regular breaks are a thing - it's thinking time so go outside take a break and have some thinking time and figure out how to do it then go and do it. Questions are prevalent, you will get more questions than you may expect from someone with ADHD and being neurodiverse you notice this more in other people.

5. Shoes on principle

At the end of the day will generally go out and do quick shopping but if you take your shoes off you are done for the day. This relates to work as if you stop, you'll not end up doing the thing you were meant to do. If you need to as a manager to know if you are required for a meeting, but let colleagues skip meetings if they are not 100% required and allow for later lunches, this also goes along with number one on Hyper Fixation.

Hope this Helps

In the end this is only a little insight into ADHDers worlds, mainly their insights and they would love to have more people to contribute this topic, they put out a post asking for ADHD contributions on LinkedIn and got zero replies so if you want to contribute you should contact them on LinkedIn.