Пример #1
0
        public void getMainPage()
        {
            this.toolStripStatusLabel.Text = "Getting front page...";
            this.Enabled = false;
            this.Cursor  = Cursors.WaitCursor;

            //Making groups...
            this.modNameColumn.GroupFormatter = delegate(OLVGroup row, GroupingParameters j) {
                row.TitleImage = Resources.book;
            };

            this.modNameColumn.GroupKeyGetter = delegate(object row) {
                ModDatabaseItem item = (ModDatabaseItem)row;
                return(item.Tags.Exists(x => x == "featured") ? "Featured" : "Hot");
            };



            //Downloads column
            this.modDownloadsColumn.AspectToStringConverter = delegate(object row) {
                long downloads = (long)row;


                if (downloads >= 1000000)
                {
                    return(String.Format("{0:#,##0.#}" + "m", ((double)downloads / 1000000)));
                }
                else if (downloads >= 1000)
                {
                    return(String.Format("{0:#,##0.#}" + "k", ((double)downloads / 1000)));
                }
                else
                {
                    return(String.Format("{0}", downloads));
                }
            };

            //Rating column
            this.modRatingColumn.Renderer     = new ImageRenderer();
            this.modRatingColumn.AspectGetter = delegate(object row) {
                ModDatabaseItem item      = (ModDatabaseItem)row;
                List <Image>    imageList = new List <Image>();

                byte starsUsed = 1;
                //Adds filled-in stars to the list
                for (; starsUsed <= item.Rating; starsUsed++)
                {
                    imageList.Add(Resources.star);
                }
                //Fills in the rest with outlined stars
                while (starsUsed <= 5)
                {
                    imageList.Add(Resources.star_empty);
                    starsUsed++;
                }
                return(imageList);
            };

            this.modsObjectListView.SetObjects(ModDatabaseItem.getList());

            this.Cursor  = Cursors.Default;
            this.Enabled = true;
            this.toolStripStatusLabel.Text = "Ready";
        }
Пример #2
0
 public ModInfo(ModDatabaseItem mod)
 {
     this.mod = mod;
     InitializeComponent();
     SetModInfo();
 }