⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmtp.pas

📁 delphi LED 显示屏用,带串口发送,内容编辑,演示功能
💻 PAS
📖 第 1 页 / 共 3 页
字号:
procedure Tfrmtpsend.screenbackClick(Sender: TObject);
begin
     myedit1.Tpcount:=myedit1.Tpcount+1;
     tpedit.SelStart:=myedit1.tppos;
     setpara;
end;

procedure Tfrmtpsend.ComdispmodeChange(Sender: TObject);
var
  i,k1,k2:integer;
begin
     myedit1.Tppos:=tpedit.SelStart+tpedit.SelLength;
     k2:=myedit1.Tpcount;
     myedit1.Tppos:=tpedit.SelStart;
     k1:=myedit1.Tpcount;
     for i:=k1 to k2 do
          dispmode[i]:=comdispmode.itemindex;
     tpedit.SetFocus;
end;

procedure Tfrmtpsend.ComhidemodeChange(Sender: TObject);
var
  i,k1,k2:integer;
begin
     myedit1.Tppos:=tpedit.SelStart+tpedit.SelLength;
     k2:=myedit1.Tpcount;
     myedit1.Tppos:=tpedit.SelStart;
     k1:=myedit1.Tpcount;
     for i:=k1 to k2 do
        hidemode[i]:=comhidemode.itemindex;
     tpedit.SetFocus;
end;

procedure Tfrmtpsend.SpinEdit1Change(Sender: TObject);
var
  i,k1,k2:integer;
begin
     myedit1.Tppos:=tpedit.SelStart+tpedit.SelLength;
     k2:=myedit1.Tpcount;
     myedit1.Tppos:=tpedit.SelStart;
     k1:=myedit1.Tpcount;
     for i:=k1 to k2 do
        stoptime[i]:=SpinEdit1.Value;
    tpedit.SetFocus;
end;

procedure Tfrmtpsend.CombospeedChange(Sender: TObject);
var
  i,k1,k2:integer;
begin
     myedit1.Tppos:=tpedit.SelStart+tpedit.SelLength;
     k2:=myedit1.Tpcount;
     myedit1.Tppos:=tpedit.SelStart;
     k1:=myedit1.Tpcount;
     for i:=k1 to k2 do
        movespeed[i]:=Combospeed.itemindex;
     tpedit.SetFocus;
end;

procedure Tfrmtpsend.Button1Click(Sender: TObject);
var
    klen:longint;
    str2,str1:ansistring;
    tf1:textfile;
begin
     openDialog1.filename:=tpfilename;
     openDialog1.Filter:='文本文件(*.TXT)|*.TXT|所有文件(*.*)|*.*';
     openDialog1.DefaultExt:='TXT';
     if OpenDialog1.Execute=true then
     begin
          if fileexists(openDialog1.filename)=false then exit;
          assignfile(tf1,openDialog1.filename);
          {$I-}
          reset(tf1);
          {$I+}
          tpedit.selstart:=0;
          tpedit.Clear;
          str2:='';
          while not EoF(tf1) do
          begin
                readln(tf1,str1);
                str2:=str2+str1+#13+#10;
          end;
          klen:=length(str2);
          if klen>=29900 then delete(str2,29900,klen-29900);
          tpedit.Text:=str2;
          closefile(tf1);
     end;
end;

