private void next_parse_mark(OutputGroup og)
        {
            string path = og.GetPath();

            for (int i = current_capture_label_index + 1; i < CaptureLabels.Count; i++)
            {
                CaptureLabel cl = CaptureLabels[i];
                if (cl.level == og.Level &&
                    cl.get_path() == path
                    )
                {
                    if (current_capture_label_index >= 0 && current_capture_label_index < CaptureLabels.Count)
                    {
                        unmark_capture_branch(CaptureLabels[current_capture_label_index]);
                    }
                    mark_capture_branch(cl, og, path);
                    current_capture_label_index = i;
                    break;
                }
            }

            if (current_capture_label_index >= 0 && current_capture_label_index < CaptureLabels.Count)
            {
                NextMark.Enabled = CaptureLabels[current_capture_label_index].index_in_path < current_path_capture_count - 1;
                PrevMark.Enabled = CaptureLabels[current_capture_label_index].index_in_path > 0;
            }
        }
        void mark_capture_branch(CaptureLabel cl, OutputGroup og, string path)
        {
            List <CaptureLabel> cls = new List <CaptureLabel>();

            for (CaptureLabel c = cl; c != null; c = c.parent)
            {
                cls.Add(c);
            }
            int total_label_length = 0;

            for (int i = cls.Count - 1; i >= 0; i--)
            {
                CaptureLabel c = cls[i];
                if (!c.visible)
                {
                    continue;
                }
                c.start3 = c.start2 + total_label_length;
                c.end3   = c.end2 + total_label_length + c.label.Length;
                if (Settings.Default.PrintCaptureLabels)
                {
                    print_capture_label(c);
                    total_label_length += c.label.Length;
                }
                highlight_capture(c);
            }
            ignore_selection_changed = false;
            TextBox.Select(cl.start3, 0);
        }
示例#3
0
        /// <summary>
        /// output the parse resutls
        /// </summary>
        /// <returns></returns>
        private string get_captures_for_selected_group(OutputGroup[] chain, string capture_separator)
        {
            StringBuilder cs = new StringBuilder("");

            List <Capture> gcs = new List <Capture>();

            // gcs.Add(SourceForm.This.GroupCapture0);
            for (int i = 0; i < chain.Length; i++)
            {
                OutputGroup    og        = chain[i];
                List <Capture> child_gcs = new List <Capture>();
                foreach (Capture gc in gcs)
                {
                    foreach (Capture child_gc in gc[og.Name])
                    {
                        child_gcs.Add(child_gc);
                    }
                }
                gcs = child_gcs;
            }
            {//getting values from the last level gcs
                foreach (Capture gc in gcs)
                {
                    cs.Append(gc.Value);
                    cs.Append(capture_separator);
                }
            }

            return(cs.ToString());
        }
示例#4
0
 internal OutputGroup(string name, OutputGroup parent)
 {
     Name   = name;
     Parent = parent;
     for (OutputGroup og = this.Parent; og != null; og = og.Parent)
     {
         Level++;
     }
 }
示例#5
0
        internal OutputGroup[] GetChain()
        {
            List <OutputGroup> chain = new List <OutputGroup>();

            for (OutputGroup og = this; og != null; og = og.Parent)
            {
                chain.Insert(0, og);
            }
            return(chain.ToArray());
        }
示例#6
0
        /// <summary>
        /// return standard path used for comparison
        /// </summary>
        /// <returns></returns>
        internal string GetPath(string separator = "/")
        {
            List <string> path = new List <string>();

            for (OutputGroup og = this; og != null; og = og.Parent)
            {
                path.Insert(0, og.Name);
            }
            return(string.Join(separator, path.ToArray()));
        }
