From 417ee9081b99a28eee34dec0ae489a75a75466d1 Mon Sep 17 00:00:00 2001 From: "Andy De George (adegeo)" Date: Thu, 24 Oct 2024 15:54:50 -0700 Subject: [PATCH 1/3] Rewrite font snippet --- ...how-to-create-a-private-font-collection.md | 8 +- .../cs/App.config | 6 + .../cs/Form1.Designer.cs | 47 +++++++ .../cs/Form1.cs | 100 +++++++++++++++ .../cs/Form1.resx | 120 ++++++++++++++++++ .../cs/Program.cs | 22 ++++ .../cs/Properties/AssemblyInfo.cs | 36 ++++++ .../cs/Properties/Resources.Designer.cs | 71 +++++++++++ .../cs/Properties/Resources.resx | 117 +++++++++++++++++ .../cs/Properties/Settings.Designer.cs | 30 +++++ .../cs/Properties/Settings.settings | 7 + .../cs/fonts.csproj | 83 ++++++++++++ .../vb/App.config | 6 + .../vb/Form1.Designer.vb | 31 +++++ .../vb/Form1.vb | 93 ++++++++++++++ .../vb/My Project/Application.Designer.vb | 38 ++++++ .../vb/My Project/Application.myapp | 11 ++ .../vb/My Project/AssemblyInfo.vb | 35 +++++ .../vb/My Project/Resources.Designer.vb | 62 +++++++++ .../vb/My Project/Resources.resx | 117 +++++++++++++++++ .../vb/My Project/Settings.Designer.vb | 73 +++++++++++ .../vb/My Project/Settings.settings | 7 + .../vb/fonts.vbproj | 120 ++++++++++++++++++ 23 files changed, 1236 insertions(+), 4 deletions(-) create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/App.config create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.Designer.cs create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.cs create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.resx create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Program.cs create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/AssemblyInfo.cs create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Resources.Designer.cs create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Resources.resx create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Settings.Designer.cs create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Settings.settings create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/fonts.csproj create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/App.config create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.Designer.vb create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.vb create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Application.Designer.vb create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Application.myapp create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/AssemblyInfo.vb create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Resources.Designer.vb create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Resources.resx create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Settings.Designer.vb create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Settings.settings create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/fonts.vbproj diff --git a/dotnet-desktop-guide/framework/winforms/advanced/how-to-create-a-private-font-collection.md b/dotnet-desktop-guide/framework/winforms/advanced/how-to-create-a-private-font-collection.md index d10fc4632c..6bf06319da 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/how-to-create-a-private-font-collection.md +++ b/dotnet-desktop-guide/framework/winforms/advanced/how-to-create-a-private-font-collection.md @@ -41,10 +41,10 @@ The class inherits from the `e`, which is a parameter of . diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/App.config b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/App.config new file mode 100644 index 0000000000..aee9adf485 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.Designer.cs b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.Designer.cs new file mode 100644 index 0000000000..c93bbeb8ce --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.Designer.cs @@ -0,0 +1,47 @@ +namespace fonts +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + } +} + diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.cs b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.cs new file mode 100644 index 0000000000..dd103877b7 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Drawing.Text; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace fonts +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + // + // Helper function to print text in a font and style + private float DrawFont(Graphics graphicsObj, + FontFamily family, + FontStyle style, + SolidBrush colorBrush, + PointF location, + string styleName) + { + // The string to print, which contains the family name and style + string familyNameAndStyle = $"{family.Name} {styleName}"; + + // Create the font object + using (Font fontObject = new Font(family.Name, 16, style, GraphicsUnit.Pixel)) + { + // Draw the string + graphicsObj.DrawString(familyNameAndStyle, fontObject, colorBrush, location); + + // Return the height of the font + return fontObject.Height; + } + } + + // The OnPaint method of a form, which provides the graphics object + protected override void OnPaint(PaintEventArgs e) + { + PointF pointF = new PointF(10, 0); + SolidBrush solidBrush = new SolidBrush(Color.Black); + + FontFamily[] fontFamilies; + PrivateFontCollection privateFontCollection = new PrivateFontCollection(); // Dispose later + + // Add three font files to the private collection. + privateFontCollection.AddFontFile(System.Environment.ExpandEnvironmentVariables("%systemroot%\\Fonts\\Arial.ttf")); + privateFontCollection.AddFontFile(System.Environment.ExpandEnvironmentVariables("%systemroot%\\Fonts\\CourBI.ttf")); + privateFontCollection.AddFontFile(System.Environment.ExpandEnvironmentVariables("%systemroot%\\Fonts\\TimesBD.ttf")); + + // Get the array of FontFamily objects. + fontFamilies = privateFontCollection.Families; + + // Process each font in the collection + for (int i = 0; i < fontFamilies.Length; i++) + { + // Draw the font in every style + + // Regular + if (fontFamilies[i].IsStyleAvailable(FontStyle.Regular)) + pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Regular, solidBrush, pointF, "Regular"); + + // Bold + if (fontFamilies[i].IsStyleAvailable(FontStyle.Bold)) + pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Bold, solidBrush, pointF, "Bold"); + + // Italic + if (fontFamilies[i].IsStyleAvailable(FontStyle.Italic)) + pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Italic, solidBrush, pointF, "Italic"); + + // Bold and Italic + if (fontFamilies[i].IsStyleAvailable(FontStyle.Bold) && + fontFamilies[i].IsStyleAvailable(FontStyle.Italic)) + pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Bold | FontStyle.Italic, solidBrush, pointF, "BoldItalic"); + + // Underline + if (fontFamilies[i].IsStyleAvailable(FontStyle.Underline)) + pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Underline, solidBrush, pointF, "Underline"); + + // Strikeout + if (fontFamilies[i].IsStyleAvailable(FontStyle.Strikeout)) + pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Strikeout, solidBrush, pointF, "Strikeout"); + + // Extra space between font families + pointF.Y += 10; + } + + privateFontCollection.Dispose(); + } + // + } +} diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.resx b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.resx new file mode 100644 index 0000000000..1af7de150c --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Program.cs b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Program.cs new file mode 100644 index 0000000000..6f5641f165 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace fonts +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/AssemblyInfo.cs b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..18c372143f --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("fonts")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("fonts")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("fb917916-71e9-4e2a-94c2-d9a3036995cb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Resources.Designer.cs b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..99535c83dc --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace fonts.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("fonts.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Resources.resx b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Settings.Designer.cs b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..289983e82d --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace fonts.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Settings.settings b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Settings.settings new file mode 100644 index 0000000000..39645652af --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/fonts.csproj b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/fonts.csproj new file mode 100644 index 0000000000..07a5de815a --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/fonts.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {FB917916-71E9-4E2A-94C2-D9A3036995CB} + WinExe + fonts + fonts + v4.8.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/App.config b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/App.config new file mode 100644 index 0000000000..23631cd6e0 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.Designer.vb b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.Designer.vb new file mode 100644 index 0000000000..a418df0ea8 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.Designer.vb @@ -0,0 +1,31 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(800, 450) + Me.Text = "Form1" + End Sub + +End Class diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.vb b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.vb new file mode 100644 index 0000000000..a71bd3f330 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.vb @@ -0,0 +1,93 @@ +Imports System.Drawing.Text + +Public Class Form1 + + ' + ' Helper function to print text in a font and style + Private Function DrawFont(graphicsObj As Graphics, + family As FontFamily, + style As FontStyle, + colorBrush As SolidBrush, + location As PointF, + styleName As String) As Single + + ' The string to print, which contains the family name and style + Dim familyNameAndStyle As String = $"{family.Name} {styleName}" + + ' Create the font object + Using fontObject As New Font(family.Name, 16, style, GraphicsUnit.Pixel) + + ' Draw the string + graphicsObj.DrawString(familyNameAndStyle, fontObject, colorBrush, location) + + ' Return the height of the font + Return fontObject.Height + + End Using + + End Function + + ' The OnPaint method of a form, which provides the graphics object + Protected Overrides Sub OnPaint(e As PaintEventArgs) + + Dim pointF As New PointF(10, 0) + Dim solidBrush As New SolidBrush(Color.Black) + + Dim fontFamilies() As FontFamily + Dim privateFontCollection As New PrivateFontCollection() ' Dispose later + + ' Add three font files to the private collection. + privateFontCollection.AddFontFile(System.Environment.ExpandEnvironmentVariables("%systemroot%\Fonts\Arial.ttf")) + privateFontCollection.AddFontFile(System.Environment.ExpandEnvironmentVariables("%systemroot%\Fonts\CourBI.ttf")) + privateFontCollection.AddFontFile(System.Environment.ExpandEnvironmentVariables("%systemroot%\Fonts\TimesBD.ttf")) + + ' Get the array of FontFamily objects. + fontFamilies = privateFontCollection.Families + + ' Process each font in the collection + For i = 0 To fontFamilies.Length - 1 + + ' Draw the font in every style + + ' Regular + If fontFamilies(i).IsStyleAvailable(FontStyle.Regular) Then + pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Regular, solidBrush, pointF, "Regular") + End If + + ' Bold + If fontFamilies(i).IsStyleAvailable(FontStyle.Bold) Then + pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Bold, solidBrush, pointF, "Bold") + End If + + ' Italic + If fontFamilies(i).IsStyleAvailable(FontStyle.Italic) Then + pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Italic, solidBrush, pointF, "Italic") + End If + + ' Bold and Italic + If fontFamilies(i).IsStyleAvailable(FontStyle.Italic) And + fontFamilies(i).IsStyleAvailable(FontStyle.Italic) Then + pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Bold Or FontStyle.Italic, solidBrush, pointF, "BoldItalic") + End If + + ' Underline + If fontFamilies(i).IsStyleAvailable(FontStyle.Underline) Then + pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Underline, solidBrush, pointF, "Underline") + End If + + ' Strikeout + If fontFamilies(i).IsStyleAvailable(FontStyle.Strikeout) Then + pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Strikeout, solidBrush, pointF, "Strikeout") + End If + + ' Extra space between font families + pointF.Y += 10 + + Next + + privateFontCollection.Dispose() + + End Sub + ' + +End Class diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Application.Designer.vb b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Application.Designer.vb new file mode 100644 index 0000000000..1041d2d0e3 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.fonts.Form1 + End Sub + End Class +End Namespace diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Application.myapp b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Application.myapp new file mode 100644 index 0000000000..1243847fd9 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/AssemblyInfo.vb b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/AssemblyInfo.vb new file mode 100644 index 0000000000..d91b714b83 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Resources.Designer.vb b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Resources.Designer.vb new file mode 100644 index 0000000000..6a4863d4f9 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("fonts.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Resources.resx b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Settings.Designer.vb b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Settings.Designer.vb new file mode 100644 index 0000000000..ae4a8c24bd --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.fonts.My.MySettings + Get + Return Global.fonts.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Settings.settings b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Settings.settings new file mode 100644 index 0000000000..85b890b3c6 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/fonts.vbproj b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/fonts.vbproj new file mode 100644 index 0000000000..7c2414d084 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/fonts.vbproj @@ -0,0 +1,120 @@ + + + + + Debug + AnyCPU + {0E2E64AB-9F0A-4684-A672-373411E7F05D} + WinExe + fonts.My.MyApplication + fonts + fonts + 512 + WindowsForms + v4.8.1 + true + true + + + AnyCPU + true + full + true + true + bin\Debug\ + fonts.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + AnyCPU + pdbonly + false + true + true + bin\Release\ + fonts.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file From 7fcff49b713c37121e9ef62d5a4e8db8d94c005f Mon Sep 17 00:00:00 2001 From: "Andy De George (adegeo)" Date: Thu, 24 Oct 2024 16:05:47 -0700 Subject: [PATCH 2/3] Add snippets config --- .../cs/snippets.5000.json | 3 + .../vb/snippets.5000.json | 3 + .../csharp/CSharpExample.csproj | 2 +- .../vb/VBExample.vbproj | 2 +- .../csharp/CSharpExample.csproj | 2 +- .../vb/MainWindow.xaml | 29 +++- .../vb/VBExample.vbproj | 2 +- .../csharp/CSharpExample.csproj | 2 +- .../vb/VBExample.vbproj | 2 +- .../csharp/ArticleExample.csproj | 2 +- .../vb/ArticleExampleVB.vbproj | 2 +- .../csharp/ArticleExample.csproj | 2 +- .../vb/ArticleExampleVB.vbproj | 2 +- .../snippets/index/csharp/bindings.csproj | 2 +- .../data/snippets/index/vb/bindings.vbproj | 2 +- .../Properties/launchSettings.json | 4 + redirects_generator/definitions.json | 2 +- redirects_generator/definitions.winforms.json | 2 +- redirects_generator/definitions.wpf.json | 138 +++++++++--------- redirects_generator/redirects.cs | 56 ++++--- redirects_generator/redirs.csproj | 3 + 21 files changed, 156 insertions(+), 108 deletions(-) create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/snippets.5000.json create mode 100644 dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/snippets.5000.json diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/snippets.5000.json b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/snippets.5000.json new file mode 100644 index 0000000000..da9ebf8da2 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/snippets.5000.json @@ -0,0 +1,3 @@ +{ + "host": "visualstudio" +} diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/snippets.5000.json b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/snippets.5000.json new file mode 100644 index 0000000000..da9ebf8da2 --- /dev/null +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/snippets.5000.json @@ -0,0 +1,3 @@ +{ + "host": "visualstudio" +} diff --git a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-style/csharp/CSharpExample.csproj b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-style/csharp/CSharpExample.csproj index 6b287e73fe..7888c4458e 100644 --- a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-style/csharp/CSharpExample.csproj +++ b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-style/csharp/CSharpExample.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows IntroToStylingAndTemplating true IntroToStylingAndTemplating diff --git a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-style/vb/VBExample.vbproj b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-style/vb/VBExample.vbproj index 374b97825b..e2f131759e 100644 --- a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-style/vb/VBExample.vbproj +++ b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-style/vb/VBExample.vbproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows IntroToStylingAndTemplating true IntroToStylingAndTemplating diff --git a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/csharp/CSharpExample.csproj b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/csharp/CSharpExample.csproj index 374b97825b..e2f131759e 100644 --- a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/csharp/CSharpExample.csproj +++ b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/csharp/CSharpExample.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows IntroToStylingAndTemplating true IntroToStylingAndTemplating diff --git a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/vb/MainWindow.xaml b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/vb/MainWindow.xaml index f62477d1ba..85697e17d1 100644 --- a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/vb/MainWindow.xaml +++ b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/vb/MainWindow.xaml @@ -7,12 +7,37 @@ mc:Ignorable="d" Title="Template Intro Sample" Loaded="WindowLoaded" SizeToContent="WidthAndHeight" MinWidth="250"> - + + + + + + + + + + + + + + + + + + + + - + diff --git a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/vb/VBExample.vbproj b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/vb/VBExample.vbproj index 374b97825b..e2f131759e 100644 --- a/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/vb/VBExample.vbproj +++ b/dotnet-desktop-guide/net/wpf/controls/snippets/how-to-create-apply-template/vb/VBExample.vbproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows IntroToStylingAndTemplating true IntroToStylingAndTemplating diff --git a/dotnet-desktop-guide/net/wpf/controls/snippets/styles-templates-overview/csharp/CSharpExample.csproj b/dotnet-desktop-guide/net/wpf/controls/snippets/styles-templates-overview/csharp/CSharpExample.csproj index 6b287e73fe..7888c4458e 100644 --- a/dotnet-desktop-guide/net/wpf/controls/snippets/styles-templates-overview/csharp/CSharpExample.csproj +++ b/dotnet-desktop-guide/net/wpf/controls/snippets/styles-templates-overview/csharp/CSharpExample.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows IntroToStylingAndTemplating true IntroToStylingAndTemplating diff --git a/dotnet-desktop-guide/net/wpf/controls/snippets/styles-templates-overview/vb/VBExample.vbproj b/dotnet-desktop-guide/net/wpf/controls/snippets/styles-templates-overview/vb/VBExample.vbproj index 374b97825b..e2f131759e 100644 --- a/dotnet-desktop-guide/net/wpf/controls/snippets/styles-templates-overview/vb/VBExample.vbproj +++ b/dotnet-desktop-guide/net/wpf/controls/snippets/styles-templates-overview/vb/VBExample.vbproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows IntroToStylingAndTemplating true IntroToStylingAndTemplating diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/binding-declarations-overview/csharp/ArticleExample.csproj b/dotnet-desktop-guide/net/wpf/data/snippets/binding-declarations-overview/csharp/ArticleExample.csproj index 0db208d36e..80b35f9f30 100644 --- a/dotnet-desktop-guide/net/wpf/data/snippets/binding-declarations-overview/csharp/ArticleExample.csproj +++ b/dotnet-desktop-guide/net/wpf/data/snippets/binding-declarations-overview/csharp/ArticleExample.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows true diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/binding-declarations-overview/vb/ArticleExampleVB.vbproj b/dotnet-desktop-guide/net/wpf/data/snippets/binding-declarations-overview/vb/ArticleExampleVB.vbproj index a7a3e24698..d7601ae1ee 100644 --- a/dotnet-desktop-guide/net/wpf/data/snippets/binding-declarations-overview/vb/ArticleExampleVB.vbproj +++ b/dotnet-desktop-guide/net/wpf/data/snippets/binding-declarations-overview/vb/ArticleExampleVB.vbproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows ArticleExampleVB true diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/how-to-bind-to-an-enumeration/csharp/ArticleExample.csproj b/dotnet-desktop-guide/net/wpf/data/snippets/how-to-bind-to-an-enumeration/csharp/ArticleExample.csproj index 0db208d36e..80b35f9f30 100644 --- a/dotnet-desktop-guide/net/wpf/data/snippets/how-to-bind-to-an-enumeration/csharp/ArticleExample.csproj +++ b/dotnet-desktop-guide/net/wpf/data/snippets/how-to-bind-to-an-enumeration/csharp/ArticleExample.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows true diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/how-to-bind-to-an-enumeration/vb/ArticleExampleVB.vbproj b/dotnet-desktop-guide/net/wpf/data/snippets/how-to-bind-to-an-enumeration/vb/ArticleExampleVB.vbproj index a7a3e24698..d7601ae1ee 100644 --- a/dotnet-desktop-guide/net/wpf/data/snippets/how-to-bind-to-an-enumeration/vb/ArticleExampleVB.vbproj +++ b/dotnet-desktop-guide/net/wpf/data/snippets/how-to-bind-to-an-enumeration/vb/ArticleExampleVB.vbproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows ArticleExampleVB true diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/bindings.csproj b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/bindings.csproj index 9150f2e904..696bb13c22 100644 --- a/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/bindings.csproj +++ b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/bindings.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows true diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/bindings.vbproj b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/bindings.vbproj index e9e19b50e4..35dbade0a4 100644 --- a/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/bindings.vbproj +++ b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/bindings.vbproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net8.0-windows bindings true diff --git a/redirects_generator/Properties/launchSettings.json b/redirects_generator/Properties/launchSettings.json index 56b4c04488..dbc5e6eaac 100644 --- a/redirects_generator/Properties/launchSettings.json +++ b/redirects_generator/Properties/launchSettings.json @@ -10,6 +10,10 @@ "Specialized-WinForms": { "commandName": "Project", "commandLineArgs": "\"C:\\Code\\Work\\dotnet\\docs-desktop\\.openpublishing.redirection.winforms.json\"" + }, + "Specialized-WPF": { + "commandName": "Project", + "commandLineArgs": "\"C:\\Code\\Work\\dotnet\\docs-desktop\\.openpublishing.redirection.wpf.json\"" } } } diff --git a/redirects_generator/definitions.json b/redirects_generator/definitions.json index 8120478157..a86fdfd27e 100644 --- a/redirects_generator/definitions.json +++ b/redirects_generator/definitions.json @@ -1,7 +1,7 @@ { "Moniker1": "netframeworkdesktop-4.8", "RepoPath1": "dotnet-desktop-guide/framework/", - "Moniker2": "netdesktop-7.0", + "Moniker2": "netdesktop-8.0", "RepoPath2": "dotnet-desktop-guide/net/", "PublishRoot": "/dotnet/desktop/", "Entries": [] diff --git a/redirects_generator/definitions.winforms.json b/redirects_generator/definitions.winforms.json index 32aa8fab0b..0109b70c94 100644 --- a/redirects_generator/definitions.winforms.json +++ b/redirects_generator/definitions.winforms.json @@ -1,7 +1,7 @@ { "Moniker1": "netframeworkdesktop-4.8", "RepoPath1": "dotnet-desktop-guide/framework/", - "Moniker2": "netdesktop-7.0", + "Moniker2": "netdesktop-8.0", "RepoPath2": "dotnet-desktop-guide/net/", "PublishRoot": "/dotnet/desktop/", "Entries": [ diff --git a/redirects_generator/definitions.wpf.json b/redirects_generator/definitions.wpf.json index 41ddfb0811..d0171ba58c 100644 --- a/redirects_generator/definitions.wpf.json +++ b/redirects_generator/definitions.wpf.json @@ -1,7 +1,7 @@ { "Moniker1": "netframeworkdesktop-4.8", "RepoPath1": "dotnet-desktop-guide/framework/", - "Moniker2": "netdesktop-7.0", + "Moniker2": "netdesktop-8.0", "RepoPath2": "dotnet-desktop-guide/net/", "PublishRoot": "/dotnet/desktop/", "Entries": [ @@ -10,267 +10,267 @@ { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/introduction-to-wpf?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/overview/?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/overview/?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/getting-started/walkthrough-my-first-wpf-desktop-application?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/get-started/create-app-visual-studio?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/get-started/create-app-visual-studio?view=netdesktop-8.0" }, // Windows { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/app-development/wpf-windows-overview?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/windows/index?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/windows/index?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/app-development/dialog-boxes-overview?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/windows/dialog-boxes-overview?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/windows/dialog-boxes-overview?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/app-development/how-to-open-a-window?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-open-window-dialog-box?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-open-window-dialog-box?view=netdesktop-8.0" }, { "Redirect": "OneWay", "SourceUrl": "/dotnet/desktop/wpf/app-development/how-to-open-a-dialog-box?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-open-window-dialog-box?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-open-window-dialog-box?view=netdesktop-8.0" }, { "Redirect": "OneWay", "SourceUrl": "/dotnet/desktop/wpf/how-to-return-a-dialog-box-result?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-open-window-dialog-box?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-open-window-dialog-box?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/app-development/how-to-open-a-message-box?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-open-message-box?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-open-message-box?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/app-development/how-to-get-and-set-the-main-application-window?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-get-set-main-application-window?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/windows/how-to-get-set-main-application-window?view=netdesktop-8.0" }, // Data { "Redirect": "OneWay", "SourceUrl": "/dotnet/desktop/wpf/data/data-binding-overview?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/data/index?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/data/index?view=netdesktop-8.0" }, { "Redirect": "OneWay", "SourceUrl": "/dotnet/desktop/wpf/data/how-to-specify-the-direction-of-the-binding?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/data/binding-declarations-overview?view=netdesktop-7.0#binding-direction" + "TargetUrl": "/dotnet/desktop/wpf/data/binding-declarations-overview?view=netdesktop-8.0#binding-direction" }, // Documents/Printing { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/printing-overview?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/documents/printing-overview?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/documents/printing-overview?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-invoke-a-print-dialog?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/documents/how-to-display-print-dialog?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/documents/how-to-display-print-dialog?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-programmatically-print-xps-files?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/documents/how-to-print-xps-files?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/documents/how-to-print-xps-files?view=netdesktop-8.0" }, // Systems - Events { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-add-an-event-handler-using-code?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/how-to-add-an-event-handler-using-code?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/how-to-add-an-event-handler-using-code?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-create-a-custom-routed-event?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/how-to-create-a-custom-routed-event?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/how-to-create-a-custom-routed-event?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/visual-basic-and-wpf-event-handling?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/visual-basic-and-wpf-event-handling?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/visual-basic-and-wpf-event-handling?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/preview-events?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/preview-events?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/preview-events?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/marking-routed-events-as-handled-and-class-handling?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/marking-routed-events-as-handled-and-class-handling?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/marking-routed-events-as-handled-and-class-handling?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/object-lifetime-events?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/object-lifetime-events?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/object-lifetime-events?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/weak-event-patterns?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/weak-event-patterns?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/weak-event-patterns?view=netdesktop-8.0" }, { "SourceUrl": "/dotnet/desktop/wpf/advanced/property-change-events?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/property-change-events?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/property-change-events?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/attached-events-overview?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/attached-events-overview?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/attached-events-overview?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/routed-events-overview?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/events/routed-events-overview?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/events/routed-events-overview?view=netdesktop-8.0" }, // Systems - Properties { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/dependency-properties-overview?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-properties-overview?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-properties-overview?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/dependency-property-value-precedence?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-property-value-precedence?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-property-value-precedence?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/attached-properties-overview?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/attached-properties-overview?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/attached-properties-overview?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/collection-type-dependency-properties?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/collection-type-dependency-properties?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/collection-type-dependency-properties?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-register-an-attached-property?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/how-to-register-an-attached-property?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/how-to-register-an-attached-property?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-implement-a-dependency-property?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/how-to-implement-a-dependency-property?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/how-to-implement-a-dependency-property?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/custom-dependency-properties?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/custom-dependency-properties?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/custom-dependency-properties?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/dependency-property-metadata?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-property-metadata?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-property-metadata?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-override-metadata-for-a-dependency-property?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/how-to-override-metadata-for-a-dependency-property?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/how-to-override-metadata-for-a-dependency-property?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/dependency-property-callbacks-and-validation?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-property-callbacks-and-validation?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-property-callbacks-and-validation?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/read-only-dependency-properties?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/read-only-dependency-properties?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/read-only-dependency-properties?view=netdesktop-8.0" }, { "SourceUrl": "/dotnet/desktop/wpf/advanced/framework-property-metadata?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/framework-property-metadata?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/framework-property-metadata?view=netdesktop-8.0" }, { "SourceUrl": "/dotnet/desktop/wpf/advanced/dependency-property-security?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-property-security?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/dependency-property-security?view=netdesktop-8.0" }, { "SourceUrl": "/dotnet/desktop/wpf/advanced/safe-constructor-patterns-for-dependencyobjects?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/safe-constructor-patterns-for-dependencyobjects?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/safe-constructor-patterns-for-dependencyobjects?view=netdesktop-8.0" }, { "SourceUrl": "/dotnet/desktop/wpf/advanced/property-value-inheritance?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/property-value-inheritance?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/property-value-inheritance?view=netdesktop-8.0" }, { "SourceUrl": "/dotnet/desktop/wpf/advanced/xaml-loading-and-dependency-properties?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/properties/xaml-loading-and-dependency-properties?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/properties/xaml-loading-and-dependency-properties?view=netdesktop-8.0" }, // Systems - XAML { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/xaml-resources-define?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-overview?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-overview?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/resources-and-code?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-and-code?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-and-code?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/merged-resource-dictionaries?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-merged-dictionaries?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-merged-dictionaries?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-define-and-reference-a-resource?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-define-and-reference?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-define-and-reference?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-use-application-resources?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-application?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-application?view=netdesktop-8.0" }, { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-use-systemfonts?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-system?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-system?view=netdesktop-8.0" }, { "Redirect": "OneWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-use-system-fonts-keys?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-system?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-system?view=netdesktop-8.0" }, { "Redirect": "OneWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-use-systemparameters?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-system?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-system?view=netdesktop-8.0" }, { "Redirect": "OneWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/how-to-use-system-parameters-keys?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-system?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-how-to-use-system?view=netdesktop-8.0" }, // XAML { "Redirect": "TwoWay", "SourceUrl": "/dotnet/desktop/wpf/advanced/xaml-in-wpf?view=netframeworkdesktop-4.8", - "TargetUrl": "/dotnet/desktop/wpf/xaml/index?view=netdesktop-7.0" + "TargetUrl": "/dotnet/desktop/wpf/xaml/index?view=netdesktop-8.0" }, // section? //{ // "Redirect": "TwoWay", // "SourceUrl": "/dotnet/desktop/wpf/aaaaaa?view=netframeworkdesktop-4.8", - // "TargetUrl": "/dotnet/desktop/wpf/aaaaaa?view=netdesktop-7.0" + // "TargetUrl": "/dotnet/desktop/wpf/aaaaaa?view=netdesktop-8.0" //}, // ======== @@ -278,42 +278,38 @@ // ======== { "Redirect": "OneWay", - "SourceUrl": "/dotnet/desktop/wpf/fundamentals/xaml?view=netdesktop-7.0", - "TargetUrl": "/dotnet/desktop/wpf/xaml/index?view=netdesktop-7.0" + "SourceUrl": "/dotnet/desktop/wpf/fundamentals/xaml?view=netdesktop-8.0", + "TargetUrl": "/dotnet/desktop/wpf/xaml/index?view=netdesktop-8.0" }, { "Redirect": "OneWay", - "SourceUrl": "/dotnet/desktop/wpf/fundamentals/xaml-resources-define?view=netdesktop-7.0", - "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-overview?view=netdesktop-7.0" + "SourceUrl": "/dotnet/desktop/wpf/fundamentals/xaml-resources-define?view=netdesktop-8.0", + "TargetUrl": "/dotnet/desktop/wpf/systems/xaml-resources-overview?view=netdesktop-8.0" }, { "Redirect": "OneWay", - "SourceUrl": "/dotnet/desktop/wpf/fundamentals/styles-templates-overview?view=netdesktop-7.0", - "TargetUrl": "/dotnet/desktop/wpf/controls/styles-templates-overview?view=netdesktop-7.0" + "SourceUrl": "/dotnet/desktop/wpf/fundamentals/styles-templates-overview?view=netdesktop-8.0", + "TargetUrl": "/dotnet/desktop/wpf/controls/styles-templates-overview?view=netdesktop-8.0" }, { "Redirect": "OneWay", - "SourceUrl": "/dotnet/desktop/wpf/fundamentals/styles-templates-create-apply-style?view=netdesktop-7.0", - "TargetUrl": "/dotnet/desktop/wpf/controls/how-to-create-apply-style?view=netdesktop-7.0" + "SourceUrl": "/dotnet/desktop/wpf/fundamentals/styles-templates-create-apply-style?view=netdesktop-8.0", + "TargetUrl": "/dotnet/desktop/wpf/controls/how-to-create-apply-style?view=netdesktop-8.0" }, { "Redirect": "OneWay", - "SourceUrl": "/dotnet/desktop/wpf/themes/how-to-create-apply-template?view=netdesktop-7.0", - "TargetUrl": "/dotnet/desktop/wpf/controls/how-to-create-apply-template?view=netdesktop-7.0" + "SourceUrl": "/dotnet/desktop/wpf/themes/how-to-create-apply-template?view=netdesktop-8.0", + "TargetUrl": "/dotnet/desktop/wpf/controls/how-to-create-apply-template?view=netdesktop-8.0" }, { "Redirect": "NormalDocId", - "SourceUrl": "/dotnet/desktop/wpf/data/data-binding-overview?view=netdesktop-7.0", - "TargetUrl": "/dotnet/desktop/wpf/data/index?view=netdesktop-7.0" - }, + "SourceUrl": "/dotnet/desktop/wpf/data/data-binding-overview?view=netdesktop-8.0", + "TargetUrl": "/dotnet/desktop/wpf/data/index?view=netdesktop-8.0" + } // ======== - // WPF Index mappings + // WPF Index mappings ... none // ======== - { - "Redirect": "Normal", - "SourceUrl": "/dotnet/desktop/wpf/whats-new/index?view=netdesktop-7.0", - "TargetUrl": "/dotnet/desktop/wpf/whats-new/net70?view=netdesktop-7.0" - } + ] } diff --git a/redirects_generator/redirects.cs b/redirects_generator/redirects.cs index 27d94b2644..a2d602e058 100644 --- a/redirects_generator/redirects.cs +++ b/redirects_generator/redirects.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; +using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; @@ -65,7 +65,7 @@ } Console.WriteLine($"Loading definitions from '{definitionsFilePath}'"); -Document document = JsonSerializer.Deserialize(System.IO.File.ReadAllText(definitionsFilePath), options); +Document definitionsDocument = JsonSerializer.Deserialize(System.IO.File.ReadAllText(definitionsFilePath), options); // Load the source redirects file RedirectsFile redirects; @@ -77,15 +77,18 @@ Counters.LoadedRedirects = redirects.redirections.Length; +// Create a copy of the existing redirects. Any left over in this collection weren't declared by the definition. +List redirectsLeftOver = new(redirects.redirections); + // Make sure there are entries -if (document.Entries.Length == 0) +if (definitionsDocument.Entries.Length == 0) { Console.WriteLine("No entries found in definition file"); Environment.Exit(0); } Console.WriteLine("Reading all entries"); -foreach (Entry item in document.Entries) +foreach (Entry item in definitionsDocument.Entries) { if (item.Redirect == RedirectType.Normal) { @@ -103,8 +106,8 @@ else { - string sourceMoniker = item.SourceUrl.Contains(document.Moniker1, StringComparison.OrdinalIgnoreCase) ? document.Moniker1 : document.Moniker2; - string targetMoniker = sourceMoniker == document.Moniker1 ? document.Moniker2 : document.Moniker1; + string sourceMoniker = item.SourceUrl.Contains(definitionsDocument.Moniker1, StringComparison.OrdinalIgnoreCase) ? definitionsDocument.Moniker1 : definitionsDocument.Moniker2; + string targetMoniker = sourceMoniker == definitionsDocument.Moniker1 ? definitionsDocument.Moniker2 : definitionsDocument.Moniker1; if (item.Redirect == RedirectType.TwoWay) { @@ -118,7 +121,23 @@ } } -Console.WriteLine($"Redirects file has {Counters.LoadedRedirects} existing entries."); +var matchedRedirects = from r in redirects.redirections + from s in definitionsDocument.Entries + where r.redirect_url == s.TargetUrl || r.redirect_url == s.SourceUrl + select r; +var unmatchedRedirects = redirects.redirections.Where(r => !matchedRedirects.Contains(r)); + +Counters.RedirectsNotDefined = unmatchedRedirects.Count(); + +Console.WriteLine($"Existing entries: {Counters.LoadedRedirects}"); +Console.WriteLine($"New entries: {Counters.NewRedirects}"); +Console.WriteLine($"Updated entries: {Counters.ModifiedRedirects}"); +Console.WriteLine($"Not-defined entries: {Counters.RedirectsNotDefined}"); + +foreach (RedirectEntry entry in unmatchedRedirects) + Console.WriteLine($" {entry.source_path}"); + +Console.WriteLine(); // After creating or updating all of the redirection entries, check to see if there were any changes if (Counters.ModifiedRedirects == 0 && Counters.NewRedirects == 0) @@ -127,15 +146,9 @@ Environment.Exit(0); } -Console.WriteLine(); -Console.WriteLine($"New entries: {Counters.NewRedirects}"); -Console.WriteLine($"Updated entries: {Counters.ModifiedRedirects}"); -Console.WriteLine(); - - // There were changes, save them. Console.WriteLine($"Erasing '{srcRedirectFilePath}'"); -System.IO.File.Delete(srcRedirectFilePath); +//System.IO.File.Delete(srcRedirectFilePath); Console.WriteLine($"Writing '{srcRedirectFilePath}'"); @@ -146,7 +159,7 @@ formattedJson += "\r\n"; // add newline at end. // Save new content to source path. -File.WriteAllText(srcRedirectFilePath, formattedJson); +//File.WriteAllText(srcRedirectFilePath, formattedJson); @@ -157,17 +170,17 @@ void CreateEntry(string sourceMoniker, string sourceUrl, string targetUrl) { // Opposite repo paths are used here according to moniker - string sourceFile = NormalizeMarkdownIndex(document.MonikerToMarkdown(sourceUrl, sourceMoniker, document.Moniker1 == sourceMoniker ? document.RepoPath2 : document.RepoPath1)); + string sourceFile = NormalizeMarkdownIndex(definitionsDocument.MonikerToMarkdown(sourceUrl, sourceMoniker, definitionsDocument.Moniker1 == sourceMoniker ? definitionsDocument.RepoPath2 : definitionsDocument.RepoPath1)); redirects.AddRedirect(sourceFile, targetUrl, false); } void CreateNormalEntry(string sourceUrl, string targetUrl, bool redirectDocId) { - if (sourceUrl.Contains(document.Moniker1, StringComparison.OrdinalIgnoreCase)) - sourceUrl = document.MonikerToMarkdown(sourceUrl, document.Moniker1, document.RepoPath1); + if (sourceUrl.Contains(definitionsDocument.Moniker1, StringComparison.OrdinalIgnoreCase)) + sourceUrl = definitionsDocument.MonikerToMarkdown(sourceUrl, definitionsDocument.Moniker1, definitionsDocument.RepoPath1); - else if (sourceUrl.Contains(document.Moniker2, StringComparison.OrdinalIgnoreCase)) - sourceUrl = document.MonikerToMarkdown(sourceUrl, document.Moniker2, document.RepoPath2); + else if (sourceUrl.Contains(definitionsDocument.Moniker2, StringComparison.OrdinalIgnoreCase)) + sourceUrl = definitionsDocument.MonikerToMarkdown(sourceUrl, definitionsDocument.Moniker2, definitionsDocument.RepoPath2); redirects.AddRedirect(sourceUrl, targetUrl, redirectDocId); } @@ -206,6 +219,7 @@ static class Counters public static int LoadedRedirects = 0; public static int NewRedirects = 0; public static int ModifiedRedirects = 0; + public static int RedirectsNotDefined = 0; } class Entry @@ -229,7 +243,7 @@ public void AddRedirect(string source, string targetUrl, bool redirectDocId) foreach (RedirectEntry item in _redirects) { - // Exisint redirect found in publishing redirection file, update it + // Existing redirect found in publishing redirection file, update it if (string.Equals(item.source_path, source, StringComparison.OrdinalIgnoreCase)) { // Entry exists and doesn't need to be modified diff --git a/redirects_generator/redirs.csproj b/redirects_generator/redirs.csproj index 99db57ebb8..a6bde46e26 100644 --- a/redirects_generator/redirs.csproj +++ b/redirects_generator/redirs.csproj @@ -9,6 +9,9 @@ Always + + Always + Always From ad49fcf61057e366cee05def726eedaf43c5d3bf Mon Sep 17 00:00:00 2001 From: "Andy De George (adegeo)" Date: Thu, 24 Oct 2024 16:32:56 -0700 Subject: [PATCH 3/3] Rename variable --- .../cs/Form1.cs | 16 ++++++++-------- .../vb/Form1.vb | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.cs b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.cs index dd103877b7..d453b72207 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.cs +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/cs/Form1.cs @@ -45,7 +45,7 @@ private float DrawFont(Graphics graphicsObj, // The OnPaint method of a form, which provides the graphics object protected override void OnPaint(PaintEventArgs e) { - PointF pointF = new PointF(10, 0); + PointF location = new PointF(10, 0); SolidBrush solidBrush = new SolidBrush(Color.Black); FontFamily[] fontFamilies; @@ -66,31 +66,31 @@ protected override void OnPaint(PaintEventArgs e) // Regular if (fontFamilies[i].IsStyleAvailable(FontStyle.Regular)) - pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Regular, solidBrush, pointF, "Regular"); + location.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Regular, solidBrush, location, "Regular"); // Bold if (fontFamilies[i].IsStyleAvailable(FontStyle.Bold)) - pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Bold, solidBrush, pointF, "Bold"); + location.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Bold, solidBrush, location, "Bold"); // Italic if (fontFamilies[i].IsStyleAvailable(FontStyle.Italic)) - pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Italic, solidBrush, pointF, "Italic"); + location.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Italic, solidBrush, location, "Italic"); // Bold and Italic if (fontFamilies[i].IsStyleAvailable(FontStyle.Bold) && fontFamilies[i].IsStyleAvailable(FontStyle.Italic)) - pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Bold | FontStyle.Italic, solidBrush, pointF, "BoldItalic"); + location.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Bold | FontStyle.Italic, solidBrush, location, "BoldItalic"); // Underline if (fontFamilies[i].IsStyleAvailable(FontStyle.Underline)) - pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Underline, solidBrush, pointF, "Underline"); + location.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Underline, solidBrush, location, "Underline"); // Strikeout if (fontFamilies[i].IsStyleAvailable(FontStyle.Strikeout)) - pointF.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Strikeout, solidBrush, pointF, "Strikeout"); + location.Y += DrawFont(e.Graphics, fontFamilies[i], FontStyle.Strikeout, solidBrush, location, "Strikeout"); // Extra space between font families - pointF.Y += 10; + location.Y += 10; } privateFontCollection.Dispose(); diff --git a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.vb b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.vb index a71bd3f330..01d1ebce86 100644 --- a/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.vb +++ b/dotnet-desktop-guide/framework/winforms/advanced/snippets/how-to-create-a-private-font-collection/vb/Form1.vb @@ -30,7 +30,7 @@ Public Class Form1 ' The OnPaint method of a form, which provides the graphics object Protected Overrides Sub OnPaint(e As PaintEventArgs) - Dim pointF As New PointF(10, 0) + Dim location As New PointF(10, 0) Dim solidBrush As New SolidBrush(Color.Black) Dim fontFamilies() As FontFamily @@ -51,37 +51,37 @@ Public Class Form1 ' Regular If fontFamilies(i).IsStyleAvailable(FontStyle.Regular) Then - pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Regular, solidBrush, pointF, "Regular") + location.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Regular, solidBrush, location, "Regular") End If ' Bold If fontFamilies(i).IsStyleAvailable(FontStyle.Bold) Then - pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Bold, solidBrush, pointF, "Bold") + location.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Bold, solidBrush, location, "Bold") End If ' Italic If fontFamilies(i).IsStyleAvailable(FontStyle.Italic) Then - pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Italic, solidBrush, pointF, "Italic") + location.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Italic, solidBrush, location, "Italic") End If ' Bold and Italic If fontFamilies(i).IsStyleAvailable(FontStyle.Italic) And fontFamilies(i).IsStyleAvailable(FontStyle.Italic) Then - pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Bold Or FontStyle.Italic, solidBrush, pointF, "BoldItalic") + location.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Bold Or FontStyle.Italic, solidBrush, location, "BoldItalic") End If ' Underline If fontFamilies(i).IsStyleAvailable(FontStyle.Underline) Then - pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Underline, solidBrush, pointF, "Underline") + location.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Underline, solidBrush, location, "Underline") End If ' Strikeout If fontFamilies(i).IsStyleAvailable(FontStyle.Strikeout) Then - pointF.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Strikeout, solidBrush, pointF, "Strikeout") + location.Y += DrawFont(e.Graphics, fontFamilies(i), FontStyle.Strikeout, solidBrush, location, "Strikeout") End If ' Extra space between font families - pointF.Y += 10 + location.Y += 10 Next