procedure Tfrmtpsend.FormCreate(Sender: TObject);
begin
    SAVETOTALNUM:=16192 div myedit1.Tpbyte div myedit1.Tprownum;
    combosize.Clear;
   combosize.Items.Add('8');
   combosize.Items.Add('9');
   combosize.Items.Add('10');
   combosize.Items.Add('11');
   combosize.Items.Add('12');
   if myedit1.Tprownum>1 then
   begin
        combosize.Items.Add('14');
        combosize.Items.Add('16');
        combosize.Items.Add('18');
        combosize.Items.Add('20');
        combosize.Items.Add('22');
        combosize.Items.Add('24');
   end;
   if myedit1.Tprownum>2 then
   begin
        combosize.Items.Add('26');
        combosize.Items.Add('28');
        combosize.Items.Add('32');
        combosize.Items.Add('36');
   end;
   if myedit1.Tprownum>3 then
   begin
        combosize.Items.Add('40');
        combosize.Items.Add('48');
   end;
   if myedit1.Tprownum>4 then
   begin
        combosize.Items.Add('52');
        combosize.Items.Add('56');
        combosize.Items.Add('60');
   end;
   if myedit1.Tprownum>5 then
   begin
        combosize.Items.Add('64');
        combosize.Items.Add('68');
        combosize.Items.Add('72');
   end;
   if myedit1.Tprownum>6 then
   begin
        combosize.Items.Add('76');
        combosize.Items.Add('80');
        combosize.Items.Add('84');
   end;
   if myedit1.Tprownum>7 then
   begin
        combosize.Items.Add('88');
        combosize.Items.Add('92');
        combosize.Items.Add('96');
   end;
   combosize.ItemIndex:=4;
    Combofont.Items:=screen.Fonts;
    inittpdata;
end;

procedure TFrmtpsend.inittpdata;
var
   i:integer;
begin
    tpeditchangflag:=false;
    for i:=0 to TPTOTALNUM do
    begin
         dispmode[i]:=0;
         hidemode[i]:=Comhidemode.Items.Count-1;
         stoptime[i]:=0;
         movespeed[i]:=0;
         SpinEdit1.Value:=stoptime[tpcounter];
         disptimeh[i]:=0;
         disptimem[i]:=0;
         closeh[i]:=0;
         closem[i]:=0;

         dweek[i]:=0
    end;
    tpcounter:=0;
    tptotal:=0;
    tpnewfile.enabled:=true;
    tpopenfile.enabled:=true;
    tpsavefile.enabled:=false;
    tpclosefile.enabled:=false;
    tpsaveas.enabled:=false;
    stpnew.enabled:=true;
    stpopen.enabled:=true;
    tpsend.enabled:=false;
    stpsave.enabled:=false;
    stpclose.enabled:=false;
    stpsend.enabled:=false;
    screenstart.enabled:=false;
    screenfront.enabled:=false;
    screenend.enabled:=false;
    screenback.enabled:=false;
    scom1.visible:=false;
    scom2.visible:=false;
    caption:='条屏发送软件';
    dispcolor.ItemIndex:=0;
    tpedit.defattributes.color:=SCREENCOLOR[0];
    Combofont.ItemIndex:=Combofont.Items.Count-1;
    copykeyflag:=false;
    tpeditchangflag:=true;
    tpeditpos:=0;
    tpedit.Clear;
    tpedit.selstart:=0;
    myedit1.Clear;
    myedit1.Clearimage;
    myedit1.writestr;
    myedit1.change;
    statusbar1.panels[0].text:='第'+inttostr(tpcounter)+'幕';
    statusbar1.panels[1].text:='共'+inttostr(tptotal)+'幕';
    Comscreenno.ItemIndex:=0;
    Comdispmode.ItemIndex:=0;
    Comhidemode.ItemIndex:=Comhidemode.Items.Count-1;
    statusbar1.panels[0].text:='第'+inttostr(tpcounter)+'幕';
    statusbar1.panels[1].text:='共'+inttostr(tptotal)+'幕';
    statusbar1.panels[2].text:='总共可输入'+inttostr(SAVETOTALNUM)+'幕';
end;

procedure Tfrmtpsend.tpnewfileClick(Sender: TObject);
begin
    tpfilename:='new.tp';
    initnewtp;
end;

procedure Tfrmtpsend.initnewtp;
begin
    tpnewfile.enabled:=false;
    tpopenfile.enabled:=false;
    tpsavefile.enabled:=true;
    tpclosefile.enabled:=true;
    tpsaveas.enabled:=true;
    tpsend.enabled:=true;
    stpnew.enabled:=false;
    stpopen.enabled:=false;
    stpsave.enabled:=true;
    stpclose.enabled:=true;
    stpsend.enabled:=true;
    caption:='条屏发送软件   --  '+tpfilename;
    tpedit.selstart:=0;
    editselectlen:=0;
    edittxt:='';
