public GameFileTileExpanded() { InitializeComponent(); BackColor = SystemColors.Control; DpiScale dpiScale = new DpiScale(CreateGraphics()); gameTile.Width = dpiScale.ScaleIntX(GameFileTile.ImageWidth); // Something in the designer is messing up the height, forcing it here gameTile.Height = gameTile.GetStandardHeight(dpiScale); Height = gameTile.Height + dpiScale.ScaleIntX(2); int pad = dpiScale.ScaleIntX(1); gameTile.DrawBorder = false; gameTile.Margin = new Padding(pad, pad, 0, 0); gameTile.TileClick += GameTile_TileClick; gameTile.TileDoubleClick += GameTile_TileDoubleClick; pnlData.Paint += PnlData_Paint; flpMain.Paint += FlpMain_Paint; pnlData.MouseClick += PnlData_Click; pnlData.DoubleClick += PnlData_DoubleClick; flpMain.MouseClick += FlpMain_MouseClick; flpMain.DoubleClick += FlpMain_DoubleClick; }
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; }
public void ShowPkContentsCheckBox(bool set) { DpiScale dpiScale = new DpiScale(CreateGraphics()); chkPkContents.Visible = set; tblMain.RowStyles[0].Height = (set ? dpiScale.ScaleIntY(80) : dpiScale.ScaleIntY(24)); }
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 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 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); } }
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 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); }
public void SetTitle(string text) { DpiScale dpiScale = new DpiScale(CreateGraphics()); lblTitle.Text = text; GetRowStyle(lblTitle).Height = lblTitle.Height + dpiScale.ScaleFloatY(6); if (GetRowStyle(lblTitle).Height < m_labelHeight) { GetRowStyle(lblTitle).Height = m_labelHeight; } }
private void ShowCommentsSection(bool bShow) { if (bShow) { DpiScale dpiScale = new DpiScale(CreateGraphics()); GetRowStyle(txtComments).Height = dpiScale.ScaleFloatY(20); } else { GetRowStyle(txtComments).Height = 0; } }
private void SetIwadInfoLabel() { if (GameFile != null && IsIwad(GameFile) && SelectedGameProfile is GameFile) { DpiScale dpiScale = new DpiScale(CreateGraphics()); tblFiles.RowStyles[0].Height = dpiScale.ScaleFloatY(40); pbInfo.Image = Properties.Resources.bon2b; lblInfo.Text = string.Format("These files will automatically be added{0} when this IWAD is selected for play.", Environment.NewLine); } else { tblFiles.RowStyles[0].Height = 0; } }
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); }
public StatsControl() { InitializeComponent(); DpiScale dpiScale = new DpiScale(CreateGraphics()); SetImage(pbMaps, Properties.Resources.map, 0.7f * dpiScale.DpiScaleY); SetImage(pbKills, Properties.Resources.kill, 0.7f * dpiScale.DpiScaleY); SetImage(pbItems, Properties.Resources.bon2b, 0.8f * dpiScale.DpiScaleY); SetImage(pbSecrets, Properties.Resources.secret, 0.8f * dpiScale.DpiScaleY); SetStatBarDpi(ctrlStatsMaps, dpiScale); SetStatBarDpi(ctrlStatsKills, dpiScale); SetStatBarDpi(ctrlStatsSecrets, dpiScale); SetStatBarDpi(ctrlStatsItems, dpiScale); }
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 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); }
public void SetStatistics(IGameFile gameFile, IEnumerable <IStatsData> stats) { if (stats.Any()) { DpiScale dpiScale = new DpiScale(CreateGraphics()); ctrlStats.Visible = true; GetRowStyle(ctrlStats).Height = dpiScale.ScaleFloatY(120); ctrlStats.SetStatistics(gameFile, stats); lblLastMap.Text = stats.OrderByDescending(x => x.RecordTime).First().MapName; } else { ctrlStats.Visible = false; GetRowStyle(ctrlStats).Height = 0; lblLastMap.Text = "N/A"; } }
public void SetTitle(string text) { if (lblTitle.Text == text) { return; } DpiScale dpiScale = new DpiScale(CreateGraphics()); lblTitle.Text = text; float height = lblTitle.Height + dpiScale.ScaleFloatY(6); if (height < m_labelHeight) { height = m_labelHeight; } GetRowStyle(lblTitle).Height = height; }
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 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); } }
public void SetStatistics(IGameFile gameFile, IEnumerable <IStatsData> stats) { if (stats.Any()) { DpiScale dpiScale = new DpiScale(CreateGraphics()); ctrlStats.Visible = true; GetRowStyle(ctrlStats).Height = dpiScale.ScaleFloatY(120); ctrlStats.SetStatistics(gameFile, stats); // Many maps can be saved at the same time, ordering by record time is not guaranteed to preserve the original order // Order by StatID to ensure the latest one is used lblLastMap.Text = stats.OrderByDescending(x => x.RecordTime).ThenByDescending(x => x.StatID).First().MapName; } else { ctrlStats.Visible = false; GetRowStyle(ctrlStats).Height = 0; lblLastMap.Text = "N/A"; } }
private void UpdateSize() { DpiScale dpiScale = new DpiScale(CreateGraphics()); Height = tblMain.RowStyles.Count * dpiScale.ScaleIntY(s_rowHeight); }
private int GetDefaultControlWidth() { DpiScale dpiScale = new DpiScale(CreateGraphics()); return(dpiScale.ScaleIntX(FullControlWidth)); }
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; }
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 int GetStandardHeight(DpiScale dpiScale) { return(dpiScale.ScaleIntY(ImageHeight) + dpiScale.ScaleIntY(LabelHeight)); }