ToString() public method

public ToString ( ) : String
return String
示例#1
2
		public static void GetHistogramEXT(HistogramTargetEXT target, bool reset, PixelFormat format, PixelType type, IntPtr values)
		{
			Debug.Assert(Delegates.pglGetHistogramEXT != null, "pglGetHistogramEXT not implemented");
			Delegates.pglGetHistogramEXT((Int32)target, reset, (Int32)format, (Int32)type, values);
			CallLog("glGetHistogramEXT({0}, {1}, {2}, {3}, 0x{4})", target, reset, format, type, values.ToString("X8"));
			DebugCheckErrors();
		}
		public static void SetBlobCacheFuncsANDROID(IntPtr dpy, SetBlobFuncDelegate set, GetBlobFuncDelegate get)
		{
			Debug.Assert(Delegates.peglSetBlobCacheFuncsANDROID != null, "peglSetBlobCacheFuncsANDROID not implemented");
			Delegates.peglSetBlobCacheFuncsANDROID(dpy, set, get);
			LogFunction("eglSetBlobCacheFuncsANDROID(0x{0}, {1}, {2})", dpy.ToString("X8"), set, get);
			DebugCheckErrors(null);
		}
示例#3
0
    /// <summary>
    /// 把指定索引的值强制转成字符串
    /// </summary>
    public static string ToLuaString(this ILuaState self, int index)
    {
        LuaTypes luaT = self.Type(index);

        switch (luaT)
        {
        case LuaTypes.LUA_TSTRING:
            return(self.ToString(index));

        case LuaTypes.LUA_TNIL:
            return(string.Empty);

        case LuaTypes.LUA_TNUMBER:
            return(self.ToNumber(index).ToString());

        case LuaTypes.LUA_TBOOLEAN:
            return(self.ToBoolean(index).ToString());

        case LuaTypes.LUA_TNONE:
            return(null);

        default:
            self.GetGlobal("tostring");
            self.PushValue(index);
            self.Call(1, 1);
            var ret = self.ToString(-1);
            self.Pop(1);
            return(ret);
        }
    }
示例#4
0
        public void RLGen()
        {
            RL.GenBuffers(1, out bufferObject);
            if (bufferObject == IntPtr.Zero)
            {
                throw new System.InvalidOperationException();
            }
#if DEBUG_BUFFER_OBJECTS
            System.Diagnostics.Debug.WriteLine("RL.GenBuffers(1) = " + bufferObject.ToString("X"));
#endif
            GhostManager.Gen();
        }
示例#5
0
    private static IEnumerator LuaCoroutine(ILuaState lua, LuaFunction luaRef, object yieldRet)
    {
        lua.GetGlobal("coroutine", "status");
        var coro_status = lua.L_Ref(LuaIndexes.LUA_REGISTRYINDEX);

        lua.GetGlobal("coroutine", "resume");
        var corou_resume = lua.L_Ref(LuaIndexes.LUA_REGISTRYINDEX);

        for (bool coroRet = true; ;)
        {
            yield return(yieldRet);

            var oldTop = lua.GetTop();

            // 检查协程状态
            lua.GetRef(coro_status);
            luaRef.push(lua);
            lua.Call(1, 1);
            var coStat = lua.ToString(-1);
            lua.Pop(1);
            if (coStat == "dead")
            {
                break;
            }

            // 再启动协程
            lua.GetRef(corou_resume);
            luaRef.push(lua);
            var status = lua.PCall(1, 2, 0);
            if (status != LuaThreadStatus.LUA_OK)
            {
                LogMgr.E(lua.ToString(-1));
                lua.SetTop(oldTop);
                break;
            }
            coroRet  = lua.ToBoolean(-2);
            yieldRet = lua.ToAnyObject(-1);
            // 弹出返回值
            lua.Pop(2);
            if (!coroRet)
            {
                LogMgr.E("{0}", yieldRet);
                break;
            }
        }

        lua.L_Unref(LuaIndexes.LUA_REGISTRYINDEX, coro_status);
        lua.L_Unref(LuaIndexes.LUA_REGISTRYINDEX, corou_resume);
        luaRef.Dispose();
    }