end;

procedure Tfrmtpsend.tpopenfileClick(Sender: TObject);
begin
     openDialog1.filename:=tpfilename;
     openDialog1.Filter:='条屏文件(*.TP)|*.TP';
     openDialog1.DefaultExt:='TP';
     if OpenDialog1.Execute=true then
     begin
          tpfilename:=openDialog1.filename;
          loadtpdata;
     end;
end;

procedure Tfrmtpsend.loadtpdata;
var
   i,k,k1,klen:longint;
   tf1:textfile;
   str1,str2,str3,str4,str5,str6:ansistring;
begin
   if fileexists(tpfilename)=false then exit;
   initnewtp;
   assignfile(tf1,tpfilename);
   {$I-}
   reset(tf1);
   {$I+}
   readln(tf1,k);
   if k>0 then timecheck.Checked:=true
   else timecheck.Checked:=false;
   readln(tf1,k);
    if k>0 then djs.Checked:=true
   else djs.Checked:=false;

   readln(tf1,k);
   for i:=1 to k do
   begin
        readln(tf1,dispmode[i]);
        readln(tf1,hidemode[i]);
        readln(tf1,stoptime[i]);
        readln(tf1,movespeed[i]);
        readln(tf1,dweek[i]);
        readln(tf1,disptimeh[i]);
        readln(tf1,disptimem[i]);
        readln(tf1,closeh[i]);
        readln(tf1,closem[i]);

   end;
   myedit1.Clearimage;
   readln(tf1,k);
   for i:=0 to k-1 do
   begin
        readln(tf1,str1);
        myedit1.Insertimage(i,str1);
   end;
   readln(tf1,str1);
   readln(tf1,str2);
   readln(tf1,str3);
   readln(tf1,str5);
   readln(tf1,str6);
   tpeditchangflag:=false;
   tpedit.Visible:=false;
   while not EOF(tf1) do// RichEdit1.Lines.Count<k do
   begin
       readln(tf1,str4);
       tpedit.text:=tpedit.text+str4;
       if not EOF(tf1) then  tpedit.text:=tpedit.text+#13+#10;
   end;
   closefile(tf1);
   edittxt:=tpedit.text;
   str4:=tpedit.text;
   klen:=length(str4);
   i:=1;
   while(i<=klen) do
   begin
      k:=1;
      if str4[i]>#$80 then k:=2;
      tpedit.selstart:=i-1;
      tpedit.sellength:=k;
      k1:=integer(str1[i]);
      if (k1>=$30) and (k1<$33) then tpedit.selattributes.color:=SCREENCOLOR[k1-$30]
      else  tpedit.selattributes.color:=SCREENCOLOR[0];
      k1:=integer(str2[i]);
      if (k1<$38) then tpedit.selattributes.size:=12
      else  tpedit.selattributes.Size:=(k1-$30);
      k1:=integer(str3[i]);
      if (k1<=$30) then tpedit.selattributes.name:=combofont.Items.Strings[Combofont.Items.Count-1]
      else  tpedit.selattributes.name:=combofont.Items.Strings[k1-$30];
      k1:=integer(str5[i]);
      tpedit.selattributes.Style:=[];
      if (k1 and $80)>0 then tpedit.selattributes.Style:=tpedit.selattributes.Style+[fsBold];
      if (k1 and $40)>0 then tpedit.selattributes.Style:=tpedit.selattributes.Style+[fsItalic];
      if (k1 and $20)>0 then tpedit.selattributes.Style:=tpedit.selattributes.Style+[fsUnderline];
      if (k1 and $10)>0 then tpedit.selattributes.Style:=tpedit.selattributes.Style+[fsStrikeOut];
      i:=i+k;
   end;
   tpedit.selstart:=0;
   tpedit.sellength:=0;
   tpedit.Visible:=true;
   for i:=0 to klen-1 do
   begin
        k1:=integer(str1[i+1]);
        if (k1>=$30) and (k1<$33) then myedit1.tpdata[i].color:=k1-$30
        else  myedit1.tpdata[i].color:=SCREENCOLOR[0];
        k1:=integer(str2[i+1]);
        if (k1<$38) then myedit1.tpdata[i].fontsize:=12
        else  myedit1.tpdata[i].fontsize:=k1-$30;
        k1:=integer(str3[i+1]);
        if (k1<$30) then myedit1.tpdata[i].fontname:=0
        else  myedit1.tpdata[i].fontname:=k1-$30;
        myedit1.tpdata[i].fontstyle:=integer(str5[i+1]);
        myedit1.tpdata[i].extra:=integer(str6[i+1]);
   end;
   myedit1.Txt:=tpedit.text;
   myedit1.writestr;
   editselectlen:=0;
   myedit1.tppos:=tpedit.selstart;
   modify:=false;
   setpara;
   tpeditchangflag:=true;
   tpedit.SetFocus;
