Beispiel #1
0
 public static Gtk.Image LoadImageFromFile(string fileName)
 {
     Stream file_stream = null;
     try {
         file_stream = System.IO.File.OpenRead(fileName);
         Gtk.Image img = new Gtk.Image(file_stream);
         img.SetSizeRequest(13, 16);
         return img;
     } catch {
         return null;
     } finally {
         try {
             if (null != file_stream)
                 file_stream.Close();
         } catch {
         }
     }
 }
Beispiel #2
0
        public static Gtk.Image LoadImageFromFile(string fileName)
        {
            Stream file_stream = null;

            try {
                file_stream = System.IO.File.OpenRead(fileName);
                Gtk.Image img = new Gtk.Image(file_stream);
                img.SetSizeRequest(13, 16);
                return(img);
            } catch {
                return(null);
            } finally {
                try {
                    if (null != file_stream)
                    {
                        file_stream.Close();
                    }
                } catch {
                }
            }
        }
Beispiel #3
0
        private void Build2()
        {
            global::Stetic.Gui.Initialize(this);
            // Widget NIRSrecorder.Splash
            this.Name           = "NIRSrecorder.Splash";
            this.Title          = global::Mono.Unix.Catalog.GetString("Splash");
            this.WindowPosition = Gtk.WindowPosition.CenterAlways;

            var buffer = System.IO.File.ReadAllBytes(@"extra/Splash.gif");
            var pixbuf = new Gdk.Pixbuf(buffer);

            int w, h;

            h = pixbuf.Height;
            w = pixbuf.Width;

            Gtk.VBox vBox = new Gtk.VBox();

            Gtk.Fixed fix = new Gtk.Fixed();
            Gtk.Image im  = new Gtk.Image();

            im.SetSizeRequest(w, h);
            im.Pixbuf = pixbuf;
            fix.Add(im);
            vBox.Add(fix);

            label = new Gtk.Label();
            vBox.Add(label);
            this.Add(vBox);


            if ((this.Child != null))
            {
                this.Child.ShowAll();
            }
            this.DefaultWidth  = 400;
            this.DefaultHeight = 300;
            this.Show();
        }
