Skip to content

Commit 86a04dc

Browse files
committed
Create First Project to replace AIPrompt code snippet
1 parent 8b59a18 commit 86a04dc

11 files changed

Lines changed: 360 additions & 12 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Build WinForms Solutions
2+
3+
on:
4+
push:
5+
paths:
6+
- '**/*.md'
7+
- 'snippets/**'
8+
pull_request:
9+
paths:
10+
- '**/*.md'
11+
- 'snippets/**'
12+
workflow_dispatch:
13+
14+
jobs:
15+
build:
16+
runs-on: windows-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Detect snippet or folder changes
23+
id: snippet_check
24+
shell: pwsh
25+
run: |
26+
git fetch --no-tags --prune --depth=0 origin
27+
# Determine comparison base (works for push + PR)
28+
if ("${{ github.event_name }}" -eq "pull_request") {
29+
$base = "${{ github.event.pull_request.base.sha }}"
30+
} else {
31+
$base = "${{ github.event.before }}"
32+
}
33+
Write-Host "Comparing against $base"
34+
$changedFiles = git diff --name-only $base HEAD
35+
if (-not $changedFiles) {
36+
echo "should_build=false" >> $env:GITHUB_OUTPUT
37+
exit 0
38+
}
39+
$shouldBuild = $false
40+
foreach ($file in $changedFiles) {
41+
Write-Host "Changed: $file"
42+
# CONDITION 1:
43+
# Any change inside /snippets folder
44+
if ($file -like "snippets/*") {
45+
Write-Host "Change inside snippets folder detected."
46+
$shouldBuild = $true
47+
break
48+
}
49+
# CONDITION 2:
50+
# .md file with snippet tag added/modified
51+
if ($file -like "*.md") {
52+
$diff = git diff $base HEAD -- $file
53+
if ($diff -match "<snippet") {
54+
Write-Host "Snippet tag change detected in markdown."
55+
$shouldBuild = $true
56+
break
57+
}
58+
}
59+
}
60+
echo "should_build=$shouldBuild" >> $env:GITHUB_OUTPUT
61+
- name: Setup .NET 10
62+
if: steps.snippet_check.outputs.should_build == 'true'
63+
uses: actions/setup-dotnet@v4
64+
with:
65+
dotnet-version: '10.0.x'
66+
67+
- name: Add Telerik NuGet source
68+
if: steps.snippet_check.outputs.should_build == 'true'
69+
shell: pwsh
70+
run: |
71+
dotnet nuget add source "https://nuget.telerik.com/v3/index.json" --name "Telerik NuGet Server" --username "api-key" --password $env:TELERIK_API_KEY --store-password-in-clear-text
72+
env:
73+
TELERIK_API_KEY: ${{ secrets.TELERIK_API_KEY }}
74+
75+
- name: Debug Telerik NuGet
76+
if: steps.snippet_check.outputs.should_build == 'true'
77+
shell: pwsh
78+
run: |
79+
Write-Host "TELERIK_API_KEY length: $($env:TELERIK_API_KEY.Length)"
80+
dotnet nuget list source
81+
- name: Restore & Build all solutions
82+
if: steps.snippet_check.outputs.should_build == 'true'
83+
shell: pwsh
84+
run: |
85+
# Find both .sln and .slnx files
86+
$solutions = Get-ChildItem "./snippets" -Recurse -Include *.sln,*.slnx -File
87+
if (-not $solutions) {
88+
Write-Error "No solution files (.sln or .slnx) found!"
89+
exit 1
90+
}
91+
foreach ($sln in $solutions) {
92+
Write-Host ""
93+
Write-Host "=============================="
94+
Write-Host "Building $($sln.FullName)"
95+
Write-Host "=============================="
96+
dotnet restore "$($sln.FullName)"
97+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
98+
dotnet build "$($sln.FullName)" `
99+
--configuration Release `
100+
--no-restore
101+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
102+
}

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,10 @@ SlugLog.log
7777
start-docs.sh
7878
start-docs.sh
7979
watch.sh
80-
watch.sh
80+
watch.sh
81+
.suo
82+
.baml
83+
**/bin/
84+
**/obj/
85+
**/.vs/
86+
**.csproj.user

controls/aiprompt/getting-started.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,8 @@ Follow the steps:
4646
You can create a new __AIPromptOutputItem__ instance and fill it with returned response from the AI model. Then, you can populate the __OutputItems__ collection of RadAIPrompt. This will create a new AIPromptOutputVisualItem in the Output view where you can interact with the response.
4747

