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

📄 main_.pas

📁 以可视的方式画IVR语音导航的流程,并把流程做为源文件保存起来
💻 PAS
📖 第 1 页 / 共 5 页
字号:
var
    tmpIVRPoint: TIVRPoint;
    tmpTreeView: TTreeNode;
    i, IndexValue: Integer;
    s:String;

begin
    NeedCenter := False;        //增加的不需要对中
    if IVRCaption = '' then
        IVRCaption := '未命名';
    tmpIVRPoint := TIVRPoint.Create(ActiveBox);
    with tmpIVRPoint do
    begin
        Parent := ActiveBox;
        Left := 10;
        Top := 10;
        Caption := IVRCaption;
        Font.Color := $00333333;
        EventColor := clWhite;
        TitleCursor := crMOVE;
        IVRMemo.iContent := iContent;
        IVRMemo.iType := iType;
        IVRMemo.ID := IDNumber;
        IVRMemo.iid0 := iType;
        IVRMemo.iid1 := iContent;
        IVRMemo.iid2 := IVRMemo.ID;
        IVRMemo.iComment := IVRCaption ;
        DrawLineColor := IVRLineColor;
        OnTMouseDown := OnIVRTitleMouseDown;
        OnTMouseUp := OnIVRTitleMouseUp;
        OnEMouseDown := OnIVREventMouseDown;
        tmpIVRPoint.OnIVRPointMove := main.OnIVRPointMove;
        OnDblClick := OnIVRDoubleClick;
       // MainImage := self.IVRImage;
       // ImageIndex := iType;
        //事件
        for i := 0 to MAXEVENTCOUNT - 1 do
        begin
            IndexValue := IndexOfEventList(iType, iContent, i);
            if IndexValue >= 0 then
            begin
                IVREvent[i].Caption := PIVREventData(IVREventData[IndexValue]).Caption;
                IVREvent[i].Hints := PIVREventData(IVREventData[IndexValue]).Hints;
            end else begin
                IVREvent[i].Caption := '';
            end;
        end;
        //属性
        for i := 0 to MAXPROPERTYCOUNT - 1 do
        begin
            IVRProperty[i].Enable := False;
            IVRProperty[i].Memo := '';
            IndexValue := IndexOfPropertyList(iType, iContent, i);
            if IndexValue >= 0 then
            begin
                IVRProperty[i].PropertyType := PIVRPropertyData(IVRPropertyData[IndexValue]).pType;
                IVRProperty[i].Caption := PIVRPropertyData(IVRPropertyData[IndexValue]).Caption;
            end else begin
                IVRProperty[i].PropertyType := tpUnknow;
                IVRProperty[i].Caption := '';
            end;
        end;
    end;

if tag = 0 then  //非初始化
begin
   //增加子流程模块 2002.09.03

    if iType = SubProcess then
      begin
        if iContent = SubiContent then
            begin
               tmpIVRPoint.SetEnable(0, true);
               s := SubCaption;
              tmpIVRPoint.IVRMemo.ParentID := BoxList.Count - 1 ;
              tmpIVRPoint.IVRMemo.fcTreeNode := TTreeNode(fcTreeCombo1.SelectedNode);
              tmpIVRPoint.TitleColor := $00C080FF ;
              tmpIVRPoint.TitleTextColor := clWhite;
            end;

        if iContent = SubStartiContent then
            s := SubStartCaption;

        if iContent = SubEndiContent then
            s := SubEndCaption;

      if (iContent = SubEndiContent) or (iContent = SubStartiContent) then
        begin
          tmpIVRPoint.IVRMemo.ParentID := BoxList.Count - 1 ;
          tmpIVRPoint.IVRMemo.fcTreeNode := TTreeNode(fcTreeCombo1.SelectedNode);
        end ;

        tmpIVRPoint.Refurbish(self.OnLineMouseDown);
        tmpIVRPoint.Caption := s;

        tmpTreeView := ActiveTree.Items.AddChild(NodeList.Items[ActiveBox.Tag],
        IntToStr(tmpIVRPoint.IVRMemo.ID) + '.' + s);
       end
    else  //非子流程元件
       begin
        tmpIVRPoint.IVRMemo.ParentID := ActiveBox.Tag ;
        // 2002.09.24
         tmpIVRPoint.IVRMemo.fcTreeNode := TTreeNode(fcTreeCombo1.SelectedNode);
        //

        tmpTreeView := ActiveTree.Items.AddChild(NodeList.Items[ActiveBox.Tag],
        IntToStr(tmpIVRPoint.IVRMemo.ID) + '.' + IVRCaption);
       end;
 end
