public GameFileTile() { InitializeComponent(); DpiScale dpiScale = new DpiScale(CreateGraphics()); int imageWidth = dpiScale.ScaleIntX(ImageWidth); int imageHeight = dpiScale.ScaleIntY(ImageHeight); int labelHeight = dpiScale.ScaleIntY(LabelHeight); Width = imageWidth; Height = GetStandardHeight(dpiScale); pb.Width = Width; pb.Height = Height - labelHeight; pb.BackColor = Color.Black; pb.SizeMode = PictureBoxSizeMode.Zoom; pb.WaitOnLoad = false; pb.LoadCompleted += Pb_LoadCompleted; MouseClick += CtrlMouseClick; pb.MouseClick += CtrlMouseClick; DoubleClick += CtrlDoubleClick; pb.DoubleClick += CtrlDoubleClick; pb.Paint += Screenshot_Paint; Paint += GameFileTile_Paint; }
public void ShowPkContentsCheckBox(bool set) { DpiScale dpiScale = new DpiScale(CreateGraphics()); chkPkContents.Visible = set; tblMain.RowStyles[0].Height = (set ? dpiScale.ScaleIntY(80) : dpiScale.ScaleIntY(24)); }
public void SetCheckBox(string text) { DpiScale dpiScale = new DpiScale(CreateGraphics()); chk.Visible = true; chk.Text = text; tblMain.RowStyles[s_checkBoxRow].Height = dpiScale.ScaleIntY(32); Height += dpiScale.ScaleIntY(32); }
public void SetLink(string text, string url) { DpiScale dpiScale = new DpiScale(CreateGraphics()); lnk.Visible = true; lnk.Text = text; m_url = url; tblMain.RowStyles[s_linkRow].Height = dpiScale.ScaleIntY(32); Height += dpiScale.ScaleIntY(32); }
private void PopulateConfiguration() { DpiScale dpiScale = new DpiScale(CreateGraphics()); IEnumerable <IConfigurationData> configItems = m_adapter.GetConfiguration().Where(x => x.UserCanModify); TableLayoutPanel tblMain = new TableLayoutPanel { Dock = DockStyle.Top }; int height = dpiScale.ScaleIntY(8); tblMain.RowStyles.Add(new RowStyle(SizeType.Absolute, height)); int height32 = dpiScale.ScaleIntY(32); foreach (IConfigurationData config in configItems) { GrowLabel lbl = new GrowLabel { Anchor = AnchorStyles.Left, Text = AddSpaceBetweenWords(config.Name), }; tblMain.RowStyles.Add(new RowStyle(SizeType.Absolute, lbl.Height < height32 ? height32 : lbl.Height)); tblMain.Controls.Add(lbl, 0, tblMain.RowStyles.Count - 1); if (!string.IsNullOrEmpty(config.AvailableValues)) { HandleComboBox(tblMain, config); } else if (config.Name == AppConfiguration.ScreenshotPreviewSizeName) //special case for TrackBar { HandleScreenshotPreviewSize(tblMain, config, dpiScale); } else { HandleTextBox(tblMain, config); } height += height32; } tblMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); tblMain.Height = height + dpiScale.ScaleIntY(8); tabControl.TabPages[0].Controls.Add(tblMain); Height = tblMain.Height + dpiScale.ScaleIntY(110); }
private void HandleScreenshotPreviewSize(TableLayoutPanel tblMain, IConfigurationData config, DpiScale dpiScale) { m_lblScreenshotWidth = new Label { Width = dpiScale.ScaleIntX(68), Height = dpiScale.ScaleIntY(16), Margin = new Padding(0, dpiScale.ScaleIntX(8), 0, 0) }; m_screenshotTrackBar = new TrackBar { Minimum = -8, Maximum = 8, Value = Convert.ToInt32(config.Value), Width = dpiScale.ScaleIntX(200) }; m_screenshotTrackBar.ValueChanged += Trk_ValueChanged; FlowLayoutPanel flp = new FlowLayoutPanel { Dock = DockStyle.Fill }; flp.Controls.Add(m_screenshotTrackBar); flp.Controls.Add(m_lblScreenshotWidth); tblMain.Controls.Add(flp, 1, tblMain.RowStyles.Count - 1); m_configValues.Add(new Tuple <IConfigurationData, object>(config, m_screenshotTrackBar)); }
public void AddDownload(object key, string text) { if (m_cancelledDownloads.Contains(key)) { m_cancelledDownloads.Remove(key); } if (!m_downloadLookup.ContainsKey(key)) { DpiScale dpiScale = new DpiScale(CreateGraphics()); DownloadViewItem item = CreateDownloadViewItem(text); m_downloadLookup.Add(key, item); tblMain.RowCount++; tblMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); tblMain.RowStyles[tblMain.RowStyles.Count - 2].SizeType = SizeType.Absolute; tblMain.RowStyles[tblMain.RowStyles.Count - 2].Height = dpiScale.ScaleIntY(s_rowHeight); tblMain.Controls.Add(item, 0, tblMain.RowStyles.Count - 2); UpdateSize(); } else { DownloadViewItem itemOld = m_downloadLookup[key]; DownloadViewItem item = CreateDownloadViewItem(text); TableLayoutPanelCellPosition pos = tblMain.GetPositionFromControl(itemOld); tblMain.Controls.Remove(itemOld); tblMain.Controls.Add(item, pos.Column, pos.Row); m_downloadLookup.Remove(key); m_downloadLookup.Add(key, item); } }
private void HandleGameFileDirectory(TableLayoutPanel tblMain, TextBox txt) { DpiScale dpiScale = new DpiScale(CreateGraphics()); m_gameFileDirectory = txt; m_gameFileDirectory.Width = dpiScale.ScaleIntX(TextBoxWidth); FlowLayoutPanel flp = new FlowLayoutPanel { Dock = DockStyle.Fill, Margin = new Padding(0) }; flp.Controls.Add(m_gameFileDirectory); Button browseButton = new Button { Text = "Browse..." }; browseButton.Width = dpiScale.ScaleIntX(browseButton.Width); browseButton.Height = dpiScale.ScaleIntY(browseButton.Height); browseButton.Click += browseButton_Click; flp.Controls.Add(browseButton); tblMain.Controls.Add(flp, 1, tblMain.RowStyles.Count - 1); }
public TextBoxForm(bool multiline, MessageBoxButtons buttons) { InitializeComponent(); DpiScale dpiScale = new DpiScale(CreateGraphics()); if (buttons != MessageBoxButtons.OK && buttons != MessageBoxButtons.OKCancel) { throw new NotSupportedException(buttons.ToString() + " not supported"); } btnCancel.Visible = buttons == MessageBoxButtons.OKCancel; HeaderText = string.Empty; txtText.Multiline = multiline; if (!multiline) { Height = dpiScale.ScaleIntY(100); Width = dpiScale.ScaleIntX(300); } tblMain.RowStyles[s_checkBoxRow].Height = 0; tblMain.RowStyles[s_linkRow].Height = 0; lnk.Visible = false; chk.Visible = false; }
private void HandleScreenshotCaptureDirectories(TableLayoutPanel tblMain, TextBox txt) { DpiScale dpiScale = new DpiScale(CreateGraphics()); m_screenshotDirectories = txt; m_screenshotDirectories.Width = dpiScale.ScaleIntX(TextBoxWidth); m_screenshotDirectories.Enabled = false; FlowLayoutPanel flp = new FlowLayoutPanel { Dock = DockStyle.Fill, Margin = new Padding(0) }; flp.Controls.Add(txt); Button changeButton = new Button { Text = "Change..." }; changeButton.Width = dpiScale.ScaleIntX(changeButton.Width); changeButton.Height = dpiScale.ScaleIntY(changeButton.Height); changeButton.Click += ChangeButton_Click; flp.Controls.Add(changeButton); tblMain.Controls.Add(flp, 1, tblMain.RowStyles.Count - 1); }
private void PnlData_Paint(object sender, PaintEventArgs e) { if (GameFile == null) { return; } DpiScale dpiScale = new DpiScale(e.Graphics); float xPos = gameTile.Location.X + dpiScale.ScaleIntX(4); int yPos = dpiScale.ScaleIntY(8); int offset = dpiScale.ScaleIntY(22); e.Graphics.DrawString("Filename", DisplayBoldFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString("Title", DisplayBoldFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString("Author", DisplayBoldFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString("Release", DisplayBoldFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString("Played", DisplayBoldFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString("Maps", DisplayBoldFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString("Tags", DisplayBoldFont, TextBrush, xPos, yPos); xPos = gameTile.Location.X + dpiScale.ScaleFloatX(82); yPos = dpiScale.ScaleIntY(8); SizeF maxLabelSize = new SizeF(pnlData.ClientRectangle.Width - xPos + dpiScale.ScaleIntX(8), 16); e.Graphics.DrawString(GameFile.FileNameNoPath, DisplayFont, Brushes.Black, xPos, yPos); yPos += offset; e.Graphics.DrawString(Util.GetClippedEllipsesText(e.Graphics, DisplayFont, GameFile.Title, maxLabelSize), DisplayFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString(Util.GetClippedEllipsesText(e.Graphics, DisplayFont, GameFile.Author, maxLabelSize), DisplayFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString(m_release, DisplayFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString(m_played, DisplayFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString(m_maps, DisplayFont, TextBrush, xPos, yPos); yPos += offset; e.Graphics.DrawString(m_tags, DisplayFont, TextBrush, xPos, yPos); }
private void Screenshot_Paint(object sender, PaintEventArgs e) { if (m_new) { DpiScale dpiScale = new DpiScale(e.Graphics); int newPadX = dpiScale.ScaleIntX(NewPadX); int newPadY = dpiScale.ScaleIntY(NewPadY); int pad1 = dpiScale.ScaleIntX(1); SizeF size = e.Graphics.MeasureString(NewString, DisplayFont); RectangleF rect = new RectangleF(pb.ClientRectangle.Right - size.Width - newPadX - pad1, pb.ClientRectangle.Height - size.Height - newPadY - pad1, size.Width + newPadX, size.Height + newPadY); e.Graphics.FillRectangle(Brushes.Red, rect); e.Graphics.DrawRectangle(Pens.Gray, rect.Left, rect.Top, rect.Width, rect.Height); e.Graphics.DrawString(NewString, DisplayFont, Brushes.White, new PointF(rect.Left + newPadX / 2 + pad1 + pad1, rect.Top + newPadY / 2 + pad1)); } }
private void DrawProgress(Point pt, int count, int total, string text) { Graphics g = CreateGraphics(); DpiScale dpiScale = new DpiScale(g); int offsetX = dpiScale.ScaleIntX(1); int offsetY = dpiScale.ScaleIntY(1); int height = Height - offsetY; int width = Width - offsetX; Pen pen = new Pen(Color.Black, 1.0f); Rectangle rect = new Rectangle(pt, new Size(width, height)); g.DrawRectangle(pen, rect); double percent = 0; if (total > 0) { percent = count / (double)total; } width = Width - offsetX; if (total != 0) { width = (int)(width * percent); } pt.Offset(offsetX, offsetY); rect = new Rectangle(pt, new Size(rect.Width - offsetX, rect.Height - offsetY)); Brush bgBrush = new LinearGradientBrush(rect, Color.DarkGray, Color.LightGray, 90.0f); Rectangle percentRect = new Rectangle(rect.Location, new Size(width, rect.Height)); Brush brush = GetPercentBrush(rect, percent, total); g.FillRectangle(bgBrush, rect); if (width > 0) { g.FillRectangle(brush, percentRect); pt.Offset(-offsetX, -offsetY); g.DrawRectangle(GetPrecentPen(percent, total), new Rectangle(pt, new Size(percentRect.Width + offsetX, percentRect.Height + offsetY))); } SizeF size = g.MeasureDisplayString(text, DisplayFont); var offset = (height - size.Height) / 2; PointF position = new PointF(pt.X + dpiScale.ScaleIntX(8), pt.Y + offset + dpiScale.ScaleFloatY(2.5f)); g.DrawString(text, DisplayFont, FontBrush, position); }
private void GameFileTile_Paint(object sender, PaintEventArgs e) { if (GameFile == null) { return; } DpiScale dpiScale = new DpiScale(e.Graphics); int labelHeight = dpiScale.ScaleIntY(LabelHeight); int pad = dpiScale.ScaleIntX(1); SizeF layout = new SizeF(Width, 16); string text; if (!string.IsNullOrEmpty(GameFile.Title)) { text = Util.GetClippedEllipsesText(e.Graphics, DisplayFont, GameFile.Title, layout); } else { text = GameFile.FileNameNoPath; } SizeF size = e.Graphics.MeasureDisplayString(text, DisplayFont); float x = Width - size.Width - (Width - size.Width) / 2; float y = Height - size.Height - (labelHeight - size.Height) / 2; if (Selected) { e.Graphics.DrawString(text, DisplayFont, new SolidBrush(SystemColors.HighlightText), x, y); } else { e.Graphics.DrawString(text, DisplayFont, new SolidBrush(m_titleColor), x, y); } if (DrawBorder && !Selected) { e.Graphics.DrawRectangle(SeparatorPen, 0, 0, Width - pad, Height - pad); } }
private void DrawProgress(Point pt, int count, int total, string text) { Graphics g = CreateGraphics(); DpiScale dpiScale = new DpiScale(g); int offsetX = dpiScale.ScaleIntX(1); int offsetY = dpiScale.ScaleIntY(1); int height = Height - offsetX; int width = Width - offsetY; Pen pen = new Pen(Color.Black, 1.0f); Rectangle rect = new Rectangle(pt, new Size(width, height)); g.DrawRectangle(pen, rect); double percent = 0; if (total > 0) { percent = count / (double)total; } width = (int)((Width - offsetX) * percent); pt.Offset(offsetX, offsetY); rect = new Rectangle(pt, new Size(rect.Width - offsetX, rect.Height - offsetY)); Brush bgBrush = new LinearGradientBrush(rect, Color.DarkGray, Color.LightGray, 90.0f); Rectangle percentRect = new Rectangle(rect.Location, new Size(width, rect.Height)); Brush brush = GetPercentBrush(rect, percent); g.FillRectangle(bgBrush, rect); if (percent > 0) { g.FillRectangle(brush, percentRect); pt.Offset(-offsetX, -offsetY); g.DrawRectangle(GetPrecentPen(percent), new Rectangle(pt, new Size(percentRect.Width + offsetX, percentRect.Height + offsetY))); } Brush fontBrush = new SolidBrush(Color.Black); PointF position = new PointF(pt.X + dpiScale.ScaleIntX(8), pt.Y + dpiScale.ScaleFloatY(2.5f)); g.DrawString(text, new Font(FontFamily.GenericSerif, 10.0f, FontStyle.Bold), fontBrush, position); }
private void UpdateSize() { DpiScale dpiScale = new DpiScale(CreateGraphics()); Height = tblMain.RowStyles.Count * dpiScale.ScaleIntY(s_rowHeight); }
private void SetStatBarDpi(StatBar statBar, DpiScale dpiScale) { statBar.MaximumSize = new Size(statBar.MaximumSize.Width, dpiScale.ScaleIntY(statBar.MaximumSize.Height)); statBar.SetMaxHeight(statBar.MaximumSize.Height); statBar.Size = MaximumSize; }
public int GetStandardHeight(DpiScale dpiScale) { return(dpiScale.ScaleIntY(ImageHeight) + dpiScale.ScaleIntY(LabelHeight)); }