public void loadscrollpanel(bool wasbackclicked) { scrollpanel.AutoScroll = true; //scrollpanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; scrollpanel.Location = new System.Drawing.Point(0, searchBtn.Bottom); scrollpanel.Size = new System.Drawing.Size(searchBtn.Right, Height - searchBtn.Bottom - next_page_btn.Height); //also set the position of next back buttons here //next_page_btn.Top = scrollpanel.Bottom; //next_page_btn.Left = Width - next_page_btn.Width; next_page_btn.Visible = true; if (resultsStartIndex != 0) { back_page_btn.Visible = true; } //Debug.WriteLine("search btn top: "+ searchBtn.Top + " search btn left: "+ searchBtn.Left); //int end; //scrollpanel.AutoScroll = true; //scrollpanel.ResumeLayout(false); //this.ResumeLayout(false); //this.Refresh(); //scrollpanel.Height = ni0.Height * 5; //this.Refresh(); loading_search.Hide(); scrollpanel.Controls.Clear(); /* * NOPSAImageHolder temp = new NOPSAImageHolder(); * temp.img_url = "http://nopsa.hiit.fi/pmg/images/square_3846620713_9b60cdf7c2_t.jpg"; * temp.img_creator = "Hasanat"; * temp.img_holder = "img holder url"; * temp.img_id = "1234567"; * temp.img_rights = "Google"; * temp.img_source = "http://sourceuri"; * temp.tags = new List<NOPSAImageTagHolder>(); * NOPSAImageTagHolder temptag = new NOPSAImageTagHolder(); * temptag.tag_id = "111111"; * temptag.tag_relevence = "1"; * temptag.tag_string = "good tag"; * temp.tags.Add(temptag); * NOPSAImageTagHolder temptag2 = new NOPSAImageTagHolder(); * temptag2.tag_id = "222222"; * temptag2.tag_relevence = "2"; * temptag2.tag_string = "bad tag"; * temp.tags.Add(temptag2); * NOPSAImageTagHolder temptag3 = new NOPSAImageTagHolder(); * temptag3.tag_id = "333333"; * temptag3.tag_relevence = "3"; * temptag3.tag_string = "i m tag 3 :P"; * temp.tags.Add(temptag3); * NOPSAImageTagHolder temptag4 = new NOPSAImageTagHolder(); * temptag4.tag_id = "444444"; * temptag4.tag_relevence = "4"; * temptag4.tag_string = "yo baby"; * //temp.tags.Add(temptag4); * NOPSAImageTagHolder temptag5 = new NOPSAImageTagHolder(); * temptag5.tag_id = "555555"; * temptag5.tag_relevence = "5"; * temptag5.tag_string = "tag 5 bitch"; * //temp.tags.Add(temptag5); * * MessageBox.Show("creating nopsaimage"); * try * { * NopsaImage nicheck = new NopsaImage(temp, cm); * } * catch (Exception ex) * { * MessageBox.Show("NopsaImage couldn't failed to create with temp as arg " + ex.StackTrace); * } * NopsaImage ni0 = new NopsaImage(temp, cm); * ni0.Location = new Point(0, 0); * scrollpanel.Controls.Add(ni0); * * * NopsaImage ni1 = new NopsaImage(temp, cm); * ni1.Location = new Point(0, ni0.Height); * scrollpanel.Controls.Add(ni1); * * NopsaImage ni2 = new NopsaImage(temp, cm); * ni2.Location = new Point(0, ni1.Height * 2); * scrollpanel.Controls.Add(ni2); * * NopsaImage ni3 = new NopsaImage(temp, cm); * ni3.Location = new Point(0, ni2.Height * 3); * scrollpanel.Controls.Add(ni3); */ /* * int nloc = 0; * int counter = 10; * while (counter!= 0) * { * int source_num = resultsStartIndex % Search_Data.sources.Count; * int img_num = resultsStartIndex / Search_Data.sources.Count; * resultsStartIndex++; * //Debug.WriteLine("source: " + source_num); * //Debug.WriteLine("image: " + img_num); * * int madcounter = 0; * NOPSAImageHolder temp; * try * { * temp = Search_Data.images[source_num][img_num]; * NopsaImage n = new NopsaImage(temp); * n.Location = new Point(0, nloc); * nloc = nloc + n.Height; * scrollpanel.Controls.Add(n); * counter--; * * } * catch(Exception e) * { * madcounter++; * if (madcounter == 30) break; * continue; * } * * } */ ////// ////////////// ////////////////// ///////////////////// INTRODUCE SOME SHUFFING ALGO HERE ///////////////////// I AM HARDCODING .. THIS IS BAD if (!wasbackclicked) // i.e. next page was clicked { int nloc = 0; for (int j = 0; j < Search_Data.sources.Count; j++) { for (int i = resultsStartIndex; i < Search_Data.images[j].Count; i++) { NopsaImage n = new NopsaImage(Search_Data.images[j][i], cm); n.Location = new Point(0, nloc); nloc = nloc + n.Height; scrollpanel.Controls.Add(n); if (i == 10 + resultsStartIndex) { resultsStartIndex = resultsStartIndex + 10; break; } } } } else //back page clicked { int nloc = 0; for (int j = 0; j < Search_Data.sources.Count; j++) { //for (int i = resultsStartIndex; i > Search_Data.images[j].Count - 10 ; i--) for (int i = 10; i > -1; i--) { NopsaImage n = new NopsaImage(Search_Data.images[j][resultsStartIndex], cm); n.Location = new Point(0, nloc); nloc = nloc + n.Height; scrollpanel.Controls.Add(n); if (resultsStartIndex == 0) { break; } resultsStartIndex--; } } } this.Width = this.Width + 1; //just to trigger onresize }
public void loadscrollpanel( bool wasbackclicked) { scrollpanel.AutoScroll = true; //scrollpanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; scrollpanel.Location = new System.Drawing.Point(0, searchBtn.Bottom); scrollpanel.Size = new System.Drawing.Size(searchBtn.Right, Height - searchBtn.Bottom - next_page_btn.Height); //also set the position of next back buttons here //next_page_btn.Top = scrollpanel.Bottom; //next_page_btn.Left = Width - next_page_btn.Width; next_page_btn.Visible = true; if (resultsStartIndex != 0) back_page_btn.Visible = true; //Debug.WriteLine("search btn top: "+ searchBtn.Top + " search btn left: "+ searchBtn.Left); //int end; //scrollpanel.AutoScroll = true; //scrollpanel.ResumeLayout(false); //this.ResumeLayout(false); //this.Refresh(); //scrollpanel.Height = ni0.Height * 5; //this.Refresh(); loading_search.Hide(); scrollpanel.Controls.Clear(); /* NOPSAImageHolder temp = new NOPSAImageHolder(); temp.img_url = "http://nopsa.hiit.fi/pmg/images/square_3846620713_9b60cdf7c2_t.jpg"; temp.img_creator = "Hasanat"; temp.img_holder = "img holder url"; temp.img_id = "1234567"; temp.img_rights = "Google"; temp.img_source = "http://sourceuri"; temp.tags = new List<NOPSAImageTagHolder>(); NOPSAImageTagHolder temptag = new NOPSAImageTagHolder(); temptag.tag_id = "111111"; temptag.tag_relevence = "1"; temptag.tag_string = "good tag"; temp.tags.Add(temptag); NOPSAImageTagHolder temptag2 = new NOPSAImageTagHolder(); temptag2.tag_id = "222222"; temptag2.tag_relevence = "2"; temptag2.tag_string = "bad tag"; temp.tags.Add(temptag2); NOPSAImageTagHolder temptag3 = new NOPSAImageTagHolder(); temptag3.tag_id = "333333"; temptag3.tag_relevence = "3"; temptag3.tag_string = "i m tag 3 :P"; temp.tags.Add(temptag3); NOPSAImageTagHolder temptag4 = new NOPSAImageTagHolder(); temptag4.tag_id = "444444"; temptag4.tag_relevence = "4"; temptag4.tag_string = "yo baby"; //temp.tags.Add(temptag4); NOPSAImageTagHolder temptag5 = new NOPSAImageTagHolder(); temptag5.tag_id = "555555"; temptag5.tag_relevence = "5"; temptag5.tag_string = "tag 5 bitch"; //temp.tags.Add(temptag5); MessageBox.Show("creating nopsaimage"); try { NopsaImage nicheck = new NopsaImage(temp, cm); } catch (Exception ex) { MessageBox.Show("NopsaImage couldn't failed to create with temp as arg " + ex.StackTrace); } NopsaImage ni0 = new NopsaImage(temp, cm); ni0.Location = new Point(0, 0); scrollpanel.Controls.Add(ni0); NopsaImage ni1 = new NopsaImage(temp, cm); ni1.Location = new Point(0, ni0.Height); scrollpanel.Controls.Add(ni1); NopsaImage ni2 = new NopsaImage(temp, cm); ni2.Location = new Point(0, ni1.Height * 2); scrollpanel.Controls.Add(ni2); NopsaImage ni3 = new NopsaImage(temp, cm); ni3.Location = new Point(0, ni2.Height * 3); scrollpanel.Controls.Add(ni3); */ /* int nloc = 0; int counter = 10; while (counter!= 0) { int source_num = resultsStartIndex % Search_Data.sources.Count; int img_num = resultsStartIndex / Search_Data.sources.Count; resultsStartIndex++; //Debug.WriteLine("source: " + source_num); //Debug.WriteLine("image: " + img_num); int madcounter = 0; NOPSAImageHolder temp; try { temp = Search_Data.images[source_num][img_num]; NopsaImage n = new NopsaImage(temp); n.Location = new Point(0, nloc); nloc = nloc + n.Height; scrollpanel.Controls.Add(n); counter--; } catch(Exception e) { madcounter++; if (madcounter == 30) break; continue; } } */ ////// ////////////// ////////////////// ///////////////////// INTRODUCE SOME SHUFFING ALGO HERE ///////////////////// I AM HARDCODING .. THIS IS BAD if (!wasbackclicked) // i.e. next page was clicked { int nloc = 0; for (int j = 0; j < Search_Data.sources.Count; j++) { for (int i = resultsStartIndex; i < Search_Data.images[j].Count; i++) { NopsaImage n = new NopsaImage(Search_Data.images[j][i], cm); n.Location = new Point(0, nloc); nloc = nloc + n.Height; scrollpanel.Controls.Add(n); if (i == 10 + resultsStartIndex) { resultsStartIndex = resultsStartIndex + 10; break; } } } } else //back page clicked { int nloc = 0; for (int j = 0; j < Search_Data.sources.Count; j++) { //for (int i = resultsStartIndex; i > Search_Data.images[j].Count - 10 ; i--) for (int i = 10; i > -1; i--) { NopsaImage n = new NopsaImage(Search_Data.images[j][resultsStartIndex], cm); n.Location = new Point(0, nloc); nloc = nloc + n.Height; scrollpanel.Controls.Add(n); if (resultsStartIndex == 0) { break; } resultsStartIndex--; } } } this.Width = this.Width + 1; //just to trigger onresize }