Esempio n. 1
0
 void Exit()
 {
     capture.StopCapturing();
     t.Abort();
     Tcp_packets_holder.StopWorking();
     Application.Quit();
 }
Esempio n. 2
0
    public MainWindow() : base("catcher")
    {
        Build();
        view                = new ItemsView();
        view.Reorderable    = true;
        view.Selection.Mode = SelectionMode.Multiple;

        view.KeyPressEvent += (object o, KeyPressEventArgs args) =>
        {
            if (args.Event.Key == Gdk.Key.Delete)
            {
                var         s_items = view.SelectedItems.ToList <ItemModel>();
                List <long> ids     = new List <long>();
                if (s_items.Count > 0)
                {
                    textview1.Buffer.Text = "";
                    textview2.Buffer.Text = "";

                    lock (_lock)
                    {
                        selection_on = false;
                        foreach (ItemModel i in s_items)
                        {
                            view.RemoveItem(i);
                            items.Remove(i);
                            ids.Add(i.Pair.Id);
                        }
                        Capturing.RegisterRemovePairs(ids);
                        selection_on = true;
                    }
                }
            }
        };

        foreach (var column in view.Columns)
        {
            column.Reorderable = true;
        }
        listview1.Child = view;
        listview1.ShowAll();
        view.ModifyFont(FontDescription.FromString("serif 9"));
        //view.ModifyBase(StateType.Normal, new Gdk.Color(150,205,205));
        //view.ModifyText(StateType.Normal, new Gdk.Color(230,232,250));
        textview1.ModifyFont(FontDescription.FromString("monospace bold 10"));
        textview2.ModifyFont(FontDescription.FromString("monospace bold 10"));
        textview1.ModifyBase(StateType.Normal, new Gdk.Color(82, 82, 82));
        textview1.ModifyText(StateType.Normal, new Gdk.Color(217, 135, 25));
        textview2.ModifyBase(StateType.Normal, new Gdk.Color(82, 82, 82));
        textview2.ModifyText(StateType.Normal, new Gdk.Color(217, 135, 25));

        view.ItemSelected += (ItemModel[] items) =>
        {
            if (selection_on)
            {
                lock (_lock)
                {
                    if (items.Count() > 0)
                    {
                        if (!string.IsNullOrEmpty(items[0].RequestText))
                        {
                            textview1.Buffer.Text = items[0].RequestText;
                        }
                        else
                        {
                            textview1.Buffer.Text = "";
                        }
                        if (!string.IsNullOrEmpty(items[0].ResponseText))
                        {
                            textview2.Buffer.Text = items[0].ResponseText;
                        }
                        else
                        {
                            textview2.Buffer.Text = "";
                        }
                    }
                    else
                    {
                        textview1.Buffer.Text = "";
                        textview2.Buffer.Text = "";
                    }
                    SelectedItem = items[0];
                }
            }
            else
            {
                SelectedItem = null;
            }
        };

        Tcp_packets_holder.StartWorking();
        StartCapturing();
    }