コード例 #1
0
ファイル: VolumeView.cs プロジェクト: pulb/basenji
        public VolumeView()
        {
            iconCache = new IconCache(this);
            sortProperty = VolumeSortProperty.VolumeID;
            toggleColumn = false;

            //
            // init columns
            //
            TreeViewColumn col;

            col = new TreeViewColumn(string.Empty, new CellRendererPixbuf(), "pixbuf", 0);
            col.Expand = false;
            AppendColumn(col);

            col = new TreeViewColumn(string.Empty, new CellRendererText(), "markup", 1);
            col.Expand = true;
            AppendColumn(col);

            //
            // setup store
            //
            ListStore store = new Gtk.ListStore(typeof(Gdk.Pixbuf),
                                                typeof(string),
                                                /* Volume - not visible */
                                                typeof(Volume));

            // must be assignet before
            // assinging the sort func
            this.Model = store;

            Gtk.TreeIterCompareFunc sortfunc = delegate(TreeModel m, TreeIter a, TreeIter b) {
                Volume vol_a = GetVolume(a);
                Volume vol_b = GetVolume(b);

                if (vol_a == null || vol_b == null)
                    return 0;

                switch (sortProperty) {
                    case VolumeSortProperty.Added:
                        return Math.Sign(vol_a.Added.Subtract(vol_b.Added).Ticks);
                    case VolumeSortProperty.ArchiveNo:
                        return Sorting.NatCompare(vol_a.ArchiveNo, vol_b.ArchiveNo);
                    case VolumeSortProperty.Category:
                        return string.Compare(vol_a.Category, vol_b.Category);
                    case VolumeSortProperty.DriveType:
                        return Math.Sign(vol_a.DriveType - vol_b.DriveType);
                    case VolumeSortProperty.Title:
                        return string.Compare(vol_a.Title, vol_b.Title);
                    case VolumeSortProperty.VolumeID:
                        return Math.Sign(vol_a.VolumeID - vol_b.VolumeID);
                    default:
                        throw new ArgumentException("Invalid VolumeSortProperty");
                }

                return 0;
            };

            store.SetSortFunc(0, sortfunc);
            store.SetSortFunc(1, sortfunc);

            // set initial sorting
            /* Sort(sortProperty, true); */
        }
コード例 #2
0
ファイル: VolumeView.cs プロジェクト: balihb/basenji
        public VolumeView()
        {
            iconCache    = new IconCache(this);
            sortProperty = VolumeSortProperty.VolumeID;
            toggleColumn = false;

            //
            // init columns
            //
            TreeViewColumn col;

            col        = new TreeViewColumn(string.Empty, new CellRendererPixbuf(), "pixbuf", 0);
            col.Expand = false;
            AppendColumn(col);

            col        = new TreeViewColumn(string.Empty, new CellRendererText(), "markup", 1);
            col.Expand = true;
            AppendColumn(col);

            //
            // setup store
            //
            ListStore store = new Gtk.ListStore(typeof(Gdk.Pixbuf),
                                                typeof(string),
                                                /* Volume - not visible */
                                                typeof(Volume));

            // must be assignet before
            // assinging the sort func
            this.Model = store;

            Gtk.TreeIterCompareFunc sortfunc = delegate(TreeModel m, TreeIter a, TreeIter b) {
                Volume vol_a = GetVolume(a);
                Volume vol_b = GetVolume(b);

                if (vol_a == null || vol_b == null)
                {
                    return(0);
                }

                switch (sortProperty)
                {
                case VolumeSortProperty.Added:
                    return(Math.Sign(vol_a.Added.Subtract(vol_b.Added).Ticks));

                case VolumeSortProperty.ArchiveNo:
                    return(Sorting.NatCompare(vol_a.ArchiveNo, vol_b.ArchiveNo));

                case VolumeSortProperty.Category:
                    return(string.Compare(vol_a.Category, vol_b.Category));

                case VolumeSortProperty.DriveType:
                    return(Math.Sign(vol_a.DriveType - vol_b.DriveType));

                case VolumeSortProperty.Title:
                    return(string.Compare(vol_a.Title, vol_b.Title));

                case VolumeSortProperty.VolumeID:
                    return(Math.Sign(vol_a.VolumeID - vol_b.VolumeID));

                default:
                    throw new ArgumentException("Invalid VolumeSortProperty");
                }

                return(0);
            };

            store.SetSortFunc(0, sortfunc);
            store.SetSortFunc(1, sortfunc);

            // set initial sorting
            /* Sort(sortProperty, true); */
        }
コード例 #3
0
ファイル: VolumeView.cs プロジェクト: pulb/basenji
 public void SetSortProperty(VolumeSortProperty sortProperty, bool descending)
 {
     this.sortProperty = sortProperty;
     toggleColumn = !toggleColumn;
     ((ListStore)Model).SetSortColumnId(toggleColumn ? 0 : 1, descending ? SortType.Descending : SortType.Ascending);
 }
コード例 #4
0
ファイル: VolumeView.cs プロジェクト: balihb/basenji
 public void SetSortProperty(VolumeSortProperty sortProperty, bool descending)
 {
     this.sortProperty = sortProperty;
     toggleColumn      = !toggleColumn;
     ((ListStore)Model).SetSortColumnId(toggleColumn ? 0 : 1, descending ? SortType.Descending : SortType.Ascending);
 }