public void Add(IDrawable drawable) { if (drawable == null) throw new ArgumentNullException("drawable"); lock (_drawingsSync) { _grpdrawings.Add(drawable); } }
public BeamRenderer(int count, IDrawable part, Vector3 dist) { Count = count; Part = part; Distance = dist; Offset = Matrix4Extensions.FromTranslation(Distance); }
internal static void AddObject (IDrawable obj) { var client = CallContext.Client; if (!objects.ContainsKey (client)) objects [client] = new List<IDrawable> (); objects [client].Add (obj); }
public IDrawable remove(IDrawable d) { bool removed=myDrawables.Remove(d); if (index >= myDrawables.Count) index = 0; return removed?d:null; }
public Direction IntersectWith(IDrawable obj) { if ((this.Position.Left > obj.Position.Left && this.Position.Left < obj.Position.Left + obj.Size.Width) || (this.Position.Left + this.Size.Width > obj.Position.Left && this.Position.Left + this.Size.Width < obj.Position.Left + obj.Size.Width) || (this.Position.Left == obj.Position.Left && this.Position.Left + this.Size.Width == obj.Position.Left + obj.Size.Width)) { if (this.Position.Top + this.Size.Height >= obj.Position.Top && this.Position.Top + this.Size.Height < obj.Position.Top + obj.Size.Height) { return Direction.Down; } if (this.Position.Top <= obj.Position.Top + obj.Size.Height && this.Position.Top > obj.Position.Top) { return Direction.Up; } } if ((this.Position.Top > obj.Position.Top && this.Position.Top < obj.Position.Top + obj.Size.Height) || (this.Position.Top + this.Size.Height > obj.Position.Top && this.Position.Top + this.Size.Height < obj.Position.Top + obj.Size.Height) || (this.Position.Top == obj.Position.Top && this.Position.Top + this.Size.Height == obj.Position.Top + obj.Size.Height)) { if (this.Position.Left <= obj.Position.Left + obj.Size.Width && this.Position.Left > obj.Position.Left) { return Direction.Left; } if (this.Position.Left + this.Size.Width >= obj.Position.Left && this.Position.Left + this.Size.Width < obj.Position.Left + obj.Size.Width) { return Direction.Right; } } return Direction.None; }
/// <summary> /// Constructs the tile drawable object. /// </summary> public TileDrawable( Tile tile, IDrawable drawable) { this.tile = tile; this.drawable = drawable; }
public GlListDrawable(IDrawable drawable) { if (drawable == null) { throw new ArgumentNullException("drawable"); } this.refresh = -1; this.drawable = drawable; this.bufferedDrawable = drawable as BufferedDrawable; }
public Computer(CPU cpu, RAM ram, HardDriver hardDriver, IDrawable videoCard) { this.CPU = cpu; this.RAM = ram; this.HardDrives = hardDriver; this.VideoCard = videoCard; }
/// <summary> /// Draws out the particle with the given drawable at the /// particle's position. /// </summary> public void Draw(IDrawable drawable, DrawingArgs args) { double ratio = secondsRemaining / Constants.MaxSwarmParticleLife; Color c = Color.FromArgb((int) (ratio * 255.0), Color.White); PointF p = new PointF(CurrentX, CurrentY); drawable.Draw(p, c, args.BackendDrawingArgs); }
public Drawable(Generator g) : base(g, typeof(IDrawable), false) { inner = (IDrawable)Handler; inner.Create (); Initialize (); }
internal static void RemoveObject (IDrawable obj) { var client = CallContext.Client; if (!objects.ContainsKey (client) || !objects [client].Contains (obj)) throw new ArgumentException ("Drawing object not found"); obj.Destroy (); objects [client].Remove (obj); }
public Form1() { InitializeComponent(); li = new Line(this.pictureBox1); ((Line)li).setStart(new Point(200, 230)); ((Line)li).setEnd(new Point(0, 20)); }
public Image( IDrawable drawable, Scaling scaling = Scaling.Stretch, int align = AlignInternal.center ) { setDrawable( drawable ); _scaling = scaling; _align = align; setSize( preferredWidth, preferredHeight ); touchable = Touchable.Disabled; }
public bool unregister(IDrawable component) { if (isRegistered(component)) { list.Remove(component); return true; } return false; }
public bool register(IDrawable component) { if (!isRegistered(component)) { list.Add(component); list.Sort((x, y) => priority(x).CompareTo(priority(y))); return true; } return false; }
public virtual void SetParameters(IDrawable a_renderable) { if (SetUserParameters != null) { SetUserParameters(BackingEffect, a_renderable); } BackingEffect.CommitChanges(); }
public Asteroid(float radius, IDrawable model) { Draw = new ArrayList(); Draw.Add(model); Radius = radius; RenderRadius = Radius; Hull = new Hull(1000); }
private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { if (current != null) { _list.Add(current); current = null; pictureBox1.Invalidate(); } }
/// <summary> /// Poistaa olion, kun kerrosta ei tunneta. /// Käy läpi kaikki kerrokset, kunnes olio löytyy. /// </summary> /// <param name="obj">Poistettava olio.</param> /// <returns></returns> public static bool RemoveFromDraw(IDrawable obj) { for (int i = 0; i < Layers.Length; i++) { if (Layers[i].objectsOnLayer.Remove(obj)) return true; } return false; }
IDrawable run(IDrawable input) { if (!(input is PointSet)) { throw new Exception("PointTest. Input is not Points."); } var inp = input as PointSet; Point a = inp[0]; Point b = inp[1]; bool x = Intersect.IsIntersected(a,b); if (x) return new PointSet(a); else return new PointSet(new Point(0,0)); }
IDrawable run(IDrawable input) { if (!(input is CircleSet)) { throw new Exception("CircleTest. Input is not Circles."); } var inp = input as CircleSet; Circle a = inp[0]; Circle b = inp[1]; bool x = Intersect.IsIntersected(a,b); if (x) return DrawableElement.Text(0, 0, "Vse horosho"); else return DrawableElement.Text(0, 0, "Vse ploho"); }
private int priority(IDrawable idrawable) { if (idrawable.GetType() == typeof(Player) || idrawable.GetType() == typeof(DummyBoss) || idrawable.GetType() == typeof(Boss)) { return 0; } else if (idrawable.GetType() == typeof(HUD)) { return 1; } else if (idrawable.GetType() == typeof(Fader)) { return 2; } else if (idrawable.GetType() == typeof(PauseScreen)) { return 4; } else { return 3; } }
public static void Draw(IDrawable drawling) { if (drawling.Texture == null) return; Color color = (drawling.Transparent) ? Color.Transparent : drawling.Color; if (drawling.SourceRectangle != Rectangle.Empty && drawling.SourceRectangle != null) { DrawWithSourceRect(drawling); return; } if (drawling.Visible) spriteBatch.Draw(drawling.Texture, drawling.Rectangle, color ); }
public Image setDrawable( IDrawable drawable ) { if( _drawable != drawable ) { if( _drawable != null ) { if( preferredWidth != drawable.minWidth || preferredHeight != drawable.minHeight ) invalidateHierarchy(); } else { invalidateHierarchy(); } _drawable = drawable; } return this; }
IDrawable run(IDrawable input) { if (!(input is PointSet)) { throw new Exception("PointSegmentTest. Input is not PointSegmentTest."); } var inp = input as PointSet; Point a = inp[0]; Point b = inp[1]; Point c = inp[2]; Segment d = new Segment(b, c); bool x = Intersect.IsIntersected(a,d); if (x) return new DrawableSet(new List<IDrawable>() {new SegmentSet(d), DrawableElement.Text(0, 0, "Vse horosho")}); else return new DrawableSet(new List<IDrawable>() { new SegmentSet(d), DrawableElement.Text(0, 0, "Vse ploho") }); }
IDrawable run(IDrawable input) { if (!(input is PointSet)) { throw new Exception("SegmentCircleTest. Input is not SegmentCircleTest."); } var inp = input as PointSet; Point a = inp[0]; Point b = inp[1]; Point c = inp[2]; Circle d = new Circle(b.X, b.Y, c.X); Segment e = new Segment(new Point(0, 0), a); bool x = Intersect.IsIntersected(a,d); if (x) return new DrawableSet(new List<IDrawable>() { new SegmentSet(e), new CircleSet(d), DrawableElement.Text(0, 0, "Vse horosho") }); else return new DrawableSet(new List<IDrawable>() { new SegmentSet(e), new CircleSet(d), DrawableElement.Text(0, 0, "Vse Ploho") }); }
IDrawable run(IDrawable input) { if (!(input is SegmentSet)) { throw new Exception("SegmentTest. Input is not Segments."); } var inp = input as SegmentSet; Segment a = inp[0]; Segment b = inp[1]; //Circle circle = new Circle(a.End,1); //Segment a = new Segment(20,0,20,80); //Segment b = new Segment(0, 20, 0, 80); var x = Intersect.GetIntersection(a, b); //var x = Intersect.GetArrowBase(a.Begin, a.End); if (x.Count > 0) return new PointSet(x[0]); else return new PointSet(); }
public void EnqueueForDrawing(IDrawable obj) { char[,] objImage = obj.GetBody(); int imageRows = objImage.GetLength(0); int imageCols = objImage.GetLength(1); int XPos = obj.GetCoordinates().XPosition; int YPos = obj.GetCoordinates().YPosition; if (obj is GameObject) { GameObject thisObj = obj as GameObject; ConsoleColor color = thisObj.Color; for (int row = 0; row < objImage.GetLength(0); row++) { for (int col = 0; col < objImage.GetLength(1); col++) { if (YPos + row < visibleRows && YPos >= 0) { ConsoleBuffer.Draw(objImage[row, col].ToString(), XPos + col, YPos + row, (short)thisObj.Color); } } } } else { for (int row = 0; row < objImage.GetLength(0); row++) { for (int col = 0; col < objImage.GetLength(1); col++) { if (YPos + row < visibleRows && YPos >= 0) { ConsoleBuffer.Draw(objImage[row, col].ToString(), XPos + row, YPos, 4); } } } } }
// TODO: We need a parameter here because not all the views are games // we need to extend the concept of view to include Widgets public bool CreateImage(IDrawable drawable, string file) { Cairo.ImageSurface cairo_image = null; gbrainy.Core.Main.CairoContextEx cr = null; try { file = Path.GetFullPath (file); cairo_image = new Cairo.ImageSurface (Cairo.Format.ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT); cr = new gbrainy.Core.Main.CairoContextEx (cairo_image, "sans 12", 96); // Draw Image drawable.Draw (cr, IMAGE_WIDTH, IMAGE_WIDTH, false); cairo_image.WriteToPng (file); if (File.Exists (file) == false) Logger.Error ("Game.CreateImage. Error writting {0}", file); else Logger.Debug ("Game.CreateImage. Wrote image {0}", file); } catch (Exception e) { Logger.Error ("Game.CreateImage. Error writting {0} {1}", file, e); return false; } finally { if (cr != null) ((IDisposable) cr).Dispose (); if (cairo_image != null) ((IDisposable) cairo_image).Dispose (); } return true; }
/// <summary> /// Constructs the token sprite based on the individual /// components. This is the "view" part of a token. /// </summary> public TokenSprite( Display display, Token token) { this.display = display; this.token = token; // Create the tile typeSprite = token.TypeSpriteName; tileDrawable = Game.Theme.DrawableFactory.Create(typeSprite); // Create the letter valueSprite = token.ValueSpriteName; letterDrawable = Game.Theme.DrawableFactory.Create(valueSprite); letterState = new DrawableState(); // Create the selected selectedDrawable = Game.Theme.DrawableFactory.Create("selected"); selectedState = new DrawableState(); // Randomize it Randomize(); }
public override bool Contains(IDrawable drawable) { return(false); }
public void AddDrawable(IDrawable drawable) { _drawables.Add(drawable); drawable.OnRedrawRequest += RequestUpdate; }
void InitWithDrawable(IDrawable drawable, ResourceManager res, bool draw, bool staticpos, bool havePhys = true) { Resources = res; dr = drawable; PhysicsComponent phys = null; bool isCmp = false; string name = ""; if (dr is SphFile) { var radius = ((SphFile)dr).Radius; phys = new PhysicsComponent(this) { SphereRadius = radius }; name = ((SphFile)dr).SideMaterialNames[0]; } else if (dr is ModelFile) { var mdl = dr as ModelFile; var path = Path.ChangeExtension(mdl.Path, "sur"); name = Path.GetFileNameWithoutExtension(mdl.Path); if (File.Exists(path)) { phys = new PhysicsComponent(this) { SurPath = path } } ; } else if (dr is CmpFile) { isCmp = true; var cmp = dr as CmpFile; CmpParts = new List <Part>(); CmpConstructs = cmp.Constructs.CloneAll(); foreach (var part in cmp.Parts) { CmpParts.Add(part.Clone(CmpConstructs)); } if (cmp.Animation != null) { AnimationComponent = new AnimationComponent(this, cmp.Animation); Components.Add(AnimationComponent); } var path = Path.ChangeExtension(cmp.Path, "sur"); name = Path.GetFileNameWithoutExtension(cmp.Path); if (File.Exists(path)) { phys = new PhysicsComponent(this) { SurPath = path } } ; } if (havePhys && phys != null) { PhysicsComponent = phys; Components.Add(phys); } PopulateHardpoints(dr); if (draw) { if (isCmp) { RenderComponent = new ModelRenderer(CmpParts, (dr as CmpFile)) { Name = name } } ; else { RenderComponent = new ModelRenderer(dr) { Name = name } }; } }
/// <summary> /// background may be null to clear the background. /// </summary> /// <returns>this</returns> /// <param name="background">Background.</param> public Label setBackground(IDrawable background) { _style.background = background; invalidate(); return(this); }
public void RegisterDrawable(IDrawable drawable) { drawables.Add(drawable); }
public ShapeDecorator(IDrawable decoratedShape) { DecoratedShape = decoratedShape; }
public void Add(IDrawable d) { components.Add(d); }
private void findTargetChildren() { Debug.Assert(childDrawables.Count == 0, $"{nameof(childDrawables)} should be empty but has {childDrawables.Count} elements."); Debug.Assert(nestedTtcChildDrawables.Count == 0, $"{nameof(nestedTtcChildDrawables)} should be empty but has {nestedTtcChildDrawables.Count} elements."); Debug.Assert(newChildDrawables.Count == 0, $"{nameof(newChildDrawables)} should be empty but has {newChildDrawables.Count} elements."); Debug.Assert(targetChildren.Count == 0, $"{nameof(targetChildren)} should be empty but has {targetChildren.Count} elements."); // Skip all drawables in the hierarchy prior to (and including) ourself. var targetCandidates = inputManager.PositionalInputQueue.Reverse().SkipWhile(d => d != this).Skip(1); childDrawables.Add(this); // keep track of all hovered drawables below this and nested effect containers // so we can decide which ones are valid candidates for receiving our effect and so // we know when we can abort our search. foreach (var candidate in targetCandidates) { // Children of drawables we are responsible for transitively also fall into our subtree, // and therefore we need to handle them. If they are not children of any drawables we handle, // it means that we iterated beyond our subtree and may terminate. IDrawable parent = candidate.Parent; // We keep track of all drawables we found while traversing the parent chain upwards. newChildDrawables.Clear(); newChildDrawables.Add(candidate); // When we encounter a drawable we already encountered before, then there is no need // to keep going upward, since we already recorded it previously. At that point we know // the drawables we found are in fact children of ours. while (!childDrawables.Contains(parent)) { // If we reach to the root node (i.e. parent == null), then we found a drawable // which is no longer a child of ours and we may terminate. if (parent == null) { return; } newChildDrawables.Add(parent); parent = parent.Parent; } // Assuming we did _not_ end up terminating, then all found drawables are children of ours // and need to be added. childDrawables.UnionWith(newChildDrawables); // Keep track of child drawables whose effects are managed by a nested effect container. // Note, that nested effect containers themselves could implement TTarget and // are still our own responsibility to handle. nestedTtcChildDrawables.UnionWith( ((IEnumerable <IDrawable>)newChildDrawables).Reverse() .SkipWhile(d => d.Parent == this || !(d.Parent is TSelf) && !nestedTtcChildDrawables.Contains(d.Parent))); // Ignore drawables whose effects are managed by a nested effect container. if (nestedTtcChildDrawables.Contains(candidate)) { continue; } TTarget target = candidate as TTarget; if (target != null && target.IsHovered) { // We found a valid candidate; keep track of it targetChildren.Add(target); } } }
/// <summary> /// Adds a drawable object to the plot surface. If the object is an IPlot, /// the PlotSurface2D axes will also be updated. /// </summary> /// <param name="p">The IDrawable object to add to the plot surface.</param> public void Add(IDrawable p) { ps_.Add(p); }
public ImageTextButtonStyle(IDrawable up, IDrawable down, IDrawable over, BitmapFont font) : base(up, down, over, font) { }
public void AddObject(IDrawable drawable) { _drawableObjects.Add(drawable); }
/// <summary> /// Returns the rectangular region of the given tile /// </summary> /// <param name="d">The IDrawable's region to return</param> /// <returns>The region</returns> public static Rectangle GetMapTile(IDrawable d) { return(TileMap[d.Tilename.ToLower()]); }
public TextTooltipStyle(LabelStyle label, IDrawable background) { LabelStyle = label; Background = background; }
public ItemButton(IDrawable imageUp, IDrawable imageDown, IDrawable imageOver) : base(imageUp, imageDown, imageOver) { }
void InitWithDrawable(IDrawable drawable, ResourceManager res, bool staticpos) { Resources = res; dr = drawable; Shape collisionShape = null; bool isCmp = false; if (dr is SphFile) { var radius = ((SphFile)dr).Radius; collisionShape = new SphereShape(radius); } else if (dr is ModelFile) { var mdl = dr as ModelFile; var path = Path.ChangeExtension(mdl.Path, "sur"); if (File.Exists(path)) { SurFile sur = res.GetSur(path); var shs = new List <CompoundSurShape.TransformedShape>(); foreach (var s in sur.GetShape(0)) { shs.Add(new CompoundSurShape.TransformedShape(s, Matrix3.Identity, Vector3.Zero)); } collisionShape = new CompoundSurShape(shs); } } else if (dr is CmpFile) { isCmp = true; var cmp = dr as CmpFile; CmpParts = new List <Part>(); CmpConstructs = cmp.Constructs.CloneAll(); foreach (var part in cmp.Parts.Values) { CmpParts.Add(part.Clone(CmpConstructs)); } if (cmp.Animation != null) { AnimationComponent = new AnimationComponent(this, cmp.Animation); Components.Add(AnimationComponent); } var path = Path.ChangeExtension(cmp.Path, "sur"); if (File.Exists(path)) { SurFile sur = res.GetSur(path); var shapes = new List <CompoundSurShape.TransformedShape>(); foreach (var part in CmpParts) { var crc = CrcTool.FLModelCrc(part.ObjectName); if (!sur.HasShape(crc)) { FLLog.Warning("Sur", "No hitbox for " + part.ObjectName); continue; } var colshape = sur.GetShape(crc); if (part.Construct == null) { foreach (var s in colshape) { shapes.Add(new CompoundSurShape.TransformedShape(s, Matrix3.Identity, Vector3.Zero)); } } else { var tr = part.Construct.Transform; var pos = tr.ExtractTranslation(); var q = tr.ExtractRotation(true); var rot = Matrix3.CreateFromQuaternion(q); foreach (var s in colshape) { shapes.Add(new CompoundSurShape.TransformedShape(s, rot, pos) { Tag = part.Construct }); } } } collisionShape = new CompoundSurShape(shapes); } } if (collisionShape != null) { PhysicsComponent = new RigidBody(collisionShape); PhysicsComponent.Tag = this; PhysicsComponent.IsStatic = staticpos; if (staticpos) { PhysicsComponent.Material.Restitution = 1; } } PopulateHardpoints(dr); if (isCmp) { RenderComponent = new ModelRenderer(CmpParts, (dr as CmpFile)); } else { RenderComponent = new ModelRenderer(dr); } }
/// <summary> /// Adds a drawable object to the plot surface. If the object is an IPlot, /// the PlotSurface2D axes will also be updated. /// </summary> /// <param name="p">The IDrawable object to add to the plot surface.</param> /// <param name="zOrder">The z-ordering when drawing (objects with lower numbers are drawn first)</param> public void Add(IDrawable p, int zOrder) { ps_.Add(p, zOrder); }
public void SetIcon(IDrawable icon) { this.icon = icon; }
/// <summary> /// Adds a drawable object to the plot surface against the specified axes. If /// the object is an IPlot, the PlotSurface2D axes will also be updated. /// </summary> /// <param name="p">the IDrawable object to add to the plot surface</param> /// <param name="xp">the x-axis to add the plot against.</param> /// <param name="yp">the y-axis to add the plot against.</param> /// <param name="zOrder">The z-ordering when drawing (objects with lower numbers are drawn first)</param> public void Add(IDrawable p, Florence.PlotSurface2D.XAxisPosition xp, Florence.PlotSurface2D.YAxisPosition yp, int zOrder) { ps_.Add(p, xp, yp, zOrder); }
public void DeleteDrawable(IDrawable drawable) { drawables.Remove(drawable); }
/// <summary> /// Remove a drawable object from the plot surface. /// </summary> /// <param name="p">the drawable to remove</param> /// <param name="updateAxes">whether or not to update the axes after removing the idrawable.</param> public void Remove(IDrawable p, bool updateAxes) { ps_.Remove(p, updateAxes); }
public BrightnessImage(string roleName, IDrawable drawable, int brighnessVar) : base(roleName, drawable) { SaveAdjustedBrightness(brighnessVar); }
/// <summary> /// Creates a new <see cref="DrawNode"/>. /// </summary> /// <param name="source">The <see cref="Drawable"/> to draw with this <see cref="DrawNode"/>.</param> public DrawNode(IDrawable source) { Source = source; Reference(); }
public PropertyItem(MemberInfo info, IDrawable d) { Type type; switch (info.MemberType) { case MemberTypes.Property: PropertyInfo propertyInfo = (PropertyInfo)info; type = propertyInfo.PropertyType; getValue = () => propertyInfo.GetValue(d); break; case MemberTypes.Field: FieldInfo fieldInfo = (FieldInfo)info; type = fieldInfo.FieldType; getValue = () => fieldInfo.GetValue(d); break; default: throw new NotImplementedException(@"Not a value member."); } RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; AddRangeInternal(new Drawable[] { new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Right = 6 }, Child = new FillFlowContainer <SpriteText> { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Horizontal, Spacing = new Vector2(10f), Children = new[] { new SpriteText { Text = info.Name, Colour = Color4.LightBlue, }, new SpriteText { Text = $@"[{type.Name}]:", Colour = Color4.MediumPurple, }, valueText = new SpriteText { Colour = Color4.White, }, } } }, changeMarker = new Box { Size = new Vector2(4, 18), Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, Colour = Color4.Red } }); // Update the value once updateValue(); }
public ItemButton(IDrawable imageUp, IDrawable imageDown) : base(imageUp, imageDown) { }
public void RemoveDrawable(IDrawable drawable) { drawable.OnRedrawRequest -= RequestUpdate; _drawables.Remove(drawable); }
public ItemButton(IDrawable imageUp) : base(imageUp) { }
public void Add(IDrawable drawable) { drawable.Draw(buffer); }
public GameObject(IDrawable drawable, ResourceManager res, bool staticpos = false) { isstatic = staticpos; InitWithDrawable(drawable, res, staticpos); }
public override bool Remove(IDrawable drawable) { throw new InvalidOperationException("Can't remove element from unmodifiable drawable list"); }
public override bool Add(IDrawable drawable) { throw new InvalidOperationException("Can't add element to unmodifiable drawable list"); }