forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Template): Make manifest.json optional
Make manifest.json optional for WASM templates. For Visual Studio 2022, the wizard should show an additional dialog to ask whether the user wants a manifest.json file. For `dotnet new unoapp` and `dotnet new unoapp-uwp-net6`, a parameter, `--wasm-pwa-manifest` can be used.
- Loading branch information
1 parent
9b802c5
commit 572c991
Showing
14 changed files
with
462 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/SolutionTemplate/UnoSolutionTemplate.Wizard.2022/Forms/UnoOptionsBaseForm.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System.Drawing; | ||
using System; | ||
using System.Windows.Forms; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace UnoSolutionTemplate.Wizard.Forms | ||
{ | ||
public class UnoOptionsBaseForm : Form | ||
{ | ||
private IServiceProvider _serviceProvider; | ||
|
||
public UnoOptionsBaseForm(IServiceProvider serviceProvider) | ||
{ | ||
_serviceProvider = serviceProvider; | ||
} | ||
|
||
public UnoOptionsBaseForm() | ||
{ | ||
|
||
} | ||
|
||
protected void InitializeFont() | ||
{ | ||
ThreadHelper.ThrowIfNotOnUIThread(); | ||
|
||
if (_serviceProvider.GetService(typeof(IUIHostLocale)) is IUIHostLocale2 hostLocale) | ||
{ | ||
UIDLGLOGFONT[] array = (UIDLGLOGFONT[])(object)new UIDLGLOGFONT[1]; | ||
if (hostLocale.GetDialogFont(array) == 0) | ||
{ | ||
Font = FontFromUIDLGLOGFONT(array[0]); | ||
} | ||
} | ||
} | ||
|
||
private static Font FontFromUIDLGLOGFONT(UIDLGLOGFONT logFont) | ||
{ | ||
var fonts = new char[logFont.lfFaceName.Length]; | ||
|
||
var num = 0; | ||
ushort[] lfFaceName = logFont.lfFaceName; | ||
foreach (ushort num2 in lfFaceName) | ||
{ | ||
fonts[num++] = (char)num2; | ||
} | ||
|
||
var familyName = new string(fonts); | ||
var emSize = -logFont.lfHeight; | ||
var fontStyle = FontStyle.Regular; | ||
|
||
if (logFont.lfItalic > 0) | ||
{ | ||
fontStyle |= FontStyle.Italic; | ||
} | ||
if (logFont.lfUnderline > 0) | ||
{ | ||
fontStyle |= FontStyle.Underline; | ||
} | ||
if (logFont.lfStrikeOut > 0) | ||
{ | ||
fontStyle |= FontStyle.Strikeout; | ||
} | ||
if (logFont.lfWeight > 400) | ||
{ | ||
fontStyle |= FontStyle.Bold; | ||
} | ||
|
||
var unit = GraphicsUnit.Pixel; | ||
var lfCharSet = logFont.lfCharSet; | ||
|
||
return new Font(familyName, emSize, fontStyle, unit, lfCharSet); | ||
} | ||
|
||
protected void ResizeLabelDescription(Label labelDescription) | ||
{ | ||
using Graphics graphics = CreateGraphics(); | ||
var sizeF = graphics.MeasureString(labelDescription.Text, Font); | ||
|
||
int widthRatio = (int)(sizeF.Width / (float)labelDescription.Width); | ||
if (widthRatio != 0) | ||
{ | ||
int heightCeil = (int)Math.Ceiling(sizeF.Height); | ||
SuspendLayout(); | ||
labelDescription.Height = heightCeil + widthRatio * heightCeil; | ||
ResumeLayout(performLayout: true); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.