예제 #1
0
        public DarkFileDisplay(int width, int height, Bitmap thumbnail, bool framed, string fileName, Control target)
        {
            MainSize  = new Size(width, height);
            Thumbnail = thumbnail;
            Framed    = framed;
            FileName  = fileName;



            int thumbBottomY = height - (int)((decimal)height / 3.4M);

            panel_Background        = new Panel();
            panel_Background.Size   = MainSize;
            panel_Background.Paint += PaintBackgroundPanel;

            //target.Controls.Add(panel_Background);

            if (framed)
            {
                panel_Background.BackgroundImage       = Properties.Resources.file_cornice;
                panel_Background.BackgroundImageLayout = ImageLayout.Stretch;
            }

            TransparentControl panel_MouseEvents = new TransparentControl();

            panel_MouseEvents.Size      = panel_Background.Size;
            panel_MouseEvents.BackColor = Color.Transparent;

            panel_MouseEvents.MouseEnter += (sender, args) =>
            {
                if (!IsSelected)
                {
                    panel_Background.BackColor = MouseOverColor;
                }
                else
                {
                    PaintBorder = true;
                    panel_Background.Invalidate();
                }
            };

            panel_MouseEvents.MouseLeave += (sender, args) =>
            {
                if (!IsSelected)
                {
                    panel_Background.BackColor = Color.Transparent;
                }

                PaintBorder = false;
                panel_Background.Invalidate();
            };

            panel_MouseEvents.MouseClick += (sender, args) =>
            {
                foreach (Action a in ClickActionsList)
                {
                    a.Invoke();
                }
            };

            panel_Background.Controls.Add(panel_MouseEvents);


            //
            // Picturebox Thumbnail
            //

            pBox_Thumbnail = new PictureBox();

            int p_width;
            int p_height;

            if (thumbnail.Width > thumbnail.Height)
            {
                p_width  = (int)(((decimal)MainSize.Width / 100M) * 75);
                p_height = (int)(((decimal)MainSize.Height / 100M) * 40);
            }
            else if (thumbnail.Width < thumbnail.Height)
            {
                decimal newHeight = MainSize.Height - (MainSize.Height - thumbBottomY);
                //p_width = (int)(((decimal)MainSize.Width / 100M) * 40);
                //p_height = (int)(((decimal)MainSize.Height / 100M) * 60);
                p_width  = (int)(((decimal)MainSize.Width / 100M) * 50);
                p_height = (int)((newHeight / 100M) * 85);
            }
            else
            {
                p_width  = (int)(((decimal)MainSize.Width / 100M) * 60);
                p_height = (int)(((decimal)MainSize.Height / 100M) * 60);
            }

            pBox_Thumbnail.Size     = new Size(p_width, p_height);
            pBox_Thumbnail.SizeMode = PictureBoxSizeMode.StretchImage;
            pBox_Thumbnail.Location = new Point((panel_Background.Width / 2) - p_width / 2, thumbBottomY - p_height);

            // Goal: The bottom of the image is always at the same Y coordinate.

            pBox_Thumbnail.Image = ImageEditing.DrawImageScaled(pBox_Thumbnail.Width, pBox_Thumbnail.Height, thumbnail);

            //pBox_Thumbnail.Image = ImageEditing.DrawImageScaled(pBox_Thumbnail.Width, pBox_Thumbnail.Height, thumbnail);
            // pBox_Thumbnail.Image = thumbnail;

            panel_Background.Controls.Add(pBox_Thumbnail);

            //
            // File name label
            //

            Label label_FileName = new Label();

            label_FileName.Font        = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel);
            label_FileName.ForeColor   = GUITools.COLOR_DarkMode_Text_Bright;
            label_FileName.MaximumSize = new Size((int)(((decimal)MainSize.Width / 100M) * 80), MainSize.Height - thumbBottomY - 5);
            label_FileName.AutoSize    = false;
            label_FileName.Text        = GUITools.FitTextLenghtToLabelSize(fileName, label_FileName);
            label_FileName.BackColor   = Color.Transparent;

            label_FileName.Location = new Point(MainSize.Width / 2 - label_FileName.Width / 2, thumbBottomY + 5);

            panel_Background.Controls.Add(label_FileName);

            progress_Download = new CustomProgressBar()
            {
                Size     = new Size(width, 8),
                Location = new Point(0, 0),
            };

            progress_Download.BackgroundBarColor = GUITools.COLOR_DarkMode_Light;
            progress_Download.ProgressBarColor   = Color.Green;
            progress_Download.Percentage         = 0;


            progress_Download.Visible = false;

            panel_Background.Controls.Add(progress_Download);

            panel_Check          = new Panel();
            panel_Check.Size     = new Size(10, 10);
            panel_Check.Location = new Point(panel_Background.Width / 2 - panel_Check.Width / 2, 0);
            panel_Check.Visible  = false;
            panel_Check.BackgroundImageLayout = ImageLayout.Stretch;
            panel_Background.Controls.Add(panel_Check);


            // Always as last thing
            panel_MouseEvents.BringToFront();
        }
예제 #2
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;
        }