Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(Session["username"] == null))
            {
                btnLogin.Text = (string)Session["username"];
            }

            if (Session["pictureName"] == null)
            {
                Response.Redirect("SignIngPage.aspx");
            }

            Objects.PictureCollection pictureCollection = (Objects.PictureCollection)HttpRuntime.Cache.Get("allPictures");
            List <Objects.Picture>    allPictures       = pictureCollection.allPictures;

            Objects.Picture pictureToDisplay = new Objects.Picture();

            for (int i = 0; i < allPictures.Count; i++)
            {
                if ((string)Session["pictureName"] == allPictures[i].pictureName)
                {
                    pictureToDisplay = allPictures[i];
                    break;
                }
            }

            for (int i = 0; i < pictureToDisplay.categories.Count - 1; i++)
            {
                lblCategories.InnerText = lblCategories.InnerText + pictureToDisplay.categories[i] + ", ";
            }
            lblCategories.InnerText = lblCategories.InnerText + pictureToDisplay.categories[pictureToDisplay.categories.Count - 1];
            imgImage.Src            = "img/" + pictureToDisplay.pictureName;
        }
        protected void btnViewImage_Click(object sender, EventArgs e)
        {
            List <string> categories    = new List <string>();
            string        allCategories = hdnCategories.Value;
            string        filename      = fleNewImage.FileName;

            string[] myCategories = allCategories.Split(',');

            for (int i = 0; i < myCategories.Length - 1; i++)
            {
                categories.Add(myCategories[i]);
            }
            Objects.Picture pictureToAdd = new Objects.Picture(filename, filename, (string)Session["username"], 1, DateTime.Now, categories);

            Objects.PictureCollection allPictures = (Objects.PictureCollection)HttpRuntime.Cache.Get("allPictures");
            allPictures.add(pictureToAdd);
            HttpRuntime.Cache.Insert("allPictures", allPictures);
            Session["pictureName"] = filename;
            Response.Redirect("ViewImage.aspx");
        }
