Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        private void InitGridSetting()
        {
            m_ListSetting = new TraceEventListSetting();

            // providers

            if (m_Config.Providers != null)
            {
                foreach (EtwLogViewerConfig.ProviderConfig provider in m_Config.Providers)
                {
                    m_ListSetting.Providers.Add(new EtwProvider(provider.FriendlyName, provider.Name, provider.ID));
                }
            }

            // fields

            IDictionary <TraceEventFieldIndex, TraceEventField> allFields = TraceEventField.GetAllFields(m_ListSetting, TraceEventListSetting.DefaultColumnWidth);

            IDictionary <string, TraceEventPayload> allPayloads = new Dictionary <string, TraceEventPayload>();

            if (m_Config.KnownPayloads != null)
            {
                foreach (string name in m_Config.KnownPayloads)
                {
                    allPayloads[name] = new TraceEventPayload(name, TraceEventListSetting.DefaultColumnWidth);
                }
            }

            m_ListSetting.AddHideFields(allFields.Values);
            m_ListSetting.AddHideFields(allPayloads.Values);

            if (m_Config.Fields != null)
            {
                foreach (EtwLogViewerConfig.FieldConfig field in m_Config.Fields)
                {
                    if (field.IsTraceEventField)
                    {
                        if (allFields.TryGetValue(field.GetTraceEventField(), out TraceEventField found))
                        {
                            m_ListSetting.VisibleFields.Add(found);
                            m_ListSetting.HideFields.Remove(found);
                            found.SetWidth(field.Width);
                        }
                    }
                    else if (field.IsTraceEventPayload)
                    {
                        if (allPayloads.TryGetValue(field.GetTraceEventPayload(), out TraceEventPayload found))
                        {
                            m_ListSetting.VisibleFields.Add(found);
                            m_ListSetting.HideFields.Remove(found);
                            found.SetWidth(field.Width);
                        }
                        else
                        {
                            m_ListSetting.VisibleFields.Add(new TraceEventPayload(field.GetTraceEventPayload(), field.Width));
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal static EtwLogViewerConfig CreateDefault()
        {
            TraceEventListSetting listSetting = new TraceEventListSetting();

            EtwLogViewerConfig config = new EtwLogViewerConfig();

            // providers
            List <ProviderConfig> providers = new List <ProviderConfig>();

            providers.Add(new ProviderConfig()
            {
                FriendlyName = "provider1", Name = "providerName1", ID = Guid.NewGuid()
            });
            providers.Add(new ProviderConfig()
            {
                FriendlyName = "provider2", Name = "providerName2"
            });
            providers.Add(new ProviderConfig()
            {
                FriendlyName = "provider3", ID = Guid.NewGuid()
            });

            config.Providers = providers.ToArray();

            // payloads
            config.KnownPayloads = new string[] { "payloadName1", "payloadName2", "payloadName3" };

            // fields
            List <FieldConfig> fields = new List <FieldConfig>();

            foreach (KeyValuePair <TraceEventFieldIndex, TraceEventField> field in TraceEventField.GetAllFields(listSetting, TraceEventListSetting.DefaultColumnWidth))
            {
                fields.Add(new FieldConfig()
                {
                    Name = field.Key.ToString(), Width = field.Value.GetWidth()
                });
            }

            config.Fields = fields.ToArray();

            return(config);
        }