Exemplo n.º 1
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            //FrameworkElement element = container as FrameworkElement;
            //if (element != null && item != null && item is Task)

            DIDeviceInfo diDeviceInfo = item as DIDeviceInfo;

            if (diDeviceInfo != null)
            {
                return(_DIDeviceInfoDT);
            }
            else
            {
                PnPEntityInfo pnpEntityInfo = item as PnPEntityInfo;
                if (pnpEntityInfo != null)
                {
                    return(_PnPEntityInfoDT);
                }
            }

            return(null);
        }
        public static void FormatDataIntoRichText(InlineCollection inlines, DIDeviceInfo diDeviceInfo)
        {
            inlines.Add(
                new Run($"ProductName: {diDeviceInfo.ProductName}")
            {
                FontWeight = PnPEntityInfo_To_RichText_Converter.ImportantFontWeight,
                Foreground = PnPEntityInfo_To_RichText_Converter.ImportantBrush
            }
                );
            inlines.Add(new LineBreak());
            inlines.Add(new Run($"InstanceName: {diDeviceInfo.ProductName}"));
            inlines.Add(new LineBreak());
            inlines.Add(new LineBreak());


            inlines.Add(new Run($"VID_PID: ")
            {
                FontWeight = PnPEntityInfo_To_RichText_Converter.ImportantFontWeight
            });
            inlines.Add(
                new Run(diDeviceInfo.VID_PID.ToString())
            {
                FontWeight = PnPEntityInfo_To_RichText_Converter.ImportantFontWeight,
                Foreground = PnPEntityInfo_To_RichText_Converter.ImportantBrush
            }
                );
            inlines.Add(new LineBreak());
            inlines.Add(new Run($"PID_VID string: ")
            {
                FontWeight = PnPEntityInfo_To_RichText_Converter.ImportantFontWeight
            });
            inlines.Add(
                new Run(diDeviceInfo.PID_VIDstring.ToString())
            {
                FontWeight = PnPEntityInfo_To_RichText_Converter.ImportantFontWeight,
                Foreground = PnPEntityInfo_To_RichText_Converter.ImportantBrush
            }
                );
            inlines.Add(new LineBreak());
            inlines.Add(new LineBreak());


            // ProductGuid formating
            string productGuidString        = diDeviceInfo.ProductGuid.ToString();
            int    productGuidPartAEndIndex = productGuidString.IndexOf('-');

            inlines.Add(new Run("ProductGuid: ")
            {
                FontWeight = PnPEntityInfo_To_RichText_Converter.ImportantFontWeight
            });
            inlines.Add(
                new Run(productGuidString.SubstringR(0, productGuidPartAEndIndex - 1))
            {
                FontWeight = PnPEntityInfo_To_RichText_Converter.ImportantFontWeight,
                Foreground = PnPEntityInfo_To_RichText_Converter.ImportantBrush
            }
                );
            inlines.Add(new Run(productGuidString.Substring(productGuidPartAEndIndex)));
            inlines.Add(new LineBreak());

            inlines.Add(new Run("             " + diDeviceInfo.ProductGuid.ToString("D")));
            inlines.Add(new LineBreak());
            inlines.Add(new Run("             " + diDeviceInfo.ProductGuid.ToStringDecimals()));
            inlines.Add(new LineBreak());

            inlines.Add(new Run($"InstanceGuid: {diDeviceInfo.InstanceGuid}"));
            inlines.Add(new LineBreak());
            inlines.Add(new Run($"FFDriverGuid: {diDeviceInfo.FFDriverGuid}"));
            inlines.Add(new LineBreak());
            inlines.Add(new LineBreak());


            inlines.Add(new Run($"DeviceType: {diDeviceInfo.DeviceType}"));
            inlines.Add(new LineBreak());
            inlines.Add(new Run($"DeviceSubType: {diDeviceInfo.DeviceSubType}"));
            inlines.Add(new LineBreak());
            inlines.Add(new Run($"Riva.Input GamingDeviceType: {diDeviceInfo.RGamingDeviceType}"));
            inlines.Add(new LineBreak());
            inlines.Add(new LineBreak());


            inlines.Add(new Run($"Usage: {diDeviceInfo.Usage}"));
            inlines.Add(new LineBreak());
            inlines.Add(new Run($"UsagePage: {diDeviceInfo.UsagePage}"));
            inlines.Add(new LineBreak());
        }