コード例 #1
0
        // Begins a "group" which groups several Highlights together.
        public static void OpenGroup(OpenGroupParams openGroupParams)
        {
            if (!instanceCreated)
            {
                Debug.LogError("ERROR: Cannot open a group. The SDK has not been initialized.");
                return;
            }

            OpenGroupParamsInternal ogp = new OpenGroupParamsInternal();

            ogp.id = openGroupParams.Id;

            StringBuilder sb = new StringBuilder();

            foreach (TranslationEntry te in openGroupParams.GroupDescriptionTable)
            {
                sb.Append(te.Language).Append("\a").Append(te.Translation).Append("\a");
            }

            ogp.groupDescriptionTable = sb.ToString();

            IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(ogp));

            try
            {
                Marshal.StructureToPtr(ogp, pnt, false);
                Highlights_OpenGroupAsync(pnt);
            }
            finally {
                Marshal.FreeHGlobal(pnt);
            }
        }
コード例 #2
0
ファイル: Highlights.cs プロジェクト: xiangweizheng/Spark
        // Begins a "group" which groups several Highlights together.
        public static void OpenGroup(OpenGroupParams openGroupParams, EmptyCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Console.WriteLine("ERROR: Cannot open a group. The SDK has not been initialized.");
                return;
            }

            OpenGroupParamsInternal ogp = new OpenGroupParamsInternal();

            ogp.id = openGroupParams.Id;

            StringBuilder sb = new StringBuilder();

            foreach (TranslationEntry te in openGroupParams.GroupDescriptionTable)
            {
                sb.Append(te.Language).Append("\a").Append(te.Translation).Append("\a");
            }

            ogp.groupDescriptionTable = sb.ToString();

            IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(ogp));

            EmptyCallbackId cid = new EmptyCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr asyncOp = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                Marshal.StructureToPtr(ogp, pnt, false);
                Marshal.StructureToPtr(cid, asyncOp, false);

                Highlights_OpenGroupAsync(pnt, asyncOp);
            }
            finally
            {
                Marshal.FreeHGlobal(pnt);
                Marshal.FreeHGlobal(asyncOp);
            }
        }