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

📄 main.pas

📁 有关多媒体的各个细节
💻 PAS
📖 第 1 页 / 共 2 页
字号:
 ShowFirstRecord;//显示第一章第一节
end;
//更新节内容
procedure TMainForm.UpdateExerciseMemo(Const TabVar:TTabSet);
var
 i:Integer;
begin
 Exercisememo.Clear;
 for i:=0 to TabVar.Tabs.Count-1 do
  begin
   if TabVar.Tabs[i]<>'所有' then
    begin
     GetNowMemo(TabVar.Tabs[i],ExerciseMemo,ExeMemo);
    end;
  end;
end;
//处理标签变化,即节的变化
procedure TMainForm.TabControlChange(const TabVar:TTabSet);
begin
 if TabVar.Tabs[TabVar.Tag]='所有' then
  UpdateExerciseMemo(TabVar)
  else
   begin
    Exercisememo.Clear;
    GetNowMemo(TabVar.Tabs[TabVar.Tag],ExerciseMemo,ExeMemo);
   end;
 TranslateStr;
end;

//具体“节”内容信息翻译
procedure TMainForm.TranslateStr;
var
 i,j,k,m,StrLength,Num,StrPos:Integer;
 NumArray:Array[0..4] of Integer;
 StrArray:Array[0..6] of string[80];
 Str:Array[0..4] of string[80];
begin
 {初始化数组}
 for i:=0 to 6 do
  begin
   StrArray[i]:='';
   if i<=4 then
    begin
     NumArray[i]:=0;
     Str[i]:='';
    end;
  end;

 {分离一行代码}
 i:=0;
 while i<=ExerciseMemo.Lines.Count-1 do
  begin
   j:=0;
   Num:=0;
   StrLength:=Length(ExerciseMemo.Lines[i]);
   while j<=Strlength do{得到';'的位置}
    begin
     if Copy(ExerciseMemo.Lines[i],j,1)=';' then
      begin
        NumArray[1+Num]:=j;
        if Num=0 then
         Str[Num]:=Copy(ExerciseMemo.Lines[i],NumArray[Num],NumArray[1+Num]-NumArray[Num]-1)
        else
         Str[Num]:=Copy(ExerciseMemo.Lines[i],NumArray[Num]+1,NumArray[1+Num]-NumArray[Num]-1);

          {分离功能数据}
          k:=1;
          StrPos:=0;
          while k<=Length(Str[Num]) do
           begin
             if Str[Num][k]<>',' then
              StrArray[StrPos]:=StrArray[StrPos]+Str[Num][k]
             else
              begin
               Inc(StrPos);
              end;
            inc(k);
           end;
          {具体某一功能的数据}
          case StrToInt(StrArray[0]) of
           0:{图形}
              begin
                ShowArray[i].Bmp.TitleName:=StrArray[1];
                ShowArray[i].Bmp.FileName:=StrArray[2];
                ShowArray[i].Bmp.SmallFileName:=StrArray[3];
              end;
           1:{动画}
              begin
                ShowArray[i].Avi.FileName:=StrArray[1];
                ShowArray[i].Avi.Left:=MyStrToInt(StrArray[2]);
                ShowArray[i].Avi.Top:=MyStrToInt(StrArray[3]);
                ShowArray[i].Avi.Width:=MyStrToInt(StrArray[4]);
                ShowArray[i].Avi.Height:=MyStrToInt(StrArray[5]);
              end;
           2:{文本}
              begin
                ShowArray[i].Txt.FileName:=StrArray[1];
                ShowArray[i].Txt.Left:=MyStrToInt(StrArray[2]);
                ShowArray[i].Txt.Top:=MyStrToInt(StrArray[3]);
                ShowArray[i].Txt.Width:=MyStrToInt(StrArray[4]);
                ShowArray[i].Txt.Height:=MyStrToInt(StrArray[5]);
              end;
           3:{闪烁}
              begin
                ShowArray[i].Blink.Blink:=StrArray[1];
                ShowArray[i].Blink.Left:=MyStrToInt(StrArray[2]);
                ShowArray[i].Blink.Top:=MyStrToInt(StrArray[3]);
                ShowArray[i].Blink.Width:=MyStrToInt(StrArray[4]);
                ShowArray[i].Blink.Height:=MyStrToInt(StrArray[5]);
              end;
           4:{声音}
              begin
                ShowArray[i].WavFileName:=StrArray[1];
              end;
          end;

        //清StrArray数组
        for m:=0 to 6 do
         begin
          StrArray[m]:='';
         end;
         //处理下一行数据
        Inc(Num);
      end;
     Inc(j);
    end;
   Inc(i);
  end;
end;
//返回当前显示的行号
function TMainForm.ReturnCurrentDisplayLineNum(const WantfindStr:String):Integer;
var i,MaxNum:Integer;
begin
 i:=0;
 MaxNum:=MaxShowBmpNum+30;
 Result:=0;
 while i<MaxNum do
  begin
   if MainForm.ShowArray[i].Bmp.TitleName=WantfindStr then
     begin
      Result:=i;
      i:=i+MaxNum;
     end
   else
    Inc(i);
  end;