else  //初试化
  begin
     tmpIVRPoint.IVRMemo.ParentID := ActiveBox.Tag ;
     //2002.09.24
     tmpIVRPoint.IVRMemo.fcTreeNode := TTreeNode(fcTreeCombo1.SelectedNode);
     //2002.09.24

      if tmpIVRPoint.IVRMemo.ParentID =0 then  //主流程部分
        tmpTreeView := ActiveTree.Items.AddChild(nil,
        IntToStr(tmpIVRPoint.IVRMemo.ID) + '.' + IVRCaption)
      else  //子流程部分
         if NonInit then
             tmpTreeView := ActiveTree.Items.AddChild(IVRIDToNode(GodID),
             IntToStr(tmpIVRPoint.IVRMemo.ID) + '.' + IVRCaption)

          else //导入,复制
            begin
             tmpTreeView := ActiveTree.Items.AddChild(NodeList.Items[ActiveBox.Tag],
             IntToStr(tmpIVRPoint.IVRMemo.ID) + '.' + IVRCaption) ;
            end;

    if (iType=SubProcess) and (iContent = SubiContent) then
          begin
            NodeList.Add(tmpTreeView);
            tmpIVRPoint.Tag := 1;
            tmpIVRPoint.TitleColor := $00C080FF ;
            tmpIVRPoint.TitleTextColor := clWhite;
          end;

  end;
        tmpTreeView.ImageIndex := tmpIVRPoint.ImageIndex ;
        tmpTreeView.Data := tmpIVRPoint;
        ActiveTree.Selected := tmpTreeView;
        tmpIVRPoint.IVRMemo.Node := tmpTreeView;
        Result := tmpIVRPoint;

end;

//项目存盘动作
procedure Tmain.actFileSaveExecute(Sender: TObject);
begin
     NewSaveFile();
end;

//IVR菜单的OnClick事件
procedure Tmain.IVRPointClick(Sender: TObject);
var
    tmpMenuItem: TMenuItem;
begin
    tmpMenuItem := TMenuItem(Sender);
    SelectIVRPointMenu(
        tmpMenuItem.Caption,
        StrToInt(Copy(tmpMenuItem.Name, 4, 2)),
        StrToInt(Copy(tmpMenuItem.Name, 6, 2)),
        NowID);

end;

//删除指定IVR节点
procedure Tmain.actEditDeleteIVRExecute(Sender: TObject);
var
    j: Integer;
    tmpIVRPoint, tmpIVR: TIVRPoint;
    Node : TTreeNode;
begin

    if not  clSureBoxEx('确认删除节点' + ActiveTree.Selected.Text + '?') then
        exit ;

        Node := ActiveTree.Selected ;
        tmpIVRPoint := TIVRPoint(Node.Data);

        if (tmpIVRPoint.IVRMemo.iType = SubProcess) and 
                  ( tmpIVRPoint.IVRMemo.iContent = SubStartiContent )
                    then
         begin
            ShowMessage('不能删除子流程模块的开始节点!');
            exit;
         end;


        for j := 0 to tmpIVRPoint.UpLink.Count - 1 do
        begin
            tmpIVR := IVRIdToPoint(PUpData(tmpIVRPoint.UpLink[j]).UpID);
            tmpIVR.ClearEventLink(PUpData(tmpIVRPoint.UpLink[j]).UpEvent);
        end;

        for j := 0 to MAXEVENTCOUNT - 1 do
        begin
            if tmpIVRPoint.IVREvent[j].NextPoint < 0 then
                Continue;
            tmpIVR := IVRIdToPoint(tmpIVRPoint.IVREvent[j].NextPoint);
            if tmpIVR <> nil then
            begin
                tmpIVR.DeleteUpLink(tmpIVRPoint.IVRMemo.ID, j);
            end;
        end;

     //删除子流程 2002.09.04
       if (tmpIVRPoint.IVRMemo.iType = SubProcess) and   ( tmpIVRPoint.Tag >0 )  and (tmpIVRPoint.IVRMemo.iContent = SubiContent) then
          begin
             DelSubProcess(Node);
          end;

        tmpIVRPoint.Free();
      
        Node.Delete();
        ActiveBox.Refresh();
        SetSomeMenuEnable();

        ActiveTree.SetFocus();
        SelectIVRForce := nil ;
       
end;

//获得指定IVR节点在IVR队列里面的位置
function Tmain.IndexOfIVRList(InIVRPoint: TIVRPoint): Integer;
var
    i: Integer;
begin
    Result := -1;
    for i := 0 to ActiveTree.Items.Count - 1 do
    begin
        if InIVRPoint = ActiveTree.Items.Item[i].Data then
        begin
            Result := i;
            Exit;
        end;
    end;
end;

//获取指定ID号的IVR节点在IVR队列里面的位置
function Tmain.IndexOfIVRList(IVRID: Integer): Integer;
var
    i: Integer;
    tmpIVR: TIVRPoint;
begin
    Result := -1;
    for i := 0 to ActiveTree.Items.Count - 1 do
    begin
        tmpIVR := ActiveTree.Items.Item[i].Data;
        if tmpIVR.IVRMemo.ID = IVRID then
        begin
            Result := i;
            Exit;
        end;
    end;
end;

//IVR节点的标题的鼠标DOWN事件
procedure Tmain.OnIVRTitleMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
    i: Integer;
    tmpTreeView: TTreeNode;
