/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Handles a selected index changed on a transform in the list view /// </summary> /// <history> /// 01 Nov 18 Cynic - Started /// </history> private void listViewAvailableTransforms_SelectedIndexChanged(object sender, EventArgs e) { // just send a clearing event if (TransformPickedEvent != null) { TransformPickedEvent(this, null); } if (CurrentTransformCategory == null) { return; } TantaMFTCapabilityContainer selectedTransform = GetSelectedTransformContainer(); if (selectedTransform == null) { return; } // just send the event if (TransformPickedEvent != null) { TransformPickedEvent(this, GetSelectedTransformContainer()); } // set the display SetTransformInfoPanel(selectedTransform); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Handles a double click on a transform in the list view /// </summary> /// <history> /// 01 Nov 18 Cynic - Started /// </history> private void listViewAvailableTransforms_DoubleClick(object sender, EventArgs e) { LogMessage("listViewAvailableTransforms_DoubleClick"); // get the selected transform TantaMFTCapabilityContainer selectedTransform = GetSelectedTransformContainer(); if (selectedTransform == null) { return; } // send the event to report this if (TransformPickedEvent != null) { TransformPickedEvent(this, selectedTransform); } }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Sets the transform information panel on the control /// </summary> /// <param name="transformToDisplay">the transform to display</param> /// <history> /// 01 Nov 18 Cynic - Started /// </history> private void SetTransformInfoPanel(TantaMFTCapabilityContainer transformToDisplay) { List <IMFMediaType> outputTypes = null; List <IMFMediaType> inputTypes = null; StringBuilder displaySb = new StringBuilder(); StringBuilder outputSb = new StringBuilder(); StringBuilder inputSb = new StringBuilder(); StringBuilder headerSb = new StringBuilder(); StringBuilder outSb; HResult hr; // clear it down ClearTransformInfoPanel(); if (transformToDisplay == null) { return; } // set up our header information headerSb.Append(transformToDisplay.TransformFriendlyName); headerSb.Append("\r\n"); headerSb.Append(transformToDisplay.TransformGuidValueAsString); headerSb.Append("\r\n"); if (transformToDisplay.IsAsyncMFT == "x") { headerSb.Append("IsAsyncMFT" + ", "); } if (transformToDisplay.IsSyncMFT == "x") { headerSb.Append("IsSyncMFT" + ", "); } if (transformToDisplay.IsFieldOfUse == "x") { headerSb.Append("IsFieldOfUse" + ", "); } // we do not include these, the enum function does not give us this // if (transformToDisplay.IsHardware == "x") headerSb.Append("IsHardware" + ", "); // if (transformToDisplay.IsLocalMFT == "x") headerSb.Append("IsLocalMFT" + ", "); // if (transformToDisplay.IsTranscodeOnly == "x") headerSb.Append("IsTranscodeOnly" + ", "); headerSb.Append("\r\n"); try { // populate the RichText box with the input media type capabilities inputTypes = TantaWMFUtils.GetInputMediaTypesFromTransformByGuid(transformToDisplay.TransformGuidValue, false); // do we have any input types? if ((inputTypes != null) && (inputTypes.Count != 0)) { // go through the types foreach (IMFMediaType mediaType in inputTypes) { // the major media type hr = TantaMediaTypeInfo.GetMediaMajorTypeAsText(mediaType, out outSb); if (hr != HResult.S_OK) { continue; } if (outSb == null) { continue; } inputSb.Append(outSb); inputSb.Append("\r\n"); // the sub media type hr = TantaMediaTypeInfo.GetMediaSubTypeAsText(mediaType, out outSb); if (hr != HResult.S_OK) { continue; } if (outSb == null) { continue; } inputSb.Append(outSb); inputSb.Append("\r\n"); // enumerate all of the possible Attributes so we can see which ones are present that we did not report on StringBuilder allAttrs = new StringBuilder(); hr = TantaMediaTypeInfo.EnumerateAllAttributeNamesInMediaTypeAsText(mediaType, true, true, TantaWMFUtils.MAX_TYPES_TESTED_PER_TRANSFORM, out allAttrs); if (hr != HResult.S_OK) { continue; } char[] charsToTrim = { ',', '.', ' ' }; inputSb.Append("OtherAttrs=" + allAttrs.ToString().TrimEnd(charsToTrim)); inputSb.Append("\r\n"); inputSb.Append("\r\n"); } } } finally { // release the list of media type objects if ((inputTypes != null) && (inputTypes.Count != 0)) { foreach (IMFMediaType mediaType in inputTypes) { Marshal.ReleaseComObject(mediaType); } } } try { // populate the RichText box with the output media type capabilities outputTypes = TantaWMFUtils.GetOutputMediaTypesFromTransformByGuid(transformToDisplay.TransformGuidValue, false); // do we have any output types? if ((outputTypes != null) && (outputTypes.Count != 0)) { // go through the types foreach (IMFMediaType mediaType in outputTypes) { // the major media type hr = TantaMediaTypeInfo.GetMediaMajorTypeAsText(mediaType, out outSb); if (hr != HResult.S_OK) { continue; } if (outSb == null) { continue; } outputSb.Append(outSb); outputSb.Append("\r\n"); // the sub media type hr = TantaMediaTypeInfo.GetMediaSubTypeAsText(mediaType, out outSb); if (hr != HResult.S_OK) { continue; } if (outSb == null) { continue; } outputSb.Append(outSb); outputSb.Append("\r\n"); // enumerate all of the possible Attributes so we can see which ones are present that we did not report on StringBuilder allAttrs = new StringBuilder(); hr = TantaMediaTypeInfo.EnumerateAllAttributeNamesInMediaTypeAsText(mediaType, true, true, TantaWMFUtils.MAX_TYPES_TESTED_PER_TRANSFORM, out allAttrs); if (hr != HResult.S_OK) { continue; } char[] charsToTrim = { ',', '.', ' ' }; outputSb.Append("OtherAttrs=" + allAttrs.ToString().TrimEnd(charsToTrim)); outputSb.Append("\r\n"); outputSb.Append("\r\n"); } } } finally { // release the list of media type objects if ((outputTypes != null) && (outputTypes.Count != 0)) { foreach (IMFMediaType mediaType in outputTypes) { Marshal.ReleaseComObject(mediaType); } } } // display what we have displaySb.Append(headerSb); displaySb.Append("\r\n"); displaySb.Append("\r\n"); displaySb.Append("####\r\n"); displaySb.Append("#### INPUT TYPES\r\n"); displaySb.Append("####\r\n"); displaySb.Append("\r\n"); if (inputSb.Length > 0) { displaySb.Append(inputSb); } else { displaySb.Append("<not known>"); displaySb.Append("\r\n"); } displaySb.Append("\r\n"); displaySb.Append("####\r\n"); displaySb.Append("#### OUTPUT TYPES\r\n"); displaySb.Append("####\r\n"); displaySb.Append("\r\n"); if (outputSb.Length > 0) { displaySb.Append(outputSb); } else { displaySb.Append("<not known>"); displaySb.Append("\r\n"); } displaySb.Append("\r\n"); richTextBoxtTransformDetails.Text = displaySb.ToString(); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Displays the transforms for the currently selected category. Since each /// </summary> /// <history> /// 01 Nov 18 Cynic - Started /// </history> private void DisplayTransformsForCurrentCategory() { int numResults; IMFActivate[] activatorArray; List <TantaMFTCapabilityContainer> transformList = new List <TantaMFTCapabilityContainer>(); HResult hr; try { // clear what we have now listViewAvailableTransforms.Clear(); // reset this listViewAvailableTransforms.ListViewItemSorter = null; // get the currently selected major category TantaGuidNamePair currentCategory = (TantaGuidNamePair)comboBoxTransformCategories.SelectedItem; if (currentCategory == null) { return; } // we have multiple sub-categories. These are set by specific flags on the MFTEnumX call. We iterate // through each flag and get the matching transforms. If we already have it we just set the flag on // the exisiting one to show it is in multiple sub-categories foreach (MFT_EnumFlag flagVal in Enum.GetValues(typeof(MFT_EnumFlag))) { // we do not need this one if (flagVal == MFT_EnumFlag.None) { continue; } // The documentation states that there is no way to enumerate just local MFTs and nothing else. // Setting Flags equal to MFT_ENUM_FLAG_LOCALMFT is equivalent to including the MFT_ENUM_FLAG_SYNCMFT flag // which messes us up. This also appears to be true for the FieldOfUse and transcode only flags so we // do not include them if (flagVal == MFT_EnumFlag.LocalMFT) { continue; } if (flagVal == MFT_EnumFlag.FieldOfUse) { continue; } if (flagVal == MFT_EnumFlag.TranscodeOnly) { continue; } // some of the higher flags are just for sorting the return results if (flagVal >= MFT_EnumFlag.All) { break; } hr = MFExtern.MFTEnumEx(currentCategory.GuidValue, flagVal, null, null, out activatorArray, out numResults); if (hr != HResult.S_OK) { throw new Exception("DisplayTransformsForCurrentCategory, call to MFExtern.MFTEnumEx failed. HR=" + hr.ToString()); } // now loop through the returned activators for (int i = 0; i < numResults; i++) { // extract the friendlyName and symbolicLinkName Guid outGuid = TantaWMFUtils.GetGuidForKeyFromActivator(activatorArray[i], MFAttributesClsid.MFT_TRANSFORM_CLSID_Attribute); string friendlyName = TantaWMFUtils.GetStringForKeyFromActivator(activatorArray[i], MFAttributesClsid.MFT_FRIENDLY_NAME_Attribute); // create a new TantaMFTCapabilityContainer for it TantaMFTCapabilityContainer workingMFTContainer = new TantaMFTCapabilityContainer(friendlyName, outGuid, currentCategory); // do we have this in our list yet int index = transformList.FindIndex(x => x.TransformGuidValue == workingMFTContainer.TransformGuidValue); if (index >= 0) { // yes, it does contain this transform, just record the new sub-category transformList[index].EnumFlags |= flagVal; } else { // no, it does not contain this transform yet, set the sub-category workingMFTContainer.EnumFlags = flagVal; // and add it transformList.Add(workingMFTContainer); if ((activatorArray[i] is IMFAttributes) == true) { StringBuilder outSb = null; List <string> attributesToIgnore = new List <string>(); attributesToIgnore.Add("MFT_FRIENDLY_NAME_Attribute"); attributesToIgnore.Add("MFT_TRANSFORM_CLSID_Attribute"); attributesToIgnore.Add("MF_TRANSFORM_FLAGS_Attribute"); attributesToIgnore.Add("MF_TRANSFORM_CATEGORY_Attribute"); hr = TantaWMFUtils.EnumerateAllAttributeNamesAsText((activatorArray[i] as IMFAttributes), attributesToIgnore, 100, out outSb); } } // clean up our activator Marshal.ReleaseComObject(activatorArray[i]); } } // now display the transforms foreach (TantaMFTCapabilityContainer mftCapability in transformList) { ListViewItem lvi = new ListViewItem(new[] { mftCapability.TransformFriendlyName, mftCapability.IsSyncMFT, mftCapability.IsAsyncMFT, mftCapability.IsHardware, /* mftCapability.IsFieldOfUse, mftCapability.IsLocalMFT, mftCapability.IsTranscodeOnly, */ mftCapability.TransformGuidValueAsString }); lvi.Tag = mftCapability; listViewAvailableTransforms.Items.Add(lvi); } listViewAvailableTransforms.Columns.Add("Name", 250); listViewAvailableTransforms.Columns.Add("IsSyncMFT", 70); listViewAvailableTransforms.Columns.Add("IsAsyncMFT", 90); listViewAvailableTransforms.Columns.Add("IsHardware", 90); // listViewAvailableTransforms.Columns.Add("IsFieldOfUse", 90); // listViewAvailableTransforms.Columns.Add("IsLocalMFT", 90); // listViewAvailableTransforms.Columns.Add("IsTranscodeOnly", 90); listViewAvailableTransforms.Columns.Add("Guid", 200); } finally { } }