Ejemplo n.º 1
0
        /// <summary>
        /// Добавление UserControl с рекламой
        /// </summary>
        public static void AddNewBlock(object sender, EventArgs e)
        {
            Control c = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;


            List <string> paramsArt = new List <string>();

            paramsArt.Add("5");
            paramsArt.Add("5");
            paramsArt.AddRange(URLs);

            UCParameters p = new UCParameters("AdsUserControl", paramsArt);

            p.ShowDialog();

            if (p.ParamsList != new List <string>())
            {
                AdsUserControl a1        = new AdsUserControl(p.ParamsList);
                string         shsvfhksv = "";
                foreach (string asd in paramsArt)
                {
                    shsvfhksv += asd + ',';
                }
                Menus.InsertBlockToDB(sender, a1, shsvfhksv);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Добавление UserControl с детальной инфой о статье
        /// </summary>
        public static void AddNewBlock(object sender, EventArgs e)
        {
            Control      c = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            UCParameters p = new UCParameters("ArticleDetailsUserControl", new List <string>());

            p.ParamsList.Add("Война и мир");
            p.ShowDialog();
            ArticleDetailsUserControl a1 = new ArticleDetailsUserControl(p.ParamsList);
            string Buff = "";

            foreach (string Param in p.ParamsList)
            {
                Buff += Param + ',';
            }
            Menus.InsertBlockToDB(sender, a1, Buff);
        }
        /// <summary>
        /// Добавление UserControl с аутентификацией
        /// </summary>
        public static void AddNewBlock(object sender, EventArgs e)
        {
            Control      c = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            UCParameters p = new UCParameters("AuthenticationUserControl", new List <string>());

            p.ShowDialog();
            AuthenticationUserControl a1 = new AuthenticationUserControl(p.ParamsList);

            a1.Location = p.UCLocation;
            string shsvfhksv = "";

            foreach (string asd in p.ParamsList)
            {
                shsvfhksv += asd + ',';
            }
            Menus.InsertBlockToDB(sender, a1, shsvfhksv);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Добавление UserControl с инфой о статье в режиме предпросмотра
        /// </summary>
        public static void AddNewBlock(object sender, EventArgs e)
        {
            Control      c = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            UCParameters p = new UCParameters("ArticlePreviewUserControl", new List <string>());

            p.ParamsList.Add("Война и мир");
            p.ParamsList.Add("5");
            p.ShowDialog();
            ArticlePreviewUserControl a1 = new ArticlePreviewUserControl(p.ParamsList);
            string shsvfhksv             = "";

            foreach (string asd in p.ParamsList)
            {
                shsvfhksv += asd + ',';
            }
            Menus.InsertBlockToDB(sender, a1, shsvfhksv);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Добавление UserControl поиска
        /// </summary>
        public static void AddNewBlock(object sender, EventArgs e)
        {
            Control      c = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            UCParameters p = new UCParameters("UserControlSearch", new List <string>()
            {
                "1"
            });

            p.ShowDialog();
            UserControlSearch a1        = new UserControlSearch(p.ParamsList);
            string            shsvfhksv = "";

            foreach (string asd in p.ParamsList)
            {
                shsvfhksv += asd + ',';
            }
            Menus.InsertBlockToDB(sender, a1, shsvfhksv);
        }
        /// <summary>
        /// Добавление UserControl со списком авторов
        /// </summary>
        public static void AddNewBlock(object sender, EventArgs e)
        {
            Control      c = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            UCParameters p = new UCParameters("UserControlAutorsList", new List <string>()
            {
            });

            p.ShowDialog();
            UserControlAutorsList a1 = new UserControlAutorsList(new List <string> {
                p.Amount.ToString(), p.SortOrder, p.DistanceBetween.ToString()
            });
            string shsvfhksv = "";

            foreach (string asd in new List <string> {
                p.Amount.ToString(), p.SortOrder, p.DistanceBetween.ToString()
            })
            {
                shsvfhksv += asd + ',';
            }
            Menus.InsertBlockToDB(sender, a1, shsvfhksv);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Добавление UserControl с категориями
        /// </summary>
        public static void AddNewBlock(object sender, EventArgs e)
        {
            Control      c = ((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            UCParameters p = new UCParameters("CategoriesUserControl", new List <string>()
            {
                "2", "2"
            });

            p.ShowDialog();
            if (p.ParamsList != new List <string>())
            {
                CategoriesUserControl a1 = new CategoriesUserControl(p.ParamsList);
                string shsvfhksv         = "";
                foreach (string asd in p.ParamsList)
                {
                    shsvfhksv += asd + ',';
                }
                a1.Controls.Add(CategoriesUserControl.l1);
                Menus.InsertBlockToDB(sender, a1, shsvfhksv);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Функция указания текущих параметров перед показом формы UCParameters.
        /// </summary>
        public static void SetUCParametersToCurrent(object sender, EventArgs e)
        {
            UserControl   pb     = (UserControl)((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            List <string> dnonil = new List <string>();

            switch (pb.GetType().ToString().Replace("OnlineMag.", ""))
            {
            case "AdsUserControl":
                AdsUserControl pb1 = (AdsUserControl)pb;
                dnonil.Add(pb1.amount.ToString());
                dnonil.Add(pb1.progal.ToString());
                break;

            case "ArticleDetailsUserControl":
                ArticleDetailsUserControl pb2 = (ArticleDetailsUserControl)pb;
                dnonil.Add(pb2.ListOfArticles[0]);
                break;

            case "ArticlePreviewUserControl":
                ArticlePreviewUserControl pb3 = (ArticlePreviewUserControl)pb;
                dnonil.Add(pb3.Article);
                dnonil.Add("5");
                break;

            case "CategoriesUserControl":
                CategoriesUserControl pb4 = (CategoriesUserControl)pb;
                if (pb4.asd.Count >= 2)
                {
                    dnonil.Add(pb4.asd[0]);
                    dnonil.Add(pb4.asd[1]);
                }
                break;

            case "UserControlAutorsList":
                UserControlAutorsList pb5 = (UserControlAutorsList)pb;
                if (pb5.asd.Count >= 3)
                {
                    dnonil.Add(pb5.asd[0]);
                    dnonil.Add(pb5.asd[1]);
                    dnonil.Add(pb5.asd[2]);
                }
                break;

            case "UserControlMainAuthor":
                UserControlMainAuthor pb6 = (UserControlMainAuthor)pb;
                dnonil.AddRange(pb6.par);
                break;

            case "UserControlSearch":
                UserControlSearch pb7 = (UserControlSearch)pb;
                dnonil.Add(" ");
                break;

            case "AuthenticationUserControl":
                AuthenticationUserControl pb8 = (AuthenticationUserControl)pb;
                dnonil.Add("");
                break;
            }

            UCParameters p = new UCParameters(pb.GetType().ToString().Replace("OnlineMag.", ""), dnonil);

            p.UCSize     = pb.Size;
            p.UCLocation = pb.Location;

            p.ShowDialog();
            pb.Size     = p.UCSize;
            pb.Location = p.UCLocation;
            if (pb.GetType().ToString().Replace("OnlineMag.", "") == "UserControlMainAuthor")
            {
                UserControlMainAuthor pb33 = (UserControlMainAuthor)pb;
                pb33.par = new List <string>()
                {
                    p.UserName
                };
                dnonil = pb33.par;
                pb33.Init(pb33.par);
            }
            else if (pb.GetType().ToString().Replace("OnlineMag.", "") == "CategoriesUserControl")
            {
                CategoriesUserControl pb2 = (CategoriesUserControl)pb;
                pb2.asd = p.ParamsList;
                dnonil  = p.ParamsList;
                CategoriesUserControl.RefreshUC(pb2, Convert.ToInt32(pb2.asd[0]));
            }

            else if (pb.GetType().ToString().Replace("OnlineMag.", "") == "UserControlAutorsList")
            {
                UserControlAutorsList pb2 = (UserControlAutorsList)pb;
                pb2.asd.Clear();
                pb2.asd         = p.ParamsList;
                pb2.authorsList = SQLClass.Select("SELECT `UserName` FROM `Authors` LIMIT 0," + p.Amount);
                pb2.UserControlAutorsList_Load(null, null);
                if (pb2.asd[2] == "")
                {
                    pb2.asd[2] = "0";
                }
                dnonil = pb2.asd;
            }

            else if (pb.GetType().ToString().Replace("OnlineMag.", "") == "ArticlePreviewUserControl")
            {
                ArticlePreviewUserControl pb2 = (ArticlePreviewUserControl)pb;

                pb2.Article         = p.ParamsList[0];
                pb2.linkLabel1.Text = pb2.Article;
                pb2.asd             = p.ParamsList;
                dnonil = pb2.asd;

                try
                {
                    List <string> kart = SQLClass.Select("SELECT `Picture` FROM `Articles1` WHERE `Header` = '" + pb2.Article + "'");
                    pb2.pictureBox1.Load(kart[0]);

                    List <string> likes = SQLClass.Select("SELECT `LikesCount`, `DisCount` FROM `Likes` WHERE `Article` = '" + pb2.Article + "'");
                    pb2.LikeCount.Text    = likes[0];
                    pb2.DisLikeCount.Text = likes[1];
                    pb2.like    = Convert.ToInt32(likes[0]);
                    pb2.dislike = Convert.ToInt32(likes[1]);
                }
                catch
                {
                    pb2.pictureBox1.Image = null;
                }
            }
            else if (pb.GetType().ToString().Replace("OnlineMag.", "") == "ArticleDetailsUserControl")
            {
                ArticleDetailsUserControl pb2 = (ArticleDetailsUserControl)pb;
                pb2.ListOfArticles.Clear();

                pb2.ListOfArticles    = p.ParamsList;
                pb2.ArticleLabel.Text = p.ParamsList[0];
                List <string> kart = SQLClass.Select("SELECT Picture, IFNULL(Text,'Ничего'), IFNULL(Author,'Никто')  FROM Articles1 WHERE Header = '" + pb2.ArticleLabel.Text + "'");
                if (kart.Count > 2)
                {
                    try
                    {
                        pb2.ArticlePicture.Load(kart[0]);
                    }
                    catch
                    {
                        pb2.ArticlePicture.Image = null;
                    }

                    pb2.ArticleTextLabel.Text = kart[1];
                    pb2.AuthorsNameLabel.Text = kart[2];
                }

                dnonil = pb2.ListOfArticles;
            }
            else if (pb.GetType().ToString().Replace("OnlineMag.", "") == "AdsUserControl")
            {
                AdsUserControl pb2 = (AdsUserControl)pb;
                pb2.ParamsAds = p.ParamsList;
                pb2.amount    = p.Amount;
                pb2.progal    = p.DistanceBetween;
                pb2.refreshADS();
                dnonil = pb2.ParamsAds;
            }
            else if (pb.GetType().ToString().Replace("OnlineMag.", "") == "UserControlAutorsList")
            {
                UserControlAutorsList pb2 = (UserControlAutorsList)pb;
                pb2.asd = p.ParamsList;
                dnonil  = p.ParamsList;
            }

            #region Сохранение в БД
            string param3 = "";
            foreach (string pr in dnonil)
            {
                param3 += pr + ",";
            }
            SQLClass.Update("UPDATE block SET" +
                            " Params = '" + param3 +
                            "' WHERE id = '" + pb.Tag + "'");
            SQLClass.Update("UPDATE block SET" +
                            " x = " + pb.Location.X.ToString() + "," +
                            " y = " + pb.Location.Y.ToString() +
                            " WHERE id = '" + pb.Tag + "'");
            #endregion
        }