示例#6
0
 public void Dispose()
 {
     if (!disposed)
     {
         if (textureObject != IntPtr.Zero)
         {
             GhostManager.Add(new TextureRLGhost(textureObject));
             Debug.WriteLine("GhostTexture: " + textureObject.ToString());
             textureObject = IntPtr.Zero;
         }
         GC.SuppressFinalize(this);
         disposed = true;
     }
 }
		public static void ClearDepthOES(IntPtr depth)
		{
			Debug.Assert(Delegates.pglClearDepthxOES != null, "pglClearDepthxOES not implemented");
			Delegates.pglClearDepthxOES(depth);
			LogFunction("glClearDepthxOES(0x{0})", depth.ToString("X8"));
			DebugCheckErrors(null);
		}
		public static void IglooInterfaceSGIX(Int32 pname, IntPtr @params)
		{
			Debug.Assert(Delegates.pglIglooInterfaceSGIX != null, "pglIglooInterfaceSGIX not implemented");
			Delegates.pglIglooInterfaceSGIX(pname, @params);
			LogFunction("glIglooInterfaceSGIX({0}, 0x{1})", LogEnumName(pname), @params.ToString("X8"));
			DebugCheckErrors(null);
		}
		public static void MultiDrawArraysIndirectBindNV(Int32 mode, IntPtr indirect, Int32 drawCount, Int32 stride, Int32 vertexBufferCount)
		{
			Debug.Assert(Delegates.pglMultiDrawArraysIndirectBindlessNV != null, "pglMultiDrawArraysIndirectBindlessNV not implemented");
			Delegates.pglMultiDrawArraysIndirectBindlessNV(mode, indirect, drawCount, stride, vertexBufferCount);
			LogFunction("glMultiDrawArraysIndirectBindlessNV({0}, 0x{1}, {2}, {3}, {4})", LogEnumName(mode), indirect.ToString("X8"), drawCount, stride, vertexBufferCount);
			DebugCheckErrors(null);
		}
示例#10
0
    public static int __newindex(ILuaState L)
    {
        // 从元表取出field的值
        string field = L.ToString(2);

        L.GetMetaTable(1);
        L.PushString(field);
        L.RawGet(-2);
        L.Remove(-2);

        var luaT = L.Type(-1);

        if (luaT == LuaTypes.LUA_TTABLE)
        {
            // 该field只能是个属性
            L.RawGetI(-1, 2);
            L.PushValue(1);
            L.Call(1, 1);
            L.Remove(-2);
        }
        else
        {
            L.L_Error(string.Format("field or property {0} does not exist, get {1}", field, luaT));
            L.Pop(1);
            return(0);
        }

        return(1);
    }
示例#11
0
    static int HttpGet(ILuaState lua)
    {
        string tag     = lua.ChkString(1);
        string url     = lua.ChkString(2);
        float  timeout = (float)lua.OptNumber(4, 10);
        string param   = null;
        var    luaT    = lua.Type(3);

        if (luaT == LuaTypes.LUA_TSTRING)
        {
            param = lua.ToString(3);
        }
        else
        {
            var joParam = lua.ToJsonObj(3) as TinyJSON.ProxyObject;
            if (joParam != null)
            {
                param = KeyValue2Param(joParam);
            }
        }

        var httpHandler = NetworkMgr.Instance.GetHttpHandler("HTTP");

        if (httpHandler)
        {
            httpHandler.StartGet(tag, url, param, timeout);
        }

        return(0);
    }
		public static void MultiDrawArraysIndirectARB(Int32 mode, IntPtr indirect, IntPtr drawcount, Int32 maxdrawcount, Int32 stride)
		{
			Debug.Assert(Delegates.pglMultiDrawArraysIndirectCountARB != null, "pglMultiDrawArraysIndirectCountARB not implemented");
			Delegates.pglMultiDrawArraysIndirectCountARB(mode, indirect, drawcount, maxdrawcount, stride);
			LogFunction("glMultiDrawArraysIndirectCountARB({0}, 0x{1}, 0x{2}, {3}, {4})", LogEnumName(mode), indirect.ToString("X8"), drawcount.ToString("X8"), maxdrawcount, stride);
			DebugCheckErrors(null);
		}
示例#13
0
		public static void GetColorTableSGI(ColorTableTargetSGI target, PixelFormat format, PixelType type, IntPtr table)
		{
			Debug.Assert(Delegates.pglGetColorTableSGI != null, "pglGetColorTableSGI not implemented");
			Delegates.pglGetColorTableSGI((Int32)target, (Int32)format, (Int32)type, table);
			CallLog("glGetColorTableSGI({0}, {1}, {2}, 0x{3})", target, format, type, table.ToString("X8"));
			DebugCheckErrors();
		}
		public static void BufferPageCommitmentARB(Int32 target, IntPtr offset, UInt32 size, bool commit)
		{
			Debug.Assert(Delegates.pglBufferPageCommitmentARB != null, "pglBufferPageCommitmentARB not implemented");
			Delegates.pglBufferPageCommitmentARB(target, offset, size, commit);
			LogFunction("glBufferPageCommitmentARB({0}, 0x{1}, {2}, {3})", LogEnumName(target), offset.ToString("X8"), size, commit);
			DebugCheckErrors(null);
		}
		public static void ElementPointerAPPLE(Int32 type, IntPtr pointer)
		{
			Debug.Assert(Delegates.pglElementPointerAPPLE != null, "pglElementPointerAPPLE not implemented");
			Delegates.pglElementPointerAPPLE(type, pointer);
			LogFunction("glElementPointerAPPLE({0}, 0x{1})", LogEnumName(type), pointer.ToString("X8"));
			DebugCheckErrors(null);
		}
		public static void ClearColorOES(IntPtr red, IntPtr green, IntPtr blue, IntPtr alpha)
		{
			Debug.Assert(Delegates.pglClearColorxOES != null, "pglClearColorxOES not implemented");
			Delegates.pglClearColorxOES(red, green, blue, alpha);
			LogFunction("glClearColorxOES(0x{0}, 0x{1}, 0x{2}, 0x{3})", red.ToString("X8"), green.ToString("X8"), blue.ToString("X8"), alpha.ToString("X8"));
			DebugCheckErrors(null);
		}
		public static void IglooInterfaceSGIX(Int32 pname, IntPtr @params)
		{
			Debug.Assert(Delegates.pglIglooInterfaceSGIX != null, "pglIglooInterfaceSGIX not implemented");
			Delegates.pglIglooInterfaceSGIX(pname, @params);
			CallLog("glIglooInterfaceSGIX({0}, 0x{1})", pname, @params.ToString("X8"));
			DebugCheckErrors();
		}
		public static void AlphaFuncOES(Int32 func, IntPtr @ref)
		{
			Debug.Assert(Delegates.pglAlphaFuncxOES != null, "pglAlphaFuncxOES not implemented");
			Delegates.pglAlphaFuncxOES(func, @ref);
			LogFunction("glAlphaFuncxOES({0}, 0x{1})", LogEnumName(func), @ref.ToString("X8"));
			DebugCheckErrors(null);
		}
