/// <summary> /// Jos content on control, kutsuu sen drawia. Basea ei tarvise kutsua jos ylikirjoitetaan. /// </summary> protected virtual void DrawContent(SpriteBatch spriteBatch) { if (contentControl != null) { contentControl.Draw(spriteBatch); } }
void IDrawable.Draw(GameTime gameTime) { if (_isDirty) { lock (_controls) { if (_controlCount >= _currentlyControls.Length) { Array.Resize(ref _currentlyControls, _currentlyControls.Length * 2); } else if (_controlCount < _currentlyControlCount) { Array.Clear(_currentlyControls, _controlCount, _currentlyControlCount - _controlCount); } Array.Copy(_controls, _currentlyControls, _currentlyControlCount = _controlCount); } _isDirty = false; } _canvas.Begin(); for (int i = _currentlyControlCount - 1; i >= 0; i--) { Control control = _currentlyControls[i]; if (control.BeginDraw()) { control.Draw(gameTime.DeltaTimeS, _canvas); control.EndDraw(); } } _canvas.End(); }
public void Draw(GameTime gameTime, ScreenManager screenManager) { if (!BaseScreen.Hidden) { BaseScreen.Draw(gameTime, screenManager); } }
/// <summary> /// Standard Unity OnGUI call. Make sure to call <c>base.OnGUI()</c> when overriding this method. /// </summary> protected virtual void OnGUI() { if (m_rootObject == null) { Initialize(); } if (position.width != m_cachedScreenSize.x || position.height != m_cachedScreenSize.y) { m_cachedScreenSize.x = position.width; m_cachedScreenSize.y = position.height; if (m_rootObject != null) { m_rootObject.Size = m_cachedScreenSize; } } if (m_rootObject != null) { m_rootObject.Layout(); m_rootObject.Draw(); m_rootObject.ProcessEvents(Event.current); } m_frame++; }
public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination) { var sourceRect = new CGRect(source.X, (float)Control.Size.Height - source.Y - source.Height, source.Width, source.Height); var destRect = graphics.TranslateView(destination.ToNS(), true, true); Control.Draw(destRect, sourceRect, NSCompositingOperation.SourceOver, 1, true, null); }
public static void CallDrawing(Control guiRoot, GPUContext context, RenderTarget output, RenderTarget depthBuffer, Matrix viewProjection) { if (context == null || output == null || guiRoot == null) { throw new ArgumentNullException(); } if (depthBuffer != null) { if (!depthBuffer.IsAllocated) { throw new InvalidOperationException("Depth buffer is not allocated. Use RenderTarget.Init before rendering."); } if (output.Size != depthBuffer.Size) { throw new InvalidOperationException("Output buffer and depth buffer dimensions must be equal."); } } #if UNIT_TEST_COMPILANT throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set."); #else if (Internal_DrawBegin2(context.unmanagedPtr, output.unmanagedPtr, Object.GetUnmanagedPtr(depthBuffer), ref viewProjection)) { throw new InvalidOperationException("Cannot perform GUI rendering."); } guiRoot.Draw(); Internal_DrawEnd(); #endif }
private static void AssertEqual(Control <char, object, TestKey> control, string etalon, char empty = ' ') { var terminal = new TestTerminal(control.Width, control.Height, empty); control.Draw(terminal); Assert.AreEqual(etalon, terminal.ToString()); }
public void EndUpdate(Control control) { if (updating) { ConsoleRenderer.ActiveBuffer.Clear(oldRectangle); foreach (var ctrl in controls) { if (ctrl != control && ctrl.IntersectsWith(oldRectangle)) { ctrl.Draw(ctrl.Rectangle.Intersect(oldRectangle)); } } control.Draw(); int index = controls.IndexOf(control); for (int i = index + 1; i < controls.Count; i++) { var ctrl = controls[i]; if (ctrl.IntersectsWith(control.Rectangle)) { ctrl.Draw(ctrl.Rectangle.Intersect(control.Rectangle)); } } ConsoleRenderer.RenderArea(oldRectangle); ConsoleRenderer.RenderArea(control.Rectangle); updating = false; } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == "Height") //プロパティHeight若しくはWidthが変更された時、再描画する { Control.Draw(); //再描画メソッド } }
public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination) { var destRect = graphics.TranslateView(destination.ToSD(), false).ToEto(); var drawRect = GetDrawRect(ref source, ref destRect, Control.Size.ToEto()); graphics.Control.ClipToRect(destRect.ToSD()); // first apply the clip since destination is in view coordinates. Control.Draw(drawRect.ToSD(), CGBlendMode.Normal, 1); }
public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination) { var sourceRect = graphics.Translate(source.ToSD(), Control.Size.Height); var destRect = graphics.TranslateView(destination.ToSD(), true, true); graphics.Control.ConcatCTM(new CGAffineTransform(1, 0, 0, -1, 0, graphics.ViewHeight)); destRect.Y = graphics.ViewHeight - destRect.Y - destRect.Height; Control.Draw(destRect, sourceRect, NSCompositingOperation.SourceOver, 1); }
public void Draw(GameTime gameTime) { WindowPanel.Draw(gameTime); TitleBar.Draw(gameTime); Title.Draw(gameTime); btnClose.Draw(gameTime); btnMax.Draw(gameTime); btnMin.Draw(gameTime); app.Draw(gameTime); }
public void AddControl(Control control) { if (control == null) { return; } control.ContainingApp = ContainingApp; _controls.Add(control); control.Draw(); }
void OnRadiusUpdate(bool init) { int topLeft = Forms.ConvertToScaledPixel(Element.CornerRadius.TopLeft); int topRight = Forms.ConvertToScaledPixel(Element.CornerRadius.TopRight); int bottomLeft = Forms.ConvertToScaledPixel(Element.CornerRadius.BottomLeft); int bottomRight = Forms.ConvertToScaledPixel(Element.CornerRadius.BottomRight); Control.SetRadius(topLeft, topRight, bottomLeft, bottomRight); if (!init) { Control.Draw(); } }
public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination) { if (Control.Template) { DrawTemplateImage(graphics, source, destination); return; } var sourceRect = new CGRect(source.X, (float)Control.Size.Height - source.Y - source.Height, source.Width, source.Height); var destRect = destination.ToNS(); Control.Draw(destRect, sourceRect, NSCompositingOperation.SourceOver, 1, true, null); }
public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination) { var sourceRect = new CGRect(source.X, (float)Control.Size.Height - source.Y - source.Height, source.Width, source.Height); var destRect = destination.ToNS(); if (alpha) { Control.Draw(destRect, sourceRect, NSCompositingOperation.SourceOver, 1, true, null); } else { Control.Draw(destRect, sourceRect, NSCompositingOperation.Copy, 1, true, null); } }
public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination) { var sourceRect = new sd.RectangleF(source.X, Control.Size.Height - source.Y - source.Height, source.Width, source.Height); var destRect = graphics.TranslateView(destination.ToSD(), true, true); if (alpha) { Control.Draw(destRect, sourceRect, NSCompositingOperation.SourceOver, 1, true, null); } else { Control.Draw(destRect, sourceRect, NSCompositingOperation.Copy, 1, true, null); } }
public override void Draw(SpriteBatch sb, bool mouseOver) { Control.Draw(sb); if (OnDraw != null) { OnDraw(this, sb, mouseOver); } if (GlobalDraw != null) { GlobalDraw(this, sb, mouseOver); } base.Draw(sb, mouseOver); }
public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination) { var sourceRect = source.ToSD(); //graphics.Translate(source.ToSD (), nsimage.Size.Height); SD.RectangleF destRect = graphics.TranslateView(destination.ToSD(), false); if (source.TopLeft != Point.Empty || sourceRect.Size != Control.Size) { graphics.Control.SaveState(); //graphics.Context.ClipToRect(destRect); if (graphics.Flipped) { graphics.Control.TranslateCTM(0, Control.Size.Height); graphics.Control.ScaleCTM(Control.Size.Width / destRect.Width, -(Control.Size.Height / destRect.Height)); } else { graphics.Control.ScaleCTM(Control.Size.Width / destRect.Width, Control.Size.Height / destRect.Height); } graphics.Control.DrawImage(new SD.RectangleF(SD.PointF.Empty, destRect.Size), Control.CGImage); //nsimage.CGImage(destRect, CGBlendMode.Normal, 1); graphics.Control.RestoreState(); //var imgportion = nsimage..CGImage.WithImageInRect(sourceRect); /*graphics.Context.SaveState(); * if (graphics.Flipped) { * graphics.Context.TranslateCTM(0, destRect.Bottom); * graphics.Context.ScaleCTM(1.0F, -1.0F); * }*/ //var context = graphics.ControlObject as CGContext; //Console.WriteLine("drawing source:{0} dest:{1}", source, destRect); //graphics.Context.DrawImage(destRect, imgportion); //nsimage = UIImage.FromImage(imgportion); //nsimage.Draw(destRect, CGBlendMode.Normal, 1); //imgportion.Dispose(); //nsimage.Dispose(); //graphics.Context.RestoreState(); } else { //graphics.Context.DrawImage(destRect, nsimage.CGImage); //Console.WriteLine("drawing full image"); Control.Draw(destRect, CGBlendMode.Normal, 1); } }
static void Main(string[] args) { Overlay overlay = new Overlay(); foreach (FieldInfo field in overlay.GetType().GetFields()) { if (typeof(Control).IsAssignableFrom(field.FieldType)) { Control c = field.GetValue(overlay) as Control; if (c != null) { c.Draw(); } } } }
public void Draw(Batcher2D batcher) { SortControlsByInfo(); for (int i = _gumps.Count - 1; i >= 0; i--) { Control g = _gumps[i]; if (g.IsInitialized) { g.Draw(batcher, g.Location); } } GameCursor.Draw(batcher); }
public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination) { var sourceRect = graphics.Translate(source.ToSD(), Control.Size.Height); var destRect = graphics.TranslateView(destination.ToSD(), true, true); graphics.FlipDrawing(); destRect.Y = graphics.ViewHeight - destRect.Y - destRect.Height; if (alpha) { Control.Draw(destRect, sourceRect, NSCompositingOperation.SourceOver, 1); } else { Control.Draw(destRect, sourceRect, NSCompositingOperation.Copy, 1); } }
public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination) { var sourceRect = source.ToSD(); var imgsize = Control.Size; SD.RectangleF destRect = graphics.TranslateView(destination.ToSD(), false); if (source.TopLeft != Point.Empty || sourceRect.Size != imgsize) { graphics.Control.TranslateCTM(destRect.X - sourceRect.X, imgsize.Height - (destRect.Y - sourceRect.Y)); graphics.Control.ScaleCTM(imgsize.Width / sourceRect.Width, -(imgsize.Height / sourceRect.Height)); graphics.Control.DrawImage(new SD.RectangleF(SD.PointF.Empty, destRect.Size), Control.CGImage); } else { Control.Draw(destRect, CGBlendMode.Normal, 1); } }
public void Draw(SpriteBatch spriteBatch) { spriteBatch.Begin(); if (!control.HasFightEnded) { map.Draw(spriteBatch); foreach (Bar bar in bars) { bar.Draw(spriteBatch); } fighter.Draw(spriteBatch); enemy.Draw(spriteBatch); drawNames.Draw(spriteBatch); foreach (GameItem gi in gameItems) { gi.Draw(spriteBatch); } foreach (var atk in attacks) { atk.Draw(spriteBatch); } //test spriteBatch.DrawString(font, "ph: " + playerHealth, playerHealthPos, Color.Black); spriteBatch.DrawString(font, "pm: " + playerMana, playerManaPos, Color.Black); spriteBatch.DrawString(font, "pa: " + playerAtk, playerAtkPos, Color.White); spriteBatch.DrawString(font, "ps: " + playerSpAtk, playerSpAtkPos, Color.White); spriteBatch.DrawString(font, "eh: " + enemyHealth, enemyHealthPos, Color.Black); spriteBatch.DrawString(font, "em: " + enemyMana, enemyManaPos, Color.Black); spriteBatch.DrawString(font, "ea: " + enemyAtk, enemyAtkPos, Color.White); spriteBatch.DrawString(font, "es: " + enemySpAtk, enemySpAtkPos, Color.White); //test spriteBatch.DrawString(font, numberOne, positionOne, Color.White); spriteBatch.DrawString(font, numberTwo, positionTwo, Color.White); spriteBatch.DrawString(font, numberThree, positionThree, Color.White); spriteBatch.DrawString(font, numberFour, positionFour, Color.White); } else { control.Draw(spriteBatch); } spriteBatch.End(); }
public static void CallDrawing(Control guiRoot, GPUContext context, RenderTarget output) { if (context == null || output == null || guiRoot == null) { throw new ArgumentNullException(); } #if UNIT_TEST_COMPILANT throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set."); #else if (Internal_DrawBegin1(context.unmanagedPtr, output.unmanagedPtr)) { throw new InvalidOperationException("Cannot perform GUI rendering."); } guiRoot.Draw(); Internal_DrawEnd(); #endif }
public static void Draw(UltimaBatcher2D batcher) { SortControlsByInfo(); batcher.GraphicsDevice.Clear(Color.Transparent); batcher.Begin(); for (int i = Gumps.Count - 1; i >= 0; i--) { Control g = Gumps[i]; g.Draw(batcher, g.X, g.Y); } GameCursor?.Draw(batcher); batcher.End(); }
public void Draw(Batcher2D batcher) { SortControlsByInfo(); batcher.GraphicsDevice.Clear(Color.Transparent); batcher.Begin(); for (int i = _gumps.Count - 1; i >= 0; i--) { Control g = _gumps[i]; if (g.IsInitialized) { g.Draw(batcher, g.X, g.Y); } } GameCursor?.Draw(batcher); batcher.End(); }
protected void EnsureRep() { if (rep == null) { rep = GetBestRepresentation(); } // on Big Sur, rep is usually going to be a proxy, so let's find the concrete NSBitmapImageRep class the slow way.. if (bmprep != null) { return; } if (rep is IconFrameHandler.LazyImageRep lazyRep) { bmprep = lazyRep.Rep; } else { bmprep = rep as NSBitmapImageRep ?? GetBestRepresentation() as NSBitmapImageRep; } if (bmprep != null) { return; } // go through concrete representations as we might have a proxy (Big Sur) // this is fixed with MonoMac, but not Xamarin.Mac. var representations = Control.Representations(); for (int i = 0; i < representations.Length; i++) { NSImageRep rep = representations[i]; if (rep is NSBitmapImageRep brep) { bmprep = brep; return; } } // create a new bitmap rep and copy the contents var size = Size; int numComponents = rep.HasAlpha ? 4 : 3; int bitsPerComponent = 8; int bitsPerPixel = numComponents * bitsPerComponent; int bytesPerPixel = bitsPerPixel / 8; int bytesPerRow = bytesPerPixel * size.Width; bmprep = new NSBitmapImageRep(IntPtr.Zero, size.Width, size.Height, bitsPerComponent, numComponents, rep.HasAlpha, false, rep.ColorSpaceName, bytesPerRow, bitsPerPixel); var graphicsContext = NSGraphicsContext.FromBitmap(bmprep); NSGraphicsContext.GlobalSaveGraphicsState(); NSGraphicsContext.CurrentContext = graphicsContext; Control.Draw(CGPoint.Empty, new CGRect(CGPoint.Empty, size.ToNS()), NSCompositingOperation.Copy, 1); NSGraphicsContext.GlobalRestoreGraphicsState(); // remove all existing representations for (int i = 0; i < representations.Length; i++) { NSImageRep rep = representations[i]; Control.RemoveRepresentation(rep); } // add the new one back Control.AddRepresentation(bmprep); }
protected override void UpdateLayout() { base.UpdateLayout(); Control.Draw(Control.Geometry); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.SetRenderTarget(renderTarget); GraphicsDevice.Clear(Color.CornflowerBlue); /*spriteBatch.Begin(); * spriteBatch.Draw(tex, Vector2.Zero, Color.White); * spriteBatch.End();*/ var label = new Label { Left = 0, Top = 0, Width = 720, Height = 75, Background = new Color(27, 38, 44), Caption = "Village", Color = new Color(187, 225, 250), Font = header }; label.Draw(spriteBatch); var image = new Image { Left = 0, Top = label.Height, Width = 720, Height = 450, Background = Color.Transparent, Texture = villageBg }; image.Draw(spriteBatch); var items = new[] { "Waterhouse", "Field", "My house" }; var itemSeprator = new Control { Left = 0, Top = image.Top + image.Height, Width = 720, Height = 10, Background = new Color(50, 130, 184) }; itemSeprator.Draw(spriteBatch); var itemControl = new Control { Left = 0, Top = itemSeprator.Top + itemSeprator.Height, Width = 720, Height = 100, Background = new Color(15, 76, 117) }; itemSeprator.Top += itemSeprator.Height + itemControl.Height; for (int i = 0; i < items.Length; ++i) { itemControl.Draw(spriteBatch); itemSeprator.Draw(spriteBatch); var text = new Label { Left = 0, Top = itemControl.Top, Width = 720, Height = itemControl.Height, Background = Color.Transparent, Caption = items[i], Color = new Color(187, 225, 250), Font = listItem }; text.Draw(spriteBatch); itemControl.Top += itemControl.Height + itemSeprator.Height; itemSeprator.Top += itemControl.Height + itemSeprator.Height; } GraphicsDevice.SetRenderTarget(null); spriteBatch.Begin(); spriteBatch.Draw(renderTarget, GraphicsDevice.Viewport.Bounds, Color.White); spriteBatch.End(); base.Draw(gameTime); }
public void Run(Control root) { SDCardManager.Mount(); // load in the system font _systemFont = Font.LoadFromFile("DEJAVU.FNT"); var timer = new Timer(); timer.start(); // for fps info update float lastDebugTime = 0; float lastUpdateTime = 0; string infoString = ""; while (true) { FrameTime = timer.read(); // fixed time step - both for update and draw if (FrameTime - lastUpdateTime >= DeltaTime) { int touches = Touch.GetTouchInfo(); for (int i = 0; i < touches; i++) { // near a touch we have seen recently ? var previous = _activeTouches.Find(x => Math.Abs(x.Position.X - Touch.X[i]) < TouchTrackTolerance && Math.Abs(x.Position.Y - Touch.Y[i]) < TouchTrackTolerance); if (previous == null) { _nextTouchId++; // remember this touch _activeTouches.Add(new TouchInfo { Position = new Point((int)Touch.X[i], (int)Touch.Y[i]), LastSeenTime = FrameTime, Id = _nextTouchId }); // new touch so send message to root control root.SendMessage(UIMessage.TouchStart, new TouchEventArgs(_nextTouchId, new Point((int)Touch.X[i], (int)Touch.Y[i]))); } else { bool hasMoved = (Math.Abs(previous.Position.X - Touch.X[i]) > 0 || Math.Abs(previous.Position.Y - Touch.Y[i]) > 0); // touch seen again - update for tracking previous.Position = new Point((int)Touch.X[i], (int)Touch.Y[i]); previous.LastSeenTime = FrameTime; // moved at all ? if (hasMoved) { root.SendMessage(UIMessage.TouchMove, new TouchEventArgs(previous.Id, previous.Position)); } } } // get rid of old touches for (int i = _activeTouches.Count - 1; i >= 0; i--) { if (FrameTime - _activeTouches[i].LastSeenTime > 0.1f) { root.SendMessage(UIMessage.TouchEnd, new TouchEventArgs(_activeTouches[i].Id, _activeTouches[i].Position)); _activeTouches.RemoveAt(i); } } lastUpdateTime = FrameTime; Display.Clear(0xFFFFFFFF); root.Update(DeltaTime); root.Draw(); if (ShowDebug) { // show debug info every couple of seconds if (timer.read_ms() - lastDebugTime > 2.0f) { // string.format broken? //infoString = String.Format("FPS: {0} MEMAVAIL: {1} MEMALOC: {2}", // Display.Fps, // Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory, // Microsoft.Zelig.Runtime.MemoryManager.Instance.AllocatedMemory); infoString = "FPS: " + Display.Fps.ToString() + " MEMAVAIL: " + Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory.ToString(); lastDebugTime = timer.read(); } //Display.DrawString(infoString, 0, 0); } // show the back buffer Display.Flip(); } } }