Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<TextBlock Grid.Row="1" Text="Choose Version of .NET:" FontSize="18" FontFamily="Inria Sans" FontWeight="DemiBold" VerticalAlignment="Center" Margin="0,0,0,60"/>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" Margin="0,0,0,60">
<ComboBox x:Name="DotNetVersionComboBox" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="0" Margin="20,0"
FontSize="22" Foreground="#1157FA" FontWeight="SemiBold" SelectedIndex="2" SelectedValuePath="Version" Cursor="Hand">
FontSize="22" Foreground="#1157FA" FontWeight="SemiBold" SelectedIndex="2" SelectedValuePath="Version" Cursor="Hand" SelectionChanged="DotNetVersionComboBox_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate DataType="models:DotNetOption">
<StackPanel Orientation="Vertical">
Expand All @@ -57,12 +57,18 @@
<models:DotNetOption Title=".NET 8" SupportDescription="Long Term Support" Version="Net8" Notes="* .NET 8 requires Visual Studio 2022 v17.8 or newer"/>
<models:DotNetOption Title=".NET 9" SupportDescription="Standard Term Support" Version="Net9" Notes="* .NET 9 requires Visual Studio 2022 v17.12 or newer"/>
</ComboBox>
<TextBlock Grid.Row="1" Text="{Binding SelectedItem.Notes, ElementName=DotNetVersionComboBox}"
<TextBlock Grid.Row="1" Text="{Binding SelectedItem.Notes, ElementName=DotNetVersionComboBox}"
TextWrapping="Wrap" Foreground="Gray" VerticalAlignment="Center"/>
</StackPanel>

<TextBlock Grid.Row="2" Text="Choose Target Platforms:" FontSize="18" FontFamily="Inria Sans" FontWeight="DemiBold" Margin="0,25,20,0"/>
<local:PlatformsView x:Name="platformList" Grid.Row="2" Grid.Column="1" d:SelectedIndex="1" SelectionChanged="PlatformList_SelectionChanged"/>
<!-- Overlay Rectangle for grayed-out effect -->
<Rectangle x:Name="PlatformListDisabledOverlay"
Grid.Row="2" Grid.Column="1"
Fill="#80FFFFFF"
Visibility="Collapsed"
IsHitTestVisible="True"/>
</Grid>

<Grid Grid.Row="1" Margin="0,60,0,0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using OpenSilver.TemplateWizards.AppCustomizationWindow.Models;
using OpenSilver.TemplateWizards.Shared;
using OpenSilver.TemplateWizards.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;

Expand Down Expand Up @@ -50,30 +50,15 @@ public MauiHybridPlatform MauiHybridPlatform
{
get
{
MauiHybridPlatform platforms = MauiHybridPlatform.None;

foreach (var platform in platformList.SelectedItems.OfType<TargetPlatform>())
{
switch (platform.Title.ToLower())
{
case "ios":
platforms |= MauiHybridPlatform.iOS;
break;
case "android":
platforms |= MauiHybridPlatform.Android;
break;
case "windows":
platforms |= MauiHybridPlatform.Windows;
break;
case "macos":
platforms |= MauiHybridPlatform.Mac;
break;
default:
break;
}
}
return GetMauiHybridPlatforms(platformList.SelectedItems.OfType<TargetPlatform>());
}
}

return platforms;
public bool IsPhotinoSelected
{
get
{
return platformList.SelectedItems.OfType<TargetPlatform>().Any(p => p.Tag?.ToString() == "linux");
}
}

Expand All @@ -97,40 +82,21 @@ public AppConfigurationWindow(EnvDTE.DTE dte = null, bool isBusiness = false)
}
}

private bool ValidateMaui()
private MauiHybridPlatform GetMauiHybridPlatforms(IEnumerable<TargetPlatform> targetPlatforms)
{
if (MauiHybridPlatform == MauiHybridPlatform.None)
{
return true;
}
MauiHybridPlatform platforms = MauiHybridPlatform.None;

if (_dte != null)
foreach (var tp in targetPlatforms)
{
ThreadHelper.ThrowIfNotOnUIThread();
}
object tagValue = tp.Tag;

try
{
if (_dte != null)
if (tagValue is MauiHybridPlatform platform)
{
var serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_dte);

var checker = new MauiInstallationChecker(serviceProvider);
bool mauiInstalled = checker.IsMauiInstalled();

if (mauiInstalled)
{
return true;
}
platforms |= platform;
}

return new InstallMauiWindow().ShowDialog() == true;
}
catch (System.Exception ex)
{
MessageBox.Show($"Exception: {ex.Message}");
return true;
}

return platforms;
}

