如何在C#中将一个事件处理程序传递给另一事件处理程序

时间:2019-03-17 00:50:15

标签: eventhandler

我有一个软件可以显示4个摄像机的视图。它的工作正常。我要修改它。

现在的问题是我想从4个不同的相机视图中捕获图片。该软件仅捕获4个摄像机视图,除非在调用此选择click事件期间单击其中一个视图,否则它将传递特定的摄像机事件处理程序并将该处理程序数据存储到数组中。获得相机面板处理程序后,我可以单击相机图像捕获按钮进行快照。

但是我想将事件摄像机处理程序(告诉我要为屏幕截图选择哪个屏幕)传递给捕获按钮事件。

那怎么可能呢?有没有人有主意。复制下面的两个事件处理程序代码。

此API从private void realPanel_Click(object sender, EventArgs e)

选择的相机屏幕上捕获快照
private void CapturePicture_Click(object sender, EventArgs e)
{
    if (m_curRealPanel.m_playhandle == IntPtr.Zero)
    {
        return;
    }
    String strTemp = string.Copy(LocalSetting.m_strPicSavePath);
    DateTime oDate = DateTime.Now;
    String strCurTime = oDate.ToString("yyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
    LocalSetting.m_strPicSavePath += m_deviceInfoList[m_curRealPanel.m_deviceIndex].m_ip;
    LocalSetting.m_strPicSavePath += "_";
    LocalSetting.m_strPicSavePath += (m_curRealPanel.m_channelIndex + 1);
    LocalSetting.m_strPicSavePath += "_";
    LocalSetting.m_strPicSavePath += strCurTime;

    byte[] picSavePath;
    GetUTF8Buffer(LocalSetting.m_strPicSavePath, NETDEVSDK.NETDEV_LEN_260, out picSavePath);
    int iRet = NETDEVSDK.NETDEV_CapturePicture(m_curRealPanel.m_playhandle, picSavePath, (int)NETDEV_PICTURE_FORMAT_E.NETDEV_PICTURE_JPG);
    if (NETDEVSDK.FALSE == iRet)
    {
        showFailLogInfo(m_deviceInfoList[m_curSelectedTreeDeviceIndex].m_ip + " chl:" + (m_curSelectedTreeChannelIndex + 1), "CapturePicture", NETDEVSDK.NETDEV_GetLastError());
        //return;
    }

    showSuccessLogInfo(m_deviceInfoList[m_curSelectedTreeDeviceIndex].m_ip + " chl:" + (m_curSelectedTreeChannelIndex + 1), "CapturePicture");

    LocalSetting.m_strPicSavePath = strTemp;
}

private void realPanel_Click(object sender, EventArgs e)
{
    m_curRealPanel = sender as PlayPanel;
    setDeviceTreeSelectNode();

    if (true == m_curRealPanel.m_recordStatus)
    {
        LocalRecodBtn.Text = "Stop";
    }
    else
    {
        LocalRecodBtn.Text = "Record";
    }
}

0 个答案:

没有答案