我已經按照這個很棒的教程來設計現代 UI 使用FontAwsome.Sharp

這就是它在除錯中的樣子:[
][]
該表單有兩個停靠面板和一些IconButtons,以下是當前屬性:
面板選單
Panel
Dock Left
Size 231, 687
IconButtons
Size 231, 60
Dock Top
FlatStyle Flat
ImageAlign MiddleLeft
TextAlign MiddleLeft
TextImageRelation ImageBeforeText
第二個問題,即使設計是正確的這種方法:
ActivateButton(object senderBtn, Color color)
什么都不做,它應該改變BackColor,IconButtons移動圖示和顯示按鈕的側面小邊框。我將代碼與源代碼進行了比較,沒有問題
public partial class MainForm : Form
{
// Fields
private IconButton currentBtn;
private Panel leftBorderBtn;
private Form currentChildForm;
public MainForm()
{
InitializeComponent();
leftBorderBtn = new Panel();
leftBorderBtn.Size = new Size(7, 60);
panelMenu.Controls.Add(leftBorderBtn);
}
private struct RGBColors
{
public static Color color1 = Color.FromArgb(172, 126, 241);
public static Color color2 = Color.FromArgb(249, 118, 176);
public static Color color3 = Color.FromArgb(253, 138, 114);
public static Color color4 = Color.FromArgb(95, 77, 221);
public static Color color5 = Color.FromArgb(249, 88, 155);
public static Color color6 = Color.FromArgb(24, 161, 251);
}
// Methods
private void ActivateButton(object senderBtn, Color color)
{
if (currentBtn != null)
{
DisableButton();
currentBtn = (IconButton)senderBtn;
currentBtn.BackColor = Color.FromArgb(37,36,81);
currentBtn.ForeColor = color;
currentBtn.TextAlign = ContentAlignment.MiddleCenter;
currentBtn.IconColor = color;
currentBtn.TextImageRelation = TextImageRelation.TextBeforeImage;
currentBtn.ImageAlign = ContentAlignment.MiddleRight;
// Left Border Button
leftBorderBtn.BackColor = color;
leftBorderBtn.Location = new Point(0, currentBtn.Location.Y);
leftBorderBtn.Visible = true;
leftBorderBtn.BringToFront();
}
}
// Disable Button
private void DisableButton()
{
if (currentBtn != null)
{
currentBtn.BackColor = Color.FromArgb(31, 30, 68);
currentBtn.ForeColor = Color.Gainsboro;
currentBtn.TextAlign = ContentAlignment.MiddleLeft;
currentBtn.IconColor = Color.Gainsboro;
currentBtn.TextImageRelation = TextImageRelation.ImageBeforeText;
currentBtn.ImageAlign = ContentAlignment.MiddleLeft;
}
}
private void btnItems_Click(object sender, EventArgs e)
{
ActivateButton(sender, RGBColors.color1);
}
我正在使用視覺作業室 2015 。很抱歉這篇文章很長,但您的幫助將不勝感激。
編輯#1:我已經構建了表格并在筆記本電腦上使用它,設計還可以,問題是我目前的 43 英寸螢屏,有沒有辦法適合所有螢屏?
uj5u.com熱心網友回復:
我不確切知道,但看起來你的螢屏比例為 125% 而不是 100%。這是可能的?我在用戶電腦上制作的應用程式也遇到了類似的問題,就是因為這個原因。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/467713.html
上一篇:將選定欄位發送到另一個反應組件
