예제 #1
0
        public FileUploadVisual(int x, int y, int width, int height, LocalFileStructure fStruct)
        {
            // TEMP
            Size thumbSize = new Size(50, height - 15);

            panel_Background = new Panel()
            {
                BackColor = Color.Transparent,
                Size      = new Size(width, height),
                Location  = new Point(x, y)
            };

            //
            // bar_Progress
            //

            bar_Progress = new RoundedProgressBar()
            {
                Location = new Point(thumbSize.Width + 20, (int)((decimal)thumbSize.Height / 1.3M)),
                //Size = new Size((int)((decimal)width / 1.5M), 10),
                BorderStyle = BorderStyle.None,
                //BackColor = Color.White,
                BackgroundBarColor = Color.FromArgb(255, 220, 220, 220),
                ProgressBarColor   = Color.Green,
                Percentage         = 0
            };

            bar_Progress.Size       = new Size(width - bar_Progress.Location.X - 20, 10);
            bar_Progress.Percentage = 70;


            //bar_Progress = new ProgressBar()
            //{
            //    Location = new Point(thumbSize.Width + 20, (int)((decimal)thumbSize.Height / 1.3M)),
            //    //Size = new Size((int)((decimal)width / 1.5M), 10),
            //    BackColor = Color.White,

            //};
            //bar_Progress.Maximum = 100;
            //bar_Progress.Value = 50;
            //bar_Progress.Size = new Size(width - bar_Progress.Location.X - 20, 10);

            //
            // Thumbnail
            //

            if (imageExtensions.Contains(fStruct.FileExtension.ToLower()))
            {
                // Create the thumbnail
                Bitmap img = new Bitmap(fStruct.FilePath);
                FileThumbnail = ImageEditing.DrawImageScaled(thumbSize.Width, thumbSize.Height, img);

                img.Dispose();
            }
            else
            {
                FileThumbnail = Icon.ExtractAssociatedIcon(fStruct.FilePath).ToBitmap();
            }

            pBox_Thumbnail = new PictureBox()
            {
                Size     = thumbSize,
                Location = new Point(5, 7),
                Image    = ImageEditing.AddThumbnailShadow((Bitmap)FileThumbnail, Properties.Resources.shadow_base_full),
                SizeMode = PictureBoxSizeMode.Zoom
            };

            //
            // btn_CheckCross
            //

            btn_CheckCross = new Button()
            {
                BackgroundImage       = Properties.Resources.TransferResult_CrossThick,
                BackgroundImageLayout = ImageLayout.Zoom,
                Size      = new Size(25, 25),
                BackColor = Color.Transparent,
                FlatStyle = FlatStyle.Flat,
            };



            //
            // label_FileName
            //

            label_FileName = new Label()
            {
                Font      = new Font("Bahnschrift", 12),
                Location  = new Point(bar_Progress.Location.X - 3, bar_Progress.Location.Y - 25),
                ForeColor = Color.FromArgb(200, 80, 80, 80),
                Size      = new Size(bar_Progress.Width - btn_CheckCross.Width - 10, 50)
            };

            // Automatically adjust the text lenght in relation to the label width. Dynamic
            label_FileName.Text = GUITools.FitTextLenghtToLabelSize(fStruct.FullName, label_FileName);

            //Console.WriteLine($"Width of: {label_FileName.Text}: {size.Width}");


            btn_CheckCross.Location = new Point(bar_Progress.Location.X + bar_Progress.Size.Width - btn_CheckCross.Size.Width,
                                                label_FileName.Location.Y - 5);

            btn_CheckCross.FlatAppearance.BorderSize = 0;
        }
예제 #2
0
        private async void GetThumbnails()
        {
            if (FileDataList == null)
            {
                return;
            }

            for (int i = 0; i < CurrentShownFiles.Count; i++)
            {
                if (CurrentShownFiles[i] == null || CurrentShownFiles[i].CurrentState == FileStatus.Deleted)
                {
                    continue;
                }

                FileVisualDisplay fVis = CurrentShownFiles[i];

                if (fVis.FileStructOnline.Thumbnail.Length > 0)
                {
                    byte[] thumbnailBytes = await ApiCommunication.GetThumbnail(fVis.FileStructOnline.Thumbnail, UserSettings.UserAccessToken);

                    if (thumbnailBytes == null)
                    {
                        Image thumb = CreateThumbnailForFile(fVis.FileStructOnline.FileExtension);
                        fVis.panel_Thumbnail.BackgroundImage = thumb;
                        continue;
                    }

                    Image thumbnail = Image.FromStream(new MemoryStream(thumbnailBytes));

                    if (fVis != null)
                    {
                        fVis.panel_Thumbnail.BackgroundImage = ImageEditing.AddThumbnailShadow((Bitmap)thumbnail, shadow_base);
                    }
                }
                else
                {
                    Image thumb = CreateThumbnailForFile(fVis.FileStructOnline.FileExtension);
                    fVis.panel_Thumbnail.BackgroundImage = thumb;
                }
            }

            //foreach(FileVisualDisplay fVis in CurrentShownFiles)
            //{
            //    if(fVis.FileStructOnline.Thumbnail.Length > 0)
            //    {
            //        byte[] thumbnailBytes = await ApiCommunication.GetThumbnail(fVis.FileStructOnline.Thumbnail, UserSettings.UserAccessToken);

            //        if (thumbnailBytes == null)
            //        {
            //            Image thumb = CreateThumbnailForFile(fVis.FileStructOnline.FileExtension);
            //            fVis.panel_Thumbnail.BackgroundImage = thumb;
            //            continue;
            //        }

            //        Image thumbnail = Image.FromStream(new MemoryStream(thumbnailBytes));

            //        fVis.panel_Thumbnail.BackgroundImage = thumbnail;
            //    }
            //    else
            //    {
            //        Image thumb = CreateThumbnailForFile(fVis.FileStructOnline.FileExtension);
            //        fVis.panel_Thumbnail.BackgroundImage = thumb;
            //    }
            //}
        }