public static FilterItem FromOSD(OSDMap map)
        {
            var ret = new FilterItem();

            ret.Name = map["name"];
            ret.enabled = map["enabled"];
            ret.Type = (ItemType)map["type"].AsInteger();

            return ret;
        }
Ejemplo n.º 2
0
        void cbCell_Toggled(object o, ToggledArgs args)
        {
            TreeIter iter;

            if (store.GetIterFromString(out iter, args.Path))
            {
                FilterItem item = store.GetValue(iter, 0) as FilterItem;
                if (null != item)
                {
                    item.Enabled = !item.Enabled;
                    store.SetValue(iter, 0, item);
                }
            }
        }
Ejemplo n.º 3
0
        protected void ShowContext()
        {
            var selected = Selection.GetSelectedRows();

            if (selected.Length < 1)
            {
                return;
            }

            Menu context = new Menu();

            MenuItem item = new MenuItem("Remove");

            item.Activated += (sender, e) =>
            {
                foreach (var p in selected)
                {
                    TreeIter iter;
                    if (Messages.GetIter(out iter, p))
                    {
                        Messages.Remove(ref iter);
                    }
                }
                Selection.UnselectAll();
            };
            context.Add(item);

            if (selected.Length == 1)
            {
                TreeIter iter;
                Messages.GetIter(out iter, selected[0]);
                var session = Messages.GetValue(iter, 0) as Session;
                if (session != null)
                {
                    item            = new MenuItem("Remove All " + session.Name);
                    item.Activated += (sender, e) =>
                    {
                        TreeIter delIter;
                        Messages.GetIterFirst(out delIter);

                        while (Messages.IterIsValid(delIter))
                        {
                            var delSession = Messages.GetValue(delIter, 0) as Session;
                            if (delSession != null && delSession.GetType() == session.GetType() && delSession.Name == session.Name)
                            {
                                Messages.Remove(ref delIter);
                            }
                            else
                            {
                                Messages.IterNext(ref delIter);
                            }
                        }
                    };
                    context.Add(item);

                    item            = new MenuItem("Remove and Filter Out All " + session.Name);
                    item.Activated += (sender, e) =>
                    {
                        TreeIter delIter;
                        Messages.GetIterFirst(out delIter);

                        FilterItem filterOut = Main.GetFilter(session);
                        if (filterOut != null)
                        {
                            filterOut.Enabled = false;
                        }
                        Main.RedrawFilters();

                        while (Messages.IterIsValid(delIter))
                        {
                            var delSession = Messages.GetValue(delIter, 0) as Session;
                            if (delSession != null && delSession.GetType() == session.GetType() && delSession.Name == session.Name)
                            {
                                Messages.Remove(ref delIter);
                            }
                            else
                            {
                                Messages.IterNext(ref delIter);
                            }
                        }
                    };
                    context.Add(item);


                    FilterItem filter = Main.GetFilter(session);
                    if (filter != null)
                    {
                        var citem = new CheckMenuItem("Receive " + session.Name);
                        citem.Active   = filter.Enabled;
                        citem.Toggled += (sender, e) =>
                        {
                            filter.Enabled = !filter.Enabled;
                            Main.RedrawFilters();
                        };
                        context.Add(citem);
                    }
                }
            }

            context.Add(new SeparatorMenuItem());

            item            = new MenuItem("Select All");
            item.Activated += (sender, e) =>
            {
                Selection.SelectAll();
            };
            context.Add(item);

            item            = new MenuItem("Deselect");
            item.Activated += (sender, e) =>
            {
                Selection.UnselectAll();
            };
            context.Add(item);

            context.Add(new SeparatorMenuItem());

            item            = new MenuItem("Copy");
            item.Activated += (sender, e) =>
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                foreach (var p in selected)
                {
                    TreeIter iter;
                    if (Messages.GetIter(out iter, p))
                    {
                        var session = Messages.GetValue(iter, 0) as Session;
                        if (session != null)
                        {
                            sb.AppendLine(string.Join(" | ", session.Columns));
                        }
                    }

                    Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false)).Text = sb.ToString().TrimEnd();
                }
            };
            context.Add(item);

            item            = new MenuItem("Clear");
            item.Activated += (sender, e) =>
            {
                Selection.UnselectAll();
                Messages.Clear();
            };
            context.Add(item);

            context.ShowAll();
            context.Popup();
        }