本文整理汇总了C#中Container.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Container.Add方法的具体用法?C# Container.Add怎么用?C# Container.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Application.Init (false);
var d = new Container (0, 0, Application.Cols, Application.Lines);
d.Add (new Label (10, 10, "Text"));
d.Add (new Entry (16, 10, 20, "Edit me"));
Application.Run (d);
}
示例2: AddWidget
public static void AddWidget(Container box, Widget widget, int position, bool expandAndFill = false)
{
box.Add(widget);
((Box.BoxChild)box[widget]).Position = position;
((Box.BoxChild)box[widget]).Expand = expandAndFill;
((Box.BoxChild)box[widget]).Fill = expandAndFill;
}
示例3: Reset
public override void Reset()
{
base.Reset();
Clock.ProcessFrame();
Container approachContainer = new Container { Depth = float.MinValue, };
Add(approachContainer);
const int count = 10;
for (int i = 0; i < count; i++)
{
var h = new HitCircle
{
StartTime = Clock.CurrentTime + 1000 + i * 80,
Position = new Vector2((i - count / 2) * 14),
};
DrawableHitCircle d = new DrawableHitCircle(h)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = i,
State = ArmedState.Hit,
Judgement = new OsuJudgementInfo { Result = HitResult.Hit }
};
approachContainer.Add(d.ApproachCircle.CreateProxy());
Add(d);
}
}
示例4: HUD
public HUD(SoulGame game, ContentManager content, GraphicsDevice graphicsDevice)
{
Container = new Container(game, content, graphicsDevice);
btn1 = new Button();
btn1.X = 100;
btn1.Y = 100;
btn1.Text = "oi";
btn1.Width = 100;
btn1.Height = 50;
btn1.Font = content.Load<SpriteFont>("World");
btn1.Click += btn1_Click;
Container.Add(btn1);
txt1 = new TextBox();
txt1.X = 300;
txt1.Y = 300;
txt1.Width = 200;
txt1.Height = 30;
txt1.Font = content.Load<SpriteFont>("World");
Container.Add(txt1);
txt1.EnterPressed += txt1_EnterPressed;
}
示例5: CreateContainer
public Container CreateContainer()
{
if (container != null)
throw new InvalidOperationException();
container = new Container();
container.Add(new MyComponent());
container.Add(this);
return container;
}
示例6: StartScreen
/// <summary>
/// Erzeugt eine neue Instanz eines StartScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt.
/// </summary>
public StartScreen(GameCore game)
: base(game)
{
// leere den Screen-Stack beim Öffnen dieses Screens
ClearScreenHistory = true;
// der Container für die Buttons
buttons = new Container (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.Menu);
// logo
logo = this.LoadTexture (name: "logo");
if (Config.Default ["debug", "projector-mode", false]) {
logo = ContentLoader.InvertTexture (screen: this, texture: logo);
}
// create a new SpriteBatch, which can be used to draw textures
spriteBatch = new SpriteBatch (GraphicsDevice);
// menu
buttons.ItemAlignX = HorizontalAlignment.Center;
buttons.ItemAlignY = VerticalAlignment.Center;
Button creativeButton = new Button (
screen: this,
drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
name: "Creative",
onClick: (time) => NextScreen = new CreativeMainScreen (Game)
);
creativeButton.SetCoordinates (left: 0.700f, top: 0.250f, right: 0.960f, bottom: 0.380f);
Button challengeButton = new Button (
screen: this,
drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
name: "Challenge",
onClick: (time) => NextScreen = new ChallengeStartScreen (Game)
);
challengeButton.SetCoordinates (left: 0.000f, top: 0.050f, right: 0.380f, bottom: 0.190f);
Button settingsButton = new Button (
screen: this,
drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
name: "Settings",
onClick: (time) => NextScreen = new GeneralSettingsScreen (Game)
);
settingsButton.SetCoordinates (left: 0.260f, top: 0.840f, right: 0.480f, bottom: 0.950f);
Button exitButton = new Button (
screen: this,
drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
name: String.Empty, // "Exit",
onClick: (time) => Game.Exit ()
);
exitButton.AddKey (Keys.Escape);
exitButton.SetCoordinates (left: 0.815f, top: 0.585f, right: 0.895f, bottom: 0.705f);
exitButton.BackgroundTexture = this.LoadTexture ("exit300");
if (Config.Default ["debug", "projector-mode", false]) {
exitButton.BackgroundTexture = ContentLoader.InvertTexture (screen: this, texture: exitButton.BackgroundTexture);
}
buttons.Add (creativeButton);
buttons.Add (challengeButton);
buttons.Add (settingsButton);
buttons.Add (exitButton);
// Linien:
lines.AddPoints (
0.000f,
0.050f,
0.380f,
0.250f,
0.960f,
0.380f,
0.700f,
0.160f,
1.000f
);
lines.AddPoints (0.000f,
0.190f,
0.620f,
0.785f,
0.800f,
0.565f, // Exit oben.
0.910f, // Exit rechts.
0.730f, // Exit unten.
0.480f,
0.950f,
0.260f,
0.840f,
0.520f,
1.000f
);
}
示例7: RunGui
static void RunGui ()
{
Container a = new Container (0, 0, Application.Cols, Application.Lines);
Frame ftorrents = new Frame (0, 0, 0, 0, "Torrents");
a.Add (ftorrents);
// Add
Button badd = new Button (1, 1, "Add");
badd.Clicked += delegate { AddDialog (); };
ftorrents.Add (badd);
// Options
Button boptions = new Button (9, 1, "Options");
boptions.Clicked += delegate { OptionsDialog (); };
ftorrents.Add (boptions);
// Quit
Button bquit = new Button (21, 1, "Quit");
bquit.Clicked += delegate {
// FIXME: shut down torrent here
a.Running = false;
};
ftorrents.Add (bquit);
// Random widget tests
//f.Add (new Label (7, 3, "Name:"));
//f.Add (new Entry (13, 3, 20, "First"));
//f.Add (new Label (4, 5, "Address:"));
//f.Add (new Entry (13, 5, 20, "Second"));
ListView ltorrents = new ListView (1, 5, 0, 0, torrent_list);
ltorrents.Fill = Fill.Horizontal | Fill.Vertical;
ftorrents.Add (ltorrents);
Frame fprogress = new Frame ("Messages");
fprogress.Add (log_widget = new LogWidget (0, 0));
a.Add (fprogress);
// For testing focus, not ready
//f.Add (new Label (0, 0, "->0<-"));
//f.Add (new Entry (7, 0, 20, "Another"));
// Details
Frame fdetails = new Frame ("Details");
fdetails.Add (new Label (1, 1, "Files for: "));
torrent_name = new TrimLabel (12, 1, 10, "");
torrent_name.Fill = Fill.Horizontal;
fdetails.Add (torrent_name);
details_list = new TorrentDetailsList ();
list_details = new ListView (1, 3, 0, 0, details_list);
list_details.Fill = Fill.Horizontal | Fill.Vertical;
fdetails.Add (list_details);
a.Add (fdetails);
// Status
Frame fstatus = SetupStatus ();
a.Add (fstatus);
iteration = new Label (35, 0, "0");
fstatus.Add (iteration);
Application.Timeout = 1000;
Application.Iteration += delegate {
iteration.Text = (it++).ToString ();
UpdateStatus ();
lock (queue){
if (queue.Count > 0){
foreach (string s in queue){
log_widget.AddText (s);
}
queue.Clear ();
}
}
Application.Refresh ();
};
LayoutDialogs (ftorrents, fstatus, fdetails, fprogress);
a.SizeChangedEvent += delegate {
LayoutDialogs (ftorrents, fstatus, fdetails, fprogress);
};
UpdateStatus ();
Application.Run (a);
}
示例8: CreativeMainScreen
/// <summary>
/// Erzeugt ein neues CreativeMainScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
/// </summary>
public CreativeMainScreen(GameCore game)
: base(game)
{
buttons = new Container (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
buttons.ItemAlignX = HorizontalAlignment.Center;
buttons.ItemAlignY = VerticalAlignment.Center;
Button newKnotButton = new Button (
screen: this,
drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
name: "NEW\nKnot",
onClick: (time) => NextScreen = new CreativeModeScreen (Game, new Knot ())
);
newKnotButton.SetCoordinates (left: 0.100f, top: 0.150f, right: 0.300f, bottom: 0.350f);
Button loadKnotButton = new Button (
screen: this,
drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
name: "LOAD\nKnot",
onClick: (time) => NextScreen = new CreativeLoadScreen (Game)
);
loadKnotButton.SetCoordinates (left: 0.675f, top: 0.300f, right: 0.875f, bottom: 0.475f);
Button newChallengeButton = new Button (
screen: this,
drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
name: "NEW\nChallenge",
onClick: (time) => NextScreen = new ChallengeCreateScreen (Game)
);
newChallengeButton.SetCoordinates (left: 0.250f, top: 0.525f, right: 0.600f, bottom: 0.750f);
Button backButton = new Button (
screen: this,
drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
name: "Back",
onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(
s is CreativeMainScreen
|| s is CreativeLoadScreen
|| s is ChallengeCreateScreen)).ElementAt (0)
);
backButton.AddKey (Keys.Escape);
backButton.SetCoordinates (left: 0.825f, top: 0.850f, right: 0.975f, bottom: 0.950f);
buttons.Add (newKnotButton);
buttons.Add (loadKnotButton);
buttons.Add (newChallengeButton);
buttons.Add (backButton);
buttons.IsVisible = true;
// die Linien
lines.AddPoints (0.000f, 0.150f,
0.300f, 0.350f, 0.100f, 0.070f, 0.600f, 0.750f, 0.250f,
0.525f, 0.875f, 0.300f, 0.675f, 0.475f, 0.950f, 0.000f
);
lines.AddPoints (0.975f, 0.850f, 0.825f, 0.950f, 0.975f, 0.850f);
}
示例9: ConvertTo
public void ConvertTo()
{
ReferenceConverter converter = new ReferenceConverter(typeof(ITestInterface));
string referenceName = "reference name";
Assert.Equal("(none)", (string)converter.ConvertTo(null, null, null, typeof(string)));
TestComponent component = new TestComponent();
// no context
Assert.Equal(String.Empty, (string)converter.ConvertTo(null, null, component, typeof(string)));
// context with IReferenceService
TestReferenceService referenceService = new TestReferenceService();
referenceService.AddReference(referenceName, component);
TestTypeDescriptorContext context = new TestTypeDescriptorContext(referenceService);
Assert.Equal(referenceName, (string)converter.ConvertTo(context, null, component, typeof(string)));
// context with Component without IReferenceService
Container container = new Container();
container.Add(component, referenceName);
context = new TestTypeDescriptorContext();
context.Container = container;
Assert.Equal(referenceName, (string)converter.ConvertTo(context, null, component, typeof(string)));
}
示例10: ConvertFrom
public void ConvertFrom()
{
ReferenceConverter converter = new ReferenceConverter(typeof(ITestInterface));
string referenceName = "reference name";
// no context
Assert.Null(converter.ConvertFrom(null, null, referenceName));
TestComponent component = new TestComponent();
// context with IReferenceService
TestReferenceService referenceService = new TestReferenceService();
referenceService.AddReference(referenceName, component);
TestTypeDescriptorContext context = new TestTypeDescriptorContext(referenceService);
Assert.Same(component, converter.ConvertFrom(context, null, referenceName));
// context with Component without IReferenceService
Container container = new Container();
container.Add(component, referenceName);
context = new TestTypeDescriptorContext();
context.Container = container;
Assert.Same(component, converter.ConvertFrom(context, null, referenceName));
}
示例11: LoadComplete
protected override void LoadComplete()
{
base.LoadComplete();
Add(new Drawable[] {
new VolumeControlReceptor
{
RelativeSizeAxes = Axes.Both,
ActionRequested = delegate(InputState state) { volume.Adjust(state); }
},
mainContent = new Container
{
RelativeSizeAxes = Axes.Both,
},
volume = new VolumeControl(),
overlayContent = new Container{ RelativeSizeAxes = Axes.Both },
new GlobalHotkeys //exists because UserInputManager is at a level below us.
{
Handler = globalHotkeyPressed
}
});
(modeStack = new Intro()).Preload(this, d =>
{
mainContent.Add(d);
modeStack.ModePushed += modeAdded;
modeStack.Exited += modeRemoved;
modeStack.DisplayAsRoot();
});
//overlay elements
(chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add);
(options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add);
(musicController = new MusicController() { Depth = -3 }).Preload(this, overlayContent.Add);
Dependencies.Cache(options);
Dependencies.Cache(musicController);
(Toolbar = new Toolbar
{
Depth = -2,
OnHome = delegate { mainMenu?.MakeCurrent(); },
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
}).Preload(this, t =>
{
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
PlayMode.TriggerChange();
overlayContent.Add(Toolbar);
});
options.StateChanged += delegate
{
switch (options.State)
{
case Visibility.Hidden:
intro.MoveToX(0, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
break;
case Visibility.Visible:
intro.MoveToX(OptionsOverlay.SIDEBAR_WIDTH / 2, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
break;
}
};
Cursor.Alpha = 0;
}
示例12: AddTo
public void AddTo(Container container)
{
container.Add(this);
}
示例13: HighscoreDialog
/// <summary>
///
/// </summary>
public HighscoreDialog(IScreen screen, DisplayLayer drawOrder, Challenge challenge)
: base(screen, drawOrder, "Highscores")
{
// Der Titel-Text ist mittig ausgerichtet
AlignX = HorizontalAlignment.Center;
Bounds.Size = new ScreenPoint (screen, 0.60f, 0.5f);
// Erstelle das Highscore-Menü
highscoreList = new Menu (Screen, Index + DisplayLayer.Menu);
highscoreList.Bounds = ContentBounds;
highscoreList.ItemAlignX = HorizontalAlignment.Left;
highscoreList.ItemAlignY = VerticalAlignment.Center;
if (challenge.Highscore != null) {
//sotiert die Highscoreliste wird nach der Zeit sotiert
int highscoreCounter = 0;
foreach (KeyValuePair<string, int> entry in challenge.Highscore.OrderBy (key => key.Value)) {
TimeSpan playTime = TimeSpan.FromSeconds (entry.Value);
string formattedPlayTime = (playTime.Hours * 60 + playTime.Minutes).ToString ("D2") + "m " + playTime.Seconds.ToString ("D2") + "s";
TextItem firstScore = new TextItem (screen, drawOrder, formattedPlayTime + " " + entry.Key);
highscoreList.Add (firstScore);
highscoreCounter++;
if (highscoreCounter > 8) {
break;
}
}
}
buttons = new Container (screen, Index + DisplayLayer.Menu);
buttons.ItemBackgroundColor =(s) => Design.DialogBackground;
buttons.ItemAlignX = HorizontalAlignment.Center;
// Button zum Neustarten der Challenge
Action<GameTime> restartAction = (time) => {
Close (time);
Screen.NextScreen = new ChallengeModeScreen (Screen.Game, challenge);
};
MenuEntry restartButton = new MenuEntry (
screen: Screen,
drawOrder: Index + DisplayLayer.MenuItem,
name: "Restart challenge",
onClick: restartAction
);
restartButton.Bounds.Size = new ScreenPoint (screen, ContentBounds.Size.Relative.X / 2, 0.05f);
restartButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
- restartButton.Bounds.Size.OnlyY;
buttons.Add (restartButton);
// Button für die Rückkehr zum StartScreen
Action<GameTime> returnAction = (time) => {
Close (time);
Screen.NextScreen = new StartScreen (Screen.Game);
};
MenuEntry returnButton = new MenuEntry (
screen: Screen,
drawOrder: Index + DisplayLayer.MenuItem,
name: "Return to menu",
onClick: returnAction
);
returnButton.Bounds.Size = new ScreenPoint (screen, ContentBounds.Size.Relative.X / 2, 0.05f);
returnButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
- returnButton.Bounds.Size.OnlyY + ContentBounds.Size.OnlyX / 2;
buttons.Add (returnButton);
}
示例14: ConfirmDialog
/// <summary>
/// Erzeugt ein neues ConfirmDialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt.
/// Zudem sind Angaben zur Zeichenreihenfolge, einer Zeichenkette für den Titel und für den eingeblendeten Text Pflicht.
/// [base=screen, drawOrder, title, text]
/// </summary>
public ConfirmDialog(IScreen screen, DisplayLayer drawOrder, string title)
: base(screen, drawOrder, title)
{
// Der Titel-Text ist mittig ausgerichtet
AlignX = HorizontalAlignment.Center;
Cancel = (time) => {
Close (time);
};
Submit = (time) => {
Close (time);
};
// Keys
ValidKeys.AddRange (new Keys[] { Keys.Enter, Keys.Escape });
// Menü, in dem die Textanzeige angezeigt wird
menu = new Menu (Screen, Index + DisplayLayer.Menu);
menu.Bounds = ContentBounds;
menu.ItemForegroundColor = (s) => Color.White;
menu.ItemBackgroundColor = (s) => Color.Transparent;
menu.ItemAlignX = HorizontalAlignment.Left;
menu.ItemAlignY = VerticalAlignment.Center;
// Button-Container
buttons = new Container (screen, Index + DisplayLayer.Menu);
buttons.ItemAlignX = HorizontalAlignment.Center;
buttons.ItemBackgroundColor = (s) => Design.DialogBackground;
// Button zum Canceln
Action<GameTime> cancelAction = (time) => {
Cancel (time);
};
MenuEntry cancelButton = new MenuEntry (
screen: Screen,
drawOrder: Index + DisplayLayer.MenuItem,
name: "Cancel",
onClick: cancelAction
);
cancelButton.Bounds.Size = new ScreenPoint (screen, ()=>ContentBounds.Size.Relative.X / 2, ()=>0.05f);
cancelButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
- cancelButton.Bounds.Size.OnlyY;
buttons.Add (cancelButton);
// Button zum Submitten
Action<GameTime> submitAction = (time) => {
Submit (time);
};
MenuEntry submitButton = new MenuEntry (
screen: Screen,
drawOrder: Index + DisplayLayer.MenuItem,
name: "Confirm",
onClick: submitAction
);
submitButton.Bounds.Size = new ScreenPoint (screen, ()=>ContentBounds.Size.Relative.X / 2, ()=>0.05f);
submitButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
- submitButton.Bounds.Size.OnlyY + ContentBounds.Size.OnlyX / 2;
buttons.Add (submitButton);
// Buttons zum Menü hinzufügen
menu.Add (buttons);
}
示例15: RunCUI
static void RunCUI()
{
Container a = new Container (0, 0, Application.Cols, Application.Lines);
Frame fMain = new Frame(0, 0, 0, 0, "zerob0t");
Frame fHighA = new Frame(0, 0, 0, 0, "fHighA");
Frame fHighB = new Frame(0, 0, 0, 0, "fHighB");
Frame fHighLR = new Frame(0, 0, 0, 0, "Info");
Frame fHighSR = new Frame(0, 0, 0, 0, "fHighSR");
a.Add(fMain);
a.Add(fHighA);
a.Add(fHighB);
a.Add(fHighLR);
a.Add(fHighSR);
Button bQuit = new Button(1, 1, "Quit");
bQuit.Clicked += delegate {
a.Running = false;
};
fMain.Add(bQuit);
// Final setup details
// GUI.cs Colors:
// 0: Black
// 1:
// 2:
// 3:
// 4:
// 5:
// 6:
// 7:
// 8:
// 9:
// 10:
// 11:
// 12:
// 13:
// 14:
// 15:
// ColorBasic is
// Application.ColorBasic = 3585;
// ColorDialogFocus is
// Application.ColorDialogFocus = 0;
// ColorDialogHotFocus is
// Application.ColorDialogHotFocus = 0;
// Application.ColorDialogHotNormal = 0;
// ColorDialogNormal is label background color
// Application.ColorDialogNormal = 0;
// Application.ColorError = 0;
// ColorFocus is background of whatever widget has focus
// Application.ColorFocus = 0;
// Application.ColorNormal = 0;
LayoutDialogs(fMain, fHighA, fHighB, fHighLR, fHighSR);
Application.Timeout = 1000;
Application.Iteration += delegate {
Application.Refresh();
};
a.SizeChangedEvent += delegate {
LayoutDialogs(fMain, fHighA, fHighB, fHighLR, fHighSR);
};
Application.Run(a);
}