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

📄 property_.pas

📁 以可视的方式画IVR语音导航的流程,并把流程做为源文件保存起来
💻 PAS
字号:
unit property_;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls, ComCtrls, IVRPoint, CheckLst, CLTools,
  CLAdvanceVCL;

type
  TPropertyForm = class(TForm)
    PageControl1: TPageControl;
    GernalSheet: TTabSheet;
    PropertySheet: TTabSheet;
    EventSheet: TTabSheet;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    memoMemo: TMemo;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    editIID_0: TEdit;
    editIID_1: TEdit;
    editIID_2: TEdit;
    editSubType: TEdit;
    radioTong: TRadioButton;
    radioYi: TRadioButton;
    EventList: TCheckListBox;
    CheckProperty: TCheckBox;
    editProperty: TEdit;
    Button1: TButton;
    UpLinkList: TListBox;
    Label7: TLabel;
    SpeedBtnSelectValue: TSpeedButton;
    radioProperty: TRadioGroup;
    listProperty: TCLHintListBox;
    procedure FormShow(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure listPropertyClick(Sender: TObject);
    procedure editPropertyChange(Sender: TObject);
    procedure CheckPropertyClick(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure SpeedBtnSelectValueClick(Sender: TObject);
    procedure editPropertyKeyPress(Sender: TObject; var Key: Char);
    procedure radioPropertyClick(Sender: TObject);
    procedure UpLinkListDblClick(Sender: TObject);
  private
    iid_1, iid_2, iid_0: Integer;
    iMode: Integer;
    iSub: String;
    iComment: String;
    PropertyMemo: array [0..MAXPROPERTYCOUNT - 1] of String;
    PropertySwitch: array [0..MAXPROPERTYCOUNT - 1] of Boolean;
    PropertyType: array [0..MAXPROPERTYCOUNT - 1] of TPropertyType;
    pointIVR: PIVRPoint;
    procedure ReSetGernal;
    procedure ReSetProperty;
    procedure ReSetEvent;
    { Private declarations }
  public
    function SetIVRPointProperty(IVRPoint: PIVRPoint; IDNumber: Integer): Boolean;
    { Public declarations }
  end;

var
  PropertyForm: TPropertyForm;

implementation

uses main_;

{$R *.DFM}

procedure TPropertyForm.FormShow(Sender: TObject);
begin
    GernalSheet.Show();

    ReSetGernal();
    ReSetProperty();
    ReSetEvent();
end;

procedure TPropertyForm.BitBtn2Click(Sender: TObject);
begin
    Close();
end;

function TPropertyForm.SetIVRPointProperty(IVRPoint: PIVRPoint; IDNumber: Integer): Boolean;
var
    i: Integer;
begin
    Result := False;
    if IVRPoint = nil then
        Exit;

    pointIVR := IVRPoint;
    with pointIVR^ do
    begin
        PropertyForm.Caption := Format('[%d.%d]%s的属性', [IVRMemo.iType, IVRMemo.iContent, Caption]);
        iid_0 := IVRMemo.iid0;
        iid_1 := IVRMemo.iid1;
        iid_2 := IVRMemo.iid2;
        iMode := IVRMemo.iMode;
        iSub := IVRMemo.iSubType;
        iComment := IVRMemo.iComment;
        for i := 0 to UpLink.Count - 1 do
        begin
            UpLinkList.Items.Add(
                IntToStr(PUpData(UpLink[i]).UpEvent) + '/' +
                main.IVRIdToPoint(PUpData(UpLink[i]).UpID).Caption);
        end;
    end;
    //nowIVRPoint := IVRPoint;
    Result := True;
end;

procedure TPropertyForm.ReSetGernal;
begin
    editIID_0.Text := IntToStr(iid_0);
    editIID_1.Text := IntToStr(iid_1);
    editIID_2.Text := IntToStr(iid_2);
    if iMode = 1 then
        radioTong.Checked := true
    else
        radioYi.Checked := true;
    editSubType.Text := Trim(iSub);
    memoMemo.Text := Trim(iComment);
end;

procedure TPropertyForm.ReSetProperty;
var
    i: Integer;
begin
    listProperty.Items.Clear();
    CheckProperty.Checked := False;
    editProperty.Text := '';
    for i := 0 to MAXPROPERTYCOUNT - 1 do
    begin
        listProperty.Items.Add(pointIVR.IVRProperty[i].Caption);
        PropertyMemo[i] := pointIVR.IVRProperty[i].Memo;
        PropertySwitch[i] := pointIVR.IVRProperty[i].Enable;
        PropertyType[i] := pointIVR.IVRProperty[i].PropertyType;
    end;
    listProperty.ItemIndex := -1;
    listPropertyClick(Self);
end;

procedure TPropertyForm.ReSetEvent;
var
    i: Integer;
    s: String;
begin
    EventList.Clear();
    for i := 0 to MAXEVENTCOUNT - 1 do
    begin
        if pointIVR.IVREvent[i].Caption <> '' then
        begin
            s := IntToStr(i);
            if Length(s) = 1 then
                s := '0' + s;
            EventList.Items.Add('事件' + s + ':' + pointIVR.IVREvent[i].Hints);
            EventList.ItemEnabled[i] := true;
            EventList.Checked[i] := pointIVR.IVREvent[i].Enable;
        end else begin
            EventList.Items.Add('<未定义事件>');
            EventList.ItemEnabled[i] := False;
        end;
    end;
end;

//存盘
procedure TPropertyForm.BitBtn1Click(Sender: TObject);
var
    i: Integer;
    tmpIVR: TIVRPoint;
begin
    //基本
    with pointIVR.IVRMemo do
    begin
        iSubType := Trim(Copy(editSubType.Text, 1, 20));
        iComment := Trim(Copy(memoMemo.Text, 1, 40));
        if radioTong.Checked then
            iMode := 1
        else
            iMode := 0;
    end;
    //属性
    for i := 0 to MAXPROPERTYCOUNT - 1 do
    begin
        if listProperty.Items[i] <> '' then
        begin
            pointIVR.IVRProperty[i].Enable := PropertySwitch[i];
            pointIVR.IVRProperty[i].Memo := PropertyMemo[i];
        end;
    end;
    //事件
    for i := 0 to MAXEVENTCOUNT - 1 do
    begin
        //如果没有改变,则不变动
    if (EventList.ItemEnabled[i]) and (EventList.Checked[i] <> pointIVR.IVREvent[i].Enable) then
         begin
            if pointIVR.IVREvent[i].NextPoint >= 0 then
            begin
                tmpIVR := main.IVRIdToPoint(pointIVR.IVREvent[i].NextPoint);
                tmpIVR.DeleteUpLink(pointIVR.IVRMemo.ID, i);
                pointIVR.IVREvent[i].NextPoint := -1;
            end;
            pointIVR.SetEnable(i, EventList.Checked[i]);
        end;
    end;
    pointIVR.Refurbish(main.OnLineMouseDown);

    for i := 0 to MAXEVENTCOUNT - 1 do
    begin
       if (EventList.ItemEnabled[i]) and (pointIVR.IVREvent[i].Enable) and (pointIVR.IVREvent[i].NextPoint >= 0) then
        begin
            tmpIVR := main.IVRIdToPoint(pointIVR.IVREvent[i].NextPoint);
            pointIVR.DrawPathLine(i, tmpIVR.Left, tmpIVR.Top + 6);
        end;
    end;

    Close();
end;

procedure TPropertyForm.listPropertyClick(Sender: TObject);
var
    i: Integer;
begin
  i := listProperty.ItemIndex;
  if i = -1 then
  begin
    CheckProperty.Enabled := False;
    editProperty.Visible := False;
    radioProperty.Visible := False;
    Exit;
  end;
  PropertyMemo[i] :=  Trim(PropertyMemo[i]);
  CheckProperty.Enabled := True;
  case PropertyType[i] of
  tpBOOL: begin
    radioProperty.Visible := True;
    editProperty.Visible := False;
    CheckProperty.Checked := PropertySwitch[i];
    try
      if PropertyMemo[i] = '' then
      begin
        radioProperty.ItemIndex := 0;
        PropertyMemo[i] := '0';
      end else begin
        radioProperty.ItemIndex := StrToInt(PropertyMemo[i]);
      end;
    except
      radioProperty.ItemIndex := 0;
      PropertyMemo[i] := '0';
    end;
    radioProperty.SetFocus();
   end;
  tpINT, tpSTR: begin
    radioProperty.Visible := False;
    editProperty.Visible := True;
    editProperty.Text := PropertyMemo[i];
    CheckProperty.Checked := PropertySwitch[i];
    editProperty.SetFocus();
   end;
  else
    CheckProperty.Enabled := False;
    editProperty.Visible := False;
    radioProperty.Visible := False;
  end;
end;

procedure TPropertyForm.editPropertyChange(Sender: TObject);
begin
    PropertyMemo[listProperty.ItemIndex] := Trim(editProperty.Text);
end;

procedure TPropertyForm.CheckPropertyClick(Sender: TObject);
begin
    PropertySwitch[listProperty.ItemIndex] := CheckProperty.Checked;
end;

//复位
procedure TPropertyForm.BitBtn3Click(Sender: TObject);
begin
    if GernalSheet.Visible then
        ReSetGernal();
    if PropertySheet.Visible then
        ReSetProperty();
    if EventSheet.Visible then
        ReSetEvent();
end;

procedure TPropertyForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
    //Action := caFree;
end;

procedure TPropertyForm.SpeedBtnSelectValueClick(Sender: TObject);
var
    i: Integer;
    j: Integer;
    s: String;
begin
    if not(editProperty.Visible) then
        Exit;

    i := clListBox('选择一个通道变量', main.ValueStringList);

    if i >= 0 then
       begin
         s := main.ValueStringList[i];
         j := Pos('(',s);

       if j > 0 then
          begin
             editProperty.Text := Copy(s,1,j - 1);
          end
       else
          begin
             editProperty.Text := main.ValueStringList[i];
          end;
    end;
end;

procedure TPropertyForm.editPropertyKeyPress(Sender: TObject;
  var Key: Char);
begin
    if PropertyType[listProperty.ItemIndex] = tpINT then
    begin
        if (Ord(Key) < $30) or (Ord(Key) > $39) and (Ord(Key) <> VK_BACK) then
            Key := #0;
    end;
end;

procedure TPropertyForm.radioPropertyClick(Sender: TObject);
begin
    PropertyMemo[listProperty.ItemIndex] := IntToStr(radioProperty.ItemIndex);
end;

procedure TPropertyForm.UpLinkListDblClick(Sender: TObject);
begin
    if not(main.CenterIVR(PUpData(pointIVR.UpLink[UpLinkList.ItemIndex]).UpID)) then
        MessageBeep(MB_ICONERROR);
end;

end.

⌨️ 快捷键说明

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