예제 #1
0
        private void displayCastContent(string castUId)
        {
            MovieConnector.Cast cast = null;
            string[]            arr  = castUId.Split('_');
            if (dbController.checkIfCastInDatabase(Int32.Parse(arr[1])))
            {
                cast = dbController.getCastContent(Int32.Parse(arr[1]));
            }
            else
            {
                cast = currentMovie.getCast(Int32.Parse(arr[1]));
            }
            int numObj = 3;

            if (cast != null)
            {
                Grid grid = new Grid();
                grid.Height = 478;
                grid.Width  = 844;
                var bc = new BrushConverter();
                grid.Background = (Brush)bc.ConvertFrom("#FF212121");
                GridSplitter gridSplitter = new GridSplitter();
                gridSplitter.HorizontalAlignment = HorizontalAlignment.Left;
                gridSplitter.VerticalAlignment   = VerticalAlignment.Top;
                gridSplitter.Height     = 430;
                gridSplitter.Width      = 3;
                gridSplitter.Margin     = new Thickness(252, 13, 0, 0);
                gridSplitter.Background = (Brush)bc.ConvertFrom("#FFBCBCBC");
                grid.Children.Add(gridSplitter);
                //Images
                int numImage = 1;
                //Image1
                grid.Children.Add(drawImage(numObj + "" + numImage++, "http://image.tmdb.org/t/p/w185/" + cast.ProfilePath, 301, 290, new int[] { 20, 35, 0, 0 }, cast.Image));

                //TextBlocks
                int    numTextBlock = 1;
                string text         = "";
                //textBlock1
                grid.Children.Add(drawTextBlock(numObj + "" + numTextBlock++, cast.Name, "#FFE9E9E9", FontWeights.Bold, 18, new int[] { 288, 10, 0, 0 }, new int[] { 9, 0, 0, 0 }, 31, 551));
                //textBlock2
                text += "Character: ";
                grid.Children.Add(drawTextBlock(numObj + "" + numTextBlock++, text + cast.Character, "#FFBCBCBC", FontWeights.Regular, 14, new int[] { 288, 40, 0, 0 }, new int[] { 9, 0, 0, 0 }, -1, -1));

                //Button
                Button button = new Button();
                button.Name                = "goBack_Button";
                button.Click              += goBack_Button_Click;
                button.Content             = "<Go Back";
                button.HorizontalAlignment = HorizontalAlignment.Left;
                button.VerticalAlignment   = VerticalAlignment.Top;
                button.Background          = (Brush)bc.ConvertFrom("#FF3299BB");
                button.Foreground          = (Brush)bc.ConvertFrom("#FFE9E9E9");
                button.FontWeight          = FontWeights.Bold;
                button.Width               = 75;
                button.Height              = 25;
                button.Margin              = new Thickness(20, 5, 0, 0);
                grid.Children.Add(button);
                //wrapPanel.Children.Add(grid);
                listBoxCastContent.Items.Add(grid);
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: war-man/Movie-app
        private int updateOrInsertCasts(int addOrEdit2)
        {
            int error   = 0;
            int movieId = 0;

            try
            {
                movieId = Int32.Parse(idTextBox.Text);
            }
            catch (Exception a)
            {
                MessageBox.Show("Id should be numeric for movie.");
                return(1);
            }
            for (int i = 0; i < 5;)
            {
                i++;
                string character = "", name = "";
                int    castId = 0;
                byte[] image  = null;
                if (this.Controls.ContainsKey("idText" + i.ToString()))
                {
                    TextBox idText = this.Controls["idText" + i.ToString()] as TextBox;
                    if (idText != null)
                    {
                        try
                        {
                            if (idText.Text != "")
                            {
                                castId = Int32.Parse(idText.Text);
                            }
                        }
                        catch (Exception a)
                        {
                            MessageBox.Show("Id should be numeric for cast " + i);
                            error = 1;
                        }
                    }
                }
                if (this.Controls.ContainsKey("characterText" + i.ToString()))
                {
                    TextBox characterText = this.Controls["characterText" + i.ToString()] as TextBox;
                    if (characterText != null)
                    {
                        character = characterText.Text;
                    }
                }
                if (this.Controls.ContainsKey("nameText" + i.ToString()))
                {
                    TextBox nameText = this.Controls["nameText" + i.ToString()] as TextBox;
                    if (nameText != null)
                    {
                        name = nameText.Text;
                    }
                }
                if (this.Controls.ContainsKey("pictureBox" + i.ToString()))
                {
                    PictureBox pictureBox = this.Controls["pictureBox" + i.ToString()] as PictureBox;
                    if (pictureBox != null)
                    {
                        MemoryStream ms = new MemoryStream();
                        if (pictureBox.Image != null)
                        {
                            pictureBox.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                            image = ms.GetBuffer();
                        }
                    }
                }
                if (castId != 0)
                {
                    if (character.Length > 0 && name.Length > 0 && image != null)
                    {
                        bool checkInDatabase = dbController.checkIfCastInDatabase(castId);
                        if (addOrEdit2 == 1)
                        {
                            if (checkInDatabase)
                            {
                                MessageBox.Show("Cast " + i + " with this Id is already exist");
                                error = 1;
                            }
                            else
                            {
                                dbController.insertToCast(castId, character, name, image);
                                dbController.insertCastToMovie(movieId, castId);
                            }
                        }
                        else if (addOrEdit2 == 0)
                        {
                            if (checkInDatabase)
                            {
                                dbController.updateCast(castId, character, name, image);
                            }
                            else
                            {
                                dbController.insertToCast(castId, character, name, image);
                                dbController.insertCastToMovie(movieId, castId);
                            }
                        }
                    }
                }
            }
            return(error);
        }