Add OS-specific interop

This commit is contained in:
Robert McRackan 2022-08-12 13:49:51 -04:00
parent 86c7f89788
commit aea8c11dc4
33 changed files with 1083 additions and 13 deletions

View file

@ -0,0 +1,39 @@
namespace WindowsConfigApp
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View file

@ -0,0 +1,10 @@
namespace WindowsConfigApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View file

@ -0,0 +1,18 @@
using AppScaffolding.OSInterop;
namespace WindowsConfigApp
{
class Program : OSConfigBase
{
public override Type InteropFunctionsType => typeof(WinInterop);
public override Type[] ReferencedTypes => new Type[]
{
typeof(Form1),
typeof(Bitmap),
typeof(Accessibility.IAccIdentity),
typeof(Microsoft.Win32.SystemEvents)
};
static void Main() => new Program().Run();
}
}

View file

@ -0,0 +1,33 @@
using AppScaffolding.OSInterop;
namespace WindowsConfigApp
{
internal class WinInterop : IInteropFunctions
{
public WinInterop() { }
public WinInterop(params object[] values) { }
// examples until the real interface is filled out
private string InitValue1 { get; }
private int InitValue2 { get; }
public WinInterop(string initValue1, int initValue2)
{
InitValue1 = initValue1;
InitValue2 = initValue2;
}
public void CopyTextToClipboard(string text) => Clipboard.SetDataObject(text, true, 5, 150);
public void ShowForm()
{
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
public string TransformInit1() => InitValue1.ToUpper();
public int TransformInit2() => InitValue2 * InitValue2;
}
}

View file

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\..\bin\Debug</OutputPath>
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>..\..\bin\Release</OutputPath>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\AppScaffolding\AppScaffolding.csproj" />
</ItemGroup>
</Project>