mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
added sample form
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json.Nodes;
|
||||
using Microsoft.CmdPal.Extensions;
|
||||
using Microsoft.CmdPal.Extensions.Helpers;
|
||||
|
||||
namespace SamplePagesExtension;
|
||||
|
||||
internal sealed class SampleForm : Form
|
||||
{
|
||||
public override string TemplateJson()
|
||||
{
|
||||
var json = $$"""
|
||||
{
|
||||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
|
||||
"type": "AdaptiveCard",
|
||||
"version": "1.5",
|
||||
"body": [
|
||||
{
|
||||
"type": "Input.Text",
|
||||
"style": "text",
|
||||
"id": "text1",
|
||||
"label": "Input.Text",
|
||||
"isRequired": true,
|
||||
"errorMessage": "Text is required"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "Action.Submit",
|
||||
"title": "Action.Submit",
|
||||
"data": {
|
||||
"text1": "text1",
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
""";
|
||||
return json;
|
||||
}
|
||||
|
||||
public override string DataJson() => throw new NotImplementedException();
|
||||
|
||||
public override string StateJson() => throw new NotImplementedException();
|
||||
|
||||
public override ActionResult SubmitForm(string payload)
|
||||
{
|
||||
var formInput = JsonNode.Parse(payload);
|
||||
if (formInput == null)
|
||||
{
|
||||
return ActionResult.GoHome();
|
||||
}
|
||||
|
||||
// get the name and url out of the values
|
||||
|
||||
// var testInput = formInput["test1"] ?? string.Empty;
|
||||
return ActionResult.GoHome();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.CmdPal.Extensions;
|
||||
using Microsoft.CmdPal.Extensions.Helpers;
|
||||
|
||||
namespace SamplePagesExtension;
|
||||
|
||||
internal sealed class SampleFormPage : FormPage
|
||||
{
|
||||
private readonly SampleForm sampleForm = new();
|
||||
|
||||
public override IForm[] Forms() => [sampleForm];
|
||||
|
||||
public SampleFormPage()
|
||||
{
|
||||
Name = "Sample Form";
|
||||
Icon = new(string.Empty);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,11 @@ public class SamplePagesCommandsProvider : ICommandProvider
|
||||
Title = "List Page Sample Command",
|
||||
Subtitle = "SamplePages Extension",
|
||||
},
|
||||
new ListItem(new SampleListPage())
|
||||
{
|
||||
Title = "Form Page Sample Command",
|
||||
Subtitle = "SamplePages Extension",
|
||||
}
|
||||
];
|
||||
|
||||
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
|
||||
|
||||
Reference in New Issue
Block a user