示例#19
0
		public static void ElementPointerATI(Int32 type, IntPtr pointer)
		{
			Debug.Assert(Delegates.pglElementPointerATI != null, "pglElementPointerATI not implemented");
			Delegates.pglElementPointerATI(type, pointer);
			CallLog("glElementPointerATI({0}, 0x{1})", type, pointer.ToString("X8"));
			DebugCheckErrors();
		}
示例#20
0
		public static void AlphaFuncOES(Int32 func, IntPtr @ref)
		{
			Debug.Assert(Delegates.pglAlphaFuncxOES != null, "pglAlphaFuncxOES not implemented");
			Delegates.pglAlphaFuncxOES(func, @ref);
			CallLog("glAlphaFuncxOES({0}, 0x{1})", func, @ref.ToString("X8"));
			DebugCheckErrors();
		}
		public static void BindBufferOffsetEXT(Int32 target, UInt32 index, UInt32 buffer, IntPtr offset)
		{
			Debug.Assert(Delegates.pglBindBufferOffsetEXT != null, "pglBindBufferOffsetEXT not implemented");
			Delegates.pglBindBufferOffsetEXT(target, index, buffer, offset);
			LogFunction("glBindBufferOffsetEXT({0}, {1}, {2}, 0x{3})", LogEnumName(target), index, buffer, offset.ToString("X8"));
			DebugCheckErrors(null);
		}
		public static void VertexArrayRangeNV(Int32 length, IntPtr pointer)
		{
			Debug.Assert(Delegates.pglVertexArrayRangeNV != null, "pglVertexArrayRangeNV not implemented");
			Delegates.pglVertexArrayRangeNV(length, pointer);
			LogFunction("glVertexArrayRangeNV({0}, 0x{1})", length, pointer.ToString("X8"));
			DebugCheckErrors(null);
		}
		public static void FreeMemoryNV(IntPtr pointer)
		{
			Debug.Assert(Delegates.pwglFreeMemoryNV != null, "pwglFreeMemoryNV not implemented");
			Delegates.pwglFreeMemoryNV(pointer);
			LogFunction("wglFreeMemoryNV(0x{0})", pointer.ToString("X8"));
			DebugCheckErrors(null);
		}
示例#24
0
    /// <summary>
    /// 把栈顶的数值转为一个Variant表示的值
    /// </summary>
    public static Variant ToJsonValue(ILuaState L)
    {
        var     luaT = L.Type(-1);
        Variant ret  = null;

        switch (luaT)
        {
        case LuaTypes.LUA_TTABLE: ret = L.ToJsonObj(); break;

        case LuaTypes.LUA_TBOOLEAN: ret = new ProxyBoolean(L.ToBoolean(-1)); break;

        case LuaTypes.LUA_TSTRING: ret = new ProxyString(L.ToString(-1)); break;

        case LuaTypes.LUA_TNUMBER: ret = new ProxyNumber(L.ToNumber(-1)); break;

        case LuaTypes.LUA_TFUNCTION: ret = new ProxyUserdata(L.ToLuaFunction(-1)); break;

        case LuaTypes.LUA_TLIGHTUSERDATA:
        case LuaTypes.LUA_TUSERDATA: ret = new ProxyUserdata(L.ToUserData(-1)); break;

        case LuaTypes.LUA_TNIL:
        case LuaTypes.LUA_TNONE: break;

        default:
            LogMgr.W("ToJsonValue: Unsupport type {0}", luaT);
            break;
        }
        return(ret);
    }
        private bool Result(IntPtr hwnd, IntPtr lParam)
        {
            List<IntPtr> results = GetChildWindows(hwnd);

            allWndHandle.Add(results);
            StringBuilder strbuild = new StringBuilder(256);
            Win32.GetWindowText(hwnd, strbuild, 256);
            allScndWndHandle.Add(hwnd.ToString() + " " + strbuild.ToString());
                        
            if (results.Find(
                delegate(IntPtr wnd)
                {
                    if (wnd == m_window)
                        return true;
                    else
                        return false;
                }) != IntPtr.Zero || hwnd == m_window)
            {
                StringBuilder mainWin = new StringBuilder(256);
                StringBuilder scndWin = new StringBuilder(256);
                Win32.GetWindowText(hwnd, mainWin, 256);
                Win32.GetWindowText(m_window, scndWin, 256);
                m_mainWindow = hwnd;
            }
            return true;
        }
