本文整理汇总了C#中Frame.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Frame.Add方法的具体用法?C# Frame.Add怎么用?C# Frame.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame
的用法示例。
在下文中一共展示了Frame.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddButton
public static Frame AddButton(Frame parent, SpriteFont font, int x, int y, int w, int h, string text, FrameAnchor anchor, Action action, Color bcol, bool visibility = true)
{
var button = new Frame(parent.Game, x, y, w, h, text, Color.White)
{
Anchor = anchor,
TextAlignment = Alignment.MiddleCenter,
PaddingLeft = 0,
Font = font,
Visible = visibility,
};
if (action != null)
{
button.Click += (s, e) =>
{
action();
};
}
button.StatusChanged += (s, e) =>
{
if (e.Status == FrameStatus.None) { button.BackColor = bcol; }
if (e.Status == FrameStatus.Hovered) { button.BackColor = new Color(25, 71, 138, 255); }
if (e.Status == FrameStatus.Pushed) { button.BackColor = new Color(99, 132, 181, 255); }
};
parent.Add(button);
return button;
}
示例2: OnButtonClicked
protected void OnButtonClicked(object sender, EventArgs e)
{
if (sender == button1)
{
Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog ("Choose item...", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Insert Spacer", ResponseType.None, "Add", ResponseType.Accept);
Gtk.Alignment align = new Alignment (1, 0, 0, 1);
Gtk.Frame frame = new Frame ("Position");
Gtk.HBox hbox = new HBox (false, 4);
RadioButton rbRight;
rbRight = new RadioButton ("Right");
hbox.PackEnd(rbRight, false, false, 1);
hbox.PackEnd(new RadioButton (rbRight, "Left"), false, false, 1);
frame.Add (hbox);
align.Add (frame);
align.ShowAll ();
dialog.ExtraWidget = align;
ResponseType response = (ResponseType)dialog.Run ();
if (response == ResponseType.Accept) {
RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" + dialog.Filename + "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' && /bin/sleep 1 &&/usr/bin/killall Dock");
} else if (response == ResponseType.None) {
RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '{tile-data={}; tile-type=\"spacer-tile\";}' && /bin/sleep 1 &&/usr/bin/killall Dock");
}
dialog.Destroy ();
}
}
示例3: CatalogPropertiesDialog
public CatalogPropertiesDialog(Catalog catalog)
{
this.catalog = catalog;
this.Title = String.Format (Mono.Posix.Catalog.GetString ("{0} properties"), catalog.Name);
this.HasSeparator = false;
cancelButton = (Button)this.AddButton (Stock.Cancel, 0);
okButton = (Button)this.AddButton (Stock.Ok, 1);
cancelButton.Clicked += OnCancelButtonClicked;
okButton.Clicked += OnOkButtonClicked;
VBox vBox = this.VBox;
HBox titleBox = new HBox ();
Gtk.Frame frame = new Frame ("<b>"+Mono.Posix.Catalog.GetString ("Columns to show")+"</b>");
((Label)(frame.LabelWidget)).UseMarkup = true;
titleBox.PackEnd (frame);
vBox.PackStart (titleBox);
VBox columnsBox = new VBox ();
columns = catalog.Columns;
Hashtable columnsToShow = catalog.ColumnsToShow;
checks = new Hashtable ();
foreach (string colName in columns.Keys) {
if (colName.Equals ("id")) continue;
CheckButton check = new CheckButton ((string)columns[colName]);
check.Active = (bool)columnsToShow[colName];
checks.Add (columns[colName], check);
columnsBox.PackStart (check);
}
frame.Add (columnsBox);
this.ShowAll();
}
示例4: SetUpGui
static void SetUpGui ()
{
Window w = new Window ("Sign Up");
Button b = new Button ("Testing");
Frame f = new Frame ("My Frame");
f.Add (b);
w.Add (f);
//w.SetDefaultSize (120, 120);
w.ShowAll ();
}
示例5: LendItemDialog
public LendItemDialog(Item item, Database database)
{
this.database = database;
this.item = item;
this.Title = Mono.Posix.Catalog.GetString ("Lend");
this.Modal = true;
this.HasSeparator = false;
VBox vBox = this.VBox;
HBox hBox1 = new HBox ();
string pixbuf = item.LargeCover;
if (pixbuf != null) {
image = new Gtk.Image (pixbuf);
}
label = new Label ();
// Escape specials Markups characters
string title;
title = item.Title.Replace ("&", "&");
title = title.Replace ("<", "<");
title = title.Replace (">", ">");
label.Text = "<b>"+title+"</b>";
label.UseMarkup = true;
Label label1 = new Label (Mono.Posix.Catalog.GetString ("Borrower:"));
borrowerComboBox = ComboBoxEntry.NewText ();
PopulateEntryComboBox ();
hBox1.PackStart (label1);
hBox1.PackStart (borrowerComboBox);
Gtk.Frame frame = new Frame ();
frame.Shadow = ShadowType.Out;
frame.Add (image);
vBox.PackStart (frame);
vBox.PackStart (label);
vBox.PackStart (hBox1);
vBox.Spacing = 5;
Button cancelButton = (Button)this.AddButton (Gtk.Stock.Cancel, 0);
Button okButton = (Button)this.AddButton (Gtk.Stock.Ok, 1);
cancelButton.Clicked += OnCancelButtonClicked;
okButton.Clicked += OnOkButtonClicked;
this.ShowAll();
}
示例6: ImageFileFrame
public ImageFileFrame (FileInfo fileInfo)
: base (fileInfo.Name)
{
string filename = String.Format ("{0}/{1}", fileInfo.DirectoryName, fileInfo.Name);
Image image = new Image (filename);
image.Scale (64, 64);
Frame inner_frame = new Frame (String.Empty);
inner_frame.Add (image);
//inner_frame.ShadowType = ShadowType.In;
//inner_frame.BorderWidth = 10;
this.Add (inner_frame);
//this.ShadowType = ShadowType.Out;
}
示例7: AddItemToCurrentMarketGroup
void AddItemToCurrentMarketGroup(ECM.EveItem item, TreeModel model, TreeIter iter)
{
if (vbbMarketGroups.IsRealized == false)
vbbMarketGroups.Realize();
Image itemPic = new Image();
itemPic.PixbufAnimation = new Gdk.PixbufAnimation(ECM.Core.LoadingSpinnerGIF);
itemPic.WidthRequest = 64;
itemPic.HeightRequest = 64;
BackgroundWorker fetchImage = new BackgroundWorker();
fetchImage.DoWork += delegate(object sender, DoWorkEventArgs e)
{
itemPic.Pixbuf = ECM.API.ImageApi.GetItemImageGTK(item.ID, ECM.API.ImageApi.ImageRequestSize.Size64x64);
};
fetchImage.RunWorkerAsync();
Gdk.Pixbuf buf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 22, 22);
Gdk.Pixbuf book = new Gdk.Pixbuf(ECM.Core.Skillbook22PNG);
EveItemUseability useability = Core.CurrentCharacter.GetItemUseability(item);
if (useability == EveItemUseability.Untrainable)
buf.Fill(m_Untrainable.ToUint());
else if (useability == EveItemUseability.Trainable)
buf.Fill(m_Trainable.ToUint());
else
buf.Fill(m_Useable.ToUint());
book.Composite(buf, 0, 0, buf.Width, buf.Height, 0, 0, 1, 1, Gdk.InterpType.Hyper, 255);
Image skillsMet = new Image(buf);
skillsMet.WidthRequest = 22;
skillsMet.HeightRequest = 22;
skillsMet.Xalign = 0;
Pango.FontDescription font = new Pango.FontDescription();
font.Size = 24;
Label itemName = new Label();
itemName.UseMarkup = true;
itemName.Markup = string.Format("<span size=\"large\" weight=\"bold\">{0}</span>", item.Name);
itemName.Xalign = 0;
//itemName.ModifyFont(font);
Image infoPic = new Image(ECM.Core.Info16PNG);
infoPic.WidthRequest = 16;
infoPic.HeightRequest = 16;
Button btnInfo = new Button();
btnInfo.Relief = ReliefStyle.None;
btnInfo.Add(infoPic);
btnInfo.Clicked += delegate(object sender, EventArgs e)
{
m_ViewDetails.ShowItemDetails(item);
};
HBox itemNameHeader = new HBox();
itemNameHeader.PackStart(itemName, false, false, 0);
itemNameHeader.PackStart(btnInfo, false, false, 3);
WrapLabel itemDesc = new WrapLabel(item.Description);
Frame picFrame = new Frame();
picFrame.Shadow = ShadowType.Out;
picFrame.Add(itemPic);
VBox heading = new VBox();
heading.Spacing = 6;
heading.PackEnd(itemNameHeader, false, false, 0);
if(item.HasRequirements)
heading.PackEnd(skillsMet, false, false, 0);
HBox inner = new HBox();
inner.PackStart(picFrame, false, false, 0);
inner.PackStart(heading, true, true, 1);
Button viewDets = new Button(new Label("View Market Details"));
viewDets.Clicked += delegate(object sender, EventArgs e)
{
ShowItemMarketDetails(item, model, iter);
};
HButtonBox itemButtons = new HButtonBox();
itemButtons.Layout = ButtonBoxStyle.End;
itemButtons.BorderWidth = 3;
itemButtons.Add(viewDets);
itemButtons.ShowAll();
HSeparator sep = new HSeparator();
VBox itemBlock = new VBox();
itemBlock.Spacing = 10;
itemBlock.PackStart(inner, false, false, 0);
itemBlock.PackStart(itemDesc, true, true, 0);
itemBlock.PackEnd(itemButtons, false, false, 0);
itemBlock.ShowAll();
//.........这里部分代码省略.........
示例8: AddButton
private void AddButton(Frame parent, Game game, int x, int y, int btnWidth, int btnHeight, string str, Color color, Action action)
{
var button = new Frame(game, x, y, btnWidth, btnHeight, str, color)
{
Font = font,
Border = 1,
BorderColor = Color.White,
TextAlignment = Alignment.MiddleCenter,
};
button.StatusChanged += (s, e) =>
{
if (e.Status == FrameStatus.None) { button.BackColor = Color.Zero; }
if (e.Status == FrameStatus.Hovered) { button.BackColor = new Color (20, 20, 20); }
};
if (action != null)
{
button.Click += (s, e) =>
{
action();
};
}
parent.Add(button);
}
示例9: Main
static void Main (string [] args)
{
if (args.Length > 0 && args [0] == "debug")
BoardPiece.Debug = true;
Program fifteen = new Program ("Fifteen", "0.1", Modules.UI, args);
window = new Gtk.Window ("Fifteen #");
VBox box = new VBox (false, 0);
window.Add (box);
window.DefaultWidth = 300;
window.DefaultHeight = 300;
VBox vbox = new VBox (false, 4);
vbox.BorderWidth = 4;
MenuBar menu = Create_Menu ();
box.PackStart (menu, false, false, 0);
box.PackStart (vbox, false, false, 0);
window.DeleteEvent += new DeleteEventHandler (Window_Delete);
Alignment alignment = new Alignment (0.5f, 0.5f, 0.0f, 0.0f);
vbox.PackStart (alignment, true, true, 4);
Frame frame = new Frame (null);
frame.ShadowType = ShadowType.In;
alignment.Add (frame);
canvas = new Canvas ();
canvas.SetSizeRequest (BoardPiece.PIECE_SIZE * 4 + 1, BoardPiece.PIECE_SIZE * 4 + 1);
canvas.SetScrollRegion (0, 0, BoardPiece.PIECE_SIZE * 4 + 1, BoardPiece.PIECE_SIZE * 4 + 1);
frame.Add (canvas);
board = new BoardPiece [16];
for (int i = 0; i < 15; i ++) {
int y = i /4;
int x = i % 4;
board [i] = new BoardPiece (canvas.Root (), board, x, y, i);
}
box.PackStart (new HSeparator (), false, false, 0);
HBox hbox = new HBox (false, 4);
box.PackStart (hbox, true, false, 4);
// Scramble button here.
Button scramble = new Button ("_Scramble");
scramble.BorderWidth = 8;
scramble.Clicked += new EventHandler (Scramble);
scramble.CanDefault = true;
hbox.PackStart (scramble, true, true, 4);
scramble.GrabDefault ();
// Close button
Button close = new Button ("_Close");
close.BorderWidth = 8;
close.Clicked += new EventHandler (Quit);
hbox.PackStart (close, true, true, 4);
window.ShowAll ();
fifteen.Run ();
}
示例10: addLinkPanel
/**
* Creates the "link" panel, which shows links between free blocks
* */
private void addLinkPanel()
{
//master mid panel container
midPanel = new VBox ();
//will store links between free blocks
linkPanel = new VBox ();
linkPanel.SetSizeRequest(Constants.Constants.LINK_PANEL_WIDTH, Constants.Constants.LINK_PANEL_HEIGHT);
Label linkHeader = new Label (Constants.Constants.LinkHeader);
linkHeader.Style = subHeaderLabelStyle.Copy ();
linkPanel.PackStart (linkHeader, false, false, 10);
//get the address link and insert values in form list[i] -> list[i + 1]
List<int> addresses = FileParser.FileParser.AddressList;
String link = "";
for (int i = 0; i < addresses.Count; i++)
{
//make the link string
link += "0x";
link += addresses [i].ToString ("X");
link += " -> ";
if (i < addresses.Count - 1)
link += ("0x" + addresses [i + 1].ToString ("X"));
else
link += "NULL";
//insert it into thepanel
Label linkInfoLabel = new Label (link);
linkInfoLabel.Style = linkInfoStyle.Copy ();
linkPanel.PackStart (linkInfoLabel, false, false, 5);
//reset link
link = "";
}
Viewport linkViewPort = new Viewport ();
linkViewPort.SetSizeRequest(Constants.Constants.LINK_PANEL_WIDTH, Constants.Constants.LINK_PANEL_HEIGHT);
linkViewPort.Add (linkPanel);
//add the window for the graph frame
linkWindow = new ScrolledWindow ();
linkViewPort.SetSizeRequest(Constants.Constants.LINK_PANEL_WIDTH, Constants.Constants.LINK_PANEL_HEIGHT);
linkWindow.Add (linkViewPort);
//give border to legend container
Frame f = new Frame ();
f.Add (linkWindow);
midPanel.PackStart (f, false, false, 10);
}
示例11: AddFragInfo
/**
* Adds in the fragmentation information to the side panel directly below free/alloc legend
* */
private void AddFragInfo()
{
fragInfoContainer = new VBox ();
fragInfoContainer.SetSizeRequest (Constants.Constants.FRAG_INFO_HOLDER_WIDTH, Constants.Constants.FRAG_INFO_HOLDER_HEIGHT);
Label fragInfoLabel = new Label (Constants.Constants.FRAG_INFO_HOLDER_TITLE);
fragInfoLabel.Style = sidePanelLabelStyle.Copy ();
//get the amount of external fragmentation
int externalFragAsPercent = FileParser.FileParser.getAmountExternalFragmentation();
//get % free and occupied
float percentFree = FileParser.FileParser.GetPercentFree ();
float percentOccupied = FileParser.FileParser.GetPercentOccupied ();
Label totalFreePercentHolder = new Label (percentFree.ToString("N2") + Constants.Constants.FREE_LABEL_END);
totalFreePercentHolder.Style = sidePanelLabelStyle.Copy ();
Label totalOccupiedPercentHolder = new Label (percentOccupied.ToString("N2") + Constants.Constants.OCCUPIED_LABEL_END);
totalOccupiedPercentHolder.Style = sidePanelLabelStyle.Copy ();
Label externalFragLabel = new Label (externalFragAsPercent + Constants.Constants.EXTERNAL_FRAG_LABEL_END);
externalFragLabel.Style = externalFragLabelStyle.Copy ();
fragInfoContainer.PackStart (fragInfoLabel, false, false, 50);
fragInfoContainer.PackStart (totalFreePercentHolder, false, false, 0);
fragInfoContainer.PackStart (totalOccupiedPercentHolder, false, false, 0);
fragInfoContainer.PackStart (externalFragLabel, false, false, 50);
Frame f = new Frame ();
f.Add (fragInfoContainer);
sidePanel.PackStart (f, false, false, 10);
}
示例12: PrepareValueIndexContext
private static object PrepareValueIndexContext(Compiler compiler, ExpressionContext left, Parse.Statement statement, BaseType memberType, System.Type memberNative, Frame local)
{
// Register value argument
var valueSymbol = new Object();
local.Add(statement, Name.FromComponents(Parse.ReservedWords.Value), valueSymbol);
compiler.ContextsBySymbol.Add
(
valueSymbol,
new ExpressionContext
(
null,
memberType,
left.Characteristics,
m => { m.IL.Emit(OpCodes.Ldarg_0); }
)
);
// Register index argument
var indexSymbol = new Object();
local.Add(statement, Name.FromComponents(Parse.ReservedWords.Index), indexSymbol);
compiler.ContextsBySymbol.Add
(
indexSymbol,
new ExpressionContext
(
null,
SystemTypes.Int32,
Characteristic.Default,
m => { m.IL.Emit(OpCodes.Ldarg_1); }
)
);
// If the members are tuples, declare locals for each field
if (memberType is TupleType)
{
var tupleType = (TupleType)memberType;
foreach (var attribute in tupleType.Attributes)
{
local.Add(attribute.Key.ToID(), attribute);
compiler.ContextsBySymbol.Add
(
attribute,
new ExpressionContext
(
null,
attribute.Value,
Characteristic.Default,
m =>
{
m.IL.Emit(OpCodes.Ldarg_0); // value
m.IL.Emit(OpCodes.Ldfld, memberNative.GetField(attribute.Key.ToString()));
}
)
);
}
// TODO: Add references
}
return indexSymbol;
}
示例13: CreateCharacterButton
protected Widget CreateCharacterButton(ECM.Character character)
{
HBox box = new HBox();
Frame frm = new Frame();
frm.Shadow = ShadowType.EtchedOut;
frm.BorderWidth = 3;
Image img = new Image();
img.WidthRequest = 64;
img.HeightRequest = 64;
if (character.Portrait != null)
img.Pixbuf = ECM.API.ImageApi.StreamToPixbuf(character.Portrait).ScaleSimple(64, 64, Gdk.InterpType.Bilinear);
else
img.Pixbuf = ECM.API.ImageApi.StreamToPixbuf(ECM.Core.NoPortraitJPG).ScaleSimple(64, 64, Gdk.InterpType.Bilinear);
frm.Add(img);
box.PackStart(frm, false, false, 3);
Label text = new Label();
text.UseMarkup = true;
text.Markup = string.Format("<span size=\"larger\" weight=\"bold\">{0}</span>\n<span size=\"small\">{1}\n{2:0,0.00} ISK\nLocation: {3}</span>",
character.Name, character.Background, character.AccountBalance, character.LastKnownLocation);
text.Xalign = 0;
text.Yalign = 0;
box.PackStart(text, true, true, 0);
Button btn = new Button(box);
btn.Name = string.Format("btn{0}", character.ID);
btn.Clicked += delegate(object sender, EventArgs e)
{
ECM.Core.CurrentCharacter = character;
};
btn.ShowAll();
return btn;
}
示例14: DialBOT
// This requires that the perl program autorestart wraps this....
public DialBOT()
: base("DialBOT")
{
SetDefaultSize(800, 600);
SetPosition(WindowPosition.Center);
DeleteEvent += delegate { Application.Quit(); };
// Top level container. This vertically divides the window into 3 sections:
// Top is the 2 windows (balls-deep items and console output
VBox topvbox = new VBox(false, 5);
// Lets build the top 1/3rd here.
Frame ballsdeepframe = new Frame("Balls-Deep Items");
Frame consoleframe = new Frame("Console Output");
// HBox mainhbox = new HBox(true,2);
ballsdeeptree = new TreeView();
bdstore = new TreeStore (typeof(string), typeof (string), typeof (string), typeof (string));
LoadBalls();
fillStore();
// Put the TreeStore into a TreeModelSort so we can sort columns...
// Sort by score for now
bdsorted = new TreeModelSort(bdstore);
bdsorted.SetSortColumnId(1,SortType.Descending);
// Put the TreeModelSort into a TreeModelFilter so we can implement the filtering
filterEntry = new Entry();
// filter = new TreeModelFilter(bdsorted,null);
// filter.VisibleFunc = FilterTreeFunc; // Use this as the filter function.
// And then set the visible TreeView to use the filter as it's store.
ballsdeeptree.Model = bdsorted;
ballsdeeptree.HeadersVisible = true;
ballsdeeptree.HeadersClickable=true;
ballsdeeptree.AppendColumn ("Added By", new CellRendererText (), "text", 0);
ballsdeeptree.AppendColumn ("Score", new CellRendererText (), "text", 1);
CellRendererText ballRenderer = new CellRendererText();
ballsdeeptree.AppendColumn ("Text", ballRenderer, "text", 2);
CellRendererText voteRenderer = new CellRendererText();
voteRenderer.Editable=true;
voteRenderer.Edited+=editVotes;
ballsdeeptree.AppendColumn ("Votes", voteRenderer, "text", 3);
TreeViewColumn col = ballsdeeptree.GetColumn(0);
col.Clickable=true;
col.Resizable = true;
col.Clicked += new EventHandler (col_clicked0);
col = ballsdeeptree.GetColumn(1);
col.Resizable = true;
col.Clickable=true;
col.Clicked += new EventHandler (col_clicked1);
col = ballsdeeptree.GetColumn(2);
col.Resizable = true;
col.Clickable=true;
col.Clicked += new EventHandler (col_clicked2);
col = ballsdeeptree.GetColumn(3);
col.Clickable=true;
col.Resizable = true;
col.Clicked += new EventHandler (col_clicked3);
ScrolledWindow ballsdeepscroll = new ScrolledWindow();
ballsdeepscroll.Add(ballsdeeptree);
Button deleteentry = new Button("Remove Entry");
deleteentry.SetSizeRequest(70, 30);
deleteentry.Clicked += new EventHandler(deleteBallMsg);
ballsdeepframe.Add(ballsdeepscroll);
ballsdeepframe.Add(deleteentry);
// Entry box and label to filter on message as well as an HBox to put them next to each other
filterEntry.Changed += OnFilterEntryTextChanged;
Label filterLabel = new Label("Ball Message Search: ");
HBox filterBox = new HBox();
filterBox.PackStart(filterLabel,false,false,5);
filterBox.PackStart(filterEntry,true,true,5);
VBox ballvbox = new VBox(false,5);
ballvbox.Add(ballsdeepframe);
//ballvbox.PackStart(filterBox,false,false,1);
topvbox.Add(ballvbox);
consoleview = new TextView();
consolebuffer=consoleview.Buffer;
consolebuffer.Text = consoletext;
ScrolledWindow consolescroll = new ScrolledWindow();
consolescroll.SetPolicy(PolicyType.Automatic,PolicyType.Always);
consolescroll.Add(consoleview);
consoleframe.Add(consolescroll);
//.........这里部分代码省略.........
示例15: TestAddOneThrow
public void TestAddOneThrow()
{
Frame f = new Frame();
f.Add(5);
Assert.AreEqual(5, f.Score);
}