end;

procedure Tfrmtpsend.tpsavefileClick(Sender: TObject);
begin
    savetpfile;
end;

procedure Tfrmtpsend.savetpfile;
var
   k:integer;
   tf1:textfile;
   i,klen:longint;
   str1,str2,str3,str4,str5:ansistring;
begin
   str1:='';
   str2:='';
   str3:='';
   str4:='';
   str5:='';
   klen:=length(tpedit.text);
   for i:=0 to klen-1 do
   begin
        str1:=str1+char(myedit1.tpdata[i].color+$30);
        str2:=str2+char(myedit1.tpdata[i].fontsize+$30);
        str3:=str3+char(myedit1.tpdata[i].fontname+$30);
        str4:=str4+char(myedit1.tpdata[i].fontstyle);
        str5:=str5+char(myedit1.tpdata[i].extra);
   end;

   assignfile(tf1,tpfilename);
   {$I-}
   rewrite(tf1);
   {$I+}
   if timecheck.Checked then writeln(tf1,1)
   else writeln(tf1,0);
   if  djs.checked then writeln(tf1,1)
   else writeln(tf1,0);
   writeln(tf1,tptotal);
   for i:=1 to tptotal do
   begin
        writeln(tf1,dispmode[i]);
        writeln(tf1,hidemode[i]);
        writeln(tf1,stoptime[i]);
        writeln(tf1,movespeed[i]);
        writeln(tf1,dweek[i]);
        writeln(tf1,disptimeh[i]);
        writeln(tf1,disptimem[i]);
        writeln(tf1,closeh[i]);
        writeln(tf1,closem[i]);
   end;
   k:=myedit1.GetimageCount;
   writeln(tf1,k);
   for i:=0 to k-1 do
   begin
        writeln(tf1,myedit1.getimage(i));
   end;
   writeln(tf1,str1);
   writeln(tf1,str2);
   writeln(tf1,str3);
   writeln(tf1,str4);
   writeln(tf1,str5);
   writeln(tf1,tpedit.text);
   closefile(tf1);
end;

procedure Tfrmtpsend.tpsaveasClick(Sender: TObject);
begin
    SaveDialog1.filename:=tpfilename;
    SaveDialog1.Filter:='条屏文件(*.TP)|*.TP';
    SaveDialog1.DefaultExt:='tp';
    if SaveDialog1.Execute then
    begin
       tpfilename:=SaveDialog1.filename;
       caption:='条屏发送软件  -- '+tpfilename;
       savetpfile;
    end;
end;

procedure Tfrmtpsend.tpclosefileClick(Sender: TObject);
var
   i:integer;
begin
     i:=application.MessageBox('File is save?',pchar(tpfilename),3);
     if i=6 then  tpsaveasClick(Sender);
     inittpdata;
end;

procedure Tfrmtpsend.tpsendClick(Sender: TObject);
begin
     scom1.visible:=true;
     scom2.visible:=true;
end;

procedure Tfrmtpsend.scom1Click(Sender: TObject);
begin
     com:=1;
     sendtpdata;
end;

procedure Tfrmtpsend.scom2Click(Sender: TObject);
begin
     com:=2;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -