Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Fix issue launching the sample on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezruiz committed Jul 19, 2022
1 parent 3c447ff commit 0866ce2
Show file tree
Hide file tree
Showing 25 changed files with 188 additions and 158 deletions.
12 changes: 6 additions & 6 deletions src/GraphicsControls.Sample/App.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:GraphicsControls.Sample"
x:Class="GraphicsControls.Sample.App"
windows:Application.ImageDirectory="Assets">
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:GraphicsControls.Sample"
x:Class="GraphicsControls.Sample.App">
<Application.Resources>
<ResourceDictionary>

Expand Down
4 changes: 3 additions & 1 deletion src/GraphicsControls.Sample/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace GraphicsControls.Sample
using Microsoft.Maui.Controls;

namespace GraphicsControls.Sample
{
public partial class App : Application
{
Expand Down
48 changes: 22 additions & 26 deletions src/GraphicsControls.Sample/GraphicsControls.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,57 @@

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>GraphicsControls.Sample</RootNamespace>
<UseMaui>true</UseMaui>
<LangVersion>10.0</LangVersion>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>

<!-- Display name -->
<ApplicationTitle>GraphicsControls</ApplicationTitle>
<ApplicationTitle>GraphicsControls.Sample</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.microsoft.graphicscontrols.sample</ApplicationId>
<ApplicationId>com.companyname.graphicscontrols.sample</ApplicationId>
<ApplicationIdGuid>886199C7-C6FD-4F27-B394-5AF13E61F272</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<!-- Required for C# Hot Reload -->
<UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>

<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" />
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" />
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
<!-- Required - WinUI does not yet have buildTransitive for everything -->
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.1" />
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.3.1" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GraphicsControls\GraphicsControls.csproj" />
<ProjectReference Include="..\GraphicsControls\GraphicsControls.csproj" />
</ItemGroup>

<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
<OutputType>WinExe</OutputType>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<Folder Include="Resources\Styles\" />
</ItemGroup>

</Project>
6 changes: 1 addition & 5 deletions src/GraphicsControls.Sample/MainPage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Maui;
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
using System;
Expand Down Expand Up @@ -98,8 +99,6 @@ IView CreateContent()
var cSharpFrame = new Frame
{
CornerRadius = 12,
HeightRequest = 150,
WidthRequest = 150,
Margin = new Thickness(0, 6, 6, 0)
};

Expand All @@ -124,8 +123,6 @@ IView CreateContent()
var xamlFrame = new Frame
{
CornerRadius = 12,
HeightRequest = 150,
WidthRequest = 150,
Margin = new Thickness(0, 6, 6, 0)
};

Expand Down Expand Up @@ -170,7 +167,6 @@ IView CreateContent()
var customizeFrame = new Frame
{
CornerRadius = 12,
HeightRequest = 150,
Margin = new Thickness(0, 6, 6, 0)
};

Expand Down
2 changes: 2 additions & 0 deletions src/GraphicsControls.Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using GraphicsControls.Sample.Controls;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Graphics.Controls;
using Microsoft.Maui.Graphics.Controls.Hosting;
using Microsoft.Maui.Hosting;

namespace GraphicsControls.Sample
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
16 changes: 2 additions & 14 deletions src/GraphicsControls.Sample/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
using Android.App;
using Android.Content.PM;
using Android.OS;
using Microsoft.Maui;

namespace GraphicsControls.Sample
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Platform.Init(this, savedInstanceState);
}

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Android.App;
using Android.Runtime;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using System;

namespace GraphicsControls.Sample
{
Expand Down
15 changes: 9 additions & 6 deletions src/GraphicsControls.Sample/Platforms/MacCatalyst/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Foundation;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;

namespace GraphicsControls.Sample;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
namespace GraphicsControls.Sample
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
23 changes: 12 additions & 11 deletions src/GraphicsControls.Sample/Platforms/MacCatalyst/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using ObjCRuntime;
using UIKit;

namespace GraphicsControls.Sample;

public class Program
namespace GraphicsControls.Sample
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}
17 changes: 17 additions & 0 deletions src/GraphicsControls.Sample/Platforms/Tizen/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using System;

namespace GraphicsControls.Sample
{
internal class Program : MauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
}
15 changes: 15 additions & 0 deletions src/GraphicsControls.Sample/Platforms/Tizen/tizen-manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.companyname.GraphicsControls.Sample" version="1.0.0" api-version="7" xmlns="http://tizen.org/ns/packages">
<profile name="common" />
<ui-application appid="com.companyname.GraphicsControls.Sample" exec="GraphicsControls.Sample.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
<label>GraphicsControls.Sample</label>
<icon>appicon.xhigh.png</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
</ui-application>
<shortcut-list />
<privileges>
<privilege>http://tizen.org/privilege/internet</privilege>
</privileges>
<dependencies />
<provides-appdefined-privileges />
</manifest>
37 changes: 16 additions & 21 deletions src/GraphicsControls.Sample/Platforms/Windows/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
using Microsoft.UI.Xaml;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using Microsoft.UI.Xaml;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace GraphicsControls.Sample.WinUI;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : MauiWinUIApplication
namespace GraphicsControls.Sample.WinUI
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public App()
{
this.InitializeComponent();
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

protected override void OnLaunched(LaunchActivatedEventArgs args)
public partial class App : MauiWinUIApplication
{
base.OnLaunched(args);
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
}

Platform.OnLaunched(args);
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}

}
41 changes: 13 additions & 28 deletions src/GraphicsControls.Sample/Platforms/Windows/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity
Name="606C8AB4-5534-4DD4-ABD8-07D4B8E10706"
Publisher="CN=User Name"
Version="1.0.0.0" />
<Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />

<Properties>
<DisplayName>GraphicsControls.Sample</DisplayName>
<PublisherDisplayName>Microsoft</PublisherDisplayName>
<Logo>Assets\appiconStoreLogo.png</Logo>
<DisplayName>$placeholder$</DisplayName>
<PublisherDisplayName>User Name</PublisherDisplayName>
<Logo>$placeholder$.png</Logo>
</Properties>

<Dependencies>
Expand All @@ -23,30 +19,19 @@
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
<Resource Language="x-generate" />
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="GraphicsControls.Sample"
Description="GraphicsControls.Sample"
BackgroundColor="transparent"
Square150x150Logo="Assets\appiconMediumTile.png"
Square44x44Logo="Assets\appiconLogo.png">
<uap:DefaultTile
Wide310x150Logo="Assets\appiconWideTile.png"
Square71x71Logo="Assets\appiconSmallTile.png"
Square310x310Logo="Assets\appiconLargeTile.png"
ShortName="GraphicsControls.Sample">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo"/>
<uap:ShowOn Tile="wide310x150Logo"/>
</uap:ShowNameOnTiles>
</uap:DefaultTile >
<uap:SplashScreen Image="Assets\appiconfgSplashScreen.png" />
DisplayName="$placeholder$"
Description="$placeholder$"
Square150x150Logo="$placeholder$.png"
Square44x44Logo="$placeholder$.png"
BackgroundColor="transparent">
<uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" />
<uap:SplashScreen Image="$placeholder$.png" />
</uap:VisualElements>
</Application>
</Applications>
Expand Down
Loading

0 comments on commit 0866ce2

Please sign in to comment.