protected void DrawHintAndInput() { if (!Experiment.Config.Gui.InputBarVisibility) { return; } /* Draw Hint */ if (HintText != null) { SharedBrush.Color = new Color(ForegroundColor.ToVector3(), 0.7F); RenderTarget.DrawText(HintText, InputTextFormat, new RawRectangleF(10, 0, Width - 10, InputBoxHeight / 2), SharedBrush, D2D1.DrawTextOptions.None); } /* Draw user input text */ if (InputTextLayout != null) { var rect = HintText == null ? new RawRectangleF(10, 5, Width - 10, InputBoxHeight - 5) : new RawRectangleF(10, InputBoxHeight / 2, Width - 10, InputBoxHeight); InputTextLayout.MaxWidth = rect.Right - rect.Left; InputTextLayout.MaxHeight = rect.Bottom - rect.Top; InputTextLayout.Draw(_customColorRenderer, rect.Left, rect.Top); } /* Draw Input Box Bottom Line */ SharedBrush.Color = ForegroundColor; RenderTarget.DrawLine(new RawVector2(10, InputBoxHeight + 2), new RawVector2(Width - 10, InputBoxHeight + 2), SharedBrush, 2); }
public override void Draw(GameTime gameTime, IDrawContext drawContext) { // todo: 先に LaF を描画。 base.Draw(gameTime, drawContext); if (!CubeVisible) { return; } drawContext.Flush(); // わざと Control の領域を越えるように調整。 var renderSize = RenderSize; renderSize.Width += 64; renderSize.Height += 64; using (var setViewport = drawContext.BeginViewport(new Rect(-32, -32, renderSize.Width, renderSize.Height))) { using (var setClip = drawContext.BeginNewClip(new Rect(-32, -32, renderSize.Width, renderSize.Height))) { var effect = Screen.BasicEffect; var cameraPosition = new Vector3(0, 0, 2.5f); var aspect = ((float)renderSize.Width / (float)renderSize.Height); effect.World = Orientation * Matrix.CreateScale(Scale); effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up); effect.Projection = Matrix.CreatePerspectiveFieldOfView(1, aspect, 0.1f, 10); effect.DiffuseColor = ForegroundColor.ToVector3(); // どうもデフォルトで Specular が設定されているようだ。 effect.SpecularColor = Color.Black.ToVector3(); effect.Alpha = 1; effect.EnableDefaultLighting(); effect.VertexColorEnabled = true; CubePrimitive.Draw(effect); } } }
protected override void OnDraw() { RenderTarget.Clear(BackgroundColor); if (ExperimentStarted) { DrawHintAndInput(); var debug = Experiment.Config.Test.Debug; var now = CurrentTime; var trial = _trial; var secsPassed = (now - trial?.StartTime) / 1000.0 ?? 0; /* Draw buttons */ foreach (var button in Buttons) { if (button == null) { continue; } var scheme = button.State < 0 ? null : _stimulationPatterns[button.State]; var actived = scheme != null && trial != null; if (button.BorderWidth > 0) { SharedBrush.Color = ButtonBorderColor; RenderTarget.FillRectangle(button.BorderRect, SharedBrush); } SharedBrush.Color = ButtonNormalColor; RenderTarget.FillRectangle(button.ContentRect, SharedBrush); if (actived) { var progress = (float)Math.Max(0, Math.Min(scheme.Sample(secsPassed), 1)); var color = Color.SmoothStep(ButtonNormalColor, ButtonFlashingColor, progress); // var radialGradientBrush = new D2D1.RadialGradientBrush(_renderTarget, new D2D1.RadialGradientBrushProperties // { // Center = button.Center, // RadiusX = button.Size.X / 2, // RadiusY = button.Size.Y / 2, // }, new D2D1.GradientStopCollection(_renderTarget, new[] // { // new D2D1.GradientStop // { // Position = 0, // Color = color // }, // new D2D1.GradientStop // { // Position = 0.6F, // Color = Color.SmoothStep(color, _buttonFlashingColor, 0.1F) // }, // new D2D1.GradientStop // { // Position = 1, // Color = _buttonNormalColor // }, // }, D2D1.ExtendMode.Clamp)); SharedBrush.Color = color; RenderTarget.FillRectangle(button.FlickerRect, SharedBrush); } else if (HintedButton == button) { SharedBrush.Color = ButtonHintColor; RenderTarget.FillRectangle(button.FlickerRect, SharedBrush); } if (button.Key.Name.IsNotEmpty()) { var brush = button == SelectedButton ? (SelectionFeedbackCorrect ? CorrectColorBrush : WrongColorBrush) : ForegroundBrush; RenderTarget.DrawText(button.Key.Name, ButtonLabelTextFormat, button.ContentRect, brush, D2D1.DrawTextOptions.None); } if (actived && button.FixationPointSize > 0) { SharedBrush.Color = ButtonFixationPointColor; RenderTarget.FillEllipse(button.FixationPoint, SharedBrush); } if (debug && scheme != null) { SharedBrush.Color = new Color(ForegroundColor.ToVector3(), 0.6F); RenderTarget.DrawText(scheme.ToString(), _frequencyTextFormat, button.ContentRect, SharedBrush, D2D1.DrawTextOptions.None); } } } DrawCueAndSubtitle(); }