unit uSynapseClone;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, RzButton, Vcl.ComCtrls,
  Vcl.Menus, Vcl.StdCtrls, uNeuronTypes,
  AdvShape, Vcl.ExtCtrls,
  PropSaveMain, Vcl.Buttons, uBodyPlan, uDendriteFrame, uSynapseFrame;

type
  TfrmSynapse_1 = class(TForm)

    PropSaveMain: TPropSaveMain;
    SynapseFrame: TSynapseFrame;
    pnlControl: TPanel;
    cbOn: TCheckBox;
    Button1: TButton;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure btnDockClick(Sender: TObject);
    procedure cbOnClick(Sender: TObject);
    procedure btnDisconnectClick(Sender: TObject);

  private
    { Private declarations }
    procedure WMsetFunction(var Msg: TMessage); message WM_setFunction;
    procedure WMresetFunction(var Msg: TMessage); message WM_resetFunction;
    Procedure WMsetSTDP(var Msg: TMessage); message WM_setSTPD;

  public
    { Public declarations }
    recMessage: TSetMessage;
    TagRec: TTagRec;
  end;

var
  frmSynapse_1: TfrmSynapse_1;
  Input: Single;

implementation

{$R *.dfm}

uses INIFiles;

procedure TfrmSynapse_1.btnDisconnectClick(Sender: TObject);
begin
  frmBodyPlan.RemoveEntry('Synapse_1');
end;

procedure TfrmSynapse_1.btnDockClick(Sender: TObject);
begin
  with frmBodyPlan do
    begin
      RemoveEntry('Synapse_1');
      RenumberGrid;
      Synapse_1.Parent := pnlSynapses;
      Synapse_1.Left := 15;
      Synapse_1.Top := 40;
      SetSmallestIconToFront(pnlSynapses);
    end;
  close;
end;

procedure TfrmSynapse_1.cbOnClick(Sender: TObject);
begin
  with frmBodyPlan.Synapse_1 do
    begin
      if cbOn.Checked then
        begin
          Appearance.Color := clGray;
          Appearance.ColorTo := clWhite;
        end
      else
        begin
          Appearance.Color := clSilver;
          Appearance.ColorTo := clWhite;
          close;
        end;
    end;
  SynapseFrame.FOn := cbOn.Checked;
  frmBodyPlan.DrawWires;
end;

procedure TfrmSynapse_1.FormCreate(Sender: TObject);
begin
  Tag := NativeInt(@TagRec); // Needed Jim - Trust me.
  SynapseFrame.Init;
  SynapseFrame.ThisBodyPart := 'Synapse_1';
  cbOnClick(Self);
end;

procedure TfrmSynapse_1.WMsetFunction(var Msg: TMessage);
begin
  SynapseFrame.ProcesssetFunctionMessage(Msg);
end;

procedure TfrmSynapse_1.WMresetFunction(var Msg: TMessage);
begin
  SynapseFrame.ProcesssetResetFunctionMessage(Msg);
end;

Procedure TfrmSynapse_1.WMsetSTDP(var Msg: TMessage);
begin
  SynapseFrame.ProcessSetSTDPMessage(Msg);
end;

end.
