示例#1
0
        void repPerson_ItemValueNeeded(object sender, DataRepeaterItemValueEventArgs e)
        {
            try
            {
                if (e.ItemIndex < this.dataSource.Length)
                {
                    switch (e.Control.Name)
                    {
                    case "picPerson":

                        if (File.Exists(PathUtils.GetApplicationPersonPath() + this.dataSource[e.ItemIndex].PhotoLink) == true)
                        {
                            try
                            {
                                e.Value = Image.FromFile(PathUtils.GetApplicationPersonPath() + this.dataSource[e.ItemIndex].PhotoLink);
                            }
                            catch
                            {
                                // Do nothing for image that is corrupted
                            }
                        }
                        break;

                    case "lblPersonName":

                        e.Value = this.dataSource[e.ItemIndex].FullName;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        private void repMovie_ItemValueNeeded(object sender, DataRepeaterItemValueEventArgs e)
        {
            try
            {
                if (e.ItemIndex < this.DataSource.Length)
                {
                    switch (e.Control.Name)
                    {
                    case "picImage":

                        if (File.Exists(PathUtils.GetApplicationMoviePosterPath() + this.DataSource[e.ItemIndex].PosterLink) == true)
                        {
                            try
                            {
                                e.Value = Image.FromFile(PathUtils.GetApplicationMoviePosterPath() + this.DataSource[e.ItemIndex].PosterLink);
                            }
                            catch
                            {
                                // Do nothing for image that is corrupted
                            }
                        }
                        break;

                    case "picIsSeen":

                        if (this.DataSource[e.ItemIndex].IsSeen == true)
                        {
                            e.Value = global::iMovie.Properties.Resources.seen_61;
                        }
                        else
                        {
                            e.Value = global::iMovie.Properties.Resources.not_seen_61;
                        }
                        break;

                    case "lblIMDBRate":

                        e.Value = this.DataSource[e.ItemIndex].IMDBRate.ToString();
                        break;

                    case "lblTitle":

                        e.Value = this.DataSource[e.ItemIndex].FullTitle;
                        break;

                    case "lblFavoriteRate":

                        if (this.DataSource[e.ItemIndex].FavoriteRate == 0)
                        {
                            e.Value = "-";
                        }
                        else
                        {
                            e.Value = this.DataSource[e.ItemIndex].FavoriteRate.ToString();
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }