/// <summary>
        /// Retrieves the highlighting color based on request id
        /// </summary>
        /// <param name="profile">Profile options for this file</param>
        /// <param name="description">The request description</param>
        /// <returns>Color</returns>
        public static Color GetColorForRequestId(ParsingOptions profile, string requestId)
        {
            Dictionary <string, string> hDefs = profile.GetHighlightingDefinitions();

            //check first if there is an exact match
            if (hDefs.ContainsKey(requestId))
            {
                return(TVColorConverter.GetColorFromString(hDefs[requestId]));
            }
            else
            {
                return(Color.Black);
            }
        }
        /// <summary>
        /// Retrieves the highlighting color based on request description
        /// </summary>
        /// <param name="profile">Profile options for this file</param>
        /// <param name="description">The request description</param>
        /// <returns>Color</returns>
        public static Color GetColorForRequestDescription(ParsingOptions profile, string description)
        {
            Dictionary <string, string> hDefs = profile.GetHighlightingDefinitions();

            //check first if there is an exact match
            if (hDefs.ContainsKey(description))
            {
                return(TVColorConverter.GetColorFromString(hDefs[description]));
            }
            else
            {
                //check for all definitions if there is a partial match
                foreach (KeyValuePair <string, string> hDef in hDefs)
                {
                    if (Utils.IsMatch(description, hDef.Key))
                    {
                        return(TVColorConverter.GetColorFromString(hDef.Value));
                    }
                }
            }
            return(Color.Black);
        }
Beispiel #3
0
        private void OptionsEditorLoad(object sender, EventArgs e)
        {
            if (TrafficViewerOptions.Instance.MemoryBufferSize == 1 &&
                TrafficViewerOptions.Instance.EstimatedLineSize == 1024)
            {
                _checkOptMemory.Checked = true;
                _checkOptSpeed.Checked  = false;
            }
            else
            {
                _checkOptMemory.Checked = false;
                _checkOptSpeed.Checked  = true;
            }

            _boxIp.Text = TrafficViewerOptions.Instance.TrafficServerIp;

            _numProxyPort.Value        = (decimal)TrafficViewerOptions.Instance.TrafficServerPort;
            _numServerSecurePort.Value = (decimal)TrafficViewerOptions.Instance.TrafficServerPortSecure;


            _gridDynElems.SetValues(TrafficViewerOptions.Instance.GetDynamicElements());

            //initialize the variable definitions list (in case is not set)
            TrafficViewerOptions.Instance.VariableDefinitions = TrafficViewerOptions.Instance.VariableDefinitions;

            //set the definitions list in a option grid format
            _gridVarDefs.SetValues((List <string>)
                                   TrafficViewerOptions.Instance.GetOption("VariableDefinitions"));

            //startup info
            _fileAutoLoad.Text = TrafficViewerOptions.Instance.StartupImport;

            //load profiles
            List <string> profilePaths   = TrafficViewerOptions.Instance.GetProfilePaths();
            string        startupProfile = TrafficViewerOptions.Instance.StartupImportProfile;
            int           selectedIndex  = 0;

            _boxStartupProfile.Items.Clear();
            foreach (string path in profilePaths)
            {
                try
                {
                    string fName = Path.GetFileName(path);
                    _boxStartupProfile.Items.Add(fName);
                    if (fName == startupProfile)
                    {
                        selectedIndex = _boxStartupProfile.Items.Count - 1;
                    }
                }
                catch { }
            }
            _boxStartupProfile.SelectedIndex = selectedIndex;


            _boxStartupParser.Items.Clear();

            foreach (ITrafficParser parser in TrafficViewer.Instance.TrafficParsers)
            {
                _boxStartupParser.Items.Add(parser.Name);

                if (String.Compare(parser.Name, TrafficViewerOptions.Instance.StartupParser) == 0)
                {
                    _boxStartupParser.SelectedIndex = _boxStartupParser.Items.Count - 1;
                }
            }

            _swatchBackground.Color = TVColorConverter.GetColorFromString(
                TrafficViewerOptions.Instance.ColorTextboxBackground);
            _swatchTextColor.Color = TVColorConverter.GetColorFromString(
                TrafficViewerOptions.Instance.ColorTextboxText);
            _swatchDiffColor.Color = TVColorConverter.GetColorFromString(
                TrafficViewerOptions.Instance.ColorDiffText);
            _swatchHighlightColor.Color = TVColorConverter.GetColorFromString(
                TrafficViewerOptions.Instance.ColorHighlight);

            _extensionGrid.SetValues((IEnumerable <string>)TrafficViewerOptions.Instance.GetOption("Extensions"));

            _checkPrompt.Checked = TrafficViewerOptions.Instance.ActionOnClose == (int)ConfirmCloseResult.Unknown;


            _gridSessionIds.SetValues(TrafficViewerOptions.Instance.GetSessionIdRegexes());

            _gridResponsePatterns.SetValues(TrafficViewerOptions.Instance.GetResponsePatterns());

            _boxHttpClient.Items.Clear();

            foreach (IHttpClientFactory clientFactory in TrafficViewer.Instance.HttpClientFactoryList)
            {
                _boxHttpClient.Items.Add(clientFactory.ClientType);

                if (String.Compare(clientFactory.ClientType, TrafficViewerOptions.Instance.HttpClientName) == 0)
                {
                    _boxHttpClient.SelectedIndex = _boxHttpClient.Items.Count - 1;
                }
            }

            _checkIgnoreInvalidCert.Checked = TrafficViewerOptions.Instance.IgnoreInvalidSslCert;
            _checkUseProxy.Checked          = TrafficViewerOptions.Instance.UseProxy;


            _boxProxyHost.Text           = TrafficViewerOptions.Instance.HttpProxyServer;
            _proxyCertificate.Text       = TrafficViewerOptions.Instance.ProxyCert;
            _boxProxyCertPass.Text       = TrafficViewerOptions.Instance.ProxyCertPass;
            _boxProxyPort.Value          = (decimal)TrafficViewerOptions.Instance.HttpProxyPort;
            _boxTimeout.Value            = (decimal)TrafficViewerOptions.Instance.HttpRequestTimeout;
            _numericRequestDelay.Value   = (decimal)TrafficViewerOptions.Instance.RequestDelay;
            _textRequestDelayFilter.Text = TrafficViewerOptions.Instance.RequestDelayFilter;


            _textForwardingHost.Text = TrafficViewerOptions.Instance.ForwardingHost;
            _numForwardingPort.Value = TrafficViewerOptions.Instance.ForwardingPort;
        }