end;

//初始化ShowBarArray数组
procedure TMainForm.InitShowBarArray;
var
 i:Integer;
begin
 ShowBarArray[1].BackPanel:=Panel2;
 ShowBarArray[1].ColorPanel:=Panel3;
 ShowBarArray[1].BarPanel:=Panel4;
 ShowBarArray[1].LabelShape:=Shape1;
 ShowBarArray[1].TitleLable:=Label1;
 ShowBarArray[1].ShowImage:=Image1;

 ShowBarArray[2].BackPanel:=Panel5;
 ShowBarArray[2].ColorPanel:=Panel6;
 ShowBarArray[2].BarPanel:=Panel7;
 ShowBarArray[2].LabelShape:=Shape2;
 ShowBarArray[2].TitleLable:=Label2;
 ShowBarArray[2].ShowImage:=Image2;

 ShowBarArray[3].BackPanel:=Panel8;
 ShowBarArray[3].ColorPanel:=Panel9;
 ShowBarArray[3].BarPanel:=Panel10;
 ShowBarArray[3].LabelShape:=Shape3;
 ShowBarArray[3].TitleLable:=Label3;
 ShowBarArray[3].ShowImage:=Image3;

 ShowBarArray[4].BackPanel:=Panel11;
 ShowBarArray[4].ColorPanel:=Panel12;
 ShowBarArray[4].BarPanel:=Panel13;
 ShowBarArray[4].LabelShape:=Shape4;
 ShowBarArray[4].TitleLable:=Label4;
 ShowBarArray[4].ShowImage:=Image4;


 for i:=1 to MaxShowBmpNum do
  begin
   ShowBarArray[i].ShowImage.Cursor:=crHandPoint;
   ShowBarArray[i].TitleLable.Caption:='范例'+IntToStr(i);
   ShowBarArray[i].BackPanel.Caption:='';
   ShowBarArray[i].ColorPanel.Caption:='';
   ShowBarArray[i].BarPanel.Caption:='';
  end;
end;

//处理选中画面
procedure TMainForm.Image1Click(Sender: TObject);
var
 i:Integer;
begin
 i:=1;
 while i<=MaxShowBmpNum do//哪一幅图被选中
  begin
   if ShowBarArray[i].ShowImage=(Sender As TImage) then
    begin
     CurrentClickImageNum:=i;
     i:=i+MaxShowBmpNum;
    end
   else
    i:=i+1;
  end;
  //清显示框显示颜色
  ClearShowBarColor;
  SetShowBarColor(CurrentClickImageNum);//设置选中图形框颜色

 //获取当前显示行号
 ExeForm.CurrentDisplayLine:=ReturnCurrentDisplayLineNum(ShowBarArray[CurrentClickImageNum].TitleLable.Caption);
 //在StepComboBox构件,设置当前步主题
 ExeForm.StepComboBox.Text:=ShowBarArray[CurrentClickImageNum].TitleLable.Caption;

  with ExeForm do//调用ExeForm显示
   begin
    InitStepComboBoxData;//更新步跳转数据
    StepComBoBox.ItemIndex:=CurrentClickImageNum-1;//当前步号
    StepComBoBox.Visible:=False; //不可见StepComBoBox构件
    UnVisibleCompone;//不可见构件处理,如前后翻按钮
    //显示当前画面主题文字
    Caption:=ShowBarArray[CurrentClickImageNum].TitleLable.Caption;
    ShowCurrentLine;//处理当前画面显示
    MainForm.Hide;//隐藏主画面
    Show;//显示ExeForm
   end;
end;

//启动定时器更新显示框
procedure TMainForm.Timer1Timer(Sender: TObject);
var
 i,j,SetColorNum:Integer;
begin
 if UpdateShowBarFlag then
  begin
   UpdateShowBarFlag:=False;
   UnVisibleShowBar;
   ClearShowBarColor;
   i:=0;
   if MainForm.ExerciseMemo.Lines.Count<=MaxShowBmpNum then
    begin
     j:=MainForm.ExerciseMemo.Lines.Count
    end
   else
    j:=MaxShowBmpNum;
   UpdateShowBarArray(i,j);
   VisibleShowBar(j);
   SetColorNum:=1;
   SetShowBarColor(SetColorNum);

  if MainForm.ExerciseMemo.Lines.Count>MaxShowBmpNum-1 then
   ScrollBar1.Visible:=True
   else  ScrollBar1.Visible:=False;
  end;
end;

//更新显示框数据
procedure TMainForm.UpdateShowBarArray(Var StartNum,MemoLinesCount:Integer);
var
    i,StrLength:Integer;
    WidthTimes,HeightTimes,SmallTimes:Real;
    NewBmp:TBitmap;