begin
    NeedCenter := False;

     TIVRPoint(Sender).TitleCursor := crGET;
    //突出选择的IVR
   
    ForceIVR(Pointer(Sender));
    i := IndexOfIVRList(TIVRPoint(Sender));

    if i >= 0 then
    begin
        ActiveTree.Items.Item[i].Selected := true;
        //如果已经选择一源IVR节点,则开始画线
        if SelectIVREvent.IVRPoint <> nil then
        begin
            ConnectIVR(SelectIVREvent.IVRPoint, TIVRPoint(Sender), SelectIVREvent.EventIndex);
            DeSelectIVRPointEvent();
        end;
    end else begin
        clMsgBox('节点' + TIVRPoint(Sender).Caption + '在列表中不存在,自动追加。');
        tmpTreeView := ActiveTree.Items.AddChild(nil, TIVRPoint(Sender).Caption);
        tmpTreeView.Data := Pointer(Sender);
    end;
end;

//节点列表树改变事件
procedure Tmain.IVRPointTreeChange(Sender: TObject; Node: TTreeNode);
var
    tmpIVR: TIVRPoint;
    ReadyToX, ReadyToY: Integer;

 begin

 if IVRPointTree.Tag = 1 then
    exit ;

    SetSomeMenuEnable();
    if NeedCenter then
    begin
        tmpIVR := TIVRPoint(Node.Data);
        if tmpIVR <> nil then
        begin
            ForceIVR(tmpIVR);
            ReadyToX := tmpIVR.TureLeft + tmpIVR.Width div 2 - ActiveBox.Width div 2;
            ReadyToY := tmpIVR.TureTop + tmpIVR.Height div 2 - ActiveBox.Height div 2;
            if ReadyToX < 0 then
                ReadyToX := 0;
            if ReadyToY < 0 then
                ReadyToY := 0;
            if ReadyToX > ActiveBox.HorzScrollBar.Range then
                ReadyToX := ActiveBox.HorzScrollBar.Range;
            if ReadyToY > ActiveBox.VertScrollBar.Range then
                ReadyToY := ActiveBox.VertScrollBar.Range;

             if TmpIVR.IVRMemo.ParentID <> ActiveBox.Tag then
             begin
                 fcTreeCombo1.SetSelectedNode(TfcTreeNode(tmpIVR.IVRMemo.fcTreeNode));
                 fcTreeCombo1.Text := fcTreeCombo1.SelectedNode.Text;
            end;

            ActiveBox.HorzScrollBar.Position := ReadyToX;
            ActiveBox.VertScrollBar.Position := ReadyToY;
            ActiveBox.Invalidate();
            
        end;
    end else begin
        NeedCenter := True;
    end;
end;

//指定IVR节点的属性编辑
procedure Tmain.actEditPropertyExecute(Sender: TObject);
var
    i: Integer;
    tmpIVRPoint: TIVRPoint;
begin
    i := ActiveTree.Selected.Index;
   // tmpIVRPoint := ActiveTree.Items.Item[i].Data;
    tmpIVRPoint := ActiveTree.Selected.Data;
    PropertyForm := TPropertyForm.Create(Self);
    PropertyForm.SetIVRPointProperty(@tmpIVRPoint, i);
    //PropertyForm.Show();
    PropertyForm.ShowModal();
    PropertyForm.Free();
end;

//IVR节点的标题的鼠标UP事件
procedure Tmain.OnIVRTitleMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
    MousePoint: TPoint;
    tmpIVRPoint: TIVRPoint;
begin
     TIVRPoint(Sender).TitleCursor := crMOVE;

if Button = mbRight then
    begin
         GetCursorPos(MousePoint);
         tmpIVRPoint := ActiveTree.Selected.Data;
//增加子流程菜单 2002.09.03
if (tmpIvRPoint.IVRMemo.iType = SubProcess) and (tmpIvRPoint.IVRMemo.iContent = SubiContent) then
   begin
      N34.Visible := true;
      SubMenu.Visible := true;
      MenuExport.Visible := true ;
      N45.Visible := true ;
   end
else
  begin
      N34.Visible := false;
      SubMenu.Visible := false;
     MenuExport.Visible := false ;
      N45.Visible := false ;
  end;
        TreePopupMenu.Popup(MousePoint.x, MousePoint.y);
    end;
end;

//IVR节点的事件的鼠标DOWN事件
procedure Tmain.OnIVREventMouseDown(Sender: TObject; EventIndex: Integer; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
    i: Integer;
    MousePoint: TPoint;
begin
    i := IndexOfIVRList(TIVRPoint(Sender));
    if i >= 0 then
    begin
        NeedCenter := False;
        ActiveTree.Items.Item[i].Selected := true;
        ForceIVR(TIVRPoint(Sender));
    end else begin
        Exit;
    end;

    if Button = mbLeft then
    begin
        SelectIVRPointEvent(TIVRPoint(Sender), EventIndex);
    end else begin
        DeSelectIVRPointEvent();
        tmpEventIndex := EventIndex;
        GetCursorPos(MousePoint);
        EventPopup.Popup(MousePoint.x, MousePoint.y);

⌨️ 快捷键说明

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