diff --git a/dotnet-desktop-guide/framework/winforms/controls/how-to-give-your-control-a-transparent-background.md b/dotnet-desktop-guide/framework/winforms/controls/how-to-give-your-control-a-transparent-background.md index 3187fac058..753872931a 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/how-to-give-your-control-a-transparent-background.md +++ b/dotnet-desktop-guide/framework/winforms/controls/how-to-give-your-control-a-transparent-background.md @@ -1,7 +1,7 @@ --- title: "How to: Give Your Control a Transparent Background" description: Learn how to give your control a transparent background using the properties window at design time. -ms.date: "03/30/2017" +ms.date: 06/12/2024 helpviewer_keywords: - "transparent backgrounds [Windows Forms], custom controls" - "custom controls [Windows Forms], transparent background" @@ -10,18 +10,19 @@ ms.assetid: 32433e63-f4e9-4305-9857-6de3edeb944a --- # How to: Give Your Control a Transparent Background -In earlier versions of the .NET Framework, controls didn't support setting transparent backcolors without first setting the method in the forms's constructor. In the current framework version, the backcolor for most controls can be set to in the **Properties** window at design time, or in code in the form's constructor. - -> [!NOTE] -> Windows Forms controls do not support true transparency. The background of a transparent Windows Forms control is painted by its parent. - +The background color for most controls can be set to in the **Properties** window at design time, or in code in the form's constructor. + +Windows Forms controls don't support _true transparency_. Controls are drawn to the screen in two parts. First, the background is painted, followed by the control's appearance. While you make a control "transparent" by setting the to , this actually passes the background painting to the parent control. If the parent control supports the `BackgroundImage` property, and the property is set, then this image is drawn as the background of the control. If the property isn't supported or isn't set, the `BackColor` of the parent is used to draw the background of the control. + +A better way to think of control "transparency" is to think of it as inheriting the **background** paint operation of the parent. You can't see other controls under a "transparent" control. + > [!NOTE] -> The control doesn't support a transparent backcolor even when the property is set to . - -### To give your control a transparent backcolor - -- In the Properties window, choose the property and set it to - +> The control allows you to set the `BackColor` to `Transparent`, but it has no effect on the control. + +## To give your control a transparent background + +- In the Properties window, choose the property and set it to + ## See also - diff --git a/dotnet-desktop-guide/framework/winforms/controls/picturebox-control-overview-windows-forms.md b/dotnet-desktop-guide/framework/winforms/controls/picturebox-control-overview-windows-forms.md index 3b0208a525..a943d4a805 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/picturebox-control-overview-windows-forms.md +++ b/dotnet-desktop-guide/framework/winforms/controls/picturebox-control-overview-windows-forms.md @@ -1,7 +1,7 @@ --- title: "PictureBox Control Overview" description: This article provides an overview of the PictureBox control in Windows Forms, which is used to display graphics in bitmap, GIF, JPEG, metafile, or icon format. -ms.date: "03/30/2017" +ms.date: 06/12/2024 f1_keywords: - "PictureBox" helpviewer_keywords: @@ -17,7 +17,19 @@ The Windows Forms control is used to disp ## Key Properties and Methods The picture that is displayed is determined by the property, which can be set at run time or at design time. You can alternatively specify the image by setting the property and then load the image synchronously using the method or asynchronously using the method. The property controls how the image and control fit with each other. For more information, see [How to: Modify the Size or Placement of a Picture at Run Time](how-to-modify-the-size-or-placement-of-a-picture-at-run-time-windows-forms.md). - + +## Transparent images + +The following image formats are supported for transparency: + +- 32-bit PNG +- 8-bit PNG +- 32-bit BMP +- 32-bit TIFF +- GIF + +Image transparency doesn't show other controls behind the `PictureBox` control. It only shows the background of the control. + ## See also - diff --git a/dotnet-desktop-guide/framework/winforms/controls/tablelayoutpanel-control-overview.md b/dotnet-desktop-guide/framework/winforms/controls/tablelayoutpanel-control-overview.md index 903a80996c..fb372aeb40 100644 --- a/dotnet-desktop-guide/framework/winforms/controls/tablelayoutpanel-control-overview.md +++ b/dotnet-desktop-guide/framework/winforms/controls/tablelayoutpanel-control-overview.md @@ -17,7 +17,7 @@ description: Learn how the TableLayoutPanel control arranges its content in a gr The control arranges its contents in a grid. Because the layout is performed both at design time and run time, it can change dynamically as the application environment changes. This gives the controls in the panel the ability to proportionally resize, so they can respond to changes such as the parent control resizing or text length changing due to localization. - Any Windows Forms control can be a child of the control, including other instances of . This allows you to construct sophisticated layouts that adapt to changes at run time. + Any Windows Forms control can be a child of the control, including other instances of . This allows you to construct sophisticated layouts that adapt to changes at run time. However, only a single control can exist in a cell. If you want more than one control in a cell, you must group the controls in a `UserControl` or another layout control such as `Panel` or`TableLayoutPanel`. The control can expand to accommodate new controls when they are added, depending on the value of the , , and properties. Setting either the or property to a value of 0 specifies that the will be unbound in the corresponding direction. diff --git a/dotnet-desktop-guide/framework/wpf/advanced/technology-regions-overview.md b/dotnet-desktop-guide/framework/wpf/advanced/technology-regions-overview.md index 6ca90c23cd..385add5131 100644 --- a/dotnet-desktop-guide/framework/wpf/advanced/technology-regions-overview.md +++ b/dotnet-desktop-guide/framework/wpf/advanced/technology-regions-overview.md @@ -56,7 +56,9 @@ If multiple presentation technologies are used in an application, such as WPF, W - WPF supports hardware accelerated layered windows. - WPF does not support transparency color keys, because WPF cannot guarantee to render the exact color you requested, particularly when rendering is hardware-accelerated. - + +For more information regarding the limitations of interop regions, see [HWNDs inside WPF](wpf-and-win32-interoperation.md#hwnds-inside-wpf). + ## See also - [WPF and Win32 Interoperation](wpf-and-win32-interoperation.md) diff --git a/dotnet-desktop-guide/framework/wpf/app-development/persist-and-restore-application-scope-properties.md b/dotnet-desktop-guide/framework/wpf/app-development/persist-and-restore-application-scope-properties.md index 8693aa36c1..ac993af3cb 100644 --- a/dotnet-desktop-guide/framework/wpf/app-development/persist-and-restore-application-scope-properties.md +++ b/dotnet-desktop-guide/framework/wpf/app-development/persist-and-restore-application-scope-properties.md @@ -1,7 +1,7 @@ --- title: "How to: Persist and Restore Application-Scope Properties Across Application Sessions" description: Learn how to persist and restore application-scope properties across application sessions via included code examples in XAML, C#, and Visual Basic. -ms.date: "03/30/2017" +ms.date: 06/13/2024 dev_langs: - "csharp" - "vb" @@ -18,11 +18,17 @@ ms.assetid: 55d5904a-f444-4eb5-abd3-6bc74dd14226 This example shows how to persist application-scope properties when an application shuts down, and how to restore application-scope properties when an application is next launched. -## Example +## Example - The application persists application-scope properties to, and restores them from, isolated storage. Isolated storage is a protected storage area that can safely be used by applications without file access permission. The *App.xaml* file defines the `App_Startup` method as the handler for the event, and the `App_Exit` method as the handler for the event, as shown in the highlighted lines of the first example. The second example shows a portion of the *App.xaml.cs* and *App.xaml.vb* files that highlights the code for the `App_Startup` method, which restores application-scope properties, and the `App_Exit` method, which saves application-scope properties. +The application persists application-scope properties to, and restores them from, isolated storage. Isolated storage is a protected storage area that can safely be used by applications without file access permission. The *App.xaml* file defines the `App_Startup` method as the handler for the event, and the `App_Exit` method as the handler for the event, as shown in the highlighted lines of the following XAML: - [!code-xaml[HOWTOApplicationModelSnippets#PersistRestoreAppScopePropertiesXAML1](~/samples/snippets/csharp/VS_Snippets_Wpf/HOWTOApplicationModelSnippets/CSharp/App.xaml?highlight=1-7)] - - [!code-csharp[HOWTOApplicationModelSnippets#PersistRestoreAppScopePropertiesCODEBEHIND1](~/samples/snippets/csharp/VS_Snippets_Wpf/HOWTOApplicationModelSnippets/CSharp/App.xaml.cs?highlight=17-55)] - [!code-vb[HOWTOApplicationModelSnippets#PersistRestoreAppScopePropertiesCODEBEHIND1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/HOWTOApplicationModelSnippets/visualbasic/application.xaml.vb?highlight=14-45)] +> [!NOTE] +> The following XAML is written for CSharp. The Visual Basic version omits the class declaration. + +:::code language="xaml" source="./snippets/persist-and-restore-application-scope-properties/csharp/App.xaml" highlight="5,6"::: + +This next example shows the Application code-behind, which contains the event handlers for the XAML. The `App_Startup` method restores application-scope properties, and the `App_Exit` method saves application-scope properties. + +:::code language="csharp" source="./snippets/persist-and-restore-application-scope-properties/csharp/App.xaml.cs"::: + +:::code language="vb" source="./snippets/persist-and-restore-application-scope-properties/vb/Application.xaml.vb"::: diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/App.xaml b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/App.xaml new file mode 100644 index 0000000000..d7d155ed9b --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/App.xaml @@ -0,0 +1,7 @@ + + diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/App.xaml.cs b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/App.xaml.cs new file mode 100644 index 0000000000..1a877fc76f --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/App.xaml.cs @@ -0,0 +1,66 @@ +using System.IO.IsolatedStorage; +using System.IO; +using System.Windows; + +namespace SDKSamples +{ + public partial class App : Application + { + string _filename = "App.data"; + + public App() + { + // Initialize application-scope property + Properties["NumberOfAppSessions"] = "0"; + } + + private void App_Startup(object sender, StartupEventArgs e) + { + // Restore application-scope property from isolated storage + IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForDomain(); + try + { + if (storage.FileExists(_filename)) + { + using (IsolatedStorageFileStream stream = storage.OpenFile(_filename, FileMode.Open, FileAccess.Read)) + using (StreamReader reader = new StreamReader(stream)) + { + // Restore each application-scope property individually + while (!reader.EndOfStream) + { + string[] keyValue = reader.ReadLine().Split(new char[] { ',' }); + Properties[keyValue[0]] = keyValue[1]; + } + } + } + } + catch (DirectoryNotFoundException ex) + { + // Path the file didn't exist + } + catch (IsolatedStorageException ex) + { + // Storage was removed or doesn't exist + // -or- + // If using .NET 6+ the inner exception contains the real cause + } + } + + private void App_Exit(object sender, ExitEventArgs e) + { + // Increase the amount of times the app was opened + Properties["NumberOfAppSessions"] = int.Parse((string)Properties["NumberOfAppSessions"]) + 1; + + // Persist application-scope property to isolated storage + IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForDomain(); + using (IsolatedStorageFileStream stream = storage.OpenFile(_filename, FileMode.Create, FileAccess.Write)) + using (StreamWriter writer = new StreamWriter(stream)) + { + // Persist each application-scope property individually + foreach (string key in Properties.Keys) + writer.WriteLine("{0},{1}", key, Properties[key]); + } + } + } + +} diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/AssemblyInfo.cs b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/AssemblyInfo.cs new file mode 100644 index 0000000000..cc29e7f741 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/MainWindow.xaml b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/MainWindow.xaml new file mode 100644 index 0000000000..b31dbd884b --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/MainWindow.xaml @@ -0,0 +1,14 @@ + + + + diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/MainWindow.xaml.cs b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/MainWindow.xaml.cs new file mode 100644 index 0000000000..0b0203e2e9 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/MainWindow.xaml.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace SDKSamples +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + lblTimes.Content = App.Current.Properties["NumberOfAppSessions"]; + } + } +} diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/ProjectCS.csproj b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/ProjectCS.csproj new file mode 100644 index 0000000000..0336b4ecc2 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/ProjectCS.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net481 + true + SDKSamples + app.manifest + + + diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/app.manifest b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/app.manifest new file mode 100644 index 0000000000..c522bb43f3 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/csharp/app.manifest @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/App.config b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/App.config new file mode 100644 index 0000000000..aee9adf485 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/Application.xaml b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/Application.xaml new file mode 100644 index 0000000000..fbdd38f974 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/Application.xaml @@ -0,0 +1,7 @@ + + diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/Application.xaml.vb b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/Application.xaml.vb new file mode 100644 index 0000000000..071593cd42 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/Application.xaml.vb @@ -0,0 +1,61 @@ +Imports System.IO +Imports System.IO.IsolatedStorage + +Class Application + + Private _filename As String = "App.data" + + Public Sub New() + ' Initialize application-scope property + Properties("NumberOfAppSessions") = "0" + End Sub + + Private Sub App_Startup(ByVal sender As Object, ByVal e As StartupEventArgs) + ' Restore application-scope property from isolated storage + Dim storage As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForDomain() + Try + If storage.FileExists(_filename) Then + + Using stream As IsolatedStorageFileStream = storage.OpenFile(_filename, FileMode.Open, FileAccess.Read) + Using reader As New StreamReader(stream) + + ' Restore each application-scope property individually + Do While Not reader.EndOfStream + Dim keyValue() As String = reader.ReadLine().Split(New Char() {","c}) + Properties(keyValue(0)) = keyValue(1) + Loop + + End Using + End Using + + End If + + Catch ex As DirectoryNotFoundException + ' Path the file didn't exist + Catch ex As IsolatedStorageException + ' Storage was removed or doesn't exist + ' -or- + ' If using .NET 6+ the inner exception contains the real cause + End Try + End Sub + + Private Sub App_Exit(ByVal sender As Object, ByVal e As ExitEventArgs) + 'Increase the amount of times the app was opened + Properties("NumberOfAppSessions") = Integer.Parse(DirectCast(Properties("NumberOfAppSessions"), String)) + 1 + + ' Persist application-scope property to isolated storage + Dim storage As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForDomain() + + Using stream As IsolatedStorageFileStream = storage.OpenFile(_filename, FileMode.Create, FileAccess.Write) + Using writer As New StreamWriter(stream) + + ' Persist each application-scope property individually + For Each key As String In Properties.Keys + writer.WriteLine("{0},{1}", key, Properties(key)) + Next key + + End Using + End Using + End Sub + +End Class diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/AssemblyInfo.vb b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/AssemblyInfo.vb new file mode 100644 index 0000000000..025ee7271e --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/AssemblyInfo.vb @@ -0,0 +1,11 @@ +Imports System.Windows + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/MainWindow.xaml b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/MainWindow.xaml new file mode 100644 index 0000000000..d37697b764 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/MainWindow.xaml @@ -0,0 +1,14 @@ + + + + diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/MainWindow.xaml.vb b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/MainWindow.xaml.vb new file mode 100644 index 0000000000..0f149c6098 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/MainWindow.xaml.vb @@ -0,0 +1,5 @@ +Public Class MainWindow + Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs) + lblTimes.Content = Application.Current.Properties("NumberOfAppSessions") + End Sub +End Class diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/AssemblyInfo.vb b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/AssemblyInfo.vb new file mode 100644 index 0000000000..0c518abf27 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Globalization +Imports System.Reflection +Imports System.Resources +Imports System.Runtime.InteropServices +Imports System.Windows + +' 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 + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'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/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/MyExtensions/MyWpfExtension.vb b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 0000000000..22f84b7da5 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return CType(Global.System.Windows.Application.Current, Application) + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Resources.Designer.vb b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Resources.Designer.vb new file mode 100644 index 0000000000..e7ecddcab6 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' 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("$safeprojectname$.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/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Resources.resx b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/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/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Settings.Designer.vb b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Settings.Designer.vb new file mode 100644 index 0000000000..51901f82e0 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/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.SDKSamples.My.MySettings + Get + Return Global.SDKSamples.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Settings.settings b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Settings.settings new file mode 100644 index 0000000000..40ed9fdbad --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/ProjectVB.vbproj b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/ProjectVB.vbproj new file mode 100644 index 0000000000..2198311849 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/ProjectVB.vbproj @@ -0,0 +1,136 @@ + + + + Debug + AnyCPU + {7D142ED4-D5D6-4680-BD9E-290CA944A377} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + SDKSamples + ThreadExample + v4.8.1 + Custom + true + true + + + AnyCPU + true + full + true + true + true + bin\Debug\ + ThreadExample.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + AnyCPU + pdbonly + false + false + true + false + true + bin\Release\ + ThreadExample.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + 4.0 + + + + + + + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + + MainWindow.xaml + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + + + + Designer + MSBuild:Compile + + + + \ No newline at end of file diff --git a/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/snippets.5000.json b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/snippets.5000.json new file mode 100644 index 0000000000..da9ebf8da2 --- /dev/null +++ b/dotnet-desktop-guide/framework/wpf/app-development/snippets/persist-and-restore-application-scope-properties/vb/snippets.5000.json @@ -0,0 +1,3 @@ +{ + "host": "visualstudio" +} diff --git a/dotnet-desktop-guide/framework/wpf/data/data-binding-overview.md b/dotnet-desktop-guide/framework/wpf/data/data-binding-overview.md index deee9a7c90..60cdd00923 100644 --- a/dotnet-desktop-guide/framework/wpf/data/data-binding-overview.md +++ b/dotnet-desktop-guide/framework/wpf/data/data-binding-overview.md @@ -331,7 +331,7 @@ You can implement the master-detail scenario simply by having two or more contro [!code-xaml[ListBoxContentControl](./snippets/data-binding-overview/csharp/CollectionView.xaml#ListBoxContentControl)] -Notice that both of the controls are bound to the same source, the *listingDataView* static resource (see the definition of this resource in the [How to create a view section](#how-to-create-a-view)). This binding works because when a singleton object (the in this case) is bound to a collection view, it automatically binds to the of the view. The objects automatically synchronize currency and selection. If your list control is not bound to a object as in this example, then you would need to set its property to `true` for this to work. +Notice that both of the controls are bound to the same source, the *listingDataView* static resource (see the definition of this resource in the [How to create a view section](#how-to-create-a-view)). This binding works because when an object (the in this case) is bound to a collection view, it automatically binds to the of the view. The objects automatically synchronize currency and selection. If your list control is not bound to a object as in this example, then you would need to set its property to `true` for this to work. For other examples, see [Bind to a collection and display information based on selection](how-to-bind-to-a-collection-and-display-information-based-on-selection.md) and [Use the master-detail pattern with hierarchical data](how-to-use-the-master-detail-pattern-with-hierarchical-data.md). diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-shape-using-a-streamgeometry.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-shape-using-a-streamgeometry.md index cb5b9588c1..38299fc22b 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-shape-using-a-streamgeometry.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-shape-using-a-streamgeometry.md @@ -39,8 +39,8 @@ ms.assetid: 08f7c8ce-074b-49cd-9aba-cc9592d4ee51 ## See also +- [Create a Shape by Using a PathGeometry](how-to-create-a-shape-by-using-a-pathgeometry.md) +- [Geometry Overview](geometry-overview.md) - - - -- [Create a Shape by Using a PathGeometry](how-to-create-a-shape-by-using-a-pathgeometry.md) -- [Geometry Overview](geometry-overview.md) diff --git a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/shapes-and-basic-drawing-in-wpf-overview.md b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/shapes-and-basic-drawing-in-wpf-overview.md index dce9322062..664d5bb1e1 100644 --- a/dotnet-desktop-guide/framework/wpf/graphics-multimedia/shapes-and-basic-drawing-in-wpf-overview.md +++ b/dotnet-desktop-guide/framework/wpf/graphics-multimedia/shapes-and-basic-drawing-in-wpf-overview.md @@ -20,6 +20,8 @@ This topic gives an overview of how to draw with objects are easy to use and provide many useful features, such as layout and participation in the Windows Presentation Foundation (WPF) event system. +Shape-related types are in the `Windows.Shapes` namespace. Geometry-related types are in the `System.Windows.Media` namespace. + ## Shape Objects diff --git a/dotnet-desktop-guide/net/winforms/printing/how-to-print-windows-form.md b/dotnet-desktop-guide/net/winforms/printing/how-to-print-windows-form.md index 9d4981a270..4e95822b10 100644 --- a/dotnet-desktop-guide/net/winforms/printing/how-to-print-windows-form.md +++ b/dotnet-desktop-guide/net/winforms/printing/how-to-print-windows-form.md @@ -17,10 +17,19 @@ ms.custom: devdivchpfy22 As part of the development process, you typically will want to print a copy of your Windows Form. The following code example shows how to print a copy of the current form by using the method. -In the following example, a button named **Button1** is added to the form. When the **Button1** button is clicked, it saves the form to an image in memory, and then sends it to the print object. - ## Example +To run the example code, add two components to a form with the following settings: + +| Object | Property\Event | Value | +|-------------------|----------------|------------------| +| **Button** | `Name` | `Button1` | +| | `Click` | `Button1_Click` | +| **PrintDocument** | `Name` | `PrintDocument1` | +| | `PrintPage` | `PrintDocument1_PrintPage` | + +The following code is run when the `Button1` is clicked. The code creates a `Graphics` object from the form and saves its contents to a `Bitmap` variable named `memoryImage`. The method is called, which invokes the event. The print event handler draws the `memoryImage` bitmap on the printer page's `Graphics` object. When the print event handler code returns, the page is printed. + :::code language="csharp" source="snippets/how-to-print-windows-form/csharp/Form1.cs"::: :::code language="vb" source="snippets/how-to-print-windows-form/vb/Form1.vb"::: diff --git a/dotnet-desktop-guide/net/winforms/printing/snippets/how-to-print-windows-form/csharp/Form1.cs b/dotnet-desktop-guide/net/winforms/printing/snippets/how-to-print-windows-form/csharp/Form1.cs index 8e087622f7..101e19dc37 100644 --- a/dotnet-desktop-guide/net/winforms/printing/snippets/how-to-print-windows-form/csharp/Form1.cs +++ b/dotnet-desktop-guide/net/winforms/printing/snippets/how-to-print-windows-form/csharp/Form1.cs @@ -15,13 +15,15 @@ private void Button1_Click(object sender, EventArgs e) memoryImage = new Bitmap(s.Width, s.Height, myGraphics); Graphics memoryGraphics = Graphics.FromImage(memoryImage); memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s); - + printDocument1.Print(); - } - private void PrintDocument1_PrintPage(System.Object sender, - System.Drawing.Printing.PrintPageEventArgs e) => - e.Graphics.DrawImage(memoryImage, 0, 0); - + + private void PrintDocument1_PrintPage( + System.Object sender, + System.Drawing.Printing.PrintPageEventArgs e) + { + e.Graphics.DrawImage(memoryImage, 0, 0); + } } -} \ No newline at end of file +} diff --git a/dotnet-desktop-guide/net/winforms/printing/snippets/how-to-print-windows-form/vb/Form1.vb b/dotnet-desktop-guide/net/winforms/printing/snippets/how-to-print-windows-form/vb/Form1.vb index d5b37d38e2..16ca15a632 100644 --- a/dotnet-desktop-guide/net/winforms/printing/snippets/how-to-print-windows-form/vb/Form1.vb +++ b/dotnet-desktop-guide/net/winforms/printing/snippets/how-to-print-windows-form/vb/Form1.vb @@ -2,13 +2,6 @@ Dim memoryImage As Bitmap - Private Sub printDocument1_PrintPage(ByVal sender As System.Object, - ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage - - e.Graphics.DrawImage(memoryImage, 0, 0) - - End Sub - Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim myGraphics As Graphics = Me.CreateGraphics() @@ -20,4 +13,12 @@ PrintDocument1.Print() End Sub + + Private Sub PrintDocument1_PrintPage( + ByVal sender As System.Object, + ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage + + e.Graphics.DrawImage(memoryImage, 0, 0) + + End Sub End Class diff --git a/dotnet-desktop-guide/net/wpf/data/index.md b/dotnet-desktop-guide/net/wpf/data/index.md index c5c86061a9..f7583bb513 100644 --- a/dotnet-desktop-guide/net/wpf/data/index.md +++ b/dotnet-desktop-guide/net/wpf/data/index.md @@ -355,7 +355,7 @@ You can implement the master-detail scenario simply by having two or more contro :::code language="xaml" source="./snippets/index/csharp/CollectionView.xaml" id="ListBoxContentControl"::: -Notice that both of the controls are bound to the same source, the *listingDataView* static resource (see the definition of this resource in the [How to create a view section](#how-to-create-a-view)). This binding works because when a singleton object (the in this case) is bound to a collection view, it automatically binds to the of the view. The objects automatically synchronize currency and selection. If your list control isn't bound to a object as in this example, then you would need to set its property to `true` for this to work. +Notice that both of the controls are bound to the same source, the *listingDataView* static resource (see the definition of this resource in the [How to create a view section](#how-to-create-a-view)). This binding works because when an object (the in this case) is bound to a collection view, it automatically binds to the of the view. The objects automatically synchronize currency and selection. If your list control isn't bound to a object as in this example, then you would need to set its property to `true` for this to work. For other examples, see [Bind to a collection and display information based on selection (.NET Framework)](../../../framework/wpf/data/how-to-bind-to-a-collection-and-display-information-based-on-selection.md) and [Use the master-detail pattern with hierarchical data (.NET Framework)](../../../framework/wpf/data/how-to-use-the-master-detail-pattern-with-hierarchical-data.md). diff --git a/dotnet-desktop-guide/net/wpf/overview/index.md b/dotnet-desktop-guide/net/wpf/overview/index.md index a5f0a7595f..06d8ea5d45 100644 --- a/dotnet-desktop-guide/net/wpf/overview/index.md +++ b/dotnet-desktop-guide/net/wpf/overview/index.md @@ -71,7 +71,7 @@ The following example uses XAML to implement the appearance of a window that con ```xaml @@ -97,7 +97,7 @@ The main behavior of an application is to implement the functionality that respo xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SDKSample.AWindow" - Title="Window with Button" + Title="Window with button" Width="250" Height="100"> diff --git a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/CSharp/StreamGeometryExample.cs b/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/CSharp/StreamGeometryExample.cs index a4fe1a8bfe..c57bf5d1b3 100644 --- a/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/CSharp/StreamGeometryExample.cs +++ b/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/CSharp/StreamGeometryExample.cs @@ -44,8 +44,6 @@ StreamGeometry BuildRegularPolygon(Point c, double r, int numSides, double offse using (StreamGeometryContext ctx = geometry.Open()) { - ctx.BeginFigure(new Point(), true /* is filled */, true /* is closed */); - double step = 2 * Math.PI / Math.Max(numSides, 3); Point cur = c; @@ -54,7 +52,10 @@ StreamGeometry BuildRegularPolygon(Point c, double r, int numSides, double offse { cur.X = c.X + r * Math.Cos(a); cur.Y = c.Y + r * Math.Sin(a); - ctx.LineTo(cur, true /* is stroked */, false /* is smooth join */); + if (i == 0) + ctx.BeginFigure(cur, true /* is filled */, true /* is closed */); + else + ctx.LineTo(cur, true /* is stroked */, false /* is smooth join */); } } @@ -62,4 +63,4 @@ StreamGeometry BuildRegularPolygon(Point c, double r, int numSides, double offse } } } -// \ No newline at end of file +// diff --git a/dotnet-desktop-guide/samples/snippets/visualbasic/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/visualbasic/streamgeometryexample.vb b/dotnet-desktop-guide/samples/snippets/visualbasic/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/visualbasic/streamgeometryexample.vb index 21209e3fa8..b5aef5b2cb 100644 --- a/dotnet-desktop-guide/samples/snippets/visualbasic/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/visualbasic/streamgeometryexample.vb +++ b/dotnet-desktop-guide/samples/snippets/visualbasic/VS_Snippets_Wpf/GeometriesMiscSnippets_procedural_snip/visualbasic/streamgeometryexample.vb @@ -6,58 +6,62 @@ Imports System.Windows.Media Imports System.Windows.Shapes Namespace SDKSample - Partial Public Class StreamGeometryExample - Inherits Page - Public Sub New() - ' Create a path to draw a geometry with. - Dim myPath As New Path() - myPath.Stroke = Brushes.Black - myPath.StrokeThickness = 1 - - ' Create a StreamGeometry to use to specify myPath. - Dim theGeometry As StreamGeometry = BuildRegularPolygon(New Point(200, 200), 200, 8, 0) - theGeometry.FillRule = FillRule.EvenOdd - - ' Freeze the geometry (make it unmodifiable) - ' for additional performance benefits. - theGeometry.Freeze() - - ' Use the StreamGeometry returned by the BuildRegularPolygon to - ' specify the shape of the path. - myPath.Data = theGeometry - - ' Add path shape to the UI. - Dim mainPanel As New StackPanel() - mainPanel.Children.Add(myPath) - Me.Content = mainPanel - End Sub - - Private Function BuildRegularPolygon(ByVal c As Point, ByVal r As Double, ByVal numSides As Integer, ByVal offsetDegree As Double) As StreamGeometry - ' c is the center, r is the radius, - ' numSides the number of sides, offsetDegree the offset in Degrees. - ' Do not add the last point. - - Dim geometry As New StreamGeometry() - - Using ctx As StreamGeometryContext = geometry.Open() - ctx.BeginFigure(New Point(), True, True) ' is closed - is filled - - Dim [step] As Double = 2 * Math.PI / Math.Max(numSides, 3) - Dim cur As Point = c - - Dim a As Double = Math.PI * offsetDegree / 180.0 - Dim i As Integer = 0 - Do While i < numSides - cur.X = c.X + r * Math.Cos(a) - cur.Y = c.Y + r * Math.Sin(a) - ctx.LineTo(cur, True, False) ' is smooth join - is stroked - i += 1 - a += [step] - Loop - End Using - - Return geometry - End Function - End Class + Partial Public Class StreamGeometryExample + Inherits Page + Public Sub New() + ' Create a path to draw a geometry with. + Dim myPath As New Path() + myPath.Stroke = Brushes.Black + myPath.StrokeThickness = 1 + + ' Create a StreamGeometry to use to specify myPath. + Dim theGeometry As StreamGeometry = BuildRegularPolygon(New Point(200, 200), 200, 8, 0) + theGeometry.FillRule = FillRule.EvenOdd + + ' Freeze the geometry (make it unmodifiable) + ' for additional performance benefits. + theGeometry.Freeze() + + ' Use the StreamGeometry returned by the BuildRegularPolygon to + ' specify the shape of the path. + myPath.Data = theGeometry + + ' Add path shape to the UI. + Dim mainPanel As New StackPanel() + mainPanel.Children.Add(myPath) + Me.Content = mainPanel + End Sub + + Private Function BuildRegularPolygon(ByVal c As Point, ByVal r As Double, ByVal numSides As Integer, ByVal offsetDegree As Double) As StreamGeometry + ' c is the center, r is the radius, + ' numSides the number of sides, offsetDegree the offset in Degrees. + ' Do not add the last point. + + Dim geometry As New StreamGeometry() + + Using ctx As StreamGeometryContext = geometry.Open() + + Dim [step] As Double = 2 * Math.PI / Math.Max(numSides, 3) + Dim cur As Point = c + + Dim a As Double = Math.PI * offsetDegree / 180.0 + Dim i As Integer = 0 + + For i = 0 To numSides - 1 + cur.X = c.X + r * Math.Cos(a) + cur.Y = c.Y + r * Math.Sin(a) + If i = 0 Then + ctx.BeginFigure(cur, True, True) ' is closed - is filled + Else + ctx.LineTo(cur, True, False) ' is smooth join - is stroked + End If + a += [step] + Next + + End Using + + Return geometry + End Function + End Class End Namespace -' \ No newline at end of file +' diff --git a/quest-config.json b/quest-config.json index db6b6c30a2..1661fbf933 100644 --- a/quest-config.json +++ b/quest-config.json @@ -15,14 +15,14 @@ "Label": "okr-curation", "ParentNodeId": 237271 }, - { - "Label": "okr-health", - "ParentNodeId": 237266 - }, { "Label": "user-feedback", "ParentNodeId": 233465 }, + { + "Label": "okr-health", + "ParentNodeId": 237266 + }, { "Label": "doc-bug", "ParentNodeId": 233465 @@ -32,5 +32,11 @@ "ParentNodeId": 227484 } ], - "DefaultParentNode": 227223 + "DefaultParentNode": 227223, + "WorkItemTags": [ + { + "Label": "user-feedback", + "Tag": "customer-fixed" + } + ] }