/// <summary> /// Updates the states of the connected touch devices. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> public void Update(UltravioletTime time) { foreach (var device in devices) { device.Update(time); } }
/// <summary> /// Draws the contents of the queue. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Draw(UltravioletTime)"/>.</param> /// <param name="dc">The drawing context that describes the render state of the layout.</param> public void Draw(UltravioletTime time, DrawingContext dc) { if (queue.Count == 0) return; position = null; while (true) { position = (position == null) ? queue.First : position.Next; next = position.Next; var popup = position.Value; dc.Reset(popup.View.Display); popup.EnsureIsLoaded(true); popup.Draw(time, dc); if (position.Next == null) break; } position = null; next = null; }
/// <summary> /// Updates the sprite's default animation controllers. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> public void Update(UltravioletTime time) { foreach (var animation in animations) { animation.Controller.Update(time); } }
/// <inheritdoc/> public override void Update(UltravioletTime time) { Contract.EnsureNotDisposed(this, Disposed); UpdateView(time); UpdateTransition(time); OnUpdating(time); }
/// <inheritdoc/> protected override void OnDrawing(UltravioletTime time, DrawingContext dc) { DrawBlank(dc, new RectangleD(-HalfBoxSize, -HalfBoxSize, FullBoxSize, FullBoxSize), Color.Red); DrawBlank(dc, new RectangleD(AdornedElement.RenderSize.Width - HalfBoxSize, -HalfBoxSize, FullBoxSize, FullBoxSize), Color.Lime); DrawBlank(dc, new RectangleD(-8, AdornedElement.RenderSize.Height - HalfBoxSize, FullBoxSize, FullBoxSize), Color.Blue); DrawBlank(dc, new RectangleD(AdornedElement.RenderSize.Width - HalfBoxSize, AdornedElement.RenderSize.Height - HalfBoxSize, FullBoxSize, FullBoxSize), Color.Magenta); base.OnDrawing(time, dc); }
/// <inheritdoc/> public void Update(UltravioletTime time) { Contract.EnsureNotDisposed(this, Disposed); this.keyboard.Update(time); this.mouse.Update(time); this.gamePadInfo.Update(time); this.touchInfo.Update(time); OnUpdating(time); }
/// <summary> /// Updates the subsystem's state. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> public void Update(UltravioletTime time) { Contract.EnsureNotDisposed(this, Disposed); foreach (var stack in screenStacks) { stack.Update(time); } OnUpdating(time); }
/// <inheritdoc/> public override void Draw(UltravioletTime time, SpriteBatch spriteBatch) { Contract.Require(spriteBatch, "spriteBatch"); Contract.EnsureNotDisposed(this, Disposed); if (!IsOnCurrentWindow) return; OnDrawingBackground(time, spriteBatch); DrawView(time, spriteBatch); OnDrawingForeground(time, spriteBatch); }
/// <inheritdoc/> protected override void OnUpdating(UltravioletTime time) { // ACTION: Save Image if (Ultraviolet.GetInput().GetActions().SaveImage.IsPressed() || (Ultraviolet.GetInput().GetTouchDevice()?.WasTapped() ?? false)) { content.Load <SoundEffect>(GlobalSoundEffectID.Shutter).Play(); // The SurfaceSaver class contains platform-specific functionality needed to write image // data to files. We can pass a render target directly to the SaveAsPng() or SaveAsJpg() methods. var saver = SurfaceSaver.Create(); var filename = $"output-{DateTime.Now:yyyyMMdd-HHmmss}.png"; var path = filename; #if ANDROID var dir = Android.OS.Environment.GetExternalStoragePublicDirectory( Android.OS.Environment.DirectoryPictures).AbsolutePath; path = Path.Combine(dir, filename); #endif using (var stream = File.OpenWrite(path)) saver.SaveAsPng(rtarget, stream); #if ANDROID Android.Media.MediaScannerConnection.ScanFile(ApplicationContext, new String[] { path }, new String[] { Android.Webkit.MimeTypeMap.Singleton.GetMimeTypeFromExtension("png") }, null); confirmMsgText = $"Image saved to photo gallery"; confirmMsgOpacity = 1; #else confirmMsgText = $"Image saved to {filename}"; confirmMsgOpacity = 1; #endif // Alternatively, we could populate an array with the target's data using the GetData() method... // var data = new Color[rtarget.Width * rtarget.Height]; // rtarget.GetData(data); } // ACTION: Exit Application if (Ultraviolet.GetInput().GetActions().ExitApplication.IsPressed()) { Exit(); } // Fade out save confirmation message if (confirmMsgOpacity > 0) { confirmMsgOpacity -= (1.0 / 4.0) * time.ElapsedTime.TotalSeconds; } base.OnUpdating(time); }
/// <inheritdoc/> protected override void DrawOverride(UltravioletTime time, DrawingContext dc) { if (textLayoutCommands != null && textLayoutCommands.Count > 0 && containingControl != null) { var positionRaw = Display.DipsToPixels(UntransformedAbsolutePosition + ContentOffset); var positionX = dc.IsTransformed ? positionRaw.X : Math.Floor(positionRaw.X); var positionY = dc.IsTransformed ? positionRaw.Y : Math.Floor(positionRaw.Y); var position = new Vector2((Single)positionX, (Single)positionY); View.Resources.TextRenderer.Draw((SpriteBatch)dc, textLayoutCommands, position, containingControl.Foreground * dc.Opacity); } base.DrawOverride(time, dc); }
protected override void OnUpdating(UltravioletTime time) { spinnerSprite.Update(time); if (loader.IsLoaded) { var screen = uiScreenService.Get <GameplayScreen>(); Screens.OpenBelow(screen, this); Screens.Close(this); } base.OnUpdating(time); }
/// <summary> /// Updates the screen stack's state. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> public void Update(UltravioletTime time) { RemoveClosedScreensFromStack(); for (var current = screens.First; current != null; current = current.Next) { current.Value.Update(time); } RemoveClosedScreensFromStack(); UpdatePendingOpenings(); }
/// <inheritdoc/> protected override void OnDigesting(UltravioletTime time) { var children = Children; if (children != null) { foreach (var child in children) { child.Digest(time); } } base.OnDigesting(time); }
/// <summary> /// Draws the screens in the stack. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Draw(UltravioletTime)"/>.</param> /// <param name="spriteBatch">The <see cref="SpriteBatch"/> with which to draw the screen stack's screens.</param> public void Draw(UltravioletTime time, SpriteBatch spriteBatch) { Contract.Require(spriteBatch, nameof(spriteBatch)); if (screens.Count > 0) { spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); for (var screen = FindFirstScreenToRender(); screen != null; screen = screen.Next) { screen.Value.Draw(time, spriteBatch); } spriteBatch.End(); } }
public void UpdateCamera(UltravioletTime time) { if (moveCamera) { if (-camera.Position.Y >= cameraTargetPosition * screenScale.X) { CameraMovementDone(); } else { camera.Move(new Vector2f(0, cameraSpeed * (float)time.ElapsedTime.TotalSeconds)); } } }
protected override void OnDrawing(UltravioletTime time) { spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); spriteBatch.DrawSprite(this.sprite["Explosion"].Controller, new Vector2(32, 32)); spriteBatch.DrawSprite(controller1, new Vector2(132, 32)); spriteBatch.DrawSprite(controller2, new Vector2(232, 32)); spriteBatch.DrawSprite(controller3, new Vector2(332, 32)); spriteBatch.DrawSprite(controller4, new Vector2(432, 32)); spriteBatch.End(); base.OnDrawing(time); }
public override void ImGuiUpdate(UltravioletTime time) { FontAsset asset = GetFirstAssetOfType <FontAsset>(); ImGui.SetNextWindowBgAlpha(0); ImGui.SetNextWindowPos(Entity.Transform.ToVector2()); if (ImGui.Begin(Text, ImGuiFlagsPresets.InvisibleWindow)) { ImGui.PushFont(asset.ImGuiID); ImGui.TextColored(Color, Text); ImGui.PopFont(); ImGui.End(); } }
/// <summary> /// Updates the value's animation state when using a simple animation. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> private void UpdateSimpleAnimation(UltravioletTime time) { var factor = (Single)(animationClock.ElapsedTime.TotalMilliseconds / animationClock.Duration.TotalMilliseconds); var valueStart = animatedHandOffValue; var valueEnd = animatedTargetValue; var valueInterpolated = Tweening.Tween(valueStart, valueEnd, animationEasing, factor); if (IsCoerced) { valueInterpolated = metadata.CoerceValue <T>(owner, valueInterpolated); } animatedValue = valueInterpolated; }
/// <summary> /// Updates the clock's state. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> public void Update(UltravioletTime time) { if (!IsValid || state != ClockState.Playing) { return; } total += time.ElapsedTime.TotalMilliseconds; var duration = Duration.TotalMilliseconds; var elapsedUpdated = elapsed + (delta * time.ElapsedTime.TotalMilliseconds); var elapsedClamped = (elapsedUpdated < 0) ? 0 : elapsedUpdated > duration ? duration : elapsedUpdated; if (elapsedUpdated < 0 || elapsedUpdated >= duration) { switch (LoopBehavior) { case LoopBehavior.None: elapsed = elapsedClamped; delta = 1.0; break; case LoopBehavior.Loop: elapsed = elapsedClamped % duration; delta = 1.0; break; case LoopBehavior.Reverse: { var remaining = elapsedUpdated < 0 ? Math.Abs(elapsedUpdated) : elapsedUpdated - duration; var distributed = 0.0; while (remaining > 0) { distributed = Math.Min(remaining, duration); delta = -delta; elapsedClamped += (delta * distributed); remaining -= distributed; } } elapsed = elapsedClamped; break; } } else { elapsed = elapsedUpdated; } }
/// <inheritdoc/> public override void Update(UltravioletTime time) { Contract.EnsureNotDisposed(this, Disposed); FinishLoadingView(); if (View != null && State != UIPanelState.Closed) { UpdateViewPosition(); UpdateView(time); } UpdateTransition(time); OnUpdating(time); }
protected override void OnDrawing(UltravioletTime time) { var gfx = Ultraviolet.GetGraphics(); gfx.Clear(new Color(222, 206, 206)); var viewMatrix = camera.GetTransform(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, null, viewMatrix * Matrix.CreateScale(screenScale)); _current.Draw(spriteBatch); var settings = new TextLayoutSettings(Trebuchet, null, null, TextFlags.Standard); tr.Draw(spriteBatch, "|shader:wavy|Hallo Welt ich teste gerade |shader:shaky|glyph shaders|shader| !!!", new Vector2(100, 100), Color.White, settings); spriteBatch.End(); base.OnDrawing(time); }
public static void DrawSprites(UltravioletTime time) { _spriteBatch.Begin(SpriteSortMode.BackToFront, Ultraviolet.Graphics.BlendState.AlphaBlend); foreach (var sprite in _spritesToDraw) { _spriteBatch.DrawSprite(sprite.Controller, sprite.Entity.Transform.ToVector2(), null, null, Color.White, 0, SpriteEffects.None, sprite.Entity.Transform.depth); if (_debugHitbox) { DisplayHitbox(sprite); } } _spriteBatch.End(); _spritesToDraw.Clear(); }
protected override void OnUpdating(UltravioletTime time) { if (IsReadyForInput) { var input = Ultraviolet.GetInput(); var keyboard = input.GetKeyboard(); var touch = input.GetPrimaryTouchDevice(); if (keyboard.IsKeyPressed(Key.Left) || (touch != null && touch.WasTapped())) { Screens.Close(this); } } base.OnUpdating(time); }
protected override void OnDrawingForeground(UltravioletTime time, SpriteBatch spriteBatch) { spriteBatch.Draw(blankTexture, new RectangleF(0, 0, Width, Height), new Color(180, 0, 0)); #if ANDROID var text = "This is SampleScreen1\nTap to open SampleScreen2"; #else var text = "This is SampleScreen1\nPress right arrow key to open SampleScreen2"; #endif var settings = new TextLayoutSettings(font, Width, Height, TextFlags.AlignCenter | TextFlags.AlignMiddle); textRenderer.Draw(spriteBatch, text, Vector2.Zero, Color.White * TransitionPosition, settings); base.OnDrawingForeground(time, spriteBatch); }
protected override void OnDrawing(UltravioletTime time) { Size2 size = Ultraviolet.GetPlatform().Windows.GetCurrent().ClientSize; animator.Position = new Vector2(size.Width, size.Height) / 2; spriteBatch.Begin(); animator.Draw(spriteBatch); spriteBatch.DrawString(spriteFont, textBuffer, new Vector2(size.Width - 150, 10), Color.White); spriteBatch.DrawString(spriteFont, Constants.KeyBindings, Vector2.One * 8, Color.White); spriteBatch.DrawString(spriteFont, status, new Vector2(10, size.Height - 50), Color.Black); spriteBatch.DrawString(spriteFont, metadata, new Vector2(size.Width - 300, size.Height * 0.5f), Color.Black); spriteBatch.End(); base.OnDrawing(time); }
/// <inheritdoc/> public void Update(UltravioletTime time) { Contract.EnsureNotDisposed(this, Disposed); var result = default(FMOD_RESULT); result = FMOD_System_Update(system); if (result != FMOD_OK) { throw new FMODException(result); } UpdateAudioDevices(); Updating?.Invoke(this, time); }
/// <inheritdoc/> protected override void OnUpdating(UltravioletTime time) { RunFrameActions(FrameActionType.Update, updateCount, time); if (framesToSkip == 0) { if (shouldExit()) { Exit(); } } updateCount++; base.OnUpdating(time); }
protected override void OnUpdating(UltravioletTime time) { if (IsReadyForInput) { var input = Ultraviolet.GetInput(); var keyboard = input.GetKeyboard(); var touch = input.GetTouchDevice(); if (keyboard.IsKeyPressed(Key.Right) || (touch != null && touch.WasTapped())) { var screen = uiScreenService.Get <SampleScreen2>(); Screens.Open(screen); } } base.OnUpdating(time); }
/// <summary> /// Updates the clock's state. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> public void Update(UltravioletTime time) { if (!IsValid || state != ClockState.Playing) return; total += time.ElapsedTime.TotalMilliseconds; var duration = Duration.TotalMilliseconds; var elapsedUpdated = elapsed + (delta * time.ElapsedTime.TotalMilliseconds); var elapsedClamped = (elapsedUpdated < 0) ? 0 : elapsedUpdated > duration ? duration : elapsedUpdated; if (elapsedUpdated < 0 || elapsedUpdated >= duration) { switch (LoopBehavior) { case LoopBehavior.None: elapsed = elapsedClamped; delta = 1.0; break; case LoopBehavior.Loop: elapsed = elapsedClamped % duration; delta = 1.0; break; case LoopBehavior.Reverse: { var remaining = elapsedUpdated < 0 ? Math.Abs(elapsedUpdated) : elapsedUpdated - duration; var distributed = 0.0; while (remaining > 0) { distributed = Math.Min(remaining, duration); delta = -delta; elapsedClamped += (delta * distributed); remaining -= distributed; } } elapsed = elapsedClamped; break; } } else { elapsed = elapsedUpdated; } }
/// <summary> /// Called when the application's scene is being drawn. /// </summary> /// <param name="time">Time elapsed since the last call to Draw.</param> protected override void OnDrawing(UltravioletTime time) { var gfx = Ultraviolet.GetGraphics(); var window = Ultraviolet.GetPlatform().Windows.GetCurrent(); var aspectRatio = window.DrawableSize.Width / (Single)window.DrawableSize.Height; effect.World = Matrix.CreateRotationY((float)(2.0 * Math.PI * (time.TotalTime.TotalSeconds / 10.0))); effect.View = Matrix.CreateLookAt(new Vector3(0, 3, 6), new Vector3(0, 0.75f, 0), Vector3.Up); effect.Projection = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4f, aspectRatio, 1f, 1000f); gfx.SetGeometryStream(geometryStream); void DrawGeometry(RasterizerState rasterizerState, DepthStencilState depthStencilState) { foreach (var pass in this.effect.CurrentTechnique.Passes) { pass.Apply(); gfx.SetRasterizerState(rasterizerState); gfx.SetDepthStencilState(depthStencilState); gfx.DrawPrimitives(PrimitiveType.TriangleList, 0, vertexBuffer.VertexCount / 3); //gfx.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, indexBuffer.IndexCount / 3); } } effect.FogColor = Color.Red; effect.PreferPerPixelLighting = true; effect.LightingEnabled = true; effect.SrgbColor = false; effect.VertexColorEnabled = false; effect.DiffuseColor = Color.White; effect.TextureEnabled = false; effect.Texture = texture; DrawGeometry(rasterizerStateSolid, DepthStencilState.Default); if (!gl.IsGLES) { effect.LightingEnabled = false; effect.FogEnabled = false; effect.VertexColorEnabled = false; effect.DiffuseColor = Color.Black; effect.TextureEnabled = false; DrawGeometry(rasterizerStateWireframe, DepthStencilState.None); } base.OnDrawing(time); }
/// <inheritdoc/> protected override void DrawOverride(UltravioletTime time, DrawingContext dc) { var font = Font; if (font.IsLoaded) { View.Resources.StringFormatter.Reset(); View.Resources.StringFormatter.AddArgument(Value); View.Resources.StringFormatter.Format(Format ?? "{0}", View.Resources.StringBuffer); var face = font.Resource.Value.GetFace(FontStyle); var position = Display.DipsToPixels(UntransformedAbsolutePosition); var positionRounded = dc.IsTransformed ? (Vector2)position : (Vector2)(Point2)position; dc.DrawString(face, View.Resources.StringBuffer, positionRounded, Foreground); } base.DrawOverride(time, dc); }
protected override void OnDrawing(UltravioletTime time) { var winSize = Ultraviolet.GetPlatform().Windows.GetPrimary().DrawableSize; var x = 0; var y = 0; var width = winSize.Width / 4; var height = winSize.Height; for (int i = 0; i < 4; i++) { DrawGamePadState(i, new Rectangle(x, y, width, height)); x += width; } base.OnDrawing(time); }
/// <inheritdoc/> protected override void DrawOverride(UltravioletTime time, DrawingContext dc) { var percent = 1.0; var parent = TemplatedParent as RangeBase; if (parent != null) { percent = (parent.Value - parent.Minimum) / (parent.Maximum - parent.Minimum); } var area = new RectangleD(0, 0, RenderSize.Width * percent, RenderSize.Height); DrawImage(dc, Source, area, SourceColor); base.DrawOverride(time, dc); }
protected override void OnDrawingForeground(UltravioletTime time, SpriteBatch spriteBatch) { var offset = GetScreenOffset(); spriteBatch.Draw(blankTexture, new RectangleF(offset, 0, Width, Height), new Color(0, 0, 180)); #if ANDROID || IOS var text = "This is SampleScreen2\nTap to open SampleScreen1"; #else var text = "This is SampleScreen2\nPress left arrow key to open SampleScreen1"; #endif var settings = new TextLayoutSettings(font, Width, Height, TextFlags.AlignCenter | TextFlags.AlignMiddle); textRenderer.Draw(spriteBatch, text, new Vector2(offset, 0), Color.White, settings); base.OnDrawingForeground(time, spriteBatch); }
/// <summary> /// Checks to determine whether the property's underlying value has changed, /// and if so, handles it appropriately. /// </summary> private void CheckForChanges(UltravioletTime time = null) { var original = GetValue(); if (IsAnimated && time != null) { UpdateAnimation(time); } var value = default(T); var potentiallyChanged = false; if (cachedBoundValue != null) { if (cachedBoundValue.CheckHasChanged() || IsCoercedValueDifferentFromCachedBoundValue()) { value = cachedBoundValue.Get(); potentiallyChanged = true; } } else { value = GetValue(); potentiallyChanged = !Compare(value, previousValue); } if (potentiallyChanged) { var oldValue = original; var newValue = value; if (IsCoerced) { coercedValue = metadata.CoerceValue(owner, value); potentiallyChanged = !Compare(coercedValue, original); newValue = coercedValue; } var definitelyChanged = potentiallyChanged; if (definitelyChanged) { HandleChanged(oldValue, newValue); } } previousValue = value; }
public virtual void Update(UltravioletTime time) { var moved = false; if (Effect != null) { Effect.Animate(this, time); moved = true; } if (moved) { DrawPosition = new Vector2(Pos.X, Pos.Y); TargetRect = GetTargetRect(); } UpdateAnimation(time); }
public virtual void Update(UltravioletTime time) { if (done) { return; } Vector2f playerPos = Player.getPlayer().position + new Vector2f(scale / 2, scale / 2); Vector2f next; if (playerPos.X >= borders.X && playerPos.X <= borders.Y) { next = Player.getPlayer().position + Resources.deltaTime * Player.getPlayer().velocity; if (next.Y > position - scale / 2 && next.Y <= position) { Player.getPlayer().SetCurrLine(position - scale / 2, this); } } }
/// <summary> /// Updates the value's animation state. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> private void UpdateAnimation(UltravioletTime time) { var animState = GetAnimationState(false); if (animState == null) { return; } if (animState.Animation != null) { UpdateStoryboardAnimation(time); } else { UpdateSimpleAnimation(time); } }
/// <summary> /// Updates the active clock instances when the UI subsystem is updated. /// </summary> private void StoryboardClockPool_Updating(IUltravioletSubsystem subsystem, UltravioletTime time) { if (pool == null) { return; } var upf = Ultraviolet.GetUI().GetPresentationFoundation(); upf.PerformanceStats.BeginUpdate(); pool.Update(time, (value, state) => { value.Value.Update((UltravioletTime)state); }); upf.PerformanceStats.EndUpdate(); }
/// <inheritdoc/> public override void Draw(UltravioletTime time, SpriteBatch spriteBatch, Single opacity = 1) { if (imGuiContext != IntPtr.Zero) { var spriteBatchState = spriteBatch.GetCurrentState(); spriteBatch.End(); ImGui.SetCurrentContext(imGuiContext); ImGui.Render(); var drawDataPtr = ImGui.GetDrawData(); imGuiGeometry.Draw(ref drawDataPtr); (Panel as IImGuiPanel)?.ImGuiDraw(time); spriteBatch.Begin(spriteBatchState); } }
/// <inheritdoc/> protected override void DrawOverride(UltravioletTime time, DrawingContext dc) { /* NOTE: * By pre-emptively setting the clip region in the Grid itself, we can prevent * multiple batch flushes when drawing consecutive children within the same clip region. * This is because DrawingContext evaluates the current clip state and only performs * a flush if something has changed. */ var clip = (RectangleD?)null; for (int i = 0; i < Children.Count; i++) { var child = Children.GetByZOrder(i); if (child.ClipRectangle != clip) { if (clip.HasValue) { clip = null; dc.PopClipRectangle(); } if (child.ClipRectangle.HasValue) { clip = child.ClipRectangle; dc.PushClipRectangle(clip.Value); } } child.Draw(time, dc); } if (clip.HasValue) dc.PopClipRectangle(); }
/// <inheritdoc/> public void Update(UltravioletTime time) { Contract.EnsureNotDisposed(this, Disposed); OnUpdating(time); }
/// <summary> /// Raises the <see cref="Updating"/> event. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> private void OnUpdating(UltravioletTime time) { var temp = Updating; if (temp != null) { temp(this, time); } }
/// <summary> /// Updates the player's state. /// </summary> /// <param name="time">Time elapsed since the last update.</param> public override void Update(UltravioletTime time) { Contract.EnsureNotDisposed(this, Disposed); }
/// <inheritdoc/> protected override void UpdateOverride(UltravioletTime time) { if (View != null && !View.IsInputEnabledAndAllowed) { IsPressed = false; } base.UpdateOverride(time); }
/// <summary> /// Raises the Updating event. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> private void OnUpdating(UltravioletTime time) => Updating?.Invoke(this, time);
/// <inheritdoc/> protected override void DrawOverride(UltravioletTime time, DrawingContext dc) { if (textLayoutCommands != null && textLayoutCommands.Count > 0 && containingControl != null) { var positionRaw = Display.DipsToPixels(UntransformedAbsolutePosition + ContentOffset); var positionX = dc.IsTransformed ? positionRaw.X : Math.Round(positionRaw.X, MidpointRounding.AwayFromZero); var positionY = dc.IsTransformed ? positionRaw.Y : Math.Round(positionRaw.Y, MidpointRounding.AwayFromZero); var position = new Vector2((Single)positionX, (Single)positionY); View.Resources.TextRenderer.Draw((SpriteBatch)dc, textLayoutCommands, position, containingControl.Foreground * dc.Opacity); } base.DrawOverride(time, dc); }
/// <inheritdoc/> protected override void DrawOverride(UltravioletTime time, DrawingContext dc) { if (View.Popups.IsDrawingPopup(this)) { root.Draw(time, dc); } else { EnqueueForDrawingIfOpen(time, dc); } }
/// <summary> /// Updates the active clock instances when the UI subsystem is updated. /// </summary> private void StoryboardClockPool_Updating(IUltravioletSubsystem subsystem, UltravioletTime time) { if (pool == null) return; var upf = Ultraviolet.GetUI().GetPresentationFoundation(); upf.PerformanceStats.BeginUpdate(); pool.Update(time, (value, state) => { value.Value.Update((UltravioletTime)state); }); upf.PerformanceStats.EndUpdate(); }
/// <summary> /// Updates the device's state. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Update(UltravioletTime)"/>.</param> public abstract void Update(UltravioletTime time);
/// <inheritdoc/> protected override void DrawOverride(UltravioletTime time, DrawingContext dc) { var borderColor = BorderColor; var borderThickness = BorderThickness; var borderArea = new RectangleD(0, 0, UntransformedRelativeBounds.Width, UntransformedRelativeBounds.Height); var leftSize = Math.Min(borderThickness.Left, borderArea.Width); if (leftSize > 0) { var leftArea = new RectangleD(borderArea.Left, borderArea.Top, leftSize, borderArea.Height); DrawBlank(dc, leftArea, borderColor); } var topSize = Math.Min(borderThickness.Top, borderArea.Height); if (topSize > 0) { var topArea = new RectangleD(borderArea.Left, borderArea.Top, borderArea.Width, topSize); DrawBlank(dc, topArea, borderColor); } var rightSize = Math.Min(borderThickness.Right, borderArea.Width); if (rightSize > 0) { var rightPos = Math.Max(borderArea.Left, borderArea.Right - rightSize); var rightArea = new RectangleD(rightPos, borderArea.Top, rightSize, borderArea.Height); DrawBlank(dc, rightArea, borderColor); } var bottomSize = Math.Min(borderThickness.Bottom, borderArea.Height); if (bottomSize > 0) { var bottomPos = Math.Max(borderArea.Top, borderArea.Bottom - bottomSize); var bottomArea = new RectangleD(borderArea.Left, bottomPos, borderArea.Width, bottomSize); DrawBlank(dc, bottomArea, borderColor); } base.DrawOverride(time, dc); }
/// <inheritdoc/> protected override void OnDrawing(UltravioletTime time) { if (framesToSkip == 0) { Ultraviolet.GetGraphics().SetRenderTarget(rtarget); Ultraviolet.GetGraphics().Clear(Color.Black); if (renderer != null) { renderer(Ultraviolet); } Ultraviolet.GetGraphics().SetRenderTarget(null); bmp = ConvertRenderTargetToBitmap(rtarget); } else { framesToSkip--; } base.OnDrawing(time); }
/// <inheritdoc/> protected override void OnUpdating(UltravioletTime time) { if (framesToSkip == 0) { if (shouldExit()) { Exit(); } } base.OnUpdating(time); }
/// <summary> /// If the popup is currently open, this method adds it to the view's popup queue for drawing. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Draw(UltravioletTime)"/>.</param> /// <param name="dc">The drawing context that describes the render state of the layout.</param> internal void EnqueueForDrawingIfOpen(UltravioletTime time, DrawingContext dc) { if (!IsOpen) return; EnqueueForDrawing(time, dc); }
/// <inheritdoc/> public override void Draw(UltravioletTime time, SpriteBatch spriteBatch) { Contract.Require(spriteBatch, nameof(spriteBatch)); Contract.EnsureNotDisposed(this, Disposed); if (!IsOnCurrentWindow) return; OnDrawingBackground(time, spriteBatch); Window.Compositor.BeginContext(CompositionContext.Interface); FinishLoadingView(); if (View != null) { DrawView(time, spriteBatch); OnDrawingView(time, spriteBatch); } Window.Compositor.BeginContext(CompositionContext.Overlay); OnDrawingForeground(time, spriteBatch); }
/// <summary> /// Adds the popup to the view's popup queue for drawing. /// </summary> /// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Draw(UltravioletTime)"/>.</param> /// <param name="dc">The drawing context that describes the render state of the layout.</param> internal void EnqueueForDrawing(UltravioletTime time, DrawingContext dc) { if (View.Popups.IsDrawingPopup(this)) return; View.Popups.Enqueue(this); }
/// <inheritdoc/> protected override void DrawOverride(UltravioletTime time, DrawingContext dc) { if (textLayoutCommands != null && textLayoutCommands.Count > 0 && containingControl != null) { var position = Display.DipsToPixels(UntransformedAbsolutePosition + ContentOffset); var positionRounded = dc.IsTransformed ? (Vector2)position : (Vector2)(Point2)position; View.Resources.TextRenderer.Draw((SpriteBatch)dc, textLayoutCommands, positionRounded, containingControl.Foreground * dc.Opacity); } base.DrawOverride(time, dc); }
/// <inheritdoc/> protected override void UpdateOverride(UltravioletTime time) { base.UpdateOverride(time); root.Update(time); }