示例#26
0
 public static MyType CreateWrapper(IntPtr ptr)
 {
     Console.WriteLine();
     Console.WriteLine(ptr.ToString());
     Console.WriteLine();
     return new MyType { intPtr = ptr };
 }
		public static void StringMarkerGREMEDY(Int32 len, IntPtr @string)
		{
			Debug.Assert(Delegates.pglStringMarkerGREMEDY != null, "pglStringMarkerGREMEDY not implemented");
			Delegates.pglStringMarkerGREMEDY(len, @string);
			CallLog("glStringMarkerGREMEDY({0}, 0x{1})", len, @string.ToString("X8"));
			DebugCheckErrors();
		}
		public static void MultiDrawArraysIndirectBindNV(Int32 mode, IntPtr indirect, Int32 drawCount, Int32 maxDrawCount, Int32 stride, Int32 vertexBufferCount)
		{
			Debug.Assert(Delegates.pglMultiDrawArraysIndirectBindlessCountNV != null, "pglMultiDrawArraysIndirectBindlessCountNV not implemented");
			Delegates.pglMultiDrawArraysIndirectBindlessCountNV(mode, indirect, drawCount, maxDrawCount, stride, vertexBufferCount);
			CallLog("glMultiDrawArraysIndirectBindlessCountNV({0}, 0x{1}, {2}, {3}, {4}, {5})", mode, indirect.ToString("X8"), drawCount, maxDrawCount, stride, vertexBufferCount);
			DebugCheckErrors();
		}
		public static void PixelDataRangeNV(Int32 target, Int32 length, IntPtr pointer)
		{
			Debug.Assert(Delegates.pglPixelDataRangeNV != null, "pglPixelDataRangeNV not implemented");
			Delegates.pglPixelDataRangeNV(target, length, pointer);
			LogFunction("glPixelDataRangeNV({0}, {1}, 0x{2})", LogEnumName(target), length, pointer.ToString("X8"));
			DebugCheckErrors(null);
		}
示例#30
0
    /// <summary>
    /// 把指定索引的值转成一个UnityEngine.GameObject
    /// 如果索引的值是一个字符串,将调用GameObject.Find来尝试找到一个GameObject
    /// </summary>
    public static GameObject ToGameObject(this ILuaState self, int index)
    {
        var luaT = self.Type(index);

        if (luaT == LuaTypes.LUA_TSTRING)
        {
            return(GameObject.Find(self.ToString(index)));
        }
        var obj = self.ToUnityObject(index);
        var go  = obj as GameObject;

        if (go)
        {
            return(go);
        }
        else
        {
            var com = obj as Component;
            if (com)
            {
                return(com.gameObject);
            }
        }

        return(null);
    }
		public static void TextureRangeAPPLE(Int32 target, Int32 length, IntPtr pointer)
		{
			Debug.Assert(Delegates.pglTextureRangeAPPLE != null, "pglTextureRangeAPPLE not implemented");
			Delegates.pglTextureRangeAPPLE(target, length, pointer);
			LogFunction("glTextureRangeAPPLE({0}, {1}, 0x{2})", LogEnumName(target), length, pointer.ToString("X8"));
			DebugCheckErrors(null);
		}
示例#32
0
    public static void ToStringFromatArgs(this ILuaState self, int index, out string format, out object[] args)
    {
        format = self.ChkString(index);
        int n = self.GetTop() - index;

        args   = new object[n];
        index += 1;
        for (int i = 0; i < n; ++i)
        {
            var    pos  = index + i;
            var    luaT = self.Type(pos);
            object arg  = null;
            switch (luaT)
            {
            case LuaTypes.LUA_TBOOLEAN:
                arg = self.ToBoolean(pos); break;

            case LuaTypes.LUA_TNUMBER:
                arg = self.ToNumber(pos); break;

            case LuaTypes.LUA_TSTRING:
                arg = self.ToString(pos); break;

            default:
                arg = self.ToLuaString(pos); break;
            }
            args[i] = arg;
        }
    }
