コード例 #1
0
        private async Task CreateVideoModelAndWrite(StorageFile file)
        {
            byte[] imageBytes = await ImageByteConvertor.ImageToByteArray(m_files[0]);

            string[]   date    = file.DateCreated.ToString().Split(' ');
            VideoModel myvideo = new VideoModel()
            {
                DateCreated = date[0] + " " + date[1], Name = file.DisplayName, HeadPiece = imageBytes
            };
            await WriteReadVideoModel.WriteVideoModelToFile(myvideo);
        }
コード例 #2
0
        public async Task <bool> AddContentIsSuccessful()
        {
            int count = await WriteReadVideoModel.FileCountInLocalFolder("ByteFolder");

            if (count > 0)
            {
                await AddButtonsToList(count);

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        private async Task <bool> AddContentIsSuccessful()
        {
            int count = await WriteReadVideoModel.FileCountInLocalFolder("DataFolder");

            if (count > 0)
            {
                await AddButtonsToList(count);

                GetVideoFileInMyLibrary(m_videomodels[0].Name);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        private async Task AddButtonsToList(int count)
        {
            Button[] btns = new Button[count];
            ImageGV.Items.Clear();
            my_images = new MyImageBytes[count];
            my_images = await WriteReadVideoModel.ReadImageBytes();

            for (int i = 0; i < count; i++)
            {
                btns[i]      = new Button();
                btns[i].Name = "Btn " + i;
                // StackPanel stack = new StackPanel();
                //stack.Children.Add()
                btns[i].BorderBrush = new SolidColorBrush(Windows.UI.Colors.White);
                // btns[i].Background = new SolidColorBrush(Windows.UI.Color.FromArgb(50, 0, 0, 0));
                btns[i].BorderThickness = new Thickness(2);
                //добавляем грид в btn
                Grid newGrid = new Grid();
                btns[i].Content = newGrid;
                newGrid.Margin  = new Thickness(0, 0, 0, 0);



                //Добавим элемент Image в первый столбец элемента newGrid.
                Image newImage = new Image()
                {
                    Width = 100, Height = 100
                };
                newGrid.Children.Add(newImage);
                BitmapImage image = await ImageConvertor.ByteArrayToImage(my_images[i].Bytes);

                newImage.Source  = image;
                newImage.Stretch = Stretch.Fill;
                newImage.Margin  = new Thickness(0);


                //btns[i].Click += Btn_Click;
                ImageGV.Items.Add(btns[i]);
            }
        }
コード例 #5
0
        private async Task AddButtonsToList(int count)
        {
            Button[] btns = new Button[count];
            VideoSP.Items.Clear();
            m_videomodels = new VideoModel[count];
            m_videomodels = await WriteReadVideoModel.ReadFilesInLocalFolder();

            Array.Sort(m_videomodels);
            for (int i = 0; i < count; i++)
            {
                btns[i]        = new Button();
                btns[i].Name   = "Btn " + i;
                btns[i].Width  = VideoSP.Width - 10;
                btns[i].Margin = new Thickness(5, 0, 5, 0);

                btns[i].BorderBrush     = new SolidColorBrush(Windows.UI.Colors.White);
                btns[i].Background      = new SolidColorBrush(Windows.UI.Color.FromArgb(60, 255, 255, 255));
                btns[i].BorderThickness = new Thickness(2);
                //добавляем грид в btn
                Grid newGrid = new Grid();
                btns[i].Content = newGrid;
                newGrid.Margin  = new Thickness(0, 0, 0, 0);
                newGrid.Width   = btns[i].Width;
                newGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                newGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(5, GridUnitType.Star)
                });

                // добавляем внутренний грид в newGrid
                Grid internalGrid = new Grid();
                internalGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                internalGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                newGrid.Children.Add(internalGrid);
                Grid.SetColumn(internalGrid, 1);


                //Добавим элемент Image в первый столбец элемента newGrid.
                Image newImage = new Image()
                {
                    Width = 50, Height = 50
                };
                newGrid.Children.Add(newImage);
                BitmapImage image = await ImageByteConvertor.ByteArrayToImage(m_videomodels[i].HeadPiece);

                newImage.Source  = image;
                newImage.Stretch = Stretch.Fill;
                newImage.Margin  = new Thickness(0);
                Grid.SetColumn(newImage, 0);

                //во внутренний грид помещаем текстблоки
                TextBlock nameBlock = new TextBlock()
                {
                    Text = m_videomodels[i].Name
                };
                nameBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.Black);
                TextBlock dataBlock = new TextBlock()
                {
                    Text = m_videomodels[i].DateCreated
                };
                dataBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.Black);
                internalGrid.Children.Add(nameBlock);
                internalGrid.Children.Add(dataBlock);
                Grid.SetRow(nameBlock, 0);
                Grid.SetRow(dataBlock, 1);

                btns[i].Click += Btn_Click;
                VideoSP.Items.Add(btns[i]);
            }
        }