|
@@ -9,7 +9,8 @@ interface
|
|
|
uses
|
|
|
Windows, Classes, SysUtils, FileUtil, SdpoSerial, Forms, Controls, Graphics, Dialogs,
|
|
|
Grids, ExtCtrls, Menus, ComCtrls, ActnList, StdActns, LCLProc, StdCtrls, Spin,
|
|
|
- XMLPropStorage, uSPS, LCLType, Buttons, types, MCSWINAPI, Math, fpjson, jsonparser, Midi;
|
|
|
+ XMLPropStorage, uSPS, LCLType, Buttons, types, MCSWINAPI, Math,
|
|
|
+ fpjson, jsonparser, Midi;
|
|
|
|
|
|
type
|
|
|
|
|
@@ -49,6 +50,8 @@ type
|
|
|
Label5: TLabel;
|
|
|
lbStack: TListBox;
|
|
|
MCSLabel: TLabel;
|
|
|
+ MenuItem1: TMenuItem;
|
|
|
+ pmExamples: TPopupMenu;
|
|
|
RC1: TSpinEdit;
|
|
|
RC2: TSpinEdit;
|
|
|
cbCommand: TComboBox;
|
|
@@ -127,6 +130,7 @@ type
|
|
|
tbPreset6: TToolButton;
|
|
|
tbPreset7: TToolButton;
|
|
|
tbPreset8: TToolButton;
|
|
|
+ ToolButton20: TToolButton;
|
|
|
ToolButton3: TToolButton;
|
|
|
ToolButton4: TToolButton;
|
|
|
ToolButton5: TToolButton;
|
|
@@ -163,13 +167,16 @@ type
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
procedure FormDropFiles(Sender: TObject; const FileNames: array of string);
|
|
|
procedure MCSLabelClick(Sender: TObject);
|
|
|
+ procedure MenuItem1Click(Sender: TObject);
|
|
|
procedure mnSaveClick(Sender: TObject);
|
|
|
+ procedure pmExamplesPopup(Sender: TObject);
|
|
|
procedure Shape1Paint(Sender: TObject);
|
|
|
procedure Shape2Paint(Sender: TObject);
|
|
|
procedure StringGrid1EditingDone(Sender: TObject);
|
|
|
procedure StringGrid1Selection(Sender: TObject; aCol, aRow: integer);
|
|
|
procedure tbPreset1Click(Sender: TObject);
|
|
|
- procedure tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: boolean);
|
|
|
+ procedure tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint;
|
|
|
+ var Handled: boolean);
|
|
|
procedure tbResetClick(Sender: TObject);
|
|
|
procedure Timer1Timer(Sender: TObject);
|
|
|
private
|
|
@@ -179,6 +186,7 @@ type
|
|
|
activeFile: string;
|
|
|
dirty: boolean;
|
|
|
lastNote: byte;
|
|
|
+ Examples : TStringList;
|
|
|
procedure initMidi;
|
|
|
procedure playNote(note: byte);
|
|
|
function readString(var line: string): boolean;
|
|
@@ -214,7 +222,7 @@ var
|
|
|
implementation
|
|
|
|
|
|
uses MCSAbout, uTextUi, uSelectCom, MCSTools, MCSStrings, synaser,
|
|
|
- MCSIO, mcsintelhex, MCSLSU, MCSIniFiles;
|
|
|
+ MCSIO, mcsintelhex, MCSLSU, MCSIniFiles, MCSWinHttp, luijsonutils;
|
|
|
|
|
|
{$R *.lfm}
|
|
|
|
|
@@ -259,6 +267,7 @@ begin
|
|
|
Timer1.Enabled := True;
|
|
|
MCSLSU.MakeForm('form1', 'ID_', form1);
|
|
|
initMidi;
|
|
|
+ Examples := TStringList.Create;
|
|
|
end;
|
|
|
|
|
|
procedure TForm1.initMidi;
|
|
@@ -306,11 +315,57 @@ begin
|
|
|
ShExec2(self.Handle, InfoBox.AppURL);
|
|
|
end;
|
|
|
|
|
|
+procedure TForm1.MenuItem1Click(Sender: TObject);
|
|
|
+var i : integer;
|
|
|
+begin
|
|
|
+ // todo
|
|
|
+ if (Sender is TMenuItem) then begin
|
|
|
+ i := TMenuItem(Sender).Tag;
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TForm1.mnSaveClick(Sender: TObject);
|
|
|
begin
|
|
|
Statusbar1.SimpleText := Sender.ClassName;
|
|
|
end;
|
|
|
|
|
|
+procedure TForm1.pmExamplesPopup(Sender: TObject);
|
|
|
+var
|
|
|
+ i: integer;
|
|
|
+ myName: string;
|
|
|
+ myMenu: TMenuItem;
|
|
|
+ jsonString: string;
|
|
|
+ Data, JArray: TJSONData;
|
|
|
+ JItem: TJSONData;
|
|
|
+begin
|
|
|
+ for i := pmExamples.Items.Count - 1 downto 0 do
|
|
|
+ begin
|
|
|
+ myMenu := pmExamples.Items[i];
|
|
|
+ myMenu.Free;
|
|
|
+ end;
|
|
|
+ pmExamples.Items.Clear;
|
|
|
+ Examples.Clear;
|
|
|
+
|
|
|
+ try
|
|
|
+ jsonString := DownloadFile('http://wkla.no-ip.biz/down/examples.json');
|
|
|
+ Data := StringToJSONData(jsonString);
|
|
|
+ JArray := GetJSONProp(TJSONObject(Data), 'examples');
|
|
|
+ for i := 1 to TJSONArray(JArray).Count do
|
|
|
+ begin
|
|
|
+ JItem := TJSONArray(JArray).Items[i-1];
|
|
|
+ myName := GetJsonProp(TJSONObject(JItem), 'name', '');
|
|
|
+ myName := format('%.2d - %s', [i, myName]);
|
|
|
+ myMenu := TMenuItem.Create(pmExamples);
|
|
|
+ myMenu.Caption := myName;
|
|
|
+ myMenu.Tag := i;
|
|
|
+ myMenu.OnClick := @MenuItem1Click;
|
|
|
+ pmExamples.Items.Add(myMenu);
|
|
|
+ Examples.Add(GetJsonProp(TJSONObject(JItem), 'file', ''));
|
|
|
+ end;
|
|
|
+ except
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TForm1.Shape1Paint(Sender: TObject);
|
|
|
var
|
|
|
radius: integer;
|
|
@@ -451,8 +506,8 @@ begin
|
|
|
begin
|
|
|
if (StringGrid1.Cells[1, x] <> '') then
|
|
|
begin
|
|
|
- line := StringGrid1.Cells[0, x] + ',' + StringGrid1.Cells[1, x] + ',' +
|
|
|
- StringGrid1.Cells[2, x] + ',"' + StringGrid1.Cells[4, x] + '"';
|
|
|
+ line := StringGrid1.Cells[0, x] + ',' + StringGrid1.Cells[1, x] +
|
|
|
+ ',' + StringGrid1.Cells[2, x] + ',"' + StringGrid1.Cells[4, x] + '"';
|
|
|
Writeln(f, line);
|
|
|
end;
|
|
|
end;
|
|
@@ -720,7 +775,8 @@ begin
|
|
|
tmp := tmp + '0';
|
|
|
line := line + tmp;
|
|
|
|
|
|
- line := line + ' ' + StringGrid1.Cells[3, x] + ' ,"' + StringGrid1.Cells[4, x] + '"';
|
|
|
+ line := line + ' ' + StringGrid1.Cells[3, x] + ' ,"' +
|
|
|
+ StringGrid1.Cells[4, x] + '"';
|
|
|
list.add(line);
|
|
|
end;
|
|
|
end;
|
|
@@ -873,7 +929,8 @@ begin
|
|
|
|
|
|
if (error) then
|
|
|
begin
|
|
|
- Application.MessageBox('Arduino antwortet nicht. Evtl. Arduino nicht angeschlossen oder falsche Firmware?',
|
|
|
+ Application.MessageBox(
|
|
|
+ 'Arduino antwortet nicht. Evtl. Arduino nicht angeschlossen oder falsche Firmware?',
|
|
|
'Keine Antwort',
|
|
|
MB_OK + MB_ICONEXCLAMATION);
|
|
|
end;
|
|
@@ -929,7 +986,8 @@ var
|
|
|
begin
|
|
|
if (dirty) then
|
|
|
begin
|
|
|
- i := MCSLSU.LSUAutoMsgBox('Messages', 'SAVE_CHANGES', MB_ICONQUESTION or MB_YESNOCANCEL);
|
|
|
+ i := MCSLSU.LSUAutoMsgBox('Messages', 'SAVE_CHANGES', MB_ICONQUESTION or
|
|
|
+ MB_YESNOCANCEL);
|
|
|
if (i = mrYes) then
|
|
|
begin
|
|
|
saveFile(activeFile);
|
|
@@ -1029,7 +1087,8 @@ begin
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
- Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) + ':' + ExtractFileName(activeFile);
|
|
|
+ Caption := MCSLSU.GetLSUText('form1Captions', 'ID_CAPTION', lsuCode) +
|
|
|
+ ':' + ExtractFileName(activeFile);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
@@ -1044,7 +1103,8 @@ begin
|
|
|
StringGrid1.Columns[i].Title.Caption :=
|
|
|
MCSLSU.GetLSUText('form1Captions', StringGrid1.Columns[i].Title.Caption, lsuCode);
|
|
|
end;
|
|
|
- StringGrid1.Cells[0, 0] := MCSLSU.GetLSUText('form1Captions', 'ID_GRID_STORAGE', lsuCode);
|
|
|
+ StringGrid1.Cells[0, 0] := MCSLSU.GetLSUText('form1Captions',
|
|
|
+ 'ID_GRID_STORAGE', lsuCode);
|
|
|
StringGrid1.Repaint;
|
|
|
end;
|
|
|
|
|
@@ -1184,7 +1244,8 @@ begin
|
|
|
begin
|
|
|
x := StringGrid1.Row;
|
|
|
StringGrid1.Cells[3, x] :=
|
|
|
- sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]), HexToInt(StringGrid1.Cells[2, x]));
|
|
|
+ sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]),
|
|
|
+ HexToInt(StringGrid1.Cells[2, x]));
|
|
|
setDirty(True);
|
|
|
end;
|
|
|
end;
|
|
@@ -1237,10 +1298,14 @@ begin
|
|
|
WriteIniBool(key, 'set', XMLPropStorage1.ReadBoolean(key + '.set', False), filename);
|
|
|
WriteIniBool(key, 'prg', XMLPropStorage1.ReadBoolean(key + '.prg', False), filename);
|
|
|
WriteIniBool(key, 'sel', XMLPropStorage1.ReadBoolean(key + '.sel', False), filename);
|
|
|
- WriteIniBool(key, 'input1', XMLPropStorage1.ReadBoolean(key + '.input1', False), filename);
|
|
|
- WriteIniBool(key, 'input2', XMLPropStorage1.ReadBoolean(key + '.input2', False), filename);
|
|
|
- WriteIniBool(key, 'input3', XMLPropStorage1.ReadBoolean(key + '.input3', False), filename);
|
|
|
- WriteIniBool(key, 'input4', XMLPropStorage1.ReadBoolean(key + '.input4', False), filename);
|
|
|
+ WriteIniBool(key, 'input1', XMLPropStorage1.ReadBoolean(key + '.input1', False),
|
|
|
+ filename);
|
|
|
+ WriteIniBool(key, 'input2', XMLPropStorage1.ReadBoolean(key + '.input2', False),
|
|
|
+ filename);
|
|
|
+ WriteIniBool(key, 'input3', XMLPropStorage1.ReadBoolean(key + '.input3', False),
|
|
|
+ filename);
|
|
|
+ WriteIniBool(key, 'input4', XMLPropStorage1.ReadBoolean(key + '.input4', False),
|
|
|
+ filename);
|
|
|
WriteIniInteger(key, 'adc1', XMLPropStorage1.ReadInteger(key + '.adc1', 0), filename);
|
|
|
WriteIniInteger(key, 'adc2', XMLPropStorage1.ReadInteger(key + '.adc2', 0), filename);
|
|
|
WriteIniInteger(key, 'rc1', XMLPropStorage1.ReadInteger(key + '.rc1', 0), filename);
|
|
@@ -1252,10 +1317,14 @@ begin
|
|
|
XMLPropStorage1.WriteBoolean(key + '.set', ReadIniBool(key, 'set', False, filename));
|
|
|
XMLPropStorage1.WriteBoolean(key + '.prg', ReadIniBool(key, 'prg', False, filename));
|
|
|
XMLPropStorage1.WriteBoolean(key + '.sel', ReadIniBool(key, 'sel', False, filename));
|
|
|
- XMLPropStorage1.WriteBoolean(key + '.input1', ReadIniBool(key, 'input1', False, filename));
|
|
|
- XMLPropStorage1.WriteBoolean(key + '.input2', ReadIniBool(key, 'input2', False, filename));
|
|
|
- XMLPropStorage1.WriteBoolean(key + '.input3', ReadIniBool(key, 'input3', False, filename));
|
|
|
- XMLPropStorage1.WriteBoolean(key + '.input4', ReadIniBool(key, 'input4', False, filename));
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.input1', ReadIniBool(key,
|
|
|
+ 'input1', False, filename));
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.input2', ReadIniBool(key,
|
|
|
+ 'input2', False, filename));
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.input3', ReadIniBool(key,
|
|
|
+ 'input3', False, filename));
|
|
|
+ XMLPropStorage1.WriteBoolean(key + '.input4', ReadIniBool(key,
|
|
|
+ 'input4', False, filename));
|
|
|
XMLPropStorage1.WriteInteger(key + '.adc1', ReadIniInteger(key, 'adc1', 0, filename));
|
|
|
XMLPropStorage1.WriteInteger(key + '.adc2', ReadIniInteger(key, 'adc2', 0, filename));
|
|
|
XMLPropStorage1.WriteInteger(key + '.rc1', ReadIniInteger(key, 'rc1', 0, filename));
|
|
@@ -1302,7 +1371,8 @@ begin
|
|
|
RC2.Value := XMLPropStorage1.ReadInteger(key + '.rc2', RC2.Value);
|
|
|
end;
|
|
|
|
|
|
-procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint; var Handled: boolean);
|
|
|
+procedure TForm1.tbPreset1ContextPopup(Sender: TObject; MousePos: TPoint;
|
|
|
+ var Handled: boolean);
|
|
|
var
|
|
|
key: string;
|
|
|
begin
|
|
@@ -1372,13 +1442,12 @@ begin
|
|
|
if (InfoBox.newVersion) then
|
|
|
begin
|
|
|
MCSLabel.Font.Color := clred;
|
|
|
- MCSLabel.Hint := InfoBox.versionHint + chr($0a) + chr($0d) + MCSLSU.GetLSUText(
|
|
|
- 'form1Captions', 'ID_CLICK_HERE', lsuCode);
|
|
|
+ MCSLabel.Hint := InfoBox.versionHint + chr($0a) + chr($0d) +
|
|
|
+ MCSLSU.GetLSUText('form1Captions', 'ID_CLICK_HERE', lsuCode);
|
|
|
end;
|
|
|
MCSLabel.Caption := InfoBox.versionText;
|
|
|
end;
|
|
|
|
|
|
-
|
|
|
procedure TForm1.renumberGrid;
|
|
|
var
|
|
|
x, i: integer;
|
|
@@ -1392,7 +1461,8 @@ begin
|
|
|
if (StringGrid1.Cells[2, x] = '') then
|
|
|
StringGrid1.Cells[2, x] := '0';
|
|
|
StringGrid1.Cells[3, x] :=
|
|
|
- sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]), HexToInt(StringGrid1.Cells[2, x]));
|
|
|
+ sps.getCommandText(HexToInt(StringGrid1.Cells[1, x]),
|
|
|
+ HexToInt(StringGrid1.Cells[2, x]));
|
|
|
end;
|
|
|
end;
|
|
|
|