本文整理汇总了C#中ShapeCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ShapeCollection.Add方法的具体用法?C# ShapeCollection.Add怎么用?C# ShapeCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShapeCollection
的用法示例。
在下文中一共展示了ShapeCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
/// <summary>
/// Overridden save function
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
public override bool Save(string filename)
{
PrefabDesc prefab = new PrefabDesc(filename);
ShapeCollection all = new ShapeCollection();
// the following shapes go into the prefab: lightgrid boxes, lights
foreach (ShapeBase shape in this.FilteredSupplier)
all.Add(shape);
foreach (ShapeBase shape in this.FilteredLights)
if (!all.Contains(shape))
all.Add(shape);
if (!prefab.CreateFromInstances(all, Vector3F.Zero, false, false))
return false;
return prefab.SaveToFile(null);
}
示例2: DropToFloorAction
/// <summary>
/// Alternative constructor that takes a single shape
/// </summary>
/// <param name="shape"></param>
/// <param name="mode"></param>
/// <param name="axis"></param>
/// <param name="includeShapes"></param>
public DropToFloorAction(Shape3D shape, Shape3D.DropToFloorMode mode, Vector3F axis, bool includeShapes)
: base("Drop to Floor")
{
_shapes = new ShapeCollection();
_shapes.Add(shape);
_mode = mode;
_axis = axis;
_includeShapes = includeShapes;
}
示例3: reportlist_DoubleClick
private void reportlist_DoubleClick(object sender, System.EventArgs e)
{
ShapeBase shape = (ShapeBase)reportlist.SelectedItems[0].Tag;
ShapeCollection shapes = new ShapeCollection();
shapes.Add(shape);
EditorManager.SelectedShapes = shapes;
//jump to selection
BoundingBox mergedBox = EditorManager.SelectedShapes.BoundingBox;
if (!mergedBox.Valid)
return;
// make it local again
Vector3F center = mergedBox.Center;
mergedBox.Translate(-center);
EditorManager.ActiveView.LookAt(center, mergedBox);
}
示例4: Perform2DViewAction
public override void Perform2DViewAction(Scene2DView view, GroupAction parent, string action)
{
base.Perform2DViewAction(view, parent, action);
// sector range - used by all actions
BoundingBox selBox = view.SelectionMarqueeWorldBox;
int x1, y1, x2, y2;
Config.GetSectorIndicesAtWorldPos(selBox.vMin, out x1, out y1);
Config.GetSectorIndicesAtWorldPos(selBox.vMax, out x2, out y2);
Config.ClampSectorRange(ref x1, ref y1, ref x2, ref y2);
if (action == VA_EDIT_SECTOR_PROPERTIES)
{
ShapeCollection shapes = new ShapeCollection();
for (int sy = y1; sy <= y2; sy++)
for (int sx = x1; sx <= x2; sx++)
shapes.Add(GetZone(sx, sy));
EditorManager.SelectedShapes = shapes;
}
else if (action == VA_IMPORT_HEIGHTMAP)
{
ImportHeightmapDDS import = new ImportHeightmapDDS();
x1 *= Config.SamplesPerSectorX;
y1 *= Config.SamplesPerSectorY;
x2 = (x2 + 1) * Config.SamplesPerSectorX;
y2 = (y2 + 1) * Config.SamplesPerSectorY;
ApplyHeightmapFilterDlg.RunFilter(import, x1, y1, x2, y2);
}
else if (action == VA_REPAIR_SECTORS)
{
EditorManager.Progress.ShowProgressDialog("Repair Sectors");
EngineTerrain.EnsureSectorRangeLoaded(x1, y1, x2, y2, (int)SectorEditorFlags_e.AnythingDirty, true, true, EditorManager.Progress);
EditorManager.Progress.HideProgressDialog();
}
else if (action == VA_RELOAD_SECTORS)
{
EditorManager.Progress.ShowProgressDialog("Reload Sectors");
EngineTerrain.ReloadSectorRange(x1, y1, x2, y2, false, EditorManager.Progress);
EditorManager.Progress.HideProgressDialog();
EditorManager.ActiveView.UpdateView(false);
}
}
示例5: GetRelevantShapes
ShapeCollection GetRelevantShapes()
{
if (_relevantShapes == null)
{
_relevantShapes = new ShapeCollection();
#if (MESHGROUP_USE_LINKING)
LinkCollection links = GetGroupStaticMeshesLinkSource().Links;
foreach (LinkTarget t in links)
if (t.OwnerShape is StaticMeshShape)
_relevantShapes.Add(t.OwnerShape);
#else
RecursiveAddRelevantChildren(ChildCollection);
#endif
}
return _relevantShapes;
}
示例6: recentItem_Click
private void recentItem_Click(object sender, EventArgs e)
{
this.Focus();
ToolStripMenuItem recentItem = sender as ToolStripMenuItem;
if (recentItem == null)
return;
object obj = recentItem.Tag;
if (obj == null)
return;
if (obj.GetType() == typeof(Layer) || obj.GetType() == typeof(V3DLayer))
{
IScene.SendLayerChangedEvent(new LayerChangedArgs((Layer)obj, null, LayerChangedArgs.Action.Selected));
}
else if (obj.GetType() == typeof(Zone))
{
IScene.SendZoneChangedEvent(new ZoneChangedArgs((Zone)obj, ZoneChangedArgs.Action.Selected));
}
else
{
ShapeCollection shapes = new ShapeCollection();
shapes.Add((ShapeBase)obj);
EditorManager.SelectedShapes = shapes;
// Fire event manually in case selection was the same (so event will not get fired)
EditorManager.OnShapeSelectionChanged(new ShapeSelectionChangedArgs(null, shapes));
}
}
示例7: CreateImage
//.........这里部分代码省略.........
switch (imageFormat) {
case ImageFileFormat.Svg:
throw new NotImplementedException();
case ImageFileFormat.Emf:
case ImageFileFormat.EmfPlus:
// Create MetaFile and graphics context
IntPtr hdc = infoGraphics.GetHdc();
try {
Rectangle bounds = Rectangle.Empty;
bounds.Size = imageBounds.Size;
result = new Metafile(hdc, bounds, MetafileFrameUnit.Pixel,
(imageFormat == ImageFileFormat.Emf) ? EmfType.EmfOnly : EmfType.EmfPlusDual,
Name);
} finally {
infoGraphics.ReleaseHdc(hdc);
}
break;
case ImageFileFormat.Bmp:
case ImageFileFormat.Gif:
case ImageFileFormat.Jpeg:
case ImageFileFormat.Png:
case ImageFileFormat.Tiff:
int imgWidth = imageBounds.Width;
int imgHeight = imageBounds.Height;
if (dpi > 0 && dpi != infoGraphics.DpiX || dpi != infoGraphics.DpiY) {
scaleX = dpi / infoGraphics.DpiX;
scaleY = dpi / infoGraphics.DpiY;
imgWidth = (int)Math.Round(scaleX * imageBounds.Width);
imgHeight = (int)Math.Round(scaleY * imageBounds.Height);
}
result = new Bitmap(Math.Max(1, imgWidth), Math.Max(1, imgHeight));
((Bitmap)result).SetResolution(dpi, dpi);
break;
default:
throw new NShapeUnsupportedValueException(typeof(ImageFileFormat), imageFormat);
}
// Draw diagram
using (Graphics gfx = Graphics.FromImage(result)) {
GdiHelpers.ApplyGraphicsSettings(gfx, RenderingQuality.MaximumQuality);
// Fill background with background color
if (backgroundColor.A < 255) {
if (imageFormat == ImageFileFormat.Bmp || imageFormat == ImageFileFormat.Jpeg) {
// For image formats that do not support transparency, fill background with the RGB part of
// the given backgropund color
gfx.Clear(Color.FromArgb(255, backgroundColor));
} else if (backgroundColor.A > 0) {
// Skip filling background for meta files if transparency is 100%:
// Filling Background with Color.Transparent causes graphical glitches with many applications
gfx.Clear(backgroundColor);
}
} else {
// Graphics.Clear() does not work as expected for classic EMF (fills only the top left pixel
// instead of the whole graphics context).
if (imageFormat == ImageFileFormat.Emf) {
using (SolidBrush brush = new SolidBrush(backgroundColor))
gfx.FillRectangle(brush, gfx.ClipBounds);
} else gfx.Clear(backgroundColor);
}
// Transform graphics (if necessary)
gfx.TranslateTransform(-imageBounds.X, -imageBounds.Y, MatrixOrder.Prepend);
if (scaleX != 1 || scaleY != 1) gfx.ScaleTransform(scaleX, scaleY, MatrixOrder.Append);
// Draw diagram background
if (withBackground) DrawBackground(gfx, imageBounds);
// Draw diagram shapes
if (shapes == null) {
foreach (Shape shape in diagramShapes.BottomUp) shape.Draw(gfx);
} else {
// Add shapes to ShapeCollection (in order to maintain zOrder while drawing)
int cnt = (shapes is ICollection) ? ((ICollection)shapes).Count : -1;
ShapeCollection shapeCollection = new ShapeCollection(cnt);
foreach (Shape s in shapes) {
// Sort out duplicate references to shapes (as they can occur in the result of Diagram.FindShapes())
if (shapeCollection.Contains(s)) continue;
shapeCollection.Add(s, s.ZOrder);
}
// Draw shapes
foreach (Shape shape in shapeCollection.BottomUp)
shape.Draw(gfx);
shapeCollection.Clear();
}
// Reset transformation
gfx.ResetTransform();
}
// Restore original graphics settings
HighQualityRendering = originalQualitySetting;
UpdateBrushes();
return result;
} finally {
if (disposeInfoGfx)
GdiHelpers.DisposeObject(ref infoGraphics);
}
}
示例8: AddSoundShapesRecursive
void AddSoundShapesRecursive(ShapeCollection shapeList, ShapeBase parent)
{
if (parent.ShapeVirtualCounter > 0 || !parent.Modifiable)
return;
ShapeBase soundShape = parent as ShapeObject3D;
if (soundShape != null && (soundShape.GetType().FullName == "SoundEditorPlugin.SoundShape" || soundShape.GetType().FullName == "SoundEditorPlugin.SoundCollisionShape"))
shapeList.Add(soundShape);
if (parent.HasChildren())
foreach (ShapeBase shape in parent.ChildCollection)
AddSoundShapesRecursive(shapeList, shape);
}
示例9: SortSelectedShapes
private void SortSelectedShapes(MoveShapesDirection moveDirection)
{
ShapeCollection selected = shapeTreeView.SelectedShapes;
// return if any of the indices is already on the maximum.
foreach (ShapeBase shape in selected)
{
if (moveDirection == MoveShapesDirection.Up)
{
if (shape.Parent.ChildCollection.FindIndex(i => i == shape) <= 0)
return;
}
else
if (shape.Parent.ChildCollection.FindIndex(i => i == shape) >= shape.Parent.ChildCollection.Count - 1)
return;
}
// get all parents to share modified collections between their children.
ShapeCollection parents = new ShapeCollection();
foreach (ShapeBase shape in selected)
if (!parents.Contains(shape.Parent))
parents.Add(shape.Parent);
EditorManager.Actions.StartGroup("Sort Shapes");
foreach (ShapeBase parent in parents)
{
// create copy of the original collection before sorting
ShapeCollection copyOfChildren = new ShapeCollection();
copyOfChildren.AddRange(parent.ChildCollection);
if (moveDirection == MoveShapesDirection.Up)
{
for (int i = 0; i < selected.Count; i++)
{
ShapeBase child = selected[i];
if (child.Parent == parent)
{
int index = copyOfChildren.FindIndex(c => c == child);
copyOfChildren.Remove(child);
copyOfChildren.Insert(index - 1, child);
EditorManager.Actions.Add(new SortShapeChildrenAction(parent, copyOfChildren));
}
}
}
else
for (int i = selected.Count - 1; i > -1; i--)
{
ShapeBase child = selected[i];
if (child.Parent == parent)
{
int index = copyOfChildren.FindIndex(c => c == child);
copyOfChildren.Remove(child);
copyOfChildren.Insert(index + 1, child);
EditorManager.Actions.Add(new SortShapeChildrenAction(parent, copyOfChildren));
}
}
}
EditorManager.Actions.EndGroup();
// recover selection
ArrayList newSelection = new ArrayList();
foreach (ShapeTreeNode node in shapeTreeView.Nodes)
{
if (selected.Contains(node.shape)) // root
newSelection.Add(node);
foreach (ShapeTreeNode subNode in shapeTreeView.GetChildNodes(node))
{
if (selected.Contains(subNode.shape)) // all children
newSelection.Add(subNode);
}
}
shapeTreeView.SelectedNodes = newSelection;
}
示例10: moveShapesToolStripMenuItem_Click
private void moveShapesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!treeView_Layers.Selection_ZonesOnly)
return;
ShapeCollection shapes = new ShapeCollection();
foreach (Zone zone in treeView_Layers.Selection_Zones)
{
Shape3D shape = zone.GetZoneMoveProxyShape();
if (shape != null)
shapes.Add(shape);
}
EditorManager.SelectedShapes = shapes;
}
示例11: EndEditing
void EndEditing()
{
_shape.ConstructionFinished = true;
Cursor.Show();
// Close dialog and remove callbacks
_contextDialog.FormClosed -= new FormClosedEventHandler(FormClosed);
IScene.ShapeChanged -= new ShapeChangedEventHandler(ShapeChanged);
IScene.PropertyChanged -= new CSharpFramework.PropertyChangedEventHandler(PropertyChanged);
EditorManager.BeforeSceneClosing -= new BeforeSceneClosing(SceneClosing);
EditorManager.SceneEvent -= new SceneEventHandler(EditorManager_SceneEvent);
_contextDialog.Close();
// Set selection to the edited custom volume shape
ShapeCollection selection = new ShapeCollection();
selection.Add(_shape);
EditorManager.SelectedShapes = selection;
}
示例12: OnRemoveFromScene
public override void OnRemoveFromScene()
{
base.OnRemoveFromScene();
if (EditorManager.Scene != null && _lastParent != null && _lastParent.EngineInstance != null && !_lastParent.CustomStaticMesh)
{
_lastParent.EngineInstance.UpdateStaticMesh(EngineInstanceCustomVolumeObject.VUpdateType_e.VUT_UPDATE_RETRIANGULATE);
//Select last parent to not loose focus
ShapeCollection selection = new ShapeCollection();
selection.Add(_lastParent);
EditorManager.SelectedShapes = selection;
}
//finally remove the engine instance
if (this._engineInstance != null)
{
// Important: We must call the base implementation here because the overload in this class prevents the deletion
base.RemoveEngineInstance(false);
}
}
示例13: Open
public void Open(string filename)
{
if (filename.Length == 0)
return;
if (!File.Exists(filename))
{
var directoryName = Path.GetDirectoryName(Filename);
if (directoryName == null)
{
MessageBox.Show("Error?!?");
return;
}
var nfilename = Path.Combine(directoryName, Path.GetFileName(filename));
if (File.Exists(nfilename))
filename = nfilename;
else
{
MessageBox.Show("File non trovato:\n" + filename, "Diagram Drawer", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("File non trovato:\n" + nfilename, "Diagram Drawer", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
var sett = new XmlReaderSettings
{
IgnoreWhitespace = true
};
try
{
using (var reader = XmlReader.Create(filename, sett))
{
reader.ReadToFollowing("size");
Width = reader.MoveToAttribute("width")
? Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture)
: 1000;
Height = reader.MoveToAttribute("height")
? Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture)
: 800;
reader.MoveToElement();
var toLoad = new ShapeCollection();
do
{
reader.Read();
IShapeCreator creator = null;
switch (reader.Name)
{
case "shape":
if (reader.MoveToAttribute("type"))
{
var type = reader.ReadContentAsString();
creator = ShapeTypes[type];
}
else
creator = RoundedBox.Creator;
break;
case "line":
if (reader.MoveToAttribute("type"))
{
var type = reader.ReadContentAsString();
creator = ArrowTypes[type];
}
else
creator = Line.Creator;
break;
}
IPersistableShape s;
if (creator != null)
s = creator.Create();
else
break;//We're done!
reader.MoveToElement();
using (var r = reader.ReadSubtree())
s.Load(r);
toLoad.Add(s);
} while (true);
container.ClearShapes();
container.LoadShapes(toLoad);
}
container.ForceRefresh();
Filename = filename;
if (Opened != null)
Opened(this, EventArgs.Empty);
}
catch (FileNotFoundException fnfe)
{
MessageBox.Show("[WAAAAAAAAA]\nFile non trovato: " + fnfe.FileName, "Diagram Drawer", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例14: AddPhysXComponentsRecursive
void AddPhysXComponentsRecursive(ShapeComponentCollection list, ShapeCollection entityList, ShapeBase parent)
{
if (parent.ShapeVirtualCounter > 0 || !parent.Modifiable)
return;
if (parent.ComponentCount > 0)
{
foreach (ShapeComponent comp in parent.Components)
{
if (!comp.Missing)
continue;
if (comp.DisplayName == "vPhysXRigidBody" || comp.DisplayName == "vPhysXCharacterController")
{
// Catch invalid casts
try
{
UInt32 iValue = System.Convert.ToUInt32(comp.GetPropertyValue("m_iCollisionBitmask", false));
if (iValue != 0)
list.Add(comp);
}
catch(InvalidCastException)
{}
}
}
}
EntityShape entity = parent as EntityShape;
if (entity != null && (entity.EntityClass == "vPhysXEntity" || entity.EntityClass == "LineFollowerEntity_cl"))
{
entityList.Add(entity);
}
if (parent.HasChildren())
foreach (ShapeBase shape in parent.ChildCollection)
AddPhysXComponentsRecursive(list, entityList, shape);
}
示例15: SelectEntities
private void SelectEntities(ShapeBase shape, String classText, String modelText, ShapeCollection sel)
{
//check the entity
EntityShape entity = shape as EntityShape;
if (entity!=null)
{
bool bSelect = true;
if (checkEntityClass.Checked)
bSelect &= (entity.EntityClass.ToUpper().IndexOf(classText)!=-1);
if (checkModel.Checked)
bSelect &= (entity.ModelFile.ToUpper().IndexOf(modelText)!=-1);
if (bSelect)
sel.Add(shape);
}
//check its children
foreach(ShapeBase child in shape.ChildCollection)
{
SelectEntities(child, classText, modelText, sel);
}
}