Esempio n. 1
0
        /// <summary>
        /// Metodo para añadir una foto al formulario
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void Adjuntar_Click_1(object sender, RoutedEventArgs e)
        {
            PersonPicture personPicture  = (PersonPicture)sender;
            var           fileOpenPicker = new FileOpenPicker();

            fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
            fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            fileOpenPicker.FileTypeFilter.Add(".png");
            fileOpenPicker.FileTypeFilter.Add(".jpg");
            fileOpenPicker.FileTypeFilter.Add(".jpeg");
            fileOpenPicker.FileTypeFilter.Add(".bmp");
            fileOpenPicker.FileTypeFilter.Add(".jfif");
            var storageFile = await fileOpenPicker.PickSingleFileAsync();

            if (storageFile != null)
            {
                // Ensure the stream is disposed once the image is loaded
                using (IRandomAccessStream fileStream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read))
                {
                    // Set the image source to the selected bitmap
                    BitmapImage bitmapImage = new BitmapImage();

                    await bitmapImage.SetSourceAsync(fileStream);

                    personPicture.ProfilePicture = bitmapImage;

                    clsConversorImagen conversor = new clsConversorImagen();
                    Task <byte[]>      taskImage = conversor.convertirAByte(storageFile);
                    byte[]             foto      = await taskImage;
                    personaSeleccionada.foto = foto;
                }
            }
        }
Esempio n. 2
0
        public IActionResult AddPersonPicture([FromBody] NewPersonPicture newPersonPicture)
        {
            //新建图片信息
            var picture = new Picture {
            };

            picture.pic_id   = (service.GetPictureNum() + 1).ToString();
            picture.pic_path = newPersonPicture.PicturePath;
            picture.pic_info = newPersonPicture.PictureInfo;

            context.Picture.Add(picture);
            context.SaveChanges();

            //新建联系集
            var personPicture = new PersonPicture {
            };

            personPicture.person_id = newPersonPicture.PersonID;
            personPicture.pic_id    = picture.pic_id;

            context.PersonPicture.Add(personPicture);
            context.SaveChanges();

            //全局信息
            var totalinfo = context.TotalInfo.Find("pumpkinmovies");

            totalinfo.pic_num += 1;
            context.TotalInfo.Attach(totalinfo);
            context.SaveChanges();

            return(Ok(new
            {
                Success = true,
                MovieID = personPicture.person_id,
                PictureID = personPicture.pic_id,
                PicturePath = picture.pic_path,
                msg = "Person Picture Added"
            }));
        }
        private UIElement GetAuthorInfoUIElement()
        {
            var grid = new Grid()
            {
                Margin = new Thickness(5),
                Height = 30,
            };

            Grid.SetRow(grid, 1);
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(30, GridUnitType.Pixel)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            var pers = new PersonPicture()
            {
                VerticalAlignment = VerticalAlignment.Center,
                Width             = 30,
                ProfilePicture    = new BitmapImage(new Uri(Data.pic)),
            };

            Grid.SetRowSpan(pers, 2);


            var titleTxt = new TextBlock()
            {
                Text = Data.title,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center,
                FontWeight          = new Windows.UI.Text.FontWeight()
                {
                    Weight = 700,
                },
                FontFamily   = new FontFamily("Arial Black"),
                Margin       = new Thickness(5, 0, 0, 0),
                TextTrimming = TextTrimming.CharacterEllipsis,
            };

            Grid.SetColumn(titleTxt, 1);


            var descriptionTxt = new TextBlock()
            {
                Text = Data.description,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center,
                FontSize            = 11,
                FontFamily          = new FontFamily("Arial"),
                Margin       = new Thickness(5, 0, 0, 0),
                TextTrimming = TextTrimming.CharacterEllipsis,
            };

            Grid.SetColumn(descriptionTxt, 1);
            Grid.SetRow(descriptionTxt, 1);

            grid.Children.Add(pers);
            grid.Children.Add(titleTxt);
            grid.Children.Add(descriptionTxt);
            return(grid);
        }
 public PersonPictureAutomationPeer(PersonPicture owner) : base(owner)
 {
 }