begin
 i:=0;
 NewBmp:=TBitmap.Create;
 if StartNum<=MemoLinesCount-1 then
  begin
   while StartNum<MemoLinesCount do
    begin
     {Read Now show Line}
     ShowBarArray[i+1].TitleLable.Caption:=MainForm.ShowArray[StartNum].Bmp.TitleName;
     if FileExists(MainDir+BmpDir+ShowArray[StartNum].Bmp.SmallFileName) then
       ShowBarArray[i+1].BmpFileName:=MainForm.ShowArray[StartNum].Bmp.SmallFileName
     else
       ShowBarArray[i+1].BmpFileName:=MainForm.ShowArray[StartNum].Bmp.FileName;

     {Load BmpFile and Adjust Show Position}
       UnStretchImage.Picture.LoadFromFile(MainDir+BmpDir+ShowBarArray[i+1].BmpFileName);

     WidthTimes:=UnStretchImage.Width/BarShowHeight;
     HeightTimes:=UnStretchImage.Height/BarShowWidth;

     if WidthTimes>HeightTimes then
        SmallTimes:=WidthTimes
      else
        SmallTimes:=HeightTimes;

        ShowBarArray[i+1].ShowImage.Width:=Round(UnStretchImage.Width/SmallTimes);
        ShowBarArray[i+1].ShowImage.Height:=Round(UnStretchImage.Height/SmallTimes);

      {Colorpanel}
      ShowBarArray[i+1].ColorPanel.Width:=ShowBarArray[i+1].ShowImage.Width+6;
      ShowBarArray[i+1].ColorPanel.Height:=ShowBarArray[i+1].ShowImage.Height+6;
      ShowBarArray[i+1].ColorPanel.Left:=(ShowBarArray[i+1].BackPanel.Width-ShowBarArray[i+1].ColorPanel.Width) div 2;
      ShowBarArray[i+1].ColorPanel.Top:=(ShowBarArray[i+1].BackPanel.Height-ShowBarArray[i+1].ColorPanel.Height) div 2;

      {Barpanel}
      ShowBarArray[i+1].BarPanel.Width:=ShowBarArray[i+1].ShowImage.Width+2;
      ShowBarArray[i+1].BarPanel.Height:=ShowBarArray[i+1].ShowImage.Height+2;
      ShowBarArray[i+1].BarPanel.Left:=(ShowBarArray[i+1].ColorPanel.Width-ShowBarArray[i+1].BarPanel.Width) div 2;
      ShowBarArray[i+1].BarPanel.Top:=(ShowBarArray[i+1].ColorPanel.Height-ShowBarArray[i+1].BarPanel.Height) div 2;

      ShowBarArray[i+1].ShowImage.Left:=(ShowBarArray[i+1].BarPanel.Width-ShowBarArray[i+1].ShowImage.Width) div 2;
      ShowBarArray[i+1].ShowImage.Top:=(ShowBarArray[i+1].BarPanel.Height-ShowBarArray[i+1].ShowImage.Height) div 2;

      StrLength:=Length(ShowBarArray[i+1].TitleLable.Caption);
      ShowBarArray[i+1].TitleLable.Left:=ShowBarArray[i+1].LabelShape.Left+8+(ShowBarArray[i+1].LabelShape.Width-
      ShowBarArray[i+1].TitleLable.Font.Size * StrLength) div 2;

      NewBmp.LoadFromFile(MainForm.MainDir+MainForm.BmpDir+ShowBarArray[i+1].BmpFileName);

      {避免出现半拉现象}
      ShowBarArray[i+1].ShowImage.Picture.LoadFromFile(MainDir+BmpDir+ShowBarArray[i+1].BmpFileName);

      {缩小图象}
      ShowBarArray[i+1].ShowImage.Canvas.StretchDraw(Rect(0,
      0,ShowBarArray[i+1].ShowImage.Width,ShowBarArray[i+1].ShowImage.Height),NewBmp);

     //处理下一行
     Inc(i);
     Inc(StartNum);
   end;
  end;
 NewBmp.Free;
end;

//处理滚动显示
procedure TMainForm.ScrollBar1Change(Sender: TObject);
var
  StartNum,EndNum:Integer;
begin
   Panel1.Caption:='';
   UnVisibleShowBar;
   StartNum:=ScrollBar1.Position;
   if StartNum+MaxShowBmpNum>MainForm.ExerciseMemo.Lines.Count then
    EndNum:=MainForm.ExerciseMemo.Lines.Count
   else
    EndNum:=StartNum+MaxShowBmpNum;
   VisibleShowBar(EndNum-StartNum);
   UpdateShowBarArray(StartNum,EndNum);
end;

//处理标签页的变化
procedure TMainForm.TabSet1Change(Sender: TObject; NewTab: Integer;
  var AllowChange: Boolean);
begin
 MainForm.InitShowArray;
 TabSet1.Tag:=NewTab;
 TabControlChange(TabSet1);
 ScrollBar1.Min:=0;
 if MainForm.ExerciseMemo.Lines.Count<>0 then
  ScrollBar1.Max:=MainForm.ExerciseMemo.Lines.Count-1
 else
  ScrollBar1.Max:=0;
  UpdateShowBarFlag:=True;
end;

//选中“章”
procedure TMainForm.DirListBoxClick(Sender: TObject);
begin
  InitTimeResponeData(DirListBox.Items[DirListBox.ItemIndex],TabSet1);
  ShowTimeResPone;
end;

end.

⌨️ 快捷键说明

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