本文整理汇总了C#中Panel.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Panel.Add方法的具体用法?C# Panel.Add怎么用?C# Panel.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Panel
的用法示例。
在下文中一共展示了Panel.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
Application application = new Application();
application.ShowDebug = true;
Panel panel = new Panel(application) { Left = 0, Top = 0, Width = 480, Height = 272 };
Label label = new Label(application) { Left = 10, Top = 30, Width = 200, Height = 32, Text = "Hello World" };
panel.Add(label);
Button button = new Button(application) { Left = 10, Top = 100, Width = 200, Height = 100, Text = "Touch" };
button.TouchStart += (s, e) => { label.Text = "Touched"; };
panel.Add(button);
ListView listview = new ListView(application) { Left = 239, Top = 0, Width = 240, Height = 272, RowHeight = 30 };
for (int i = 0; i < 1000; i++)
{
listview.Items.Add("ListView Item " + i.ToString());
}
panel.Add(listview);
application.Run(panel);
}
示例2: AboutModsPanel
public AboutModsPanel(Panel containingPanel, IModManager modManager, int desiredHeight = 500, int desiredWidth = 750)
{
_modManager = modManager;
ModListBox = new ListBox(containingPanel.Manager);
ModListBox.Init();
ModListBox.Top = ModListBox.Margins.Top;
ModListBox.Left = ModListBox.Margins.Left;
ModListBox.Width = 250;
ModListBox.Height = desiredHeight - containingPanel.ClientMargins.Vertical - ModListBox.Top - ModListBox.Margins.Bottom;
ModListBox.HideSelection = false;
ModListBox.c81fb310624c15a101535d14adc9ec383.Add("Gnomodia");
ModListBox.ItemIndexChanged += ModListBoxOnItemIndexChanged;
foreach (var modMetadata in modManager.ModMetadata)
{
ModListBox.c81fb310624c15a101535d14adc9ec383.Add(modMetadata.Name);
}
containingPanel.Add(ModListBox);
ModInfoPanel = new LoweredPanel(containingPanel.Manager);
ModInfoPanel.Init();
ModInfoPanel.Left = ModListBox.Left + ModListBox.Width + ModListBox.Margins.Right + ModInfoPanel.Margins.Left;
ModInfoPanel.Top = ModInfoPanel.Margins.Top;
ModInfoPanel.Width = desiredWidth - ModInfoPanel.Left - ModInfoPanel.Margins.Right;
ModInfoPanel.Height = desiredHeight - containingPanel.ClientMargins.Vertical - ModInfoPanel.Top - ModInfoPanel.Margins.Bottom;
ModInfoPanel.AutoScroll = true;
ModInfoPanel.HorizontalScrollBarEnabled = false;
ModInfoPanel.VerticalScrollBarShow = true;
containingPanel.Add(this.ModInfoPanel);
_titleLabel = new Label(containingPanel.Manager);
_titleLabel.Init();
_titleLabel.Top = _titleLabel.Margins.Top;
_titleLabel.Left = _titleLabel.Margins.Left;
_titleLabel.Height = 14;
_titleLabel.Width = ModInfoPanel.ClientWidth - _titleLabel.Margins.Horizontal;
_titleLabel.Text = "";
ModInfoPanel.Add(_titleLabel);
_versionLabel = new Label(containingPanel.Manager);
_versionLabel.Init();
_versionLabel.Left = _versionLabel.Margins.Left;
_versionLabel.Height = 14;
_versionLabel.Width = ModInfoPanel.Width - _versionLabel.Margins.Horizontal;
_versionLabel.Top = _titleLabel.Top + _titleLabel.Height + _titleLabel.Margins.Bottom + _versionLabel.Margins.Top;
_versionLabel.Text = "";
ModInfoPanel.Add(_versionLabel);
_authorLabel = new Label(containingPanel.Manager);
_authorLabel.Init();
_authorLabel.Left = _authorLabel.Margins.Left;
_authorLabel.Height = 14;
_authorLabel.Width = ModInfoPanel.Width - _authorLabel.Margins.Horizontal;
_authorLabel.Top = _versionLabel.Top + _versionLabel.Height + _versionLabel.Margins.Bottom + _authorLabel.Margins.Top;
_authorLabel.Text = "";
ModInfoPanel.Add(_authorLabel);
_infoLabel = new MultilineLabel(containingPanel.Manager);
_infoLabel.Left = _infoLabel.Margins.Left;
_infoLabel.Height = 0;
_infoLabel.Top = _authorLabel.Top + _authorLabel.Height + _authorLabel.Margins.Bottom + _infoLabel.Margins.Top;
_infoLabel.Width = ModInfoPanel.ClientWidth - _infoLabel.Margins.Horizontal;
_infoLabel.Anchor = Anchors.Top | Anchors.Left | Anchors.Right;
_infoLabel.Alignment = Alignment.TopLeft;
ModInfoPanel.Add(_infoLabel);
ModListBox.ItemIndex = 0;
}
示例3: AddNews
private void AddNews(string author, string date, string title, string message, int num) {
GroupPanel newsPnl = ScreenManager.MainWindow.ClientArea.Controls["InsaneRO News"] as GroupPanel;
Panel pnl = new Panel(WindowManager);
pnl.Init();
pnl.Text = "News_" + num;
pnl.Tag = num;
pnl.Width = newsPnl.ClientWidth - 20;
pnl.Height = 210;
pnl.Left = 10;
pnl.Top = (num * 10) + (num * 210) + 10;
pnl.BevelBorder = EBevelBorder.All;
pnl.BevelMargin = 1;
pnl.BevelStyle = EBevelStyle.Flat;
pnl.Color = Color.Transparent;
pnl.Passive = true;
Label lblTitle = new Label(WindowManager);
lblTitle.Init();
lblTitle.Skin.Layers[0].Text.Font.Resource = WindowManager.Skin.Fonts[WindowManager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFont"].Value].Resource;
lblTitle.Text = "'" + title + "' - Von " + author + " (" + date + ")";
lblTitle.TextColor = new Color(81, 172, 232);
lblTitle.Top = 5;
lblTitle.Left = 5;
lblTitle.Width = pnl.ClientWidth - 15;
lblTitle.Height = 24;
lblTitle.Alignment = EAlignment.TopLeft;
pnl.Add(lblTitle);
Label lblMessage = new Label(WindowManager);
lblMessage.Init();
lblMessage.Text = "";
lblMessage.TextLines.AddRange(message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
lblMessage.Top = 5 + 5 + 24;
lblMessage.Left = 10;
lblMessage.Width = pnl.ClientWidth - 20;
lblMessage.Height = pnl.ClientHeight - 15 - 24;
lblMessage.Ellipsis = false;
lblMessage.Alignment = EAlignment.TopLeft;
lblMessage.Autosize = true;
lblMessage.Draw += new DrawEventHandler(lblMessage_Draw);
pnl.Add(lblMessage);
newsPnl.Add(pnl);
}
示例4: Main
static void Main(string[] args)
{
var mainPanel = new Panel();
mainPanel.Name = "mainPanle";
mainPanel.Width = Application.STANDARD_ROOT_BOUNDARY.Width - 12;
mainPanel.Height = Application.STANDARD_ROOT_BOUNDARY.Height - 6;
mainPanel.Top = 3;
mainPanel.Left = 6;
#region Left Side
var leftBox = new Groupbox();
leftBox.Name = "leftBox";
leftBox.Header = "Left Box";
leftBox.Top = leftBox.Left = 0;
leftBox.Width = mainPanel.Width / 2;
leftBox.Height = mainPanel.Height;
var lblLeftStatus = new Label("Status:");
lblLeftStatus.Name = "lblLeftStatus";
lblLeftStatusText = new Label();
lblLeftStatusText.Name = "lblLeftStatusText";
lblLeftStatusText.Left = lblLeftStatus.Text.Length;
lblLeftStatusText.Width = leftBox.Width - lblLeftStatus.Width;
lblLeftStatusText.Align = ContentAlign.Right;
var btnLeftIncrement = new Button("Increment");
btnLeftIncrement.Top = 1;
btnLeftIncrement.Name = "btnLeftIncrement";
btnLeftIncrement.Pressed += BtnLeftIncrementOnPressed;
var btnLeftClear = new Button("Clear");
btnLeftClear.Top = 2;
btnLeftClear.Name = "btnLeftClear";
btnLeftClear.Pressed += (sender, eventArgs) => lblLeftStatusText.Text = "";
var txtLeftText = new Textbox();
txtLeftText.Text = "asd123";
txtLeftText.Top = 3;
txtLeftText.Left = 21;
txtLeftText.Width = 10;
txtLeftText.BackColor = ConsoleColor.Gray;
txtLeftText.ForeColor = ConsoleColor.Black;
txtLeftText.Name = "txtLeftText";
txtLeftText.EnterPressed += (sender, eventArgs) => lblLeftStatusText.Text = txtLeftText.Text;
var btnLeftSetText = new Button("Set this text =>");
btnLeftSetText.Top = 3;
btnLeftSetText.Name = "btnLeftSetText";
btnLeftSetText.Pressed += (sender, eventArgs) => lblLeftStatusText.Text = txtLeftText.Text;
var chkLeftMoveDir = new Checkbox("Move button up");
chkLeftMoveDir.Top = 5;
chkLeftMoveDir.Left = 12;
chkLeftMoveDir.Name = "chkLeftMoveDir";
chkLeftMoveDir.Checked = CheckState.Unchecked;
var prgLeftMoveButton = new Progressbar();
prgLeftMoveButton.Top = 6;
prgLeftMoveButton.Left = 12;
prgLeftMoveButton.Name = "prgLeftMoveButton";
prgLeftMoveButton.Width = chkLeftMoveDir.Text.Length + 4;
prgLeftMoveButton.Value = 10;
var lblLeftPrgDesc = new Label(@"^ Progressbar ^");
lblLeftPrgDesc.Top = 7;
lblLeftPrgDesc.Left = 14;
lblLeftPrgDesc.Name = "lblLeftPrgDesc";
var myPlayground = new Playground(7, 14);
myPlayground.Name = "playground";
myPlayground.Top = 9;
myPlayground.Left = 14;
myPlayground.BackColor = ConsoleColor.Blue;
myPlayground.ForeColor = ConsoleColor.Red;
myPlayground[0, 0] = 'x';
myPlayground[2, 2] = 'x';
myPlayground[4, 4] = 'x';
myPlayground[6, 6] = 'o';
myPlayground[4, 8] = 'x';
myPlayground[2, 10] = 'x';
myPlayground[0, 12] = 'x';
var btnLeftMove = new Button("Move");
btnLeftMove.Top = 4;
btnLeftMove.Name = "btnLeftMove";
btnLeftMove.Pressed += (sender, eventArgs) =>
{
var mv = chkLeftMoveDir.Checked == CheckState.Checked ? -1 : 1;
if(btnLeftMove.Top + mv < btnLeftMove.Container.Height - 3 &&
btnLeftMove.Top + mv > 3)
btnLeftMove.Top += mv;
prgLeftMoveButton.Value = (int)(((btnLeftMove.Top - 2) / (float)(btnLeftMove.Container.Height - 6)) * 100);
};
leftBox.Add(lblLeftStatus);
leftBox.Add(lblLeftStatusText);
leftBox.Add(btnLeftIncrement);
leftBox.Add(btnLeftClear);
leftBox.Add(btnLeftSetText);
//.........这里部分代码省略.........
示例5: Execute
public static void Execute(Atom parent)
{
var code = new Div ();
new Div (d=>{
d.ClassName="bs-docs-example";
UI.CreateContainer( d, ct=>{
UI.CreateRowFluid(ct, r=>{
new Div(r, sp=>{
sp.ClassName="span5";
var p1 =CreatePanel("Apps");
new Div(pi=>{
pi.ClassName="c-icons";
pi.Append("<style>img {height: 40px;} .c-icon {height: 95px;}</style>");
foreach( var app in GetApps()){
new ImgPicture(pi, img=>{
img.Img.Src=app.Icon;
img.Text=app.Title;
img.Clicked+= (e) =>{e.PreventDefault(); app.Title.LogInfo();};
});
}
p1.Add(pi);
});
var p2 =CreatePanel("Demo");
var color = new TextField();
var bb = new Button("Change background");
bb.Clicked+= (e) => p2.Body.Style.BackgroundColor= color.Value;
var bc = new Button("collapse");
bc.Clicked+= (e) => p2.Collapse();
p2.Add(color);
p2.Add(bb);
p2.Add(bc);
sp.JQuery.Append(p1).Append(p2);
});
new Div(r, sp=>{
sp.ClassName="span5";
var p1 =CreatePanel("El Coyote");
new Div( cy=>{
cy.ClassName="span2";
new Image(cy,i=>{
i.Src="img/coyote.jpg";
i.Style.Height="100px";
});
p1.Add(cy);
});
new Div( cy=>{
cy.ClassName="span10";
cy.Append(@"<i><b>El <a href='https://es.wikipedia.org/wiki/Coyote' title='Coyote' target='_blank'>Coyote</a> y el <a href='https://es.wikipedia.org/wiki/Geococcyx_californianus' title='Geococcyx californianus' target='_blank'>Correcaminos</a></b></i> (<i><b>Wile E. Coyote</b> and the <b>Road Runner</b></i>) son los personajes de una serie <a href='https://es.wikipedia.org/wiki/Estados_Unidos' title='Estados Unidos' target='_blank'>estadounidense</a> de <a href='https://es.wikipedia.org/wiki/Dibujos_animados' title='Dibujos animados' target='_blank'>dibujos animados</a> creada en el año de <a href='https://es.wikipedia.org/wiki/1949' title='1949' target='_blank'>1949</a> por el animador <a href='https://es.wikipedia.org/wiki/Chuck_Jones' title='Chuck Jones' target='_blank'>Chuck Jones</a> para <a href='https://es.wikipedia.org/wiki/Warner_Brothers' title='Warner Brothers' target='_blank'>Warner Brothers</a>. Chuck Jones se inspiró para crear a estos personajes en un libro de <a href='https://es.wikipedia.org/wiki/Mark_Twain' title='Mark Twain' target='_blank'>Mark Twain</a>, titulado <i>Roughin It</i>, en el que Twain denotaba que los coyotes hambrientos podrían cazar un correcaminos.
<a href='https://es.wikipedia.org/wiki/El_Coyote_y_el_Correcaminos' title='Coyote' target='_blank'>El Coyote (wikipedia)</a> ");
p1.Add(cy);
});
var p2 =CreatePanel("Table");
var tb = new Table<App>("title");
tb.Load(GetApps());
p2.Add(tb);
sp.JQuery.Append(p1).Append(p2);
});
});
});
var wn=1;
new Button(d, bt=>{
bt.Text="Window I";
bt.Clicked+=evt=>{
new Panel( new PanelOptions{Overlay=true}){
Caption="Window " +(wn++).ToString(),
Left=(wn*5).ToString()+"px",
Top=(wn*15).ToString()+"px",
Width="300px",
Height="100px",
}.Show();
};
});
//.........这里部分代码省略.........