public static void Label3_Click(object sender, EventArgs e)
        {
            statiya     stat = statiya.Click1(((Label)sender).Text);
            StatiyaForm form = new StatiyaForm(stat);

            form.ShowDialog();
        }
Exemple #2
0
        private void ArticleClick(object sender, EventArgs e)
        {
            foreach (LinkLabel lab in arts)
            {
                if (sender.Equals(lab))
                {
                    List <String> ArticleInfo = SQLClass.Select(
                        "SELECT Header, Author, Category, Text, Picture FROM " + Tables.ARTICLES +
                        " WHERE header = '" + lab.Text + "'");

                    for (int artIndex = 0; artIndex < ArticleInfo.Count; artIndex += 5)
                    {
                        statiya stat = new statiya();
                        stat.name_statiya      = ArticleInfo[artIndex].ToString();
                        stat.name_author       = ArticleInfo[artIndex + 1].ToString();
                        stat.kategorita_statii = ArticleInfo[artIndex + 2].ToString();
                        stat.text_statii       = ArticleInfo[artIndex + 3].ToString();

                        //FIXME!!! Show ternarny operator
                        stat.picture = (ArticleInfo[artIndex + 4].ToString() != "") ?
                                       ArticleInfo[artIndex + 4].ToString() :
                                       null;

                        StatiyaForm OknoStatiya = new StatiyaForm(stat, true);
                        OknoStatiya.ShowDialog();
                    }
                }
            }
        }
        void Label_Click(object sender, EventArgs e)
        {
            /* foreach (newPage Label_ in ListOfPages)
             * {*/

            statiya     stat = statiya.Click1(((Label)sender).Text);
            StatiyaForm form = new StatiyaForm(stat);

            form.ShowDialog();

            // }
        }
Exemple #4
0
 private void ArticleClick(object sender, EventArgs e)
 {
     foreach (LinkLabel lab in arts)
     {
         if (sender.Equals(lab))
         {
             statiya     stat        = statiya.Click1(((Label)sender).Text);
             StatiyaForm OknoStatiya = new StatiyaForm(stat);
             OknoStatiya.ShowDialog();
             Form1_Load(sender, e);
             break;
         }
     }
 }
