Skip to content

Commit 584b566

Browse files
authored
Reorganize WinForms C# snippets (#7676)
1 parent 3343a70 commit 584b566

File tree

2,234 files changed

+6130
-6956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,234 files changed

+6130
-6956
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>net6.0-windows</TargetFrameworks>
6+
<UseWindowsForms>true</UseWindowsForms>
7+
<StartupObject>BackgroundWorkerSimple.Program</StartupObject>
8+
</PropertyGroup>
9+
10+
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
42
using System.Windows.Forms;
53

64
namespace BackgroundWorkerSimple
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// <snippet100>
2-
using System;
32
using System.ComponentModel;
4-
using System.ComponentModel.Design;
5-
using System.Text;
63
using System.Windows.Forms;
7-
using System.Windows.Forms.Design;
84

95
namespace ReadOnlyPropertyDescriptorTest
106
{
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// <snippet10>
2-
using System;
32
using System.Collections;
43
using System.ComponentModel;
5-
using System.Text;
64
using System.Windows.Forms.Design;
75

86
namespace ReadOnlyPropertyDescriptorTest
9-
{
7+
{
108
class DemoControlDesigner : ControlDesigner
119
{
1210
// The PostFilterProperties method replaces the control's
@@ -27,4 +25,4 @@ protected override void PostFilterProperties(IDictionary properties)
2725
}
2826
}
2927
}
30-
// </snippet10>
28+
// </snippet10>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>net6.0-windows</TargetFrameworks>
6+
<UseWindowsForms>true</UseWindowsForms>
7+
</PropertyGroup>
8+
9+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
using System;
2+
using System.ComponentModel;
3+
using System.Windows.Forms;
4+
5+
namespace MyPropertyDescriptor
6+
{
7+
/// <summary>
8+
/// Summary description for Form1.
9+
/// </summary>
10+
public class Form1 : Form
11+
{
12+
private TextBox textBox1;
13+
private Button button1;
14+
/// <summary>
15+
/// Required designer variable.
16+
/// </summary>
17+
private System.ComponentModel.Container components = null;
18+
19+
public Form1()
20+
{
21+
//
22+
// Required for Windows Form Designer support
23+
//
24+
InitializeComponent();
25+
26+
//
27+
// TODO: Add any constructor code after InitializeComponent call
28+
//
29+
}
30+
31+
/// <summary>
32+
/// Clean up any resources being used.
33+
/// </summary>
34+
protected override void Dispose(bool disposing)
35+
{
36+
if (disposing)
37+
{
38+
if (components != null)
39+
{
40+
components.Dispose();
41+
}
42+
}
43+
base.Dispose(disposing);
44+
}
45+
46+
#region Windows Form Designer generated code
47+
/// <summary>
48+
/// Required method for Designer support - do not modify
49+
/// the contents of this method with the code editor.
50+
/// </summary>
51+
private void InitializeComponent()
52+
{
53+
this.textBox1 = new TextBox();
54+
this.button1 = new Button();
55+
this.SuspendLayout();
56+
//
57+
// textBox1
58+
//
59+
this.textBox1.Location = new System.Drawing.Point(120, 16);
60+
this.textBox1.Multiline = true;
61+
this.textBox1.Name = "textBox1";
62+
this.textBox1.ScrollBars = ScrollBars.Vertical;
63+
this.textBox1.Size = new System.Drawing.Size(288, 272);
64+
this.textBox1.TabIndex = 0;
65+
this.textBox1.Text = "textBox1";
66+
//
67+
// button1
68+
//
69+
this.button1.Location = new System.Drawing.Point(40, 112);
70+
this.button1.Name = "button1";
71+
this.button1.TabIndex = 1;
72+
this.button1.Text = "button1";
73+
//
74+
// Form1
75+
//
76+
this.ClientSize = new System.Drawing.Size(448, 333);
77+
this.Controls.AddRange(new Control[] {
78+
this.button1,
79+
this.textBox1});
80+
this.Name = "Form1";
81+
this.Text = "Form1";
82+
this.Load += new System.EventHandler(this.Form1_Load);
83+
this.ResumeLayout(false);
84+
}
85+
#endregion
86+
87+
/// <summary>
88+
/// The main entry point for the application.
89+
/// </summary>
90+
[STAThread]
91+
static void Main()
92+
{
93+
Application.Run(new Form1());
94+
}
95+
96+
private void Form1_Load(object sender, System.EventArgs e)
97+
{
98+
//<snippet1>
99+
// Creates a new collection and assign it the properties for button1.
100+
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
101+
102+
// Sets an PropertyDescriptor to the specific property.
103+
System.ComponentModel.PropertyDescriptor myProperty = properties.Find("Text", false);
104+
105+
// Prints the property and the property description.
106+
textBox1.Text = myProperty.DisplayName + '\n';
107+
textBox1.Text += myProperty.Description + '\n';
108+
textBox1.Text += myProperty.Category + '\n';
109+
//</snippet1>
110+
}
111+
}
112+
}

snippets/csharp/VS_Snippets_Winforms/ClickOnceAPI/CS/ClickOnceAPI.csproj renamed to snippets/csharp/System.Deployment.Application/ApplicationDeployment/Overview/ClickOnceAPI.csproj

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
22
<PropertyGroup>
33
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
44
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -26,6 +26,13 @@
2626
<MapFileExtensions>false</MapFileExtensions>
2727
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
2828
<BootstrapperEnabled>true</BootstrapperEnabled>
29+
<FileUpgradeFlags>
30+
</FileUpgradeFlags>
31+
<UpgradeBackupLocation>
32+
</UpgradeBackupLocation>
33+
<OldToolsVersion>2.0</OldToolsVersion>
34+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
35+
<TargetFrameworkProfile />
2936
</PropertyGroup>
3037
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
3138
<DebugSymbols>true</DebugSymbols>
@@ -35,6 +42,7 @@
3542
<DefineConstants>DEBUG;TRACE</DefineConstants>
3643
<ErrorReport>prompt</ErrorReport>
3744
<WarningLevel>4</WarningLevel>
45+
<Prefer32Bit>false</Prefer32Bit>
3846
</PropertyGroup>
3947
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
4048
<DebugType>pdbonly</DebugType>
@@ -43,6 +51,7 @@
4351
<DefineConstants>TRACE</DefineConstants>
4452
<ErrorReport>prompt</ErrorReport>
4553
<WarningLevel>4</WarningLevel>
54+
<Prefer32Bit>false</Prefer32Bit>
4655
</PropertyGroup>
4756
<ItemGroup>
4857
<Reference Include="System" />
@@ -73,7 +82,9 @@
7382
<Compile Include="Properties\Resources.Designer.cs">
7483
<AutoGen>True</AutoGen>
7584
<DependentUpon>Resources.resx</DependentUpon>
85+
<DesignTime>True</DesignTime>
7686
</Compile>
87+
<None Include="app.config" />
7788
<None Include="ClickOnceAPI.pfx" />
7889
<None Include="Properties\Settings.settings">
7990
<Generator>SettingsSingleFileGenerator</Generator>
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"host": "visualstudio"
3+
}

0 commit comments

Comments
 (0)