4848
````C#
49-
private void RadAIPrompt1_PromptRequest(object sender, Telerik.WinControls.UI.AIPrompt.PromptRequestEventArgs e)
50-
{
51-
AIPromptOutputItem responseAIPromptOutputItemModel = new AIPromptOutputItem()
52-
{
53-
Title = "Response from your AI model",
54-
InputText = e.InputText,
55-
ResponseText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", // Here you can set the string value returned from your AI model
56-
};
57-
58-
this.radAIPrompt1.OutputItems.Add(responseAIPromptOutputItemModel);
59-
}
49+
50+
<snippet id='aiprompt-getting-started-promptrequest' />
6051

6152
````
6253
````VB.NET

docs-builder.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ img-max-width: 100%
1616
center-images: false
1717
table-layout: fixed
1818
enable-tabbed-code-blocks: true
19+
external-snippets-path: ./snippets
1920
pdf-cover-png-path: ./images/pdf-cover.png
2021
gitLastCommitDateEnabled: true
2122
search-provider: nuclia
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net10.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<UseWindowsForms>true</UseWindowsForms>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="UI.for.WinForms.Common" Version="2026.1.210" />
13+
</ItemGroup>
14+
15+
</Project>

snippets/Telerik.WinControls.UI.Snippets/Common/Form1.Designer.cs

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Telerik.WinControls.UI.AIPrompt;
2+
3+
namespace Common
4+
{
5+
public partial class Form1 : Form
6+
{
7+
public Form1()
8+
{
9+
InitializeComponent();
10+
}
11+
12+
// >> aiprompt-getting-started-promptrequest
13+
private void RadAIPrompt1_PromptRequest(object sender, Telerik.WinControls.UI.AIPrompt.PromptRequestEventArgs e)
14+
{
15+
AIPromptOutputItem responseAIPromptOutputItemModel = new AIPromptOutputItem()
16+
{
17+
Title = "Response from your AI model",
18+
InputText = e.InputText,
19+
ResponseText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", // Here you can set the string value returned from your AI model
20+
};
21+
22+
this.radaiPrompt1.OutputItems.Add(responseAIPromptOutputItemModel);
23+
}
24+
// << aiprompt-getting-started-promptrequest
25+
}
26+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64+
<xsd:element name="root" msdata:IsDataSet="true">
65+
<xsd:complexType>
66+
<xsd:choice maxOccurs="unbounded">
67+
<xsd:element name="metadata">
68+
<xsd:complexType>
69+
<xsd:sequence>
70+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
71+
</xsd:sequence>
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
73+
<xsd:attribute name="type" type="xsd:string" />
74+
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
76+
</xsd:complexType>
77+
</xsd:element>
78+
<xsd:element name="assembly">
79+
<xsd:complexType>
80+
<xsd:attribute name="alias" type="xsd:string" />
81+
<xsd:attribute name="name" type="xsd:string" />
82+
</xsd:complexType>
83+
</xsd:element>
84+
<xsd:element name="data">
85+
<xsd:complexType>
86+
<xsd:sequence>
87+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89+
</xsd:sequence>
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
94+
</xsd:complexType>
95+
</xsd:element>
96+
<xsd:element name="resheader">
97+
<xsd:complexType>
98+
<xsd:sequence>
99+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100+
</xsd:sequence>
101+
<xsd:attribute name="name" type="xsd:string" use="required" />
102+
</xsd:complexType>
103+
</xsd:element>
104+
</xsd:choice>
105+
</xsd:complexType>
106+
</xsd:element>
107+
</xsd:schema>
108+
<resheader name="resmimetype">
109+
<value>text/microsoft-resx</value>
110+
</resheader>
111+
<resheader name="version">
112+
<value>2.0</value>
113+
</resheader>
114+
<resheader name="reader">
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116+
</resheader>
117+
<resheader name="writer">
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119+
</resheader>
120+
</root>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace Common
2+
{
3+
internal static class Program
4+
{
5+
/// <summary>
6+
/// The main entry point for the application.
7+
/// </summary>
8+
[STAThread]
9+
static void Main()
10+
{
11+
// To customize application configuration such as set high DPI settings or default font,
12+
// see https://aka.ms/applicationconfiguration.
13+
ApplicationConfiguration.Initialize();
14+
Application.Run(new Form1());
15+
}
16+
}
17+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="Telerik NuGet Server" value="https://nuget.telerik.com/v3/index.json" />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
6+
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
7+
</packageSources>
8+
</configuration>

0 commit comments

Comments
 (0)