Exemple #1
0
        void SliderScale_MouseLeftButtonUp(object send, MouseButtonEventArgs e)
        {
            try
            {
                var scale = SliderScale.Value;
                if (scale > 0)
                {
                    mScale = (int)scale;

                    //设置缩放
                    int intValue = ScreenMPInterop.VLSMonSetScale(mScale);
                    AppendMessage(string.Format("SetScaleReturn:{0}", intValue));
                }
            }
            catch (Exception ex)
            {
                AppendMessage(ex.Message);
            }
        }
Exemple #2
0
        private void DealStartSMonResponse(ReturnMessage retMessage)
        {
            try
            {
                if (retMessage.ListData == null || retMessage.ListData.Count < 2)
                {
                    CurrentApp.WriteLog("StartSMonResponse", string.Format("ListData count invalid"));
                    return;
                }
                string strMonID   = retMessage.ListData[0];
                string strMonPort = retMessage.ListData[1];
                if (strMonID == mMonitorObject.MonID)
                {
                    MonitorObject monObj = mMonitorObject;
                    int           intMonPort;
                    if (!int.TryParse(strMonPort, out intMonPort))
                    {
                        CurrentApp.WriteLog("StartSMonResponse", string.Format("Monitor port invalid"));
                        return;
                    }
                    string strHost   = monObj.Other03;  //录屏服务器的地址
                    string strChanID = monObj.Other01;
                    int    intChanID;
                    if (!int.TryParse(strChanID, out intChanID))
                    {
                        CurrentApp.WriteLog("StartSMonResponse", string.Format("Channel ID invalid"));
                        return;
                    }

                    OperationReturn optReturn = Utils.DownloadMediaUtils(CurrentApp.Session);
                    if (!optReturn.Result)
                    {
                        CurrentApp.WriteLog("StartSMonResponse",
                                            string.Format("DownloadMediaUtil fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }

                    //获取本窗口的句柄
                    int        handle     = 0;
                    HwndSource hwndSource = HwndSource.FromVisual(this) as HwndSource;
                    if (hwndSource != null)
                    {
                        //hwndSource.AddHook(WndProc);
                        handle = hwndSource.Handle.ToInt32();
                    }
                    int intReturn;
                    //设置反馈进度的频率
                    intReturn = ScreenMPInterop.VLSMonSetWaterMark(1);
                    CurrentApp.WriteLog("StartSMonResponse", string.Format("VLSMonSetWaterMarkReturn:{0}", intReturn));
                    //设置窗口尺寸
                    int intScale = 100;
                    if (ListUserParams != null)
                    {
                        var userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_PLAYSCREEN_SCALE);
                        if (userParam != null)
                        {
                            int temp;
                            if (int.TryParse(userParam.ParamValue, out temp))
                            {
                                if (temp > 0 && temp <= 100)
                                {
                                    intScale = temp;
                                }
                            }
                        }
                    }
                    intReturn = ScreenMPInterop.VLSMonSetScale(intScale);
                    CurrentApp.WriteLog("StartSMonResponse", string.Format("VLSMonSetScaleReturn:{0}", intReturn));
                    SRCMON_PARAM param = new SRCMON_PARAM();
                    param.sVocIp   = Converter.String2ByteArray(strHost, ScreenMPDefines.SIZE_IPADDRESS);
                    param.nPort    = (ushort)intMonPort;
                    param.nChannel = (ushort)intChanID;
                    intReturn      = ScreenMPInterop.VLSMonStart(ref param, null, handle);
                    CurrentApp.WriteLog("StartSMonResponse", string.Format("VLSMonStartReturn:{0}", intReturn));
                    if (intReturn == 0)
                    {
                        mIsScrWinOpened = true;
                        IntPtr hwdPlayer = ScreenMPInterop.VLSMonGetPlayerHwnd();

                        //窗口置顶
                        if (ListUserParams != null)
                        {
                            var userParam =
                                ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_PLAYSCREEN_TOPMOST);
                            if (userParam != null &&
                                userParam.ParamValue == "1" &&
                                hwdPlayer != IntPtr.Zero)
                            {
                                intReturn = User32Interop.SetWindowPos(hwdPlayer, -1, 0, 0, 0, 0, 3);
                                CurrentApp.WriteLog("StartSMonResponse", string.Format("SetWindowPos:{0}", intReturn));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CurrentApp.WriteLog("StartSMonResponse", string.Format("Fail.\t{0}", ex.Message));
            }
        }