Esempio n. 3
0
        protected void Application_Start(object sender, EventArgs e)
        {
            //Creates the users to be cached in the app
            Objects.UserCollection allUsers = new Objects.UserCollection();
            allUsers.add(new Objects.User("user1", "user1"));
            allUsers.add(new Objects.User("user2", "user2"));
            allUsers.add(new Objects.User("user3", "user3"));
            allUsers.add(new Objects.User("user4", "user4"));
            allUsers.add(new Objects.User("user5", "user5"));
            allUsers.add(new Objects.User("user6", "user6"));
            allUsers.add(new Objects.User("user7", "user7"));
            allUsers.add(new Objects.User("user8", "user8"));

            //creates the events to be cached in the app
            Objects.EventCollection allEvents = new Objects.EventCollection();
            allEvents.add(new Objects.Event(1, "HackRiddle", "2nd annual Hack Riddle", "florida", "picture", "user1", DateTime.Now));
            allEvents.add(new Objects.Event(2, "Florida Homecoming", "25th annual homecoming", "florida", "picture", "user1", DateTime.Now));
            allEvents.add(new Objects.Event(3, "Bike Week", "25th annual Bike Week", "florida", "picture", "user1", DateTime.Now));

            //creates the pictures to be cached in the app
            Objects.PictureCollection allPictures    = new Objects.PictureCollection();
            List <string>             pic1Categories = new List <string>();

            pic1Categories.Add("bike");
            pic1Categories.Add("vehicle");
            pic1Categories.Add("biker");
            pic1Categories.Add("street");
            pic1Categories.Add("motorcyclist");
            pic1Categories.Add("people");
            pic1Categories.Add("road");
            pic1Categories.Add("cyclist");
            pic1Categories.Add("motorbike");
            pic1Categories.Add("sitting");
            allPictures.add(new Objects.Picture("Biketoberfest.jpg", "~/pics1", "user1", 3, DateTime.Now, pic1Categories));
            List <string> pic2Categories = new List <string>();

            pic2Categories.Add("competition");
            pic2Categories.Add("parade");
            pic2Categories.Add("people");
            pic2Categories.Add("victory");
            pic2Categories.Add("many");
            pic2Categories.Add("man");
            pic2Categories.Add("crowd");
            pic2Categories.Add("uniform");
            pic2Categories.Add("group");
            pic2Categories.Add("ceremony");
            allPictures.add(new Objects.Picture("ufhomecoming.jpg", "~/pics1", "user1", 2, DateTime.Now, pic2Categories));
            List <string> pic3Categories = new List <string>();

            pic3Categories.Add("room");
            pic3Categories.Add("education");
            pic3Categories.Add("group");
            pic3Categories.Add("furniture");
            pic3Categories.Add("desk");
            pic3Categories.Add("meeting");
            pic3Categories.Add("classroom");
            pic3Categories.Add("adult");
            pic3Categories.Add("business");
            pic3Categories.Add("university");
            pic3Categories.Add("technology");
            allPictures.add(new Objects.Picture("hackriddleroom.jpg", "~/pics1", "user1", 1, DateTime.Now, pic3Categories));
            List <string> pic4Categories = new List <string>();

            pic4Categories.Add("smile");
            pic4Categories.Add("laughing");
            pic4Categories.Add("performance");
            pic4Categories.Add("people");
            pic4Categories.Add("music");
            pic4Categories.Add("recreation");
            pic4Categories.Add("stage");
            allPictures.add(new Objects.Picture("hackriddlecups.jpg", "~/pics1", "user1", 1, DateTime.Now, pic4Categories));
            List <string> pic5Categories = new List <string>();

            pic5Categories.Add("people");
            pic5Categories.Add("many");
            pic5Categories.Add("military");
            pic5Categories.Add("competition");
            pic5Categories.Add("bike");
            pic5Categories.Add("vehicle");
            pic5Categories.Add("uniform");
            pic5Categories.Add("crowd");
            pic5Categories.Add("helmet");
            allPictures.add(new Objects.Picture("bikersroad.jpg", "~/pics1", "user1", 3, DateTime.Now, pic5Categories));
            List <string> pic6Categories = new List <string>();

            pic6Categories.Add("people");
            pic6Categories.Add("street");
            pic6Categories.Add("competition");
            pic6Categories.Add("vehicle");
            pic6Categories.Add("festival");
            pic6Categories.Add("rally");
            pic6Categories.Add("parade");
            pic6Categories.Add("road");
            pic6Categories.Add("crowd");
            allPictures.add(new Objects.Picture("ufparade.jpg", "~/pics1", "user1", 2, DateTime.Now, pic6Categories));
            List <string> pic7Categories = new List <string>();

            pic7Categories.Add("concert");
            pic7Categories.Add("performance");
            pic7Categories.Add("music");
            pic7Categories.Add("singer");
            pic7Categories.Add("musician");
            pic7Categories.Add("festival");
            pic7Categories.Add("band");
            pic7Categories.Add("stage");
            pic7Categories.Add("celebration");
            pic7Categories.Add("pop");
            pic7Categories.Add("party");
            allPictures.add(new Objects.Picture("ufshow.jpg", "~/pics1", "user1", 2, DateTime.Now, pic7Categories));



            HttpRuntime.Cache.Insert("allUsers", allUsers, null, DateTime.MaxValue, new TimeSpan(3, 14, 15));
            HttpRuntime.Cache.Insert("allEvents", allEvents, null, DateTime.MaxValue, new TimeSpan(3, 14, 15));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Category"] == null)
            {
                Response.Redirect("AccountPage.aspx");
            }
            else
            {
                category = (string)Session["Category"];
            }
            catetitle.InnerText = category;


            Objects.PictureCollection allPictures         = (Objects.PictureCollection)HttpRuntime.Cache.Get("allPictures");
            List <Objects.Picture>    allCategoryPictures = allPictures.getPicturesByCategory(category);

            if (allCategoryPictures.Count > 5)
            {
                img0.Src = allCategoryPictures[0].pictureFilepath;
                img1.Src = allCategoryPictures[1].pictureFilepath;
                img2.Src = allCategoryPictures[2].pictureFilepath;
                img3.Src = allCategoryPictures[3].pictureFilepath;
                img4.Src = allCategoryPictures[4].pictureFilepath;
                img5.Src = allCategoryPictures[5].pictureFilepath;
            }
            else if (allCategoryPictures.Count == 5)
            {
                img0.Src     = allCategoryPictures[0].pictureFilepath;
                img1.Src     = allCategoryPictures[1].pictureFilepath;
                img2.Src     = allCategoryPictures[2].pictureFilepath;
                img3.Src     = allCategoryPictures[3].pictureFilepath;
                img4.Src     = allCategoryPictures[4].pictureFilepath;
                img5.Visible = false;
            }
            else if (allCategoryPictures.Count == 4)
            {
                img0.Src     = allCategoryPictures[0].pictureFilepath;
                img1.Src     = allCategoryPictures[1].pictureFilepath;
                img2.Src     = allCategoryPictures[2].pictureFilepath;
                img3.Src     = allCategoryPictures[3].pictureFilepath;
                img4.Visible = false;
                img5.Visible = false;
            }
            else if (allCategoryPictures.Count == 3)
            {
                img0.Src     = allCategoryPictures[0].pictureFilepath;
                img1.Src     = allCategoryPictures[1].pictureFilepath;
                img2.Src     = allCategoryPictures[2].pictureFilepath;
                img3.Visible = false;
                img4.Visible = false;
                img5.Visible = false;
            }
            else if (allCategoryPictures.Count == 2)
            {
                img0.Src     = allCategoryPictures[0].pictureFilepath;
                img1.Src     = allCategoryPictures[1].pictureFilepath;
                img2.Visible = false;
                img3.Visible = false;
                img4.Visible = false;
                img5.Visible = false;
            }
            else if (allCategoryPictures.Count == 1)
            {
                img0.Src     = allCategoryPictures[0].pictureFilepath;
                img1.Visible = false;
                img2.Visible = false;
                img3.Visible = false;
                img4.Visible = false;
                img5.Visible = false;
            }
            else if (allCategoryPictures.Count == 0)
            {
                img0.Visible = false;
                img1.Visible = false;
                img2.Visible = false;
                img3.Visible = false;
                img4.Visible = false;
                img5.Visible = false;
            }
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string username = "";

            if (Session["username"] == null)
            {
                Response.Redirect("SignInPage.aspx");
            }
            else
            {
                username            = (string)Session["username"];
                btnUsername.Text    = username;
                catetitle.InnerText = catetitle.InnerText + username + "!";
            }
            Objects.PictureCollection allPictures     = (Objects.PictureCollection)HttpRuntime.Cache.Get("allPictures");
            List <Objects.Picture>    allUserPictures = allPictures.getPicturesByUser(username);
            List <string>             allCategories   = new List <string>();
            List <int> categoryCount = new List <int>();

            for (int i = 0; i < allUserPictures.Count; i++)
            {
                for (int j = 0; j < allUserPictures[i].categories.Count; j++)
                {
                    if (!allCategories.Contains(allUserPictures[i].categories[j]))
                    {
                        allCategories.Add(allUserPictures[i].categories[j]);
                        categoryCount.Add(1);
                    }
                    else
                    {
                        categoryCount[allCategories.IndexOf(allUserPictures[i].categories[j])]++;
                    }
                }
            }
            int minimumIndex = 0;

            for (int i = 0; i < categoryCount.Count; i++)
            {
                if (categoryCount[i] < categoryCount[minimumIndex])
                {
                    minimumIndex = i;
                }
            }

            int[] top6 = new int[6] {
                minimumIndex, minimumIndex, minimumIndex, minimumIndex, minimumIndex, minimumIndex
            };


            for (int i = 0; i < categoryCount.Count; i++)
            {
                if (categoryCount[i] >= categoryCount[top6[5]])
                {
                    top6[5] = i;
                }
                else
                {
                    continue;
                }
                for (int j = 4; j >= 0; j--)
                {
                    if (categoryCount[i] >= categoryCount[top6[j]])
                    {
                        int tempIndex = top6[j];
                        top6[j]     = i;
                        top6[j + 1] = tempIndex;
                    }
                }
            }
            for (int i = 0; i < 6; i++)
            {
                categoryNames[i] = allCategories[top6[i]];
            }
            lblFirstCategory.InnerHtml  = categoryNames[0] + " <span class=\"badge\">" + categoryCount[top6[0]] + " pics</span>";
            lblSecondCategory.InnerHtml = categoryNames[1] + " <span class=\"badge\">" + categoryCount[top6[1]] + " pics</span>";
            lblThirdCategory.InnerHtml  = categoryNames[2] + " <span class=\"badge\">" + categoryCount[top6[2]] + " pics</span>";
            lblFourthCategory.InnerHtml = categoryNames[3] + " <span class=\"badge\">" + categoryCount[top6[3]] + " pics</span>";
            lblFifthCategory.InnerHtml  = categoryNames[4] + " <span class=\"badge\">" + categoryCount[top6[4]] + " pics</span>";
            lblSixthCategory.InnerHtml  = categoryNames[5] + " <span class=\"badge\">" + categoryCount[top6[5]] + " pics</span>";


            string[] imageLocations = new string[6];

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < allUserPictures.Count; j++)
                {
                    for (int k = 0; k < allUserPictures[j].categories.Count; k++)
                    {
                        if (allUserPictures[j].categories[k] == categoryNames[i])
                        {
                            imageLocations[i] = allUserPictures[j].pictureFilepath;
                            continue;
                        }
                    }
                }
            }

            img0.Src = imageLocations[0];
            img1.Src = imageLocations[1];
            img2.Src = imageLocations[2];
            img3.Src = imageLocations[3];
            img4.Src = imageLocations[4];
            img5.Src = imageLocations[5];
        }