コード例 #1
0
 ///<summary>
 ///通过f-ar接口读取屏幕信息后设置窗口位置
 ///</summary>
 ///<param name="farwin">投屏窗口句柄</param>
 ///<param name="preview">是否为3D预览窗口</param>
 public void UpdateWindowPos(IntPtr farwin)
 {
     F3Device.Screen.Monitor monitor = F3Device.DeviceManager.Instance.FindProjectionMonitor(Global.Instance.Data.MainWindowHandle);
     if (monitor != null)
     {
         F3Device.Screen.RECT rect = monitor.m_MonitorInfo.rcMonitor;
         FARDll.MoveWindow(farwin, rect.Left, rect.Top, rect.Width, rect.Height, true);
     }
     else
     {
         UnityEngine.Debug.LogError("没有找到投屏目标显示器");
     }
 }
コード例 #2
0
        ///<summary>
        ///通过f-ar接口读取屏幕信息后设置窗口位置
        ///</summary>
        ///<param name="farwin">投屏窗口句柄</param>
        public void UpdateWindowPos(IntPtr farwin)
        {
            //可先切换到扩展模式
            //SetDisplayConfig(0, IntPtr.Zero, 0, IntPtr.Zero, (SDC_APPLY | SDC_TOPOLOGY_EXTEND));
            //更新物理显示器列表
            int temp_MonitorCount = FARDll.fmARGetMonitorCount();

            if (temp_MonitorCount < 0)
            {
                UnityEngine.Debug.LogError("Direct3DWin.UpdateWindowsPos() failed with error : fmARGetMonitorCount " + temp_MonitorCount);
            }

            if (temp_MonitorCount != 2)
            {
                UnityEngine.Debug.LogError("Direct3DWin.UpdateWindows() PosCurrent monitor count : " + temp_MonitorCount);
            }

            for (int k = 0; k < temp_MonitorCount; k++)
            {
                FARDll.GCinfo gcinfo = new FARDll.GCinfo();
                int           result = FARDll.fmARGetMonitorInfoByIndex(ref gcinfo, k);
                if (result >= 0)
                {
                    if (targetMonitorName != string.Empty)
                    {
                        if (gcinfo.DeviceName.Contains(targetMonitorName))
                        {
                            UnityEngine.Debug.Log("Direct3DWin.UpdateWindows():投屏显示器:" + gcinfo.DeviceName);
                            FARDll.MoveWindow(farwin, gcinfo.RCleft, gcinfo.RCtop, gcinfo.RCright - gcinfo.RCleft, gcinfo.RCbottom - gcinfo.RCtop, true);
                            return;
                        }
                    }
                    else
                    {
                        //获取一个非GC显示器
                        if (!gcinfo.isGCmonitor)
                        {
                            UnityEngine.Debug.Log("Direct3DWin.UpdateWindows():投屏显示器:" + gcinfo.DeviceName);
                            FARDll.MoveWindow(farwin, gcinfo.RCleft, gcinfo.RCtop, gcinfo.RCright - gcinfo.RCleft, gcinfo.RCbottom - gcinfo.RCtop, true);
                            return;
                        }
                    }
                }
                else
                {
                    UnityEngine.Debug.LogError("Direct3DWin.UpdateWindows() failed with error : fmARGetMonitorInfoByIndex" + result);
                }
            }
            UnityEngine.Debug.LogError("Direct3DWin.UpdateWindows() failed with error : 没有寻找到对应的显示器");
        }