示例#7
0
        private void NavigateBy_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            Brush       brush;
            OutputGroup og = (OutputGroup)output_groups[e.Index];

            brush = new SolidBrush(Settings.Default.GetFilterBackColor(og.Level));
            e.Graphics.FillRectangle(brush, e.Bounds);
            brush = new SolidBrush(e.ForeColor);
            e.Graphics.DrawString((string)((ComboBox)sender).Items[e.Index], e.Font, brush, e.Bounds);
            e.DrawFocusRectangle();
        }
        void set_number_of_captures(OutputGroup og)
        {
            int    count = 0;
            string path  = og.GetPath();

            foreach (CaptureLabel cl in CaptureLabels)
            {
                if (cl.level != og.Level)
                {
                    continue;
                }
                string cl_path = cl.get_path();
                if (cl_path != path)
                {
                    continue;
                }
                count++;
            }
            SetStatus("Number of [" + path + "] captures: " + count);
            current_path_capture_count = count;
        }
        private void NavigateBy_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (NavigateBy.SelectedIndex < 0)
            {
                NavigateBy.BackColor = Color.Empty;
                return;
            }
            OutputGroup og = (OutputGroup)output_groups[NavigateBy.SelectedIndex];

            NavigateBy.BackColor = Settings.Default.GetFilterBackColor(og.Level);

            if (current_capture_label_index >= 0 && current_capture_label_index < CaptureLabels.Count)
            {
                unmark_capture_branch(CaptureLabels[current_capture_label_index]);
            }
            current_capture_label_index = -1;

            set_number_of_captures(og);

            NextUserMark_Click(null, null);
        }
 /// <summary>
 /// Return output group names as an array
 /// </summary>
 /// <param name="rns">root filter nodes</param>
 /// <param name="parent_og"></param>
 /// <param name="parent_group_name"></param>
 /// <param name="ogs">List</param>
 /// <param name="named_only"></param>
 internal void GetOutputGroupNames(Filter[] fs, OutputGroup parent_og, string parent_group_name, List <OutputGroup> ogs, bool named_only)
 {
     foreach (Filter f in fs)
     {
         if (parent_group_name != null && parent_group_name != f.InputGroupName)
         {
             continue;
         }
         foreach (string gn in f.GetGroupRawNames())
         {
             int         t;
             OutputGroup og = parent_og;
             if (!named_only || !int.TryParse(gn, out t))
             {//named group
                 og = new OutputGroup(gn, parent_og);
                 ogs.Add(og);
             }
             GetOutputGroupNames(f.Next, og, gn, ogs, named_only);
         }
     }
 }
示例#11
0
 internal OutputGroup(string name, OutputGroup parent)
 {
     Name = name;
     Parent = parent;
     for (OutputGroup og = this.Parent; og != null; og = og.Parent)
         Level++;
 }
示例#12
0
        /// <summary>
        /// output the parse resutls
        /// </summary>
        /// <returns></returns>
        private string get_captures_for_selected_group(OutputGroup[] chain, string capture_separator)
        {
            StringBuilder cs = new StringBuilder("");

            List<Capture> gcs = new List<Capture>();
               // gcs.Add(SourceForm.This.GroupCapture0);
            for (int i = 0; i < chain.Length; i++)
            {
                OutputGroup og = chain[i];
                List<Capture> child_gcs = new List<Capture>();
                foreach (Capture gc in gcs)
                    foreach (Capture child_gc in gc[og.Name])
                        child_gcs.Add(child_gc);
                gcs = child_gcs;
            }
            {//getting values from the last level gcs
                foreach (Capture gc in gcs)
                {
                    cs.Append(gc.Value);
                    cs.Append(capture_separator);
                }
            }

            return cs.ToString();
        }
 /// <summary>
 /// Return output group names as an array
 /// </summary>
 /// <param name="rns">root filter nodes</param>
 /// <param name="parent_og"></param>
 /// <param name="parent_group_name"></param>
 /// <param name="ogs">List</param>
 /// <param name="named_only"></param>
 internal void GetOutputGroupNames(Filter[] fs, OutputGroup parent_og, string parent_group_name, List<OutputGroup> ogs, bool named_only)
 {
     foreach (Filter f in fs)
     {
         if (parent_group_name != null && parent_group_name != f.InputGroupName)
             continue;
         foreach (string gn in f.GetGroupRawNames())
         {
             int t;
             OutputGroup og = parent_og;
             if (!named_only || !int.TryParse(gn, out t))
             {//named group
                 og = new OutputGroup(gn, parent_og);
                 ogs.Add(og);
             }
             GetOutputGroupNames(f.Next, og, gn, ogs, named_only);
         }
     }
 }