示例#33
0
    public static Color ToColor(this ILuaState self, int index)
    {
        var luaT = self.Type(index);

        switch (luaT)
        {
        case LuaTypes.LUA_TTABLE:
            float r = self.GetFloatValue(index, "r");
            float g = self.GetFloatValue(index, "g");
            float b = self.GetFloatValue(index, "b");
            float a = self.GetFloatValue(index, "a");
            return(new Color(r, g, b, a));

        case LuaTypes.LUA_TNUMBER:
            return(self.ToInteger(index).ToColor());

        case LuaTypes.LUA_TSTRING:
            var   str = self.ToString(index);
            Color color;
            if (ColorUtility.TryParseHtmlString(str, out color))
            {
                return(color);
            }
            self.L_Error(string.Format("Can't parse \"{0}\" to a UnityEngine.Color", str));
            return(Color.clear);

        default:
            self.L_Error(string.Format("Can't convert a {0} to a UnityEngine.Color", luaT));
            return(Color.clear);
        }
    }
		public static void GetnTexImageARB(Int32 target, Int32 level, Int32 format, Int32 type, Int32 bufSize, IntPtr img)
		{
			Debug.Assert(Delegates.pglGetnTexImageARB != null, "pglGetnTexImageARB not implemented");
			Delegates.pglGetnTexImageARB(target, level, format, type, bufSize, img);
			LogFunction("glGetnTexImageARB({0}, {1}, {2}, {3}, {4}, 0x{5})", LogEnumName(target), level, LogEnumName(format), LogEnumName(type), bufSize, img.ToString("X8"));
			DebugCheckErrors(null);
		}
    // Update is called once per frame
    void Update()
    {
        int processId = iiVRUnityInterface.getProcessId();

        iiVRUnityInterface.getViewCoordinates((uint)processId, out _windowsPosX, out _windowsPosY, out _windowsSizeX, out _windowsSizeY);
        //Debug.Log("ViewCoordinates " +  processId + " " + _windowsPosX + " " + _windowsPosY + " " + _windowsSizeX + " " + _windowsSizeY);
        if (_activeWindowPtr == System.IntPtr.Zero)
        {
            System.IntPtr ptr  = GetActiveWindow();
            string        Text = ptr.ToString();
            if (Text != "0")
            {
                _activeWindowPtr = ptr;
            }
        }
        else
        {
            if (_updated == false)
            {
                SetWindowPos(_activeWindowPtr, System.IntPtr.Zero, _windowsPosX, _windowsPosY, _windowsSizeX, _windowsSizeY, SWP_SHOWWINDOW);

                Screen.SetResolution(_windowsSizeX, _windowsSizeY, false);
                _updated = true;
            }
        }
    }
		public static void VertexArrayRangeAPPLE(Int32 length, IntPtr pointer)
		{
			Debug.Assert(Delegates.pglVertexArrayRangeAPPLE != null, "pglVertexArrayRangeAPPLE not implemented");
			Delegates.pglVertexArrayRangeAPPLE(length, pointer);
			CallLog("glVertexArrayRangeAPPLE({0}, 0x{1})", length, pointer.ToString("X8"));
			DebugCheckErrors();
		}
示例#37
0
		public static void VDPAUInitNV(IntPtr vdpDevice, IntPtr getProcAddress)
		{
			Debug.Assert(Delegates.pglVDPAUInitNV != null, "pglVDPAUInitNV not implemented");
			Delegates.pglVDPAUInitNV(vdpDevice, getProcAddress);
			CallLog("glVDPAUInitNV(0x{0}, 0x{1})", vdpDevice.ToString("X8"), getProcAddress.ToString("X8"));
			DebugCheckErrors();
		}
示例#38
0
        ///  _____________________  Data Writing    _____________________

        public override void WriteAddress(System.IntPtr value)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            ed.WriteMessage(MethodInfo.GetCurrentMethod().Name + " = " + "\n");
            ed.WriteMessage(value.ToString() + "\n");
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Process[] Ps = Process.GetProcessesByName(tbProcess.Text);
            if (Ps.Count<Process>() == 0)
                return;
            baseaddress = Ps[0].MainModule.BaseAddress;
            tbBase.Text = baseaddress.ToString("X");
            int address = int.Parse(tbAddress.Text, System.Globalization.NumberStyles.HexNumber);
            int length = int.Parse(tbLength.Text, System.Globalization.NumberStyles.HexNumber);
            if (length == 0)
                return;
            IntPtr readaddress;
            if (cbRelative.Checked)
                readaddress = baseaddress + address;
            else
                readaddress = (IntPtr)address;

            processHandle = OpenProcess(0x0010, false, Ps[0].Id);
            if (processHandle == IntPtr.Zero)
                return;

            rbuff = new byte[length];
            int rn = 0;
            bool ret = ReadProcessMemory(processHandle, readaddress, rbuff, length, ref rn);
            if (ret)
            {
                FileStream fs = new FileStream("mem.bin", FileMode.Create);
                fs.Write(rbuff, 0, length);
                fs.Close();
            }
            else
            {
                MessageBox.Show("Failed");
            }
        }
