本文整理汇总了C#中Group.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Group.Add方法的具体用法?C# Group.Add怎么用?C# Group.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SphereScene
internal static Scene SphereScene (int level, Vector center, double radius)
{
Sphere sphere = new Sphere (center, radius);
if (level == 1) {
return sphere;
} else {
Group scene = new Group (new Sphere (center, 3.0 * radius));
scene.Add (sphere);
double rn = 3.0 * radius / Math.Sqrt (12.0);
for (int dz = -1; dz <= 1; dz += 2) {
for (int dx = -1; dx <= 1; dx += 2) {
Vector c2 = new Vector (
center.x - dx * rn
, center.y + rn
, center.z - dz * rn
);
scene.Add (SphereScene (level - 1, c2, radius / 2.0));
}
}
return scene;
}
}
示例2: Main
public static void Main(string[] args)
{
Application.Init ();
Stage stage = Stage.Default as Stage;
(stage as Stage).KeyPressEvent += delegate {
Clutter.Main.Quit();
};
// fixme: add constructor
Clutter.Color stage_color = new Clutter.Color (0xcc, 0xcc, 0xcc, 0xff);
stage.SetColor (stage_color);
Clutter.Group group = new Group();
stage.Add (group);
group.Show ();
// Make a hand
Clutter.Actor hand = new Texture ("redhand.png");
hand.SetPosition (0,0);
hand.Show ();
// Make a rect
Clutter.Rectangle rect = new Clutter.Rectangle();
rect.SetPosition (0,0);
rect.SetSize ((int)hand.Width, (int)hand.Height);
Clutter.Color rect_bg_color = new Clutter.Color (0x33, 0x22, 0x22, 0xff);
rect.SetColor (rect_bg_color);
rect.BorderWidth = 10;
rect.Show ();
group.Add (rect);
group.Add (hand);
// Make a timeline
Timeline timeline = new Timeline (100, 26);
timeline.Loop = true;
Alpha alpha = new Alpha (timeline, (a) => a.Value);
Behaviour o_behave = new BehaviourOpacity (alpha, 0x33, 0xff);
o_behave.Apply (group);
// Make a path behaviour and apply that too
Behaviour p_behave = new BehaviourPath(alpha, knots); // fixme: add custom constructor?
p_behave.Apply (group);
// start timeline
timeline.Start ();
stage.ShowAll();
// launch
Application.Run ();
}
示例3: Main
static void Main(string[] args)
{
//Group 1, Diabetics
var Diabetics = new Group("Diabetic Patients");
var U1 = new Diabetic("Carlota");
U1.GiveDose(2, 3);
var U2 = new Diabetic("Marcia");
U2.GiveDose(3, 2);
var U3 = new Diabetic("Cynthia");
U3.GiveDose(2, 2);
Diabetics.Add(U1);
Diabetics.Add(U2);
Diabetics.Add(U3);
//Group 2, Hypertensives
var Hypertensives = new Group("Hypertensive Patients");
var U4 = new Hypertensive("Felix");
U4.GiveDose(5, 5);
var U5 = new Hypertensive("Poh");
U5.GiveDose(10, 5);
Hypertensives.Add(U4);
Hypertensives.Add(U5);
//Just one Athlete
var U6 = new Athlete("Shaniqua");
U6.GiveDose(20, 30);
//All Patients
var allPatients = new Group("Patients");
allPatients.Add(Diabetics);
allPatients.Add(Hypertensives);
allPatients.Add(U6);
//Show All Patients
allPatients.Display(0);
Console.ReadLine();
}
示例4: GroupFiles
public List<Group> GroupFiles()
{
List<Group> groups = new List<Group>();
List<Group> copyGroups = new List<Group>(groups);
Group newGroup = null;
try
{
DirectoryInfo directoryInfo = new DirectoryInfo(Path);
IEnumerable<FileInfo> files = directoryInfo.GetFiles();
// var temp = files.AsParallel().AsOrdered().Where(file => ListGroup(file)).ToList();
// groups.Add(temp.ToList<Group>());
int i = 0;
foreach (FileInfo file in files)
{
byte[] hash = GetContentHash(file);
//lock
Group group = groups.AsParallel().Where(g => g.Hash.SequenceEqual(hash)).FirstOrDefault();
if (group != null)
{
group.Add(file);
}
else
{
newGroup = new Group(file, hash);
newGroup.Add(file);
groups.Add(newGroup);
}
// Console.WriteLine("File " + i++);
}
}
catch (Exception e)
{
// Console.Write(e);
}
return groups;
}
示例5: OnConnected
public override Task OnConnected()
{
Debug.WriteLine("OnConnected");
/*
object tempObject;
Context.Request.Environment.TryGetValue("server.RemoteIpAddress", out tempObject);
*/
bool found = false;
foreach (KeyValuePair<string, Group> g in groups)
{
Group group = g.Value;
if(group.Add(Context.ConnectionId))
{
found = true;
break;
}
}
Debug.WriteLine("found: " + found);
if (!found)
{
Group newGroup = new Group();
newGroup.Add(Context.ConnectionId);
groups.TryAdd(groups.Count.ToString(), newGroup);
Debug.WriteLine("group created");
}
Debug.WriteLine("connection id: " + Context.ConnectionId);
return base.OnConnected();
}
示例6: Initialize
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// Publish the service, allowing everything to use the spriteBatch
Services.AddService(typeof(SpriteBatch), spriteBatch);
// Player classes.
player1 = new Player(this, Pallet.PlayerNumber.PlayerOne);
player1.Name = "Player 1";
player2 = new Player(this, Pallet.PlayerNumber.PlayerTwo);
player2.Name = "Player 2";
// Ball classes.
ball = new Ball(this);
// Collision groups
collisionGroup = new Group("Collisions");
playerGroup = new Group("Players");
playerGroup.Add(player1.Pallet);
playerGroup.Add(player2.Pallet);
// Groups
GroupList GameGroups = new GroupList();
GameGroups.Add(collisionGroup);
GameGroups.Add(playerGroup);
//Add the list of groups into the services so objects can retrieve info about items in specific groups
Services.AddService(typeof(GroupList), GameGroups);
// Blocks
BlockList = new BlockManager(this);
// Will initialize the basic graphical objects.
base.Initialize(); // Goes to LoadContent()
// Placed after general initialisation so the texture is already loaded and its size initialized
player1.Pallet.placeInDefaultPosition();
player2.Pallet.placeInDefaultPosition();
/* Define the block safe zone, it's meant to restrict where the blocks can appear so they don't get on top of the pallet
* or behind it. */
BlockList.BlocksSafeZone = new Rectangle((int)player1.Pallet.Position.X + 1, 0,
(int)player2.Pallet.Position.X + (int)player2.Pallet.ObjectRectangle.Width - (int)player1.Pallet.ObjectRectangle.X - BlockList.MaxBlockSize,
Window.ClientBounds.Height - BlockList.MaxBlockSize);
// Places the ball in the center position and give it a random angle.
ball.placeInDefaultPosition();
}
示例7: TestUnion2
public void TestUnion2()
{
Group a = new Group();
a.Add(0);
a.Add(10);
Group b = new Group();
Group c = a + b;
Assert.True(a.CompareTo(c) == 0);
}
示例8: TestUnion1
public void TestUnion1()
{
Group a = new Group();
a.Add(0);
a.Add(10);
Group b = new Group();
b.Add(9);
b.Add(12);
Group c = a + b;
Assert.AreEqual(2, c.Count);
Assert.AreEqual(0, c [0]);
Assert.AreEqual(12, c [1]);
}
示例9: TestSubtract2
public void TestSubtract2()
{
Group a = new Group();
a.Add(0);
a.Add(10);
Group b = a - 0;
Assert.True(b[0] == 1);
Assert.True(b[1] == 10);
}
示例10: TestSubtract1
public void TestSubtract1()
{
Group a = new Group();
a.Add(0);
a.Add(10);
Group b = new Group();
b.Add(9);
b.Add(12);
Group c = a - b;
Assert.AreEqual(2, c.Count);
Assert.AreEqual(0, c [0]);
Assert.AreEqual(9, c [1]);
}
示例11: TestSize
public void TestSize()
{
Group a = new Group();
a.Add(0);
a.Add(10);
Assert.AreEqual(10, Group.Size(a));
Assert.True(a.CompareTo(5) > 0);
Assert.True(a.CompareTo(12) < 0);
Assert.True(a.CompareTo(10) <= 0);
Assert.False(a.CompareTo(10) < 0);
Assert.True(a.CompareTo(10) >= 0);
}
示例12: TestIntersect2
public void TestIntersect2()
{
Group a = new Group();
a.Add(0);
a.Add(10);
Group b = new Group();
Group c = a * b;
Assert.AreEqual(true, Group.IsEmpty(c));
}
示例13: TestIntersect1
public void TestIntersect1()
{
Group a = new Group();
a.Add(0);
a.Add(10);
Group b = new Group();
b.Add(5);
b.Add(15);
Group c = a * b;
Assert.AreEqual(2, c.Count);
Assert.AreEqual(5, c [0]);
Assert.AreEqual(10, c [1]);
}
示例14: Group
/// <summary>
/// The contructor for Interpreter.Group.
/// </summary>
/// <param name="parentGroup">
/// The Group that contains this Group. If parentGroup is not null, then this group will be appended to
/// parentGroup.
/// </param>
public Group(Group parentGroup)
{
ParentGroup = parentGroup;
if (parentGroup != null) parentGroup.Add(this);
}
示例15: Init
public static void Init(string path)
{
ResourceManager resources = new ResourceManager("INVedit.Resources", typeof(Data).Assembly);
unknown = (Image)resources.GetObject("unknown");
string[] lines = File.ReadAllLines(path);
for (int i = 1; i <= lines.Length; ++i) {
try {
string line = lines[i-1].TrimStart();
if (line=="" || line[0]=='#') continue;
string[] split;
if (line[0] == ':') {
split = line.Split(new char[]{' '}, 2, StringSplitOptions.RemoveEmptyEntries);
switch (split[0].ToLower()) {
case ":version":
try { version = int.Parse(split[1]); }
catch (Exception e) { throw new DataException("Failed to parse option "+split[0]+" at line "+i+" in file '"+path+"'.", e); }
break;
default:
throw new DataException("Unknown option '"+split[0]+"' at line "+i+" in file '"+path+"'.");
} continue;
}
split = line.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
Exception ex = new DataException("Invalid number of colums at line "+i+" in file '"+path+"'.");
if (line[0]=='~') { if (split.Length != 4) throw ex; }
else { if (split.Length < 4 || split.Length > 5) throw ex; }
string name = split[1].Replace('_', ' ');
if (line[0]=='~') {
short icon;
try { icon = short.Parse(split[2]); }
catch (Exception e) { throw new DataException("Failed to parse column 'ICON' at line "+i+" in file '"+path+"'.", e); }
if (!items.ContainsKey(icon)) throw new DataException("Invalid item id '"+icon+"' in column 'ICON' at line "+i+" in file '"+path+"'.");
int imageIndex = items[icon].imageIndex;
string[] l = split[3].Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries);
Group group = new Group(name, imageIndex);
foreach (string n in l) {
short s;
try { s = short.Parse(n); }
catch (Exception e) { throw new DataException("Failed to parse column 'ITEMS' at line "+i+" in file '"+path+"'.", e); }
if (items.ContainsKey(s)) group.Add(items[s]);
else MessageBox.Show("Invalid item id '"+s+"' in column 'ITEMS' at line "+i+" in file '"+path+"'.",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
groups.Add(name, group);
} else {
Image image;
try { image = LoadImage(split[2]); }
catch (Exception e) { throw new DataException("Failed to load image '"+split[2]+"' at line "+i+" in file '"+path+"' ("+e.Message+").", e); }
short id;
try { id = short.Parse(split[0]); }
catch (Exception e) { throw new DataException("Failed to parse column 'ID' at line "+i+" in file '"+path+"'.", e); }
string[] cords = split[3].Split(',');
if (cords.Length != 2) throw new DataException("Failed to parse column 'CORDS' at line "+i+" in file '"+path+"'.");
int x, y;
try {
x = int.Parse(cords[0]);
y = int.Parse(cords[1]);
} catch (Exception e) { throw new DataException("Failed to parse column 'CORDS' at line "+i+" in file '"+path+"'.", e); }
if (x < 0 || y < 0 || x*16+16 > image.Width || y*16+16 > image.Height)
throw new DataException("Invalid image cords "+x+","+y+" at line "+i+" in file '"+path+"'.");
bool stackable = true;
short maxDamage = 0;
if (split.Length == 5) {
stackable = false;
try { maxDamage = short.Parse(split[4]); }
catch (Exception e) { throw new DataException("Failed to parse column 'DAMAGE' at line "+i+" in file '"+path+"'.", e); }
if (maxDamage < 0) throw new DataException("Failed to parse column 'DAMAGE' at line "+i+" in file '"+path+"'.");
}
items.Add(id, new Item(id, name, stackable, maxDamage, image, x, y));
}
} catch (Exception e) {
if (MessageBox.Show(e.Message, "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
return;
}
}
}