Inheritance: System.Windows.Forms.Control
 public static void changeNameOfPlaylist(string newName)
 {
     MovieDatabaseEntities db = new MovieDatabaseEntities();
     int usrID = getCurrentUserID();
     var playlist = db.List_Of_Playlists.SingleOrDefault(o => o.ID == (int)buttonToChangeName.Tag && o.UserID == usrID);
     playlist.Playlist_Name = newName;
     db.SaveChanges();
     buttonToChangeName.Text = playlist.Playlist_Name;
     buttonToChangeName = null;
 }
Ejemplo n.º 2
0
        // Token: 0x06000091 RID: 145 RVA: 0x0000EC04 File Offset: 0x0000CE04
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            graphics.SmoothingMode = SmoothingMode.HighQuality;
            PointF pointF = MonoFlat_Button.ImageLocation(this.GetStringFormat(this.ImageAlign), base.Size, this.ImageSize);

            switch (this.MouseState)
            {
            case 0:
                graphics.FillPath(this.InactiveGB, this.Shape);
                graphics.DrawPath(this.P1, this.Shape);
                if (this.Image == null)
                {
                    graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.R1, new StringFormat
                    {
                        Alignment     = this._TextAlignment,
                        LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    graphics.DrawImage(this._Image, pointF.X, pointF.Y, (float)this.ImageSize.Width, (float)this.ImageSize.Height);
                    graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.R1, new StringFormat
                    {
                        Alignment     = this._TextAlignment,
                        LineAlignment = StringAlignment.Center
                    });
                }
                break;

            case 1:
                graphics.FillPath(this.PressedGB, this.Shape);
                graphics.DrawPath(this.P3, this.Shape);
                if (this.Image == null)
                {
                    graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.R1, new StringFormat
                    {
                        Alignment     = this._TextAlignment,
                        LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    graphics.DrawImage(this._Image, pointF.X, pointF.Y, (float)this.ImageSize.Width, (float)this.ImageSize.Height);
                    graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.R1, new StringFormat
                    {
                        Alignment     = this._TextAlignment,
                        LineAlignment = StringAlignment.Center
                    });
                }
                break;
            }
            base.OnPaint(e);
        }
        /// <summary>
        /// removes playlist and button connected with it
        /// </summary>
        /// <param name="i">tg of removed button</param>
        /// <param name="usrID">id of current user</param>
        /// <param name="usr">Current user</param>
        private void Remove_Playlist(int i, int usrID, User usr)
        {
            MovieDatabaseEntities db = new MovieDatabaseEntities();
            foreach (Playlist pl in db.Playlists)
            {
                if (pl.PlaylistID == i && pl.UserID == usrID)
                    db.Playlists.Remove(pl);
            }

            foreach (List_Of_Playlists lop in db.List_Of_Playlists)
            {
                if (lop.ID == i && lop.UserID == usrID)
                {
                    db.List_Of_Playlists.Remove(lop);
                    usr.Number_Of_Playlists--;
                }
            }
            db.SaveChanges();

            deletePlaylistButton((int)buttonToBeRemoved.Tag);

            //Playlists_Panel.Controls.Remove(buttonToBeRemoved);
            buttonToBeRemoved = null;

            foreach (MonoFlat_Button but in Playlists_Panel.Controls)
            {
                if ((int)but.Tag > i)
                {
                    but.Location = new Point(but.Location.X - 95, but.Location.Y);
                }
            }
        }
        /// <summary>
        /// open playlist view or open menu to remove playlist
        /// </summary>
        private void Playlist_Button_Click(object sender, MouseEventArgs e)
        {
            if(e.Button == MouseButtons.Left)
            {
                MonoFlat_Button button = sender as MonoFlat_Button;
                int i = (int)button.Tag;
                actualButtonPressed = i;
                RefreshPlaylistGrid(i);
                playlistButtonPressed = true;
                homelistButtonPressed = false;
            }
            if(e.Button == MouseButtons.Right)
            {
                MonoFlat_Button button = sender as MonoFlat_Button;
                int i = (int)button.Tag;
                buttonToBeRemoved = button;
                buttonToChangeName = button;

                ContextMenuStrip cm = new ContextMenuStrip();
                cm.Items.Add("Remove Playlist");
                cm.Items.Add("Change name");
                cm.ItemClicked += new ToolStripItemClickedEventHandler(Playlist_Context_Menu_Button_Click);
                cm.Show(button, new Point(e.X, e.Y));
            }
        }
        /// <summary>
        /// Add Playlist button in Playlist_Panel
        /// </summary>
        /// <param name="i">number of user's playlists</param>
        public void createPlaylistButton(int i)
        {
            MovieDatabaseEntities db = new MovieDatabaseEntities();
            var userID = getCurrentUserID();

            var pl =
            (from playlist in db.List_Of_Playlists
             where playlist.UserID == userID && playlist.ID == i + 1
             select playlist).FirstOrDefault();
            if (pl != null)
            {
                if (Playlists_Panel.Controls.Count == 0)
                {
                    MonoFlat_Button button = new MonoFlat_Button();
                    button.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
                    button.Width = 89;
                    button.Height = 19;
                    button.Text = pl.Playlist_Name;
                    button.Location = new Point(0, 0);
                    button.MouseClick += new MouseEventHandler(Playlist_Button_Click);
                    int tag = i + 1;
                    button.Tag = tag;
                    Playlists_Panel.Controls.Add(button);
                }
                else
                {
                    int maxi = 0;
                    foreach (MonoFlat_Button but in Playlists_Panel.Controls)
                    {
                        if (Int32.Parse(but.Tag.ToString()) > maxi)
                        {
                            maxi = Int32.Parse(but.Tag.ToString());
                        }
                    }

                    foreach (MonoFlat_Button item in Playlists_Panel.Controls)
                    {
                        if (item.Tag.Equals(maxi))
                        {
                            MonoFlat_Button prevButton = item;

                            MonoFlat_Button button = new MonoFlat_Button();
                            button.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
                            button.Width = 89;
                            button.Height = 19;
                            button.Text = pl.Playlist_Name;
                            button.Location = new Point(prevButton.Bounds.Right + 6, 0);
                            button.MouseClick += new MouseEventHandler(Playlist_Button_Click);
                            int tag = i + 1;
                            button.Tag = tag;
                            Playlists_Panel.Controls.Add(button);
                        }
                    }
                }
            }
        }