using System.Drawing;
using System.Windows.Forms;
public class ExTextBox : TextBox
{
string hint;
public string Hint
{
get { return hint; }
set { hint = value; this.Invalidate(); }
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0xf)
{
if (!this.Focused && string.IsNullOrEmpty(this.Text)
&& !string.IsNullOrEmpty(this.Hint))
{
using (var g = this.CreateGraphics())
{
TextRenderer.DrawText(g, this.Hint, this.Font,
this.ClientRectangle, SystemColors.GrayText , this.BackColor,
TextFormatFlags.Top | TextFormatFlags.Left);
}
}
}
}
}
dotnet build -c Release-no-self
dotnet zip --no-restore -c Release-no-self
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>_444</RootNamespace>
<Configurations>Debug;Release;Release-no-self</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-no-self|AnyCPU'">
<SelfContained>False</SelfContained>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Packaging.Targets" Version="$(PackagingNuGetVersion)" />
</ItemGroup>
<PropertyGroup>
<PostInstallScript>
</PostInstallScript>
<PostRemoveScript>
</PostRemoveScript>
</PropertyGroup>
<Target Name="PackageZip" DependsOnTargets="CreateZip" Outputs="$(ZipPath)"/>
<Target Name="PackageTarball" DependsOnTargets="CreateTarball" Outputs="$(TarballPath)"/>
<Target Name="PackageDebian" DependsOnTargets="CreateDeb" Outputs="$(DebPath)"/>
<Target Name="PackageRpm" DependsOnTargets="CreateRpm" Outputs="$(RpmPath)"/>
</Project>
private static bool _running;
public static void Main()
{
_running = true;
ThreadPool.SetMaxThreads(5, 5);
ThreadPool.QueueUserWorkItem(ThreadProc);
while (_running)
{
Thread.Sleep(100);
}
}
static void ThreadProc(object stateInfo)
{
var start = DateTime.Now;
var proxy = GetProxy();
try
{
var id = GetNextId();
var result = proxy.Execute(id);
}
catch (Exception e)
{
_running = false;
}
var ts = DateTime.Now - start;
var delay = (int)(2 * 1000 - ts.TotalMilliseconds);
if (delay > 0)
Thread.Sleep(delay);
}
[Serializable]
public class FilmShow
{
[Serializable]
public class Place
{
public Place() { }
public int? UserId { get; set; }
public bool IsReserved { get; set; }
}
[Serializable]
public class Row
{
public Row() { }
public Place[] Places { get; set; }
}
public DateTime Date { get; set; }
public string Name { get; set; }
public Row[] Rows { get; set; }
public FilmShow()
{
}
public FilmShow(DateTime date, string name, int row, int column)
{
Date = date;
Name = name;
Rows = new Row[row];
for (var i = 0; i < Rows.Length; i++)
{
var item = new Row() { Places = new Place[column] };
for (var j = 0; j < item.Places.Length; j++)
{
item.Places[j] = new Place();
}
Rows[i] = item;
}
}
public static void Save(FilmShow filmShow, string path)
{
var formatter = new XmlSerializer(typeof(FilmShow));
using var fs = new FileStream(path, FileMode.OpenOrCreate);
formatter.Serialize(fs, filmShow);
}
public static FilmShow Load(string path)
{
var formatter = new XmlSerializer(typeof(FilmShow));
using var fs = new FileStream(path, FileMode.OpenOrCreate);
return (FilmShow)formatter.Deserialize(fs);
}
}