private void ButtonContinue_Click(object sender, RoutedEventArgs e)
Expand All @@ -147,7 +113,7 @@ private void ThemeCollectionView_SelectionChanged(object sender, ThemeOptions th

private void PlatformList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (MauiHybridPlatform != MauiHybridPlatform.None && e.AddedItems.Count != 0 && !IsMauiInstalled)
if (GetMauiHybridPlatforms(e.AddedItems.OfType<TargetPlatform>()) != MauiHybridPlatform.None && !IsMauiInstalled)
{
if (new InstallMauiWindow().ShowDialog() != true)
{
Expand All @@ -161,6 +127,27 @@ private void PlatformList_SelectionChanged(object sender, System.Windows.Control
mauiTip.Visibility = MauiHybridPlatform == MauiHybridPlatform.None ? Visibility.Hidden : Visibility.Visible;
}

private void DotNetVersionComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
var isDotNet7 = DotNetVersion == DotNetVersion.Net7;
if (isDotNet7 && platformList != null)
{
var itemsToDeselect = platformList.SelectedItems
.Cast<TargetPlatform>()
.Where(item => !Equals(item.Tag, "web")).ToList();

foreach (var item in itemsToDeselect)
{
platformList.SelectedItems.Remove(item);
}
}

if (PlatformListDisabledOverlay != null)
{
PlatformListDisabledOverlay.Visibility = isDotNet7 ? Visibility.Visible : Visibility.Collapsed;
}
}

// https://github.com/dotnet/wpf/blob/090a5230cf6186fe576dbc1729c943b36cb5db71/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ThemeManager.cs
private static bool IsSystemThemeLight()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class TargetPlatform
public string ThumbnailUri { get; set; }
public double Opacity { get; set; } = 0.6;
public bool IsAlwaysSelected { get; set; }
public object Tag { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:OpenSilver.TemplateWizards.AppCustomizationWindow.Models"
xmlns:shared="clr-namespace:OpenSilver.TemplateWizards.Shared"
d:DesignHeight="150"
d:DesignWidth="700"
d:SelectedIndex="1"
Expand Down Expand Up @@ -175,20 +176,26 @@
Framework="WebAssembly"
IsAlwaysSelected="True"
Opacity="1"
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_web.png"/>
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_web.png"
Tag="web"/>
<models:TargetPlatform Title="iOS"
Framework="MAUI Hybrid"
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_apple.png"/>
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_apple.png"
Tag="{x:Static shared:MauiHybridPlatform.iOS}"/>
<models:TargetPlatform Title="Android"
Framework="MAUI Hybrid"
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_android.png"/>
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_android.png"
Tag="{x:Static shared:MauiHybridPlatform.Android}"/>
<models:TargetPlatform Title="Windows"
Framework="MAUI Hybrid"
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_windows.png"/>
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_windows.png"
Tag="{x:Static shared:MauiHybridPlatform.Windows}"/>
<models:TargetPlatform Title="macOS"
Framework="MAUI Hybrid"
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_apple.png"/>
<!--<models:TargetPlatform Title="Linux"
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_apple.png"
Tag="{x:Static shared:MauiHybridPlatform.Mac}"/>
<models:TargetPlatform Title="Linux"
Framework="Photino"
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_linux.png"/>-->
ThumbnailUri="/OpenSilver.TemplateWizards;component/Assets/Images/platform_linux.png"
Tag="linux"/>
</ListBox>
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<DependentUpon>ThemeCollectionView.xaml</DependentUpon>
</Compile>
<Compile Include="Utils\MauiInstallationChecker.cs" />
<Compile Include="Utils\VisualStudioInstallationChecker.cs" />
<Compile Include="Utils\WizardUtilities.cs" />
<Compile Include="Wizards\AppCustomizationWizard.cs" />
<Compile Include="Wizards\ClassLibraryProjectTemplateWizard.cs" />
<Compile Include="Shared\GlobalWizardDataStore.cs" />
Expand All @@ -72,6 +72,7 @@
<Compile Include="Shared\MauiHybridPlatform.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Shared\WizardKeys.cs" />
<Compile Include="Wizards\PhotinoProjectTemplateWizard.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="AppCustomizationWindow\AppConfigurationWindow.xaml">
Expand Down
2 changes: 2 additions & 0 deletions src/OpenSilver.TemplateWizards/Shared/GlobalConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public static class GlobalConstants
public const string OpenRia46PackageVersion = "3.2.0";

public const string OpenSilverThemeModernPackageVersion = "3.2.*";

public const string OpenSilverPhotinoPackageVersion = "3.2.0";
}
}

This file was deleted.

87 changes: 87 additions & 0 deletions src/OpenSilver.TemplateWizards/Utils/WizardUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using OpenSilver.TemplateWizards.Shared;
using System.Collections.Generic;

namespace OpenSilver.TemplateWizards.Utils
{
/// <summary>
/// Utility class providing common functionality for wizards
/// </summary>
public static class WizardUtilities
{
/// <summary>
/// Gets all projects within a given project, including those in solution folders
/// </summary>
/// <param name="project">The project to search</param>
/// <returns>Enumeration of all projects</returns>
private static IEnumerable<Project> GetProjects(Project project)
{
ThreadHelper.ThrowIfNotOnUIThread();

// If this is a solution folder, it can contain other projects
if (project.Kind == ProjectKinds.vsProjectKindSolutionFolder)
{
foreach (ProjectItem projectItem in project.ProjectItems)
{
var subProject = projectItem.SubProject;
if (subProject != null)
{
foreach (var nested in GetProjects(subProject))
{
yield return nested;
}
}
}
}
else
{
yield return project;
}
}

/// <summary>
/// Gets all projects within a solution
/// </summary>
/// <param name="solution">The solution to search</param>
/// <returns>Enumeration of all projects in the solution</returns>
public static IEnumerable<Project> GetAllProjects(Solution2 solution)
{
ThreadHelper.ThrowIfNotOnUIThread();

foreach (Project topLevelProject in solution.Projects)
{
foreach (Project p in GetProjects(topLevelProject))
{
yield return p;
}
}
}

/// <summary>
/// Converts a DotNetVersion enum value to its corresponding target framework moniker string
/// </summary>
/// <param name="netTarget">The .NET version to convert</param>
/// <returns>The target framework moniker as a string (e.g., "net8.0")</returns>
public static string GetNetTarget(DotNetVersion netTarget)
{
if (netTarget == DotNetVersion.Net7)
{
return "net7.0";
}

if (netTarget == DotNetVersion.Net8)
{
return "net8.0";
}

if (netTarget == DotNetVersion.Net9)
{
return "net9.0";
}

return "";
}
}
}
Loading