Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"logging": "none",
"markup": "xaml",
"mediaElement": "false",
"meadowSupport": "false",
"navigation": "blank",
"platforms": "android|ios|maccatalyst|wasm|windows|desktop",
"rider": "true",
Expand Down Expand Up @@ -113,6 +114,7 @@
"logging": "default",
"markup": "xaml",
"mediaElement": "false",
"meadowSupport": "false",
"navigation": "regions",
"platforms": "android|ios|maccatalyst|wasm|windows|desktop",
"rider": "true",
Expand Down Expand Up @@ -198,7 +200,7 @@
{
"Title": "",
"SectionType": "MultiSelect",
"SymbolIds": [ "toolkit", "mauiEmbedding", "server", "wasmMultiThreading", "wasmPwaManifest", "vscode", "enableDeveloperMode", "mediaElement" ]
"SymbolIds": [ "toolkit", "mauiEmbedding", "server", "wasmMultiThreading", "wasmPwaManifest", "vscode", "enableDeveloperMode", "mediaElement", "meadowSupport" ]
}
],
"Framework": [
Expand Down Expand Up @@ -561,6 +563,9 @@
"mediaElement": {
"Icon": "/Assets/Features.MediaElement.svg"
},
"meadowSupport": {
"Icon": "/Assets/Features.MeadowSupport.svg"
},
"wasmPwaManifest": {
"Icon": "/Assets/Features.Wasm.svg",
"Requires": {
Expand Down Expand Up @@ -648,7 +653,8 @@
"themeService",
"continuousIntegration",
"isCustomized",
"mediaElement"
"mediaElement",
"meadowSupport"
],
"PackagesToUpdate": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
"longName": "media-element",
"shortName": "media"
},
"meadowSupport": {
"longName": "meadow-support",
"shortName": "meadow"
},
"skipRestore": {
"longName": "skip-restore",
"shortName": "skip"
Expand Down
18 changes: 18 additions & 0 deletions src/Uno.Templates/content/unoapp/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,13 @@
"datatype": "bool",
"defaultValue": "true"
},
"meadowSupport": {
"displayName": "Meadow Support",
"description": "Includes a support for Meadow by Wilderness Labs",
"type": "parameter",
"datatype": "bool",
"defaultValue": "false"
},
"mauiEmbedding": {
"displayName": ".NET MAUI Embedding",
"description": "Configures application to embed .NET MAUI controls",
Expand Down Expand Up @@ -1106,6 +1113,11 @@
"datatype": "bool",
"value": "(platforms == wasm && server)"
},
"useMeadowAndCsharpMarkup": {
"type": "computed",
"datatype": "bool",
"value": "(useCsharpMarkup && meadowSupport)"
},
"useWinAppSdk": {
"type": "computed",
"datatype": "bool",
Expand Down Expand Up @@ -3191,6 +3203,12 @@
"exclude": [
"MyExtensionsApp.1/Styles/ColorPaletteOverride.json"
]
},
{
"condition": "(!meadowSupport)",
"exclude": [
"MyExtensionsApp.1/UnoMeadowApplication.cs"
]
}
]
}
Expand Down
29 changes: 29 additions & 0 deletions src/Uno.Templates/content/unoapp/MyExtensionsApp.1/App.blank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
using System;
using Microsoft.Extensions.Logging;
#endif
#if (meadowSupport)
using Meadow;
#endif
using Uno.Resizetizer;

namespace MyExtensionsApp._1;

#if (meadowSupport)
public partial class App : UnoMeadowDesktopApplication
#else
public partial class App : Application
#endif
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
Expand All @@ -20,6 +27,24 @@ public App()

protected Window? MainWindow { get; private set; }

#if (meadowSupport)
public override Task MeadowInitialize()
{
var r = Resolver.Services.Get<IMeadowDevice>();

if (r == null)
{
Resolver.Log.Info("IMeadowDevice is null");
}
else
{
Resolver.Log.Info($"IMeadowDevice is {r.GetType().Name}");
}

return Task.CompletedTask;

}
#endif
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
#if useCsharpMarkup
Expand Down Expand Up @@ -49,6 +74,10 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
#endif
#endif
MainWindow = new Window();

#if (meadowSupport)
LoadMeadowOS();
#endif
//-:cnd:noEmit
#if DEBUG
MainWindow.UseStudio();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
//+:cnd:noEmit
using Uno.Resizetizer;
#if (meadowSupport)
using Meadow;
#endif

//-:cnd:noEmit
namespace MyExtensionsApp._1;

