public FileBrowserItem(ItemType tp, string path, Bitmap img, FileBrowser parent) { Type = tp; FullPath = path; Owner = parent; Margin = new Padding(0); FullImage = img; // FullImage - contains image in natural size. BackgroundImageLayout = ImageLayout.None; Click += ClickEvent; MouseEnter += OnMouseEnter; MouseLeave += OnMouseLeave; Text = new Label { Parent = this, AutoSize = false, AutoEllipsis = true }; SetVariables(img, parent); Text.BackColor = Color.Transparent; if (Type == ItemType.Folder || Type == ItemType.File) Text.Text = Path.GetFileName(path); if (Type == ItemType.Drive) Text.Text = FullPath; Text.BringToFront(); Text.Click += ClickEvent; Text.MouseEnter += OnMouseEnter; Text.MouseLeave += OnMouseLeave; }
public void SetVariables(Image backimg, FileBrowser parent) { Width = parent.CurrentLayout.GetElementWidth(); Height = parent.CurrentLayout.GetElementHeight(); BackgroundImage = backimg; Text.Location = parent.CurrentLayout.GetLocation(); Text.Width = parent.CurrentLayout.GetTextWidth(); Text.Height = parent.CurrentLayout.GetTextHeight(); Text.Font = new Font(Text.Font.FontFamily, parent.CurrentLayout.GetFontSize()); Text.TextAlign = parent.CurrentLayout.GetAlign(); }