示例#40
0
        public static HWND CyberpunkWindowActiv()
        {
            HWND CurrentActiveWindow = GetForegroundWindow();

            if (CurrentActiveWindow == IntPtr.Zero)
            {
                //this triggers
                Debug.WriteLine("CurrentActiveWindow: " + CurrentActiveWindow.ToString());
                Debug.WriteLine("Unable to get window handle.");
            }
            foreach (var process in Process.GetProcessesByName("Cyberpunk2077"))
            {
                if (CurrentActiveWindow == process.MainWindowHandle)
                {
                    VolumeMixer.SetApplicationMute(process.Id, false);
                }
                else
                {
                    VolumeMixer.SetApplicationMute(process.Id, true);
                }
                return(process.MainWindowHandle);
            }

            return(HWND.Zero);
        }
        public static Bitmap Create(IntPtr hDesk)
        {
            Bitmap bmp = null;

            if (!string.IsNullOrEmpty(hDesk.ToString()))
            {
                // Get window info: size, x, y
                WINDOWINFO info = new WINDOWINFO();
                info.cbSize = (uint)Marshal.SizeOf(info);
                NativeWin32.GetWindowInfo(hDesk, ref info);
                Rectangle rect = new Rectangle((int)info.rcWindow.Left, (int)info.rcWindow.Top, Math.Abs((int)info.rcWindow.Left - (int)info.rcWindow.Right), Math.Abs((int)info.rcWindow.Top - (int)info.rcWindow.Bottom));

                // Set pointers
                IntPtr hSrce = NativeWin32.GetWindowDC(hDesk);
                IntPtr hDest = NativeWin32.CreateCompatibleDC(hSrce);
                IntPtr hBmp = NativeWin32.CreateCompatibleBitmap(hSrce, rect.Width, rect.Height);
                IntPtr hOldBmp = NativeWin32.SelectObject(hDest, hBmp);

                //  Create bitmap
                bmp = new Bitmap(rect.Width, rect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                Graphics gfxScreenShot = Graphics.FromImage(bmp);
                gfxScreenShot.CopyFromScreen(rect.X, rect.Y, 0, 0, rect.Size, CopyPixelOperation.SourceCopy);

            }
            else
            {
                // logging
            }

            return bmp;
        }
示例#42
0
 public static void TraceRef(IntPtr pUnk, string msg) {
     GC.Collect(); // collect any outstanding RCW or CCW's.
     if (pUnk == IntPtr.Zero) return;
     Marshal.AddRef(pUnk);
     int count = Marshal.Release(pUnk);
     Trace.WriteLine(msg + ": 0x" + pUnk.ToString("x") + "(ref=" + count + ")");
 }
示例#43
0
		public static void GetConvolutionFilterEXT(ConvolutionTargetEXT target, PixelFormat format, PixelType type, IntPtr image)
		{
			Debug.Assert(Delegates.pglGetConvolutionFilterEXT != null, "pglGetConvolutionFilterEXT not implemented");
			Delegates.pglGetConvolutionFilterEXT((Int32)target, (Int32)format, (Int32)type, image);
			CallLog("glGetConvolutionFilterEXT({0}, {1}, {2}, 0x{3})", target, format, type, image.ToString("X8"));
			DebugCheckErrors();
		}
示例#44
0
    public static object ChkAnyObject(this ILuaState self, int index, System.Type type)
    {
        object ret = null;

        if (type.IsEnum)
        {
            return(self.ChkEnumValue(index, type));
        }

        if (type.IsSubclassOf(typeof(System.Delegate)))
        {
            // TODO
            return(null);
        }

        switch (type.FullName)
        {
        case "System.Byte": ret = (byte)self.ToInteger(index); break;

        case "System.SByte": ret = (sbyte)self.ToInteger(index); break;

        case "System.Int16": ret = (short)self.ToInteger(index); break;

        case "System.UInt16": ret = (ushort)self.ToInteger(index); break;

        case "System.Int32": ret = self.ToInteger(index); break;

        case "System.UInt32": ret = (uint)self.ToInteger(index); break;

        case "System.Int64": ret = long.Parse(self.ToString(index)); break;

        case "System.UInt64": ret = ulong.Parse(self.ToString(index)); break;

        case "UnityEngine.Vector2": ret = self.ToVector2(index); break;

        case "UnityEngine.Vector3": ret = self.ToVector3(index); break;

        case "UnityEngine.Quaternion": ret = self.ToQuaternion(index); break;

        case "UnityEngine.Color": ret = self.ToColor(index); break;

        case "TinyJSON.Variant": ret = self.ToJsonObj(index); break;

        default: ret = self.ChkUserData(index, type); break;
        }
        return(ret);
    }
示例#45
0
    public static string getMemory(object o) // 获取引用类型的内存地址方法
    {
        GCHandle h = GCHandle.Alloc(o, GCHandleType.WeakTrackResurrection);

        System.IntPtr addr = GCHandle.ToIntPtr(h);

        return("0x" + addr.ToString("X"));
    }
示例#46
0
 public static string ChkString(this ILuaState self, int index)
 {
     if (self.IsString(index))
     {
         return(self.ToString(index));
     }
     self.TypeError(index, "string");
     return(default(string));
 }
示例#47
0
        static IntPtr ObjectGetType(MonoObjectPtr mobj)
        {
            var obj = GetMonoObjectTarget(mobj);

            if (obj == null)
            {
                log_coreclr($"ObjectGetType (0x{mobj.ToString ("x")}) => null object");
                return(IntPtr.Zero);
            }
            return(GetMonoObject(obj.GetType()));
        }
示例#48
0
    public static ulong ToULong(this ILuaState self, int index)
    {
        var luaT = self.Type(index);

        if (luaT == LuaTypes.LUA_TNUMBER)
        {
            return((ulong)self.ToInteger(index));
        }

        return(ulong.Parse(self.ToString(index)));
    }
示例#49
0
 private static int SetLocalize(ILuaState lua)
 {
     if (!UILabel.LOC)
     {
         UILabel.LOC = AssetsMgr.A.Load(typeof(ScriptableObject), "Launch/Localization") as Localization;
     }
     if (UILabel.LOC)
     {
         UILabel.LOC.currentLang = lua.ToString(1);
     }
     return(0);
 }
示例#50
0
    public static void ApplyParentAndChild(ILuaState lua, out GameObject parent, out GameObject child)
    {
        parent = lua.ToGameObject(1);
        string strChild = null;

        if (lua.IsString(2))
        {
            strChild = lua.ToString(2);
            child    = AssetsMgr.A.Load <GameObject>(strChild);
        }
        else
        {
            child = lua.ToGameObject(2);
        }
    }
示例#51
0
    private static int FindComponent(ILuaState lua)
    {
        Transform  trans   = lua.ToComponent <Transform>(1);
        string     path    = lua.ToString(2);
        string     comName = lua.ToString(3);
        GameObject ret     = FindGO(trans, path);

        if (!ret)
        {
            return(0);
        }

        Component com = ret.GetComponent(comName);

        if (com != null)
        {
            lua.PushLightUserData(com);
        }
        else
        {
            lua.PushNil();
        }
        return(1);
    }
示例#52
0
        public string DeviceDescription()
        {
            string deviceDesc = "Device ";

            if (dwAddr != VALUE_NONE)
            {
                string.Concat(deviceDesc, "0x", dwAddr.ToString("X"), ", ");
            }

            return(string.Concat(deviceDesc, "vid 0x", wVid.ToString("X"),
                                 ", pid 0x", wPid.ToString("X"), ", ifc ",
                                 dwInterfaceNum.ToString(), ", alt setting ",
                                 dwAltSettingNum.ToString(), ", handle 0x",
                                 hDevice.ToString()));
        }
示例#53
0
    public static object ToEnumValue(this ILuaState self, int index, System.Type type)
    {
        var luaT = self.Type(index);

        switch (luaT)
        {
        case LuaTypes.LUA_TNUMBER:
            return(System.Enum.ToObject(type, self.ToInteger(index)));

        case LuaTypes.LUA_TSTRING:
        {
            var enName = self.ToString(index);
            if (System.Enum.IsDefined(type, enName))
            {
                return(System.Enum.Parse(type, enName));
            }
        }
        break;

        case LuaTypes.LUA_TTABLE:
        {
            self.PushString("id");
            self.RawGet(index);
            int id = self.ToInteger(-1);
            self.Pop(1);

            if (type != null)
            {
                if (System.Enum.IsDefined(type, id))
                {
                    return(System.Enum.ToObject(type, id));
                }
            }
            else
            {
                return(id);
            }
        } break;

        default:
            break;
        }

        return(null);
    }
示例#54
0
    /// <summary>
    /// 把栈顶的表转为一个ProxyObject或ProxyArray
    /// 转为ProxyArray时,其下标可能和Lua表不一致
    /// </summary>
    public static Variant ToJsonObj(this ILuaState self)
    {
        Variant ret = null;
        var     top = self.GetTop();

        self.PushNil();
        if (self.Next(top))
        {
            var key = self.ToAnyObject(-2) as string;
            if (key != null)
            {
                var obj = new ProxyObject();
                ret = obj;
                var value = ToJsonValue(self);
                obj[key] = value;
                self.Pop(1);
                while (self.Next(top))
                {
                    key      = self.ToString(-2);
                    value    = ToJsonValue(self);
                    obj[key] = value;
                    self.Pop(1);
                }
            }
            else
            {
                var array = new ProxyArray();
                ret = array;
                array.Add(ToJsonValue(self));
                self.Pop(1);
                while (self.Next(top))
                {
                    array.Add(ToJsonValue(self));
                    self.Pop(1);
                }
            }
        }
        else
        {
            return(new ProxyArray());
        }
        return(ret);
    }
示例#55
0
    /// <summary>
    /// 将指定栈位置的数据转为它确切的类型
    /// 即:自动判断其类型,然后做转换;包括Unity内置类型。
    /// </summary>
    public static object ToAnyObject(this ILuaState self, int index)
    {
        var luaT = self.Type(index);

        switch (luaT)
        {
        case LuaTypes.LUA_TNUMBER:
            return((float)self.ToNumber(index));

        case LuaTypes.LUA_TSTRING:
            return(self.ToString(index));

        case LuaTypes.LUA_TUSERDATA:
        {
            var ls    = LuaEnv.Get(self).ls;
            int udata = LuaDLL.luanet_rawnetobj(self, index);

            if (udata != -1)
            {
                object obj = null;
                ls.translator.objects.TryGetValue(udata, out obj);
                return(obj);
            }
            else
            {
                return(null);
            }
        }

        case LuaTypes.LUA_TBOOLEAN:
            return(self.ToBoolean(index));

        case LuaTypes.LUA_TTABLE:
            return(self.ToAnyTable(index));

        case LuaTypes.LUA_TFUNCTION:
            return(self.ToLuaFunction(index));

        default:
            return(null);
        }
    }
示例#56
0
 public override string ToString()
 {
     return("" + hWnd.ToString() + " | " + name + " | " + title.ToString());
 }
示例#57
0
 public override string ToString()
 {
     return(_value.ToString());
 }
示例#58
0
 public static string OptString(this ILuaState self, int index, string def)
 {
     return(self.IsNoneOrNil(index) ? def : self.ToString(index));
 }
        private void btnStart_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (isStartable)
            {
                ProcessStartInfo startInfo   = new ProcessStartInfo();
                HANDLE           eventHandle = createEvent();

                string sframeFilename = "SFrame.exe";
                startInfo.EnvironmentVariables[String.Format("{0}_PARENT", sframeFilename)] = "Launcher.exe";
                startInfo.EnvironmentVariables[String.Format("{0}_RUNNER", sframeFilename)] = eventHandle.ToString();
                startInfo.UseShellExecute = false;
                startInfo.FileName        = "SFrame.exe";
                startInfo.Arguments       = " /auth_ip:auth.heavensfall.net /use_nprotect:0 /help_url_w:611 /help_url_h:625 /locale:ASCII /country:US /cash /commercial_shop /layout_dir:6 /layout_auto:0 /cash_url_w:800 /cash_url_h:631 /network.max_msg_process:1 /user_no:1";
                try {
                    Process.Start(startInfo);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    Application.Current.Shutdown();
                }

                WaitForSingleObject(eventHandle, 10 * 1000);
                Application.Current.Shutdown();
            }
        }