Exemple #5
0
        private void dalee_Click(object sender, EventArgs e)
        {
            Dictionary <String, String> dict = new Dictionary <string, string>();

            dict.Add("STR", "%" + textBox_search.Text + "%");
            List <String> PopularArticles =
                SQLClass.Select
                    ("SELECT Header, Picture, " +
                    "(SELECT likesCount FROM " + Tables.LIKES + " WHERE Header = Article) likesCount, " +
                    "(SELECT discount FROM " + Tables.LIKES + " WHERE Header = Article) discount, " +
                    "(SELECT COUNT(*) FROM " + Tables.READ_OF_ARTICLES + " WHERE Header = name_of_article) A" +
                    " FROM " + Tables.ARTICLES +
                    " WHERE new = 0 AND (header like @STR OR category like @STR OR author like @STR)" +
                    getKak() +
                    " LIMIT " + Convert.ToString(kolvo_nazatiy * 3) + ", 3", dict);


            for (int artIndex = 0; artIndex < PopularArticles.Count; artIndex += 5)
            {
                #region Article header
                Panel articleHeaderPanel = new Panel();
                articleHeaderPanel.Size     = new Size(Centr_panel.Width, 30);
                articleHeaderPanel.Dock     = (kolvo_nazatiy > 0) ? DockStyle.Bottom : DockStyle.Top;
                articleHeaderPanel.TabIndex = (kolvo_nazatiy > 0) ? 3 * kolvo_nazatiy : 3 * kolvo_nazatiy + 2;

                LinkLabel label1 = new LinkLabel();
                label1.Location = new Point(0, 0);
                label1.Size     = new Size(180, 20);
                label1.Text     = PopularArticles[artIndex].ToString();
                label1.Click   += new System.EventHandler(ArticleClick);
                articleHeaderPanel.Controls.Add(label1);

                PictureBox likesPB = new PictureBox();
                likesPB.Size     = new Size(20, 20);
                likesPB.Location = new Point(200, 0);
                likesPB.Image    = Properties.Resources.like;
                articleHeaderPanel.Controls.Add(likesPB);

                Label likesLabel = new Label();
                likesLabel.Location = new Point(230, 0);
                likesLabel.Size     = new Size(20, 20);
                articleHeaderPanel.Controls.Add(likesLabel);

                Label dislikesLabel = new Label();
                dislikesLabel.Location = new Point(290, 0);
                dislikesLabel.Size     = new Size(20, 20);
                articleHeaderPanel.Controls.Add(dislikesLabel);

                StatiyaForm.GetStata(likesLabel, dislikesLabel, label1.Text);
                #endregion

                //Video
                if (PopularArticles[artIndex + 1].ToString().Contains("www.youtube.com"))
                {
                    String url = PopularArticles[artIndex + 1].ToString().Replace("watch?v=", "embed/");

                    String embed = "<html><head>" +
                                   "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\"/>" +
                                   "</head><body>" +
                                   "<iframe width=\"" + Centr_panel.Width + "\" src=\"{0}\"" +
                                   "frameborder = \"0\" allow = \"autoplay; encrypted-media\" allowfullscreen></iframe>" +
                                   "</body></html>";

                    WebBrowser web = new WebBrowser();
                    web.TabIndex     = 3 * kolvo_nazatiy + 1;
                    web.Dock         = (kolvo_nazatiy > 0) ? DockStyle.Bottom : DockStyle.Top;
                    web.DocumentText = string.Format(embed, url);
                    web.Location     = new Point(0, articleY + 25);

                    if (kolvo_nazatiy > 0)
                    {
                        Centr_panel.Controls.Add(web);
                        Centr_panel.Controls.Add(articleHeaderPanel);
                    }
                    else
                    {
                        Centr_panel.Controls.Add(articleHeaderPanel);
                        Centr_panel.Controls.Add(web);
                    }
                }
                //Picture
                else
                {
                    String[] chasti_stroki = PopularArticles[artIndex + 1].ToString().Split(new char[] { ' ', '/' });

                    PictureBox artImage = new PictureBox();
                    artImage.Location = new Point(0, articleY + 25);
                    artImage.Tag      = label1.Text;
                    artImage.Size     = new Size(Centr_panel.Width, 150);
                    artImage.Dock     = (kolvo_nazatiy > 0) ? DockStyle.Bottom : DockStyle.Top;
                    artImage.Click   += new System.EventHandler(clik_na_pic);
                    artImage.SizeMode = PictureBoxSizeMode.StretchImage;
                    artImage.TabIndex = 3 * kolvo_nazatiy + 1;

                    try
                    {
                        artImage.Image = new Bitmap(chasti_stroki[chasti_stroki.Length - 1]);
                    }
                    catch (Exception)
                    {
                        try
                        {
                            artImage.LoadAsync(PopularArticles[artIndex + 1].ToString());
                            Uri uri = new Uri(PopularArticles[artIndex + 1].ToString());
                            client.DownloadFileAsync(uri, chasti_stroki[chasti_stroki.Length - 1]);
                        }
                        catch (Exception)
                        {
                            artImage.Image = new Bitmap("defolt_statiy.jpg");
                        }
                    }

                    if (kolvo_nazatiy > 0)
                    {
                        Centr_panel.Controls.Add(artImage);
                        Centr_panel.Controls.Add(articleHeaderPanel);
                    }
                    else
                    {
                        Centr_panel.Controls.Add(articleHeaderPanel);
                        Centr_panel.Controls.Add(artImage);
                    }

                    piccc.Add(artImage);
                }

                Centr_panel.Controls.Add(dalee);
                arts.Add(label1);
                articleY += 180;
            }

            kolvo_nazatiy++;
        }