#if (meadowSupport)
public partial class App : UnoMeadowDesktopApplication
#else
public partial class App : Application
#endif
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
Expand All @@ -17,6 +24,26 @@ public App()
protected Window? MainWindow { get; private set; }
protected IHost? Host { get; private set; }


#if (meadowSupport)
public override Task MeadowInitialize()
{
var r = Resolver.Services.Get<IMeadowDevice>();

if (r == null)
{
Resolver.Log.Info("IMeadowDevice is null");
}
else
{
Resolver.Log.Info($"IMeadowDevice is {r.GetType().Name}");
}

return Task.CompletedTask;

}
#endif

//+:cnd:noEmit
#if useFrameNav
protected override void OnLaunched(LaunchActivatedEventArgs args)
Expand Down Expand Up @@ -196,6 +223,10 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args)
);
MainWindow = builder.Window;


#if (meadowSupport)
LoadMeadowOS();
#endif
//-:cnd:noEmit
#if DEBUG
MainWindow.UseStudio();
Expand Down
41 changes: 33 additions & 8 deletions src/Uno.Templates/content/unoapp/MyExtensionsApp.1/App.xaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
<!--#if (useCsharpMarkup)-->
<!--#if (useMeadowAndCsharpMarkup)-->
<local:UnoMeadowDesktopApplication x:Class="MyExtensionsApp._1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyExtensionsApp._1">
<!--#elif (meadowSupport)-->
<local:UnoMeadowDesktopApplication x:Class="MyExtensionsApp._1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyExtensionsApp._1"$useThemesResourceNamespace$>
<!--#elif (useCsharpMarkup)-->
<Application x:Class="MyExtensionsApp._1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyExtensionsApp._1">
<!--#else-->
<Application x:Class="MyExtensionsApp._1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"$useThemesResourceNamespace$>

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyExtensionsApp._1"$useThemesResourceNamespace$>
<!--#endif-->
<!--#if (!useCsharpMarkup)-->
<!--#if (meadowSupport)-->
<local:UnoMeadowDesktopApplication.Resources>
<!--#else-->
<Application.Resources>
<ResourceDictionary>
<!--#endif-->
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- Load WinUI resources -->
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
Expand Down Expand Up @@ -55,7 +72,15 @@
<!-- Add resources here -->

</ResourceDictionary>
<!--#if (meadowSupport)-->
</local:UnoMeadowDesktopApplication.Resources>
<!--#else-->
</Application.Resources>

<!--#endif-->
<!--#endif-->
<!--#if (meadowSupport)-->
</local:UnoMeadowDesktopApplication>
<!--#else-->
</Application>
<!--#endif-->

Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,11 @@
</ItemGroup>
<!--#endif-->

<!--#if (meadowSupport)-->
<ItemGroup>
<PackageReference Include="Meadow.Desktop" Version="2.0.1.2" />
<PackageReference Include="Meadow.Foundation" Version="2.0.1.2" />
<PackageReference Include="Meadow.Foundation.Graphics.MicroLayout" Version="2.0.1.2" />
</ItemGroup>
<!--#endif-->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using Meadow;
using Microsoft.UI.Dispatching;

namespace MyExtensionsApp._1;

public class UnoMeadowDesktopApplication: UnoMeadowApplication<Desktop>
{

}


public class UnoMeadowApplication<T> : Application, IApp
where T : class, IMeadowDevice
{
public CancellationToken CancellationToken => throw new NotImplementedException();

public static T Device => Resolver.Services.Get<IMeadowDevice>() as T;

/// <inheritdoc/>
public Dictionary<string, string> Settings { get; } = new();

/// <inheritdoc/>
public void InvokeOnMainThread(Action<object?> action, object? state = null)
{
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
dispatcherQueue.TryEnqueue(() => action(state));
}

/// <inheritdoc/>
public virtual Task OnError(Exception e)
{
return Task.CompletedTask;
}

/// <inheritdoc/>
public virtual Task OnShutdown()
{
return Task.CompletedTask;
}

/// <inheritdoc/>
public virtual void OnUpdate(Version newVersion, out bool approveUpdate)
{
approveUpdate = true;
}

/// <inheritdoc/>
public virtual void OnUpdateComplete(Version oldVersion, out bool rollbackUpdate)
{
rollbackUpdate = false;
}

public virtual Task MeadowRun()
{
return Task.CompletedTask;
}

public virtual Task MeadowInitialize()
{
return Task.CompletedTask;
}

Task IApp.Run()
{
return MeadowRun();
}

Task IApp.Initialize()
{
return MeadowInitialize();
}

public void LoadMeadowOS()
{
new Thread((o) =>
{
_ = MeadowOS.Start(this);
})
{
IsBackground = true
}
.Start();
}
}