Grilla



El mar, 13-06-2006 a las 22:36 -0400
> Hola muchachos ,
> 
> Junto con saludarlos, pregunto si a alguien le intersaria usar y/o
> mejorar una grilla como esta que adjunto, para uso general.
> 
> No es excelentemente buena, ni nada del otro mundo.
> La idea es solo facilitar la vida del programador de gtk#.
> 
> Adjunto un screenshot y el fuente que le corresponde, junto a la grilla,
> esta vez, zipeada. :-p
> 

Fuente:
http://www.esnips.com/web/mios

saludos.
using System;
using System.Collections.Generic;
using System.Text;
using GridWidget;

namespace GridTestCase
{
    public enum UserOptions
    {
        One,
        Two,
        Tree,
        Four,
        Five
    }

    [Table(RulesHint=true)]
    public class Picture
    {
        private string author;
        private int percent;
        private bool printed;
        private string title;
        private Gdk.Pixbuf foto;
        private UserOptions option;

        public Picture()
        {
            author = "";
            percent = 0;
            printed = false;
            title = "";
            foto = null;
            option = UserOptions.Tree;
        }

        [Column(Editable = true)]
        public string Title
        {
            get { return title; }
            set { title = value; }
        }

        [Column(Editable = true)]
        public bool Printed
        {
            get { return printed; }
            set { printed = value; }
        }

        [Column("Hola", Resizable=false)]
        public Gdk.Pixbuf Foto
        {
            get { return foto; }
            set { foto = value; }
        }
        [Column(Editable = true)]
        public string Author
        {
            get { return author; }
            set { author = value; }
        }

        [Column("Percentage", Type = typeof(ProgressInt))]
        public int Percent
        {
            get { return percent; }
            set { percent = value; }
        }
        public override string ToString()
        {
            return String.Format("Author: {0} %: {1}", author, percent);
        }

        public UserOptions Option
        {
            get { return option; }
            set { option = value; }
        }
    }

}
using System;
using System.Collections;
using System.Text;
using GridWidget;
using Gtk;

namespace GridTestCase
{

    public class Proggy : Window
    {
        Grid grid;

        public Proggy() : base("Test Proggy")
        {
            HeightRequest = 400;
            WidthRequest = 400;

            IList pics = LoadPictures();

            grid = new Grid();
            grid.ObjectChanged += new ObjectChangedHandler(ShowMe);
            grid.ObjectCreated += new ObjectChangedHandler(ShowNew);
            grid.ObjectDeleted += new ObjectChangedHandler(ShowDeleted);

            Add(grid);
            ShowAll();

            //grid.Setup(typeof(Picture));
            grid.Objects = pics;
            grid.CanDeleteAndAddObjects = true;
        }

        void ShowMe(object o, string s)
        {
            Console.WriteLine("Changed object : {0} ({1} was changed..)", o, s);
        }

        void ShowDeleted(object o, string s)
        {
            Console.WriteLine("Deleted object: {0}", o);
        }

        void ShowNew(object o, string s)
        {
            Console.WriteLine("New object: {0}", o);
        }

        IList LoadPictures()
        {
            ArrayList list = new ArrayList();
            Random r = new Random();

            for (int i = 1; i <= 2640; i++)
            {
                Picture p = new Picture();
                p.Author = "Who? ";
                p.Printed = i % 4 == 0;
                p.Title = "Picture Nr. " + i.ToString();
                p.Percent = r.Next(0, 100);
                p.Foto = new Gdk.Pixbuf(@"C:\hello.jpg");
                p.Option = UserOptions.Four;

                list.Add(p);
            }
            return list;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Application.Init();
            new Proggy();
            Application.Run();
        }
    }
}

Attachment: untitled.jpg
Description: JPEG image



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]