示例#60
0
            public System.IntPtr CbtHookProc(int nCode, System.IntPtr wParam, System.IntPtr lParam)
            {
                switch (nCode)
                {
                case NativeMethods.HCBT_ACTIVATE:
                    System.Diagnostics.Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "I: Dialog HCBT_ACTIVATE (hWnd={0}).    {{Medo.MessageBox}}", wParam.ToString()));

                    if (this._owner != null)
                    {
                        NativeMethods.RECT rectMessage = new NativeMethods.RECT();
                        NativeMethods.RECT rectOwner   = new NativeMethods.RECT();
                        if ((NativeMethods.GetWindowRect(wParam, ref rectMessage)) && (NativeMethods.GetWindowRect(this._owner.Handle, ref rectOwner)))
                        {
                            int widthMessage  = rectMessage.right - rectMessage.left;
                            int heightMessage = rectMessage.bottom - rectMessage.top;
                            int widthOwner    = rectOwner.right - rectOwner.left;
                            int heightOwner   = rectOwner.bottom - rectOwner.top;

                            int newLeft = rectOwner.left + (widthOwner - widthMessage) / 2;
                            int newTop  = rectOwner.top + (heightOwner - heightMessage) / 2;

                            NativeMethods.SetWindowPos(wParam, System.IntPtr.Zero, newLeft, newTop, 0, 0, NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE);
                        }
                    }

                    if (Resources.IsTranslatable)
                    {
                        NativeMethods.SetDlgItemText(wParam, NativeMethods.DLG_ID_OK, Resources.OK);
                        NativeMethods.SetDlgItemText(wParam, NativeMethods.DLG_ID_CANCEL, Resources.Cancel);
                        NativeMethods.SetDlgItemText(wParam, NativeMethods.DLG_ID_ABORT, Resources.Abort);
                        NativeMethods.SetDlgItemText(wParam, NativeMethods.DLG_ID_RETRY, Resources.Retry);
                        NativeMethods.SetDlgItemText(wParam, NativeMethods.DLG_ID_IGNORE, Resources.Ignore);
                        NativeMethods.SetDlgItemText(wParam, NativeMethods.DLG_ID_YES, Resources.Yes);
                        NativeMethods.SetDlgItemText(wParam, NativeMethods.DLG_ID_NO, Resources.No);
                    }

                    try {
                        return(NativeMethods.CallNextHookEx(this._hook, nCode, wParam, lParam));
                    } finally {
                        this.Dispose();
                    }
                }
                return(NativeMethods.CallNextHookEx(this._hook, nCode, wParam, lParam));
            }