Beispiel #4
0
        // Need an AspectFrame to set aspect ratio.
        public static Gtk.Image createImage(Pixbuf pixbuf)
        {
            Gtk.Image img = new Gtk.Image ();
            img.Name = null;
            img.Pixbuf = pixbuf;
            img.Data["pixbuf"] = pixbuf;
            img.SetSizeRequest( 0, 0 );

            if (pixbuf != null)
            {
                img.SizeAllocated += (o, args) =>
                {
                    Gtk.Image im = (o as Gtk.Image);
                    Pixbuf pb = (im.Data["pixbuf"] as Pixbuf);

                    if (im.Pixbuf.Width != args.Allocation.Width || im.Pixbuf.Height != args.Allocation.Height)
                    {
                        im.Pixbuf = pb.ScaleSimple(args.Allocation.Width, args.Allocation.Height, InterpType.Nearest);
                    }
                };
            }

            return img;
        }
        public void CreateGui()
        {
            Gtk.Image icn_reload = new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Button);
            _reload          = new Gtk.Button(icn_reload);
            _reload.Clicked += OnReload;

            _performer            = new Gtk.Entry(200);
            _title                = new Gtk.Entry(200);
            _title.WidthChars     = 60;
            _performer.WidthChars = 60;
            _subtitle             = new Gtk.Entry(300);
            _subtitle.WidthChars  = 60;
            _composer             = new Gtk.Entry(200);
            _composer.WidthChars  = 60;
            _year            = new Gtk.Entry(20);
            _year.WidthChars = 20;

            _image = new Gtk.Image();
            _image.SetSizeRequest(100, 100);
            _imagefile          = new Gtk.FileChooserButton("Choose image file", Gtk.FileChooserAction.Open);
            _imagefile.FileSet += new EventHandler(EvtImageSet);

            Gtk.Image icn_add_track = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Button);
            _add_track          = new Gtk.Button(icn_add_track);
            _add_track.Clicked += OnAddTrack;

            Gtk.Image icn_del_track = new Gtk.Image(Gtk.Stock.Delete, Gtk.IconSize.Button);
            _del_track          = new Gtk.Button(icn_del_track);
            _del_track.Clicked += OnDelTrack;

            Gtk.Image icn_save = new Gtk.Image(Gtk.Stock.Save, Gtk.IconSize.Button);
            _save          = new Gtk.Button(icn_save);
            _save.Clicked += OnSave;

            _store  = new Gtk.ListStore(typeof(int), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string));
            _tracks = new Gtk.TreeView();
            {
                Gtk.CellRendererText cr0 = new Gtk.CellRendererText();
                cr0.Scale = 0.8;
                _tracks.AppendColumn("Nr.", cr0, "text", 0);

                Gtk.CellRendererText cr_title = new Gtk.CellRendererText();
                cr_title.Scale    = 0.8;
                cr_title.Editable = true;
                cr_title.Edited  += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) {
                    setCell(1, args.NewText, new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn("Title", cr_title, "text", 1);

                Gtk.CellRendererText cr_artist = new Gtk.CellRendererText();
                cr_artist.Editable = true;
                cr_artist.Scale    = 0.8;
                cr_artist.Edited  += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) {
                    setCell(2, args.NewText, new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn("Artist", cr_artist, "text", 2);

                Gtk.CellRendererText cr_composer = new Gtk.CellRendererText();
                cr_composer.Editable = true;
                cr_composer.Scale    = 0.8;
                cr_composer.Edited  += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) {
                    setCell(3, args.NewText, new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn("Composer", cr_composer, "text", 3);

                Gtk.CellRendererText cr_piece = new Gtk.CellRendererText();
                cr_piece.Editable = true;
                cr_piece.Scale    = 0.8;
                cr_piece.Edited  += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) {
                    setCell(4, args.NewText, new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn("Piece", cr_piece, "text", 4);

                Gtk.CellRendererText cr_time = new Gtk.CellRendererText();
                cr_time.Editable = true;
                cr_time.Scale    = 0.8;
                cr_time.Edited  += new Gtk.EditedHandler(delegate(object sender, Gtk.EditedArgs args) {
                    setCell(5, args.NewText, new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn("Offset", cr_time, "text", 5);
            }

            _tracks.Model = _store;

            Gtk.Table tbl = new Gtk.Table(2, 5, false);
            tbl.Attach(new Gtk.Label("Album:"), 0, 1, 0, 1);
            tbl.Attach(_title, 1, 2, 0, 1);
            tbl.Attach(new Gtk.Label("Artist:"), 0, 1, 1, 2);
            tbl.Attach(_performer, 1, 2, 1, 2);
            tbl.Attach(new Gtk.Label("Composer:"), 0, 1, 2, 3);
            tbl.Attach(_composer, 1, 2, 2, 3);
            tbl.Attach(new Gtk.Label("Subtitle:"), 0, 1, 3, 4);
            tbl.Attach(_subtitle, 1, 2, 3, 4);
            tbl.Attach(new Gtk.Label("year:"), 0, 1, 4, 5);
            tbl.Attach(_year, 1, 2, 4, 5);

            Gtk.Frame frm = new Gtk.Frame();
            frm.Add(tbl);

            Gtk.HBox hb2 = new Gtk.HBox();
            hb2.PackEnd(_reload, false, false, 1);
            hb2.PackEnd(_del_track, false, false, 1);
            hb2.PackEnd(_add_track, false, false, 1);
            hb2.PackEnd(_save, false, false, 1);

            Gtk.HBox hb  = new Gtk.HBox();
            Gtk.VBox vb1 = new Gtk.VBox();
            vb1.PackStart(frm, false, false, 0);
            vb1.PackStart(hb2, true, true, 0);
            hb.PackStart(vb1, false, false, 0);

            Gtk.Frame frm2 = new Gtk.Frame();
            frm2.Add(_image);
            Gtk.VBox vbi = new Gtk.VBox();
            Gtk.HBox bb  = new Gtk.HBox();
            bb.PackStart(new Gtk.VBox(), true, true, 0);
            bb.PackStart(frm2, false, false, 0);
            bb.PackEnd(new Gtk.VBox(), true, true, 0);

            vbi.PackStart(bb, true, true, 2);
            vbi.PackEnd(_imagefile, false, false, 2);
            hb.PackEnd(vbi, true, true, 2);

            Gtk.ScrolledWindow scroll = new Gtk.ScrolledWindow();
            scroll.Add(_tracks);
            scroll.SetSizeRequest(800, 300);

            base.VBox.PackStart(hb, false, false, 4);
            base.VBox.PackStart(scroll, true, true, 0);
            base.VBox.ShowAll();

            base.AddButton("Close", 0);
        }
        public void CreateGui()
        {
            Gtk.Image icn_reload=new Gtk.Image(Gtk.Stock.Refresh,Gtk.IconSize.Button);
            _reload=new Gtk.Button(icn_reload);
            _reload.Clicked+=OnReload;

            _performer=new Gtk.Entry(200);
            _title=new Gtk.Entry(200);
            _title.WidthChars=60;
            _performer.WidthChars=60;
            _subtitle=new Gtk.Entry(300);
            _subtitle.WidthChars=60;
            _composer=new Gtk.Entry(200);
            _composer.WidthChars=60;
            _year=new Gtk.Entry(20);
            _year.WidthChars=20;

            _image=new Gtk.Image();
            _image.SetSizeRequest (100,100);
            _imagefile=new Gtk.FileChooserButton("Choose image file",Gtk.FileChooserAction.Open);
            _imagefile.FileSet+=new EventHandler(EvtImageSet);

            Gtk.Image icn_add_track=new Gtk.Image(Gtk.Stock.Add,Gtk.IconSize.Button);
            _add_track=new Gtk.Button(icn_add_track);
            _add_track.Clicked+=OnAddTrack;

            Gtk.Image icn_del_track=new Gtk.Image(Gtk.Stock.Delete,Gtk.IconSize.Button);
            _del_track=new Gtk.Button(icn_del_track);
            _del_track.Clicked+=OnDelTrack;

            Gtk.Image icn_save=new Gtk.Image(Gtk.Stock.Save,Gtk.IconSize.Button);
            _save=new Gtk.Button(icn_save);
            _save.Clicked+=OnSave;

            _store=new Gtk.ListStore(typeof(int),typeof(string),typeof(string),typeof(string),typeof(string),typeof(string));
            _tracks=new Gtk.TreeView();
            {
                Gtk.CellRendererText cr0=new Gtk.CellRendererText();
                cr0.Scale=0.8;
                _tracks.AppendColumn ("Nr.", cr0, "text", 0);

                Gtk.CellRendererText cr_title=new Gtk.CellRendererText();
                cr_title.Scale=0.8;
                cr_title.Editable=true;
                cr_title.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) {
                    setCell(1,args.NewText,new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn ("Title", cr_title, "text", 1);

                Gtk.CellRendererText cr_artist=new Gtk.CellRendererText();
                cr_artist.Editable=true;
                cr_artist.Scale=0.8;
                cr_artist.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) {
                    setCell(2,args.NewText,new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn ("Artist", cr_artist, "text", 2);

                Gtk.CellRendererText cr_composer=new Gtk.CellRendererText();
                cr_composer.Editable=true;
                cr_composer.Scale=0.8;
                cr_composer.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) {
                    setCell(3,args.NewText,new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn ("Composer", cr_composer, "text", 3);

                Gtk.CellRendererText cr_piece=new Gtk.CellRendererText();
                cr_piece.Editable=true;
                cr_piece.Scale=0.8;
                cr_piece.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) {
                    setCell(4,args.NewText,new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn ("Piece", cr_piece, "text", 4);

                Gtk.CellRendererText cr_time=new Gtk.CellRendererText();
                cr_time.Editable=true;
                cr_time.Scale=0.8;
                cr_time.Edited+=new Gtk.EditedHandler(delegate(object sender,Gtk.EditedArgs args) {
                    setCell (5,args.NewText,new Gtk.TreePath(args.Path));
                });
                _tracks.AppendColumn ("Offset", cr_time, "text", 5);
            }

            _tracks.Model = _store;

            Gtk.Table tbl=new Gtk.Table(2,5,false);
            tbl.Attach (new Gtk.Label("Album:"),0,1,0,1);
            tbl.Attach (_title,1,2,0,1);
            tbl.Attach (new Gtk.Label("Artist:"),0,1,1,2);
            tbl.Attach (_performer,1,2,1,2);
            tbl.Attach (new Gtk.Label("Composer:"),0,1,2,3);
            tbl.Attach (_composer,1,2,2,3);
            tbl.Attach (new Gtk.Label("Subtitle:"),0,1,3,4);
            tbl.Attach (_subtitle,1,2,3,4);
            tbl.Attach (new Gtk.Label("year:"),0,1,4,5);
            tbl.Attach (_year,1,2,4,5);

            Gtk.Frame frm=new Gtk.Frame();
            frm.Add (tbl);

            Gtk.HBox hb2=new Gtk.HBox();
            hb2.PackEnd (_reload,false,false,1);
            hb2.PackEnd (_del_track,false,false,1);
            hb2.PackEnd (_add_track,false,false,1);
            hb2.PackEnd (_save,false,false,1);

            Gtk.HBox hb=new Gtk.HBox();
            Gtk.VBox vb1=new Gtk.VBox();
            vb1.PackStart (frm,false,false,0);
            vb1.PackStart (hb2,true,true,0);
            hb.PackStart (vb1,false,false,0);

            Gtk.Frame frm2=new Gtk.Frame();
            frm2.Add (_image);
            Gtk.VBox vbi=new Gtk.VBox();
            Gtk.HBox bb=new Gtk.HBox();
            bb.PackStart(new Gtk.VBox(),true,true,0);
            bb.PackStart(frm2,false,false,0);
            bb.PackEnd (new Gtk.VBox(),true,true,0);

            vbi.PackStart (bb,true,true,2);
            vbi.PackEnd (_imagefile,false,false,2);
            hb.PackEnd (vbi,true,true,2);

            Gtk.ScrolledWindow scroll=new Gtk.ScrolledWindow();
            scroll.Add (_tracks);
            scroll.SetSizeRequest (800,300);

            base.VBox.PackStart(hb,false,false,4);
            base.VBox.PackStart(scroll,true,true,0);
            base.VBox.ShowAll ();

            base.AddButton ("Close",0);
        }