Beispiel #1
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Demonstrates the client/transform communications. Displays the
        /// frame count in the rotator transform by calling the get accessor
        /// of a property
        ///
        /// This function uses late binding and expects the rotator transform
        /// to be instantiated.
        /// </summary>
        /// <history>
        ///    01 Nov 18  Cynic - Originally Written
        /// </history>
        private void buttonGetFCViaProperty_Click(object sender, EventArgs e)
        {
            LogMessage("buttonGetFCViaProperty_Click called");

            // get the transform
            IMFTransform transformObject = ctlTantaEVRFilePlayer1.GetTransform();

            if (transformObject == null)
            {
                LogMessage("buttonGetFCViaProperty: transformObject == null");
                OISMessageBox("No transform object. Is the video running?");
                return;
            }

            // get the real type of the transform. This assumes it is a .NET
            // based transform - otherwise it will probably just be a generic
            // _ComObject and the code below will fail.
            Type transformObjectType = transformObject.GetType();

            // set up to invoke the FrameCountAsPropertyDemonstrator. Note that
            // we have to know the name of the propery we are calling and the
            // type it takes.
            try
            {
                object frameCount = transformObjectType.InvokeMember("FrameCountAsPropertyDemonstrator", BindingFlags.GetProperty, null, transformObject, null);
                if ((frameCount is int) == true)
                {
                    LogMessage("The frame count is " + frameCount.ToString());
                    OISMessageBox("FrameCount=" + frameCount.ToString());
                }
            }
            catch (Exception ex)
            {
                OISMessageBox("An error occured please see the logfile");
                LogMessage(ex.Message);
                LogMessage(ex.StackTrace);
            }
        }
Beispiel #2
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Demonstrates the client/transform communications. Displays the
        /// frame count in the rotator transform by calling the a function.
        /// The function requires two parameters a leading string and a ref string
        /// which is the output. A boolean is returned to indicate success. The
        /// frame count is appended to the user supplied leading string.
        ///
        /// This function uses late binding and expects the rotator transform
        /// to be instantiated.
        /// </summary>
        /// <history>
        ///    01 Nov 18  Cynic - Originally Written
        /// </history>
        private void buttonGetFCViaFunction_Click(object sender, EventArgs e)
        {
            LogMessage("buttonGetFCViaFunction_Click called");

            // get the transform
            IMFTransform transformObject = ctlTantaEVRFilePlayer1.GetTransform();

            if (transformObject == null)
            {
                LogMessage("buttonGetFCViaFunction: transformObject == null");
                OISMessageBox("No transform object. Is the video running?");
                return;
            }

            // get the real type of the transform. This assumes it is a .NET
            // based transform - otherwise it will probably just be a generic
            // _ComObject and the code below will fail.
            Type transformObjectType = transformObject.GetType();

            // set up our parameters. both are strings, the second is ref string
            object[] parameters = new object[2];
            string   outText    = "Unknown FrameCount";

            parameters[0] = "I just checked, the frame count is ";
            parameters[1] = outText;

            // set up our parameter modifiers. This is how we tell the InvokeMember
            // call that one of our parameters is a ref
            ParameterModifier paramMods = new ParameterModifier(2);

            paramMods[1] = true;
            ParameterModifier[] paramModifierArray = { paramMods };

            try
            {
                // set up to invoke the FrameCountAsFunctionDemonstrator. Note that
                // we have to know the name of the function we are calling, the return
                // type and its parameter types
                object retVal = transformObjectType.InvokeMember("FrameCountAsFunctionDemonstrator", BindingFlags.InvokeMethod, null, transformObject, parameters, paramModifierArray, null, null);
                if ((retVal is bool) == false)
                {
                    LogMessage("buttonGetFCViaFunction_Click: call to FrameCountAsFunctionDemonstrator failed.");
                    OISMessageBox("call to FrameCountAsFunctionDemonstrator failed.");
                    return;
                }
            }
            catch (Exception ex)
            {
                OISMessageBox("An error occured please see the logfile");
                LogMessage(ex.Message);
                LogMessage(ex.StackTrace);
            }

            if (parameters[1] == null)
            {
                LogMessage("buttonGetFCViaFunction_Click: Null value returned for ref parameter.");
                OISMessageBox("Null value returned for ref parameter.");
                return;
            }
            if ((parameters[1] is string) == false)
            {
                LogMessage("buttonGetFCViaFunction_Click: Reference value is not a string");
                OISMessageBox("Reference value is not a string.");
                return;
            }

            LogMessage("buttonGetFCViaFunction_Click: " + (parameters[1] as string));
            OISMessageBox((parameters[1] as string));
        }