unit WinForm;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, System.Globalization;

type
  TWinForm = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    /// <summary>
    /// Required designer variable.
    /// </summary>
    Components: System.ComponentModel.Container;
    TextBox1: System.Windows.Forms.TextBox;
    TextBox2: System.Windows.Forms.TextBox;
    Label1: System.Windows.Forms.Label;
    Label2: System.Windows.Forms.Label;
    Label3: System.Windows.Forms.Label;
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure InitializeComponent;
    procedure TextBox1_KeyDown(sender: System.Object; e: System.Windows.Forms.KeyEventArgs);
    procedure TextBox2_KeyDown(sender: System.Object; e: System.Windows.Forms.KeyEventArgs);
  {$ENDREGION}
  strict protected
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    procedure Dispose(Disposing: Boolean); override;
  private
    { Private Declarations }
  public
    constructor Create;
  end;

  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]

implementation

{$AUTOBOX ON}

{$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>
procedure TWinForm.InitializeComponent;
begin
  Self.TextBox1 := System.Windows.Forms.TextBox.Create;
  Self.TextBox2 := System.Windows.Forms.TextBox.Create;
  Self.Label1 := System.Windows.Forms.Label.Create;
  Self.Label2 := System.Windows.Forms.Label.Create;
  Self.Label3 := System.Windows.Forms.Label.Create;
  Self.SuspendLayout;
  // 
  // TextBox1
  // 
  Self.TextBox1.Location := System.Drawing.Point.Create(96, 9);
  Self.TextBox1.Name := 'TextBox1';
  Self.TextBox1.Size := System.Drawing.Size.Create(120, 22);
  Self.TextBox1.TabIndex := 0;
  Self.TextBox1.Text := '0';
  Include(Self.TextBox1.KeyDown, Self.TextBox1_KeyDown);
  // 
  // TextBox2
  // 
  Self.TextBox2.Location := System.Drawing.Point.Create(96, 46);
  Self.TextBox2.Name := 'TextBox2';
  Self.TextBox2.Size := System.Drawing.Size.Create(120, 22);
  Self.TextBox2.TabIndex := 1;
  Self.TextBox2.Text := '0';
  Include(Self.TextBox2.KeyDown, Self.TextBox2_KeyDown);
  // 
  // Label1
  // 
  Self.Label1.Location := System.Drawing.Point.Create(16, 9);
  Self.Label1.Name := 'Label1';
  Self.Label1.Size := System.Drawing.Size.Create(67, 27);
  Self.Label1.TabIndex := 2;
  Self.Label1.Text := 'Całkowite:';
  // 
  // Label2
  // 
  Self.Label2.Location := System.Drawing.Point.Create(8, 46);
  Self.Label2.Name := 'Label2';
  Self.Label2.Size := System.Drawing.Size.Create(77, 27);
  Self.Label2.TabIndex := 3;
  Self.Label2.Text := 'Ułamkowe:';
  // 
  // Label3
  // 
  Self.Label3.Location := System.Drawing.Point.Create(8, 80);
  Self.Label3.Name := 'Label3';
  Self.Label3.Size := System.Drawing.Size.Create(208, 32);
  Self.Label3.TabIndex := 4;
  Self.Label3.Text := 'Klawisze strzałek zmieniają wartości w polach tekstow' +
  'ych';
  // 
  // TWinForm
  // 
  Self.AutoScale := False;
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 15);
  Self.ClientSize := System.Drawing.Size.Create(224, 120);
  Self.Controls.Add(Self.Label3);
  Self.Controls.Add(Self.Label2);
  Self.Controls.Add(Self.Label1);
  Self.Controls.Add(Self.TextBox2);
  Self.Controls.Add(Self.TextBox1);
  Self.Name := 'TWinForm';
  Self.Text := 'Konwersje (Windows Forms)';
  Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure TWinForm.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor TWinForm.Create;
begin
  inherited Create;
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent;
  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

procedure TWinForm.TextBox2_KeyDown(sender: System.Object; e: System.Windows.Forms.KeyEventArgs);
const krok=0.1;
var  v: Decimal;
     ESender: TextBox;
begin
ESender:=Sender as TextBox;
if (e.KeyCode=System.Windows.Forms.Keys.Up)or(e.KeyCode=System.Windows.Forms.Keys.Down) then
begin
v:=System.Convert.ToDecimal(ESender.Text);
case e.KeyCode of
  System.Windows.Forms.Keys.Up: v:=v+krok;
  System.Windows.Forms.Keys.Down: v:=v-krok;
end;
ESender.Text:=System.Convert.ToString(v);
end;

end;

procedure TWinForm.TextBox1_KeyDown(sender: System.Object; e: System.Windows.Forms.KeyEventArgs);
var v:integer;
    ESender: TextBox;

begin
ESender:=Sender as TextBox;
if (e.KeyCode=System.Windows.Forms.Keys.Up)or(e.KeyCode=System.Windows.Forms.Keys.Down) then
begin
v:=System.Convert.ToInt32(ESender.Text);
case e.KeyCode of
System.Windows.Forms.Keys.Up: Inc(v,1);
System.Windows.Forms.Keys.Down: Dec(v,1);
end;
ESender.Text:=System.Convert.ToString(v);
end;
end;
end.
