示例#1
0
        private void BuildWidget ()
        {
            HBox box = new HBox ();

            disk_bar_align = new Alignment (0.5f, 0.5f, 1.0f, 1.0f);
            disk_bar = new SegmentedBar ();
            disk_bar.ValueFormatter = DapValueFormatter;

            disk_bar.AddSegmentRgb (Catalog.GetString ("Audio"), 0, 0x3465a4);
            disk_bar.AddSegmentRgb (Catalog.GetString ("Video"), 0, 0x73d216);
            disk_bar.AddSegmentRgb (Catalog.GetString ("Other"), 0, 0xf57900);
            disk_bar.AddSegment (Catalog.GetString ("Free Space"), 0, disk_bar.RemainderColor, false);

            UpdateUsage ();

            disk_bar_align.Add (disk_bar);

            box.PackStart (disk_bar_align, true, true, 0);
            disk_bar_align.TopPadding = 6;

            Add (box);
            box.ShowAll ();

            SizeAllocated += delegate (object o, Gtk.SizeAllocatedArgs args) {
                SetBackground ();
                disk_bar.HorizontalPadding = (int)(args.Allocation.Width * 0.25);
            };
        }
示例#2
0
        public SegmentedBarTestModule() : base("Segmented Bar")
        {
            BorderWidth  = 10;
            AppPaintable = true;

            box = new VBox {
                Spacing = 10
            };
            Add(box);

            int space = 55;

            bar = new SegmentedBar();
            bar.HorizontalPadding = bar.BarHeight / 2;
            bar.AddSegmentRgb("Audio", 0.00187992456702332, 0x3465a4);
            bar.AddSegmentRgb("Other", 0.0788718162651326, 0xf57900);
            bar.AddSegmentRgb("Video", 0.0516869922033282, 0x73d216);
            bar.AddSegment("Free Space", 0.867561266964516, bar.RemainderColor, false);

            bar.ValueFormatter = delegate(SegmentedBar.Segment segment) {
                return(string.Format("{0} GB", space * segment.Percent));
            };

            var controls = new HBox {
                Spacing = 5
            };

            var label = new Label("Height:");

            controls.PackStart(label, false, false, 0);

            var height = new SpinButton(new Adjustment(bar.BarHeight, 5, 100, 1, 1, 1), 1, 0);

            height.Activated += delegate { bar.BarHeight = height.ValueAsInt; };
            height.Changed   += delegate { bar.BarHeight = height.ValueAsInt; bar.HorizontalPadding = bar.BarHeight / 2; };
            controls.PackStart(height, false, false, 0);

            var reflect = new CheckButton("Reflection")
            {
                Active = bar.ShowReflection
            };

            reflect.Toggled += delegate { bar.ShowReflection = reflect.Active; };
            controls.PackStart(reflect, false, false, 0);

            var labels = new CheckButton("Labels")
            {
                Active = bar.ShowLabels
            };

            labels.Toggled += delegate { bar.ShowLabels = labels.Active; };
            controls.PackStart(labels, false, false, 0);

            box.PackStart(controls, false, false, 0);
            box.PackStart(new HSeparator(), false, false, 0);
            box.PackStart(bar, false, false, 0);
            box.ShowAll();

            SetSizeRequest(350, -1);

            var limits = new Gdk.Geometry {
                MinWidth  = SizeRequest().Width,
                MaxWidth  = Gdk.Screen.Default.Width,
                MinHeight = -1,
                MaxHeight = -1
            };

            SetGeometryHints(this, limits, Gdk.WindowHints.MaxSize | Gdk.WindowHints.MinSize);
        }
示例#3
0
        private string DapValueFormatter (SegmentedBar.Segment segment)
        {
            if (source == null) {
                return null;
            }

            long size = (long)(source.BytesCapacity * segment.Percent);
            return size <= 0
                ? Catalog.GetString ("None")
                : new Hyena.Query.FileSizeQueryValue (size).ToUserQuery ();
        }
示例#4
0
        public SegmentedBarTestModule () : base ("Segmented Bar")
        {
            BorderWidth = 10;
            AppPaintable = true;

            box = new VBox ();
            box.Spacing = 10;
            Add (box);

            int space = 55;
            bar = new SegmentedBar ();
            bar.HorizontalPadding = bar.BarHeight / 2;
            bar.AddSegmentRgb ("Audio", 0.00187992456702332, 0x3465a4);
            bar.AddSegmentRgb ("Other", 0.0788718162651326, 0xf57900);
            bar.AddSegmentRgb ("Video", 0.0516869922033282, 0x73d216);
            bar.AddSegment ("Free Space", 0.867561266964516, bar.RemainderColor, false);

            bar.ValueFormatter = delegate (SegmentedBar.Segment segment) {
                return String.Format ("{0} GB", space * segment.Percent);
            };

            HBox controls = new HBox ();
            controls.Spacing = 5;

            Label label = new Label ("Height:");
            controls.PackStart (label, false, false, 0);

            SpinButton height = new SpinButton (new Adjustment (bar.BarHeight, 5, 100, 1, 1, 1), 1, 0);
            height.Activated += delegate { bar.BarHeight = height.ValueAsInt; };
            height.Changed += delegate { bar.BarHeight = height.ValueAsInt; bar.HorizontalPadding = bar.BarHeight / 2; };
            controls.PackStart (height, false, false, 0);

            CheckButton reflect = new CheckButton ("Reflection");
            reflect.Active = bar.ShowReflection;
            reflect.Toggled += delegate { bar.ShowReflection = reflect.Active; };
            controls.PackStart (reflect, false, false, 0);

            CheckButton labels = new CheckButton ("Labels");
            labels.Active = bar.ShowLabels;
            labels.Toggled += delegate { bar.ShowLabels = labels.Active; };
            controls.PackStart (labels, false, false, 0);

            box.PackStart (controls, false, false, 0);
            box.PackStart (new HSeparator (), false, false, 0);
            box.PackStart (bar, false, false, 0);
            box.ShowAll ();

            SetSizeRequest (350, -1);

            Gdk.Geometry limits = new Gdk.Geometry ();
            limits.MinWidth = SizeRequest ().Width;
            limits.MaxWidth = Gdk.Screen.Default.Width;
            limits.MinHeight = -1;
            limits.MaxHeight = -1;
            SetGeometryHints (this, limits, Gdk.WindowHints.MaxSize | Gdk.WindowHints.MinSize);
        }