Exemple #1
0
 // I/F
 public virtual void Draw(Control control, IDrawContext drawContext)
 {
     if (Texture != null)
     {
         drawContext.DrawTexture(new Rect(control.RenderSize), Texture, Color);
     }
 }
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            DrawGrid(drawContext);
            DrawElements(drawContext);
        }
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            var rect = new Rect();

            rect.Width  = RenderSize.Width;
            rect.Height = 1;
            drawContext.DrawRectangle(rect, GridColor);

            rect.Y = RenderSize.Height - 1;
            drawContext.DrawRectangle(rect, GridColor);

            rect.Y      = 0;
            rect.Width  = 1;
            rect.Height = RenderSize.Height;
            for (int i = 0; i <= 16; i++)
            {
                rect.X = CellSize * i;
                drawContext.DrawRectangle(rect, GridColor);
            }

            rect.Width  = CellSize - 1;
            rect.Height = CellSize - 1;
            rect.X      = CellSize * Section.Index + 1;
            rect.Y      = 1;
            drawContext.DrawRectangle(rect, CursorColor);
        }
        void DrawElements(IDrawContext drawContext)
        {
            var rect = new Rect
            {
                Width  = CellSize - 1,
                Height = CellSize - 1
            };

            for (int y = 0; y < gridSize; y++)
            {
                rect.Y = CellSize * y + 1;
                for (int x = 0; x < gridSize; x++)
                {
                    var material = Section.GetMaterial(x, y);
                    if (material == null)
                    {
                        continue;
                    }

                    rect.X = CellSize * x + 1;
                    var color = material.DiffuseColor.ToColor();

                    drawContext.DrawRectangle(rect, color);
                }
            }
        }
Exemple #5
0
        protected override void DrawBackground(
            IDrawContext drawContext,
            Rectangle bounds)
        {
            Rectangle textBounds = new Rectangle(bounds.X, bounds.Y, bounds.Width, bounds.Height);

            if (this.IsEnabled)
            {
                base.DrawBackground(drawContext, bounds);

                var foregroundColor = this.ForegroundColor;
                if (foregroundColor.HasValue)
                {
                    drawContext.DrawText(this.Text, textBounds, foregroundColor.Value, this._textFormat);
                }
            }
            else
            {
                drawContext.Clear(Colors.Transparent);

                var foregroundColor = this.DisabledColor;
                if (foregroundColor.HasValue)
                {
                    drawContext.DrawText(this.Text, textBounds, foregroundColor.Value, this._textFormat);
                }
            }
        }
        /// <summary>
        /// Draw the given arcs and nodes from a directed graph on a drawing context.
        /// </summary>
        /// <param name="context">A drawing context.</param>
        /// <param name="arcs">Arcs to be drawn.</param>
        /// <param name="nodes">Nodes to be drawn.</param>
        public static void Draw(IDrawContext context, IEnumerable <Arc> arcs, IEnumerable <Node> nodes)
        {
            IEnumerable <DGNode> dgNodes = nodes.Select(n => new DGNode(n)).ToList();
            IEnumerable <DGArc>  dgArcs  = arcs.Select(a => new DGArc(a, dgNodes));

            Draw(context, dgArcs, dgNodes);
        }
        // I/F
        public virtual void Draw(Control control, IDrawContext drawContext)
        {
            if (control.Focused)
            {
                if (FocusTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), FocusTexture, FocusColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), FocusColor);
                }
            }

            if (control.MouseOver)
            {
                if (MouseOverTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), MouseOverTexture, MouseOverColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), MouseOverColor);
                }
            }
        }
Exemple #8
0
        private void drawLineChart(IDrawContext context, Axis axisX, Axis axisY)
        {
            var plotBase = new PointF(context.PlotArea.Left, context.PlotArea.Top);
            var startP   = new PointF();
            var endP     = new PointF();

            setPhisicalPos(ref endP, items[0].Key, items[0].Value, axisX, axisY, plotBase);

            if (items.Count == 1)
            {
                context.DrawPoint(endP, Width, Color);
                return;
            }
            startP = endP;
            for (var i = 1; i < items.Count; i++)
            {
                setPhisicalPos(ref endP, items[i].Key, items[i].Value, axisX, axisY, plotBase);
                //前から1pxも動いてなかったら線を引かない
                if (((int)(startP.X - endP.X) != 0) || ((int)(startP.Y - endP.Y) != 0))
                {
                    context.DrawLine(startP, endP, Width, Color);
                    startP = endP;
                }
            }
        }
Exemple #9
0
        protected override void DrawBackground(
            IDrawContext drawContext,
            Rectangle bounds)
        {
            const float Padding = 10.0f;

            base.DrawBackground(drawContext, bounds);

            bounds = bounds.Deflate(Padding, 0);

            float origin = (this._swipeDirection == ListViewSwipeDirection.Primary ? 1.0f : 0.0f);

            Rectangle imageBounds = new Rectangle(
                bounds.X + (origin * (bounds.Width - this._iconSize.Width)),
                bounds.Center.Y - (this._iconSize.Height / 2.0f),
                this._iconSize.Width,
                this._iconSize.Height);

            Rectangle textBounds = bounds.Deflate(imageBounds.Width + Padding, 0);

            if (null != this.Icon)
            {
                drawContext.DrawImage(this.Icon, imageBounds, this.ForegroundColor);
            }

            if (null != this.Text)
            {
                drawContext.DrawText(this.Text, textBounds, this.ForegroundColor, this._textFormat);
            }
        }
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            if (Workspace.SelectedMaterial == null) return;

            var bounds = new Rect(0, 0, RenderSize.Width, RenderSize.Height);
            using (var draw3d = drawContext.BeginDraw3D())
            using (var localViewport = drawContext.BeginViewport(bounds))
            using (var localClipping = drawContext.BeginNewClip(bounds))
            {
                var graphicsDevice = Screen.GraphicsDevice;
                graphicsDevice.BlendState = BlendState.Opaque;
                graphicsDevice.DepthStencilState = DepthStencilState.Default;

                // View を更新します。
                view.Update();

                // Projection を更新します。
                projection.AspectRatio = graphicsDevice.Viewport.AspectRatio;
                projection.Update();

                var material = Workspace.SelectedMaterial;
                var effect = cubeMesh.Effect;
                effect.View = view.Matrix;
                effect.Projection = projection.Matrix;
                effect.DiffuseColor = material.DiffuseColor.ToVector3();
                effect.EmissiveColor = material.EmissiveColor.ToVector3();
                effect.SpecularColor = material.SpecularColor.ToVector3();
                effect.SpecularPower = material.SpecularPower;

                cubeMesh.Draw();
            }
        }
Exemple #11
0
        /// <summary>
        /// X軸として描画
        /// </summary>
        /// <param name="context"></param>
        void drawAxisX(IDrawContext context)
        {
            //軸線
            var startPos = new PointF(context.PlotArea.Left, context.PlotArea.Bottom);
            var endPos   = new PointF(context.PlotArea.Right, context.PlotArea.Bottom);

            context.DrawLine(startPos, endPos, 1, Parameter.Color);

            //キャプション
            context.DrawString(startPos.X, startPos.Y, Parameter.Font.Height, Parameter.Color, Translator(LogicalMin), StringAlignment.Middle, StringAlignment.Near);
            context.DrawString(endPos.X, endPos.Y, Parameter.Font.Height, Parameter.Color, Translator(LogicalMax), StringAlignment.Middle, StringAlignment.Near);

            //途中の線とキャプション
            if (TickEnumerator != null)
            {
                foreach (var tickInfo in TickEnumerator(this))
                {
                    var c = tickInfo.Item2 ? Parameter.WideGridColor : Parameter.NarrowGridColor;
                    var e = tickInfo.Item2 ? Parameter.DrawWideGrid : Parameter.DrawNarrowGrid;
                    var w = tickInfo.Item2 ? Parameter.DrawWideTickCaption : Parameter.DrawNarrowTickCaption;
                    var x = LogicalValueToPhysicalValue(tickInfo.Item1, context.PlotArea.Location);
                    if (e)
                    {
                        context.DrawLine(new PointF(x, context.PlotArea.Top), new PointF(x, context.PlotArea.Bottom), 1, c);
                    }
                    if (w)
                    {
                        context.DrawString(x, context.PlotArea.Bottom, Parameter.Font.Height, c, Translator(tickInfo.Item1), StringAlignment.Middle, StringAlignment.Near);
                    }
                }
            }
        }
Exemple #12
0
        protected override void DrawBackground(
            IDrawContext drawContext,
            Rectangle bounds)
        {
            base.DrawBackground(drawContext, bounds);

            if ((bounds.Height <= 0) || (bounds.Width <= 0))
            {
                return;
            }

            Size      shadowPadding     = new Size(bounds.Width / 10, bounds.Height / 10);
            Size      shadowThinPadding = new Size(shadowPadding.Width / 2, shadowPadding.Height / 2);
            Rectangle buttonRect        = bounds.Deflate(shadowPadding.Width, shadowPadding.Height);
            Rectangle shadowRect        = Rectangle.FromLTRB(bounds.X, buttonRect.Top - shadowThinPadding.Height, buttonRect.Right + shadowThinPadding.Width, bounds.Bottom);
            Rectangle imageRect         = buttonRect.Deflate(buttonRect.Width / 6, buttonRect.Height / 6);

            float blurAmount = Math.Min(shadowPadding.Width, shadowPadding.Height) / 1.5f;

            Color shadowColor = Colors.Gray;

            if ((this._isTouchDown) || (!this.IsEnabled))
            {
                drawContext.FillEllipseShadow(shadowRect, shadowColor, blurAmount / 2);
                drawContext.FillEllipse(buttonRect, this.ButtonPressedBackgroundColor);
                drawContext.DrawImage(this._icon, imageRect, this.ButtonPressedForegroundColor);
            }
            else
            {
                drawContext.FillEllipseShadow(shadowRect, shadowColor, blurAmount);
                drawContext.FillEllipse(buttonRect, this.ButtonBackgroundColor);
                drawContext.DrawImage(this._icon, imageRect, this.ForegroundColor);
            }
        }
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            DrawGrid(drawContext);
            DrawElements(drawContext);
        }
Exemple #14
0
        private void resetMapData(IDrawContext context, CancellationToken cancellation)
        {
            lock (_readerLocker)
            {
                var mapsDir = PluginSettings.Instance.MapsDirectory;
                if (this.Resolution != _loadedResolution || mapsDir != _mapsDir)
                {
                    if (_polygonObjects != null)
                    {
                        removeChildren(new List <int>(_polygonObjects.Keys));
                    }

                    _mapsDir = mapsDir;

                    var ownsStatus = Utils.Instance.SetStatus("Loading " + this.PolygonType.ToString().ToLower() + " data...", true, true, 0, true);
                    var watch      = System.Diagnostics.Stopwatch.StartNew();
                    var reader     = new GSHHG2Reader();
                    // TODO: lazy load
                    // TODO: handle cancellation
                    _polygons = reader.Read(PluginSettings.Instance.MapsDirectory, this.PolygonType, this.Resolution, this.ClosePolygons).Polygons;
                    var time = watch.ElapsedMilliseconds;
                    if (ownsStatus)
                    {
                        Utils.Instance.HideStatus();
                    }
                    _polygonObjects   = new Dictionary <int, PolygonObject>();
                    _loadedResolution = this.Resolution;
                }
            }
        }
Exemple #15
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            if (Texture != null)
                drawContext.DrawTexture(new Rect(Vector2.Zero, RenderSize), Texture, BackgroundColor);
        }
Exemple #16
0
        /// <summary>
        /// Initializes the specified graphic system.
        /// </summary>
        /// <param name="graphicSystem">The graphic system.</param>
        /// <param name="physicSystem">The physic system.</param>
        /// <param name="textSystem">The text system.</param>
        /// <param name="inputSystem">The input system.</param>
        /// <param name="exitAction">The exit action.</param>
        public virtual void Initialize(
            IGraphicSystem graphicSystem,
            IPhysicSystem physicSystem,
            ITextSystem textSystem,
            IInputSystem inputSystem,
            Action exitAction)
        {
            Components          = new List <IComponent>();
            _componentsToRemove = new List <IComponent>();
            _updatables         = new List <IUpdatable>();
            _drawables          = new List <IDrawable>();

            _time = new Time();
            _pendingSceneToOpen = new NullScene(this);

            graphicSystem.Initialize();
            textSystem.Initialize();

            _drawContext  = new DrawContext(graphicSystem, textSystem);
            GraphicSystem = graphicSystem;

            Bounds       = Bounds == Rectangle.Zero ? graphicSystem.Bounds : Bounds;
            PhysicSystem = physicSystem;

            LogSystem = new NullLogSystem();

            FontSystem = textSystem;

            InputSystem = inputSystem;

            this._exitAction = exitAction;
        }
Exemple #17
0
        internal void DrawReloadTime(IDrawContext context, Vector2 offset, float angle)
        {
            const float width          = 40;
            const float height         = 10;
            var         rotationMatrix = Matrix.CreateRotationZ(angle);

            Vector2 Rotate(float w) => Center + Vector2.Transform(new Vector2(Size.X - (width - w) - offset.X, Size.Y - height - offset.Y), rotationMatrix);

            switch (FiringState)
            {
            case FiringState.Idle:
                context.FillRectangle(Rotate(0), new Vector2(width, height), Color.Green, angle);
                break;

            case FiringState.Firing:
                context.FillRectangle(Rotate(0), new Vector2(width, height), Color.Black, angle);
                break;

            case FiringState.Reloading:
                float loadedPercent = 1 - (float)TimeToNextFiringState.TotalMilliseconds / Settings.ReloadTime;
                float loadedWidth   = width * loadedPercent;
                context.FillRectangle(Rotate(0), new Vector2(loadedWidth, height), Color.Green, angle);
                context.FillRectangle(Rotate(loadedWidth), new Vector2(width - loadedWidth, height), Color.Green, angle);
                break;
            }
        }
Exemple #18
0
        /// <summary>
        /// Draws the instance on the specified draw context.
        /// </summary>
        /// <param name="drawContext">The draw context.</param>
        public void Draw(IDrawContext drawContext)
        {
            var components              = Context.Components;
            var enabledComponentsCount  = components.Count(c => c.Enabled);
            var disabledComponentsCount = components.Count(c => !c.Enabled);
            var updatablesCount         = components.Count(c => c is IUpdatable);
            var drawablesCount          = components.Count(c => c is IDrawable);
            var collidablesCount        = components.Count(c => c is ICollidable);
            var sceneSurvivablescount   = components.Count(c => c is ISceneSurvivable);

            var x  = _position.X;
            var y  = _position.Y;
            var ts = drawContext.TextSystem;

            ts
            .Draw(x, y, $"FPS                        : {(1f / Context.Time.SinceLastFrame):N0}", fontName: "Debug")
            .Draw(x, ++y, $"Since scene start          : {Context.Time.SinceSceneStart:N0}", fontName: "Debug")
            .Draw(x, ++y, $"Components                 : {components.Count}", fontName: "Debug")
            .Draw(x, ++y, $"Enabled components         : {enabledComponentsCount}", fontName: "Debug")
            .Draw(x, ++y, $"Disabled components        : {disabledComponentsCount}", fontName: "Debug")
            .Draw(x, ++y, $"Updatable components       : {updatablesCount}", fontName: "Debug")
            .Draw(x, ++y, $"Drawable components        : {drawablesCount}", fontName: "Debug")
            .Draw(x, ++y, $"Collidable components      : {collidablesCount}", fontName: "Debug")
            .Draw(x, ++y, $"Scene survivable components: {sceneSurvivablescount}", fontName: "Debug");
        }
        public override void Draw(IDrawContext drawContext, DrawingLayer drawingLayer)
        {
            var finalFrom = drawingLayer.CameraMode == CameraMode.Fix ? this.FromVector : this.FromVector
                .Scale(drawContext.Camera.ZoomFactor)
                .Translate(drawContext.Camera.GetSceneTranslationVector(drawingLayer.ParallaxScrollingVector));

            var finalTo = drawingLayer.CameraMode == CameraMode.Fix ? this.ToVector : this.ToVector
                .Scale(drawContext.Camera.ZoomFactor)
                .Translate(drawContext.Camera.GetSceneTranslationVector(drawingLayer.ParallaxScrollingVector));

            var zoom = drawingLayer.CameraMode == CameraMode.Fix ? 1.0f : this.Width * drawContext.Camera.ZoomFactor;

            //var finalWidth = this.width * camera.ZoomFactor;
            //var angle = (float)Math.Atan2(finalTo.Y - finalFrom.Y, finalTo.X - finalFrom.X);
            //var length = Vector.Distance(finalFrom, finalTo);

            var param = new DrawLineParams
            {
                VectorFrom = finalFrom,
                VectorTo = finalTo,
                Width = zoom,
                Color = this.Color
            };

            drawContext.DrawLine(param);

            //spriteBatch.Draw(this.blank, finalFrom, null, this.color, angle, Vector.Zero,
            //    new Vector(length, finalWidth), SpriteEffects.None, 0);
        }
        public void Draw(IDrawContext context)
        {
            var    drawSys = DrawSystem.GetInstance();
            Matrix layout  = m_initParam.Layout;

            foreach (char c in m_text)
            {
                var   tex    = DrawSystem.TextureData.Null();
                float offset = 0.0f;
                switch (c)
                {
                case '.':
                    tex    = m_initParam.Dot;
                    offset = -0.22f;
                    break;

                default:
                    if ('0' <= c && c <= '9')
                    {
                        int num = (int)c - (int)'0';
                        tex    = m_initParam.Numbers[num];
                        offset = -0.3f;
                    }
                    break;
                }

                Debug.Assert(tex.Resource != null, "invalid character");
                context.DrawModel(layout * m_worldTrans, Color4.White, m_plane.NodeList[0].Mesh, StandardMaterial.Create(tex), DrawSystem.RenderMode.Transparency, null);
                layout *= Matrix.Translation(offset, 0, 0);
            }
        }
Exemple #21
0
        protected override void DrawBackground(
            IDrawContext drawContext,
            Rectangle bounds)
        {
            base.DrawBackground(drawContext, bounds);

            Rectangle iconBounds = bounds;

            if (this._iconSize.HasValue)
            {
                Size iconSize = this._iconSize.Value;
                iconBounds = new Rectangle(
                    bounds.Left + ((bounds.Width - iconSize.Width) / 2),
                    bounds.Top + ((bounds.Height - iconSize.Height) / 2),
                    iconSize.Width,
                    iconSize.Height);
            }

            if (this._isChecked)
            {
                drawContext.DrawImage(this._checkedIcon, iconBounds, this._tintColor);
            }
            else
            {
                drawContext.DrawImage(this._uncheckedIcon, iconBounds, this._tintColor);
            }
        }
Exemple #22
0
        public override void Draw(IDrawContext context)
        {
            if (IsEnabled)
            {
                switch (ClickState)
                {
                case ClickState.Pressed:
                    context.FillRectangle(Bounds, new Color(Color.Orange, 0.3f));
                    break;

                case ClickState.None:
                    context.FillRectangle(Bounds, new Color(Color.Orange, 0.05f));
                    break;
                }
            }
            else
            {
                context.FillRectangle(Bounds, new Color(Color.Gray, 0.3f));
            }
            DrawContent(context);
            if (Globals.ShowButtonsInfo)
            {
                DrawInfo(context);
            }
            base.Draw(context);
        }
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            var rect = new Rect();
            rect.Width = RenderSize.Width;
            rect.Height = 1;
            drawContext.DrawRectangle(rect, GridColor);

            rect.Y = RenderSize.Height - 1;
            drawContext.DrawRectangle(rect, GridColor);

            rect.Y = 0;
            rect.Width = 1;
            rect.Height = RenderSize.Height;
            for (int i = 0; i <= 16; i++)
            {
                rect.X = CellSize * i;
                drawContext.DrawRectangle(rect, GridColor);
            }

            rect.Width = CellSize - 1;
            rect.Height = CellSize - 1;
            rect.X = CellSize * Section.Index + 1;
            rect.Y = 1;
            drawContext.DrawRectangle(rect, CursorColor);
        }
        public void PreDraw(IDrawContext drawContext)
        {
            if (this.CameraMode == GameFramework.Cameras.CameraMode.Follow
                && drawContext.Camera.ZoomFactor > 1)
            {
                drawContext.SetRenderTarget(this, drawContext.Camera.SceneViewport.Size);

                var cameraTranslation = drawContext.Camera.SceneViewport.Positon.RoundTo(0);

                for (var i = 0; i < this.MapSize.Width; i++)
                    for (var j = 0; j < this.MapSize.Height; j++)
                    {
                        if (this[i, j].ShouldDraw)
                        {
                            var destination = new Rectangle(
                                this.Offset.X + i * this.TileSize.Width,
                                this.Offset.Y + j * this.TileSize.Height,
                                this.TileSize.Width,
                                this.TileSize.Height);

                            if (drawContext.Camera.SceneViewport.IsVisible(destination))
                            {
                                var adjustedDestination = destination.Translate(-cameraTranslation);

                                this[i, j].Draw(drawContext, adjustedDestination);
                            }
                        }
                    }

                drawContext.FlushRenderTarget();
            }
        }
Exemple #25
0
        public void Run(ILSystem lSystem, IDrawContext drawCtx, int generation, string rule, ref GenerationState genState)
        {
            if (rule == "F" || rule == "")
            {
                genState.time -= this.Cost;
                this.segments++;

                //if (draw && genState.time >= 0)
                if (genState.time >= 0)
                {
                    genState.length = Math.Min(genState.length, genState.length * genState.time);

                    var state = drawCtx.CurrentState;
                    var p1    = state.Translation;

                    drawCtx.Translate(this.SegmentAxis * genState.length);

                    var p2 = state.Translation;

                    if (lSystem.Timed)
                    {
                        this.Segment.Segment(p1, p2, generation, genState.time, this.segments);
                    }
                    else
                    {
                        this.Segment.Segment(p1, p2, generation, -1, this.segments);
                    }
                }
            }
        }
Exemple #26
0
        // I/F
        public virtual void Draw(Control control, IDrawContext drawContext)
        {
            if (control.Focused)
            {
                if (FocusTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), FocusTexture, FocusColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), FocusColor);
                }
            }

            if (control.MouseOver)
            {
                if (MouseOverTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), MouseOverTexture, MouseOverColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), MouseOverColor);
                }
            }
        }
Exemple #27
0
        /// <summary>Called by base class to draw the sheet widget.</summary>
        /// <param name="cr">The context to draw in.</param>
        public bool Draw(IDrawContext cr)
        {
            try
            {
                // Do initialisation
                if (ColumnWidths == null)
                {
                    Initialise(cr);
                }

                foreach (var columnIndex in VisibleColumnIndexes)
                {
                    foreach (var rowIndex in VisibleRowIndexes)
                    {
                        DrawCell(cr, columnIndex, rowIndex);
                    }
                }
            }
            catch (Exception err)
            {
                ViewBase.MasterView.ShowError(err);
            }

            return(true);
        }
        void DrawWrappedText(TextBlock textBlock, IDrawContext drawContext)
        {
            if (builder == null) builder = new StringBuilder();

            var font = textBlock.Font ?? textBlock.Screen.Font;
            if (font == null) return;

            var bounds = new Rect(textBlock.RenderSize);
            bounds.Height = textBlock.WrappedText.MaxMeasuredHeight;

            var wrappedText = textBlock.WrappedText;
            for (int i = 0; i < wrappedText.LineCount; i++)
            {
                // 行の文字列を取得します。
                wrappedText.GetLineText(i, builder);

                // 空行は文字列描画をスキップします。
                if (builder.Length != 0)
                {
                    // 文字を描画します。
                    drawContext.DrawString(bounds, font, builder, textBlock.FontStretch,
                        textBlock.TextHorizontalAlignment, textBlock.TextVerticalAlignment,
                        Color.White, textBlock.Padding);
                }

                // 描画領域を次の行の位置へ進めます。
                bounds.Y += textBlock.WrappedText.MaxMeasuredHeight;
                // 描画対象の領域を完全に越える行は描画しません。
                if (textBlock.RenderSize.Height <= bounds.Y) break;
            }
        }
Exemple #29
0
        public override int Draw(IDrawContext drawContext, Transform transform)
        {
            this.SetSampler(drawContext);

            this.drawnElementsLastFrame = 0;

            for (var i = 0; i < this.MapSize.Width; i++)
                for (var j = 0; j < this.MapSize.Height; j++)
                {
                    if (this.map[i, j].ShouldDraw)
                    {
                        var destination = new Rectangle(
                            this.Offset.X + i * this.TileSize.Width,
                            this.Offset.Y + j * this.TileSize.Height,
                            this.TileSize.Width,
                            this.TileSize.Height);

                        if (this.CameraMode == CameraMode.Follow)
                        {
                            destination = destination
                                .Scale(drawContext.Camera.ZoomFactor)
                                .Translate(drawContext.Camera.GetSceneTranslationVector(this.ParallaxScrollingVector));
                        }

                        if (drawContext.Camera.Viewport.IsVisible(destination))
                        {
                            this.map[i, j].Draw(drawContext, destination);
                            this.drawnElementsLastFrame++;
                        }
                    }
                }

            return this.drawnElementsLastFrame;
        }
        protected override bool OnDraw(IDrawContext context)
        {
            var value = ((char)Value).ToString(CultureInfo.InvariantCulture);

            context.BeginLook(true);
            try
            {
                string newValue = EditorGUILayout.TextField(value);
                if (newValue.Length != 0)
                {
                    if (newValue.Length > 1)
                    {
                        newValue = newValue.Remove(0, newValue.Length - 1);
                    }

                    if (!newValue.Equals(value))
                    {
                        Value = char.Parse(newValue);
                        return(true);
                    }
                }
                return(false);
            }
            finally { context.EndLook(); }
        }
Exemple #31
0
        protected override void DrawBackground(
            IDrawContext drawContext,
            Rectangle bounds)
        {
            base.DrawBackground(drawContext, bounds);

            // Calculate text bounds

            float     textHeight = bounds.Height / 4;
            Rectangle textBounds = new Rectangle(bounds.X, bounds.Bottom - textHeight, bounds.Width, textHeight);

            // Calculate button bounds

            float     buttonDimension = Math.Min(bounds.Width, bounds.Height - textHeight);
            float     buttonRadius    = buttonDimension / 2;
            Rectangle buttonBounds    = new Rectangle(
                bounds.Center.X - buttonRadius,
                bounds.Center.Y - (textHeight / 2) - buttonRadius,
                buttonDimension,
                buttonDimension);

            // Calculate image bounds

            float     imageDimension = buttonDimension / 2;
            Rectangle imageBounds    = new Rectangle(
                buttonBounds.Center.X - (imageDimension / 2),
                buttonBounds.Center.Y - (imageDimension / 2),
                imageDimension,
                imageDimension);

            Bitmap icon = this.RadioButtonItem.Icon;

            if (this._isTouchDown)
            {
                drawContext.FillEllipse(buttonBounds, this.Theme.SubtleForegroundColor);
                if (null != icon)
                {
                    drawContext.DrawImage(icon, imageBounds, Colors.White);
                }
            }
            else if (this.IsChecked)
            {
                drawContext.FillEllipse(buttonBounds, this.Theme.AccentColor);
                if (null != icon)
                {
                    drawContext.DrawImage(icon, imageBounds, Colors.White);
                }
            }
            else
            {
                drawContext.DrawEllipse(buttonBounds.Center, buttonRadius - 1.0f, buttonRadius - 1.0f, this.Theme.SubtleForegroundColor, strokeWidth: 1.0f);
                if (null != icon)
                {
                    drawContext.DrawImage(icon, imageBounds, this.Theme.SubtleForegroundColor);
                }
            }

            drawContext.DrawText(this.RadioButtonItem.Text, textBounds, this.Theme.SubtleForegroundColor, this._textFormat);
        }
Exemple #32
0
 public override void Draw(IDrawContext context)
 {
     foreach (var enemySet in Sets)
     {
         enemySet.Draw(context);
     }
     base.Draw(context);
 }
Exemple #33
0
 public override void Draw(IDrawContext context)
 {
     foreach (var enemy in enemies)
     {
         enemy.Draw(context);
     }
     base.Draw(context);
 }
Exemple #34
0
        public void Draw(IDrawContext drawContext)
        {
            var flyContext = (IFlyDrawContext)drawContext;

            flyContext.Camera = this.camera;

            this.ingameRenderer.Draw(flyContext);
        }
Exemple #35
0
        public virtual void DrawInfo(IDrawContext context)
        {
            Vector2 position = new Vector2(Bounds.Right + 2, Bounds.Top);

            context.DrawString(GlobalContent.Default.InfoFont, ClickState.ToString(), position, Color.Yellow);
            position += new Vector2(0, 20 + 4);
            context.DrawString(GlobalContent.Default.InfoFont, IsEnabled ? "Enabled": "Not enabled", position, Color.Yellow);
        }
Exemple #36
0
        public override void Draw(IDrawContext drawContext)
        {
            drawContext.Canvas
            .Draw(circle, false, Pixel.Default);

            drawContext.TextSystem
            .Draw(0, 0, Context.Time.Now.ToString("HH:mm:ss"), "Default");
        }
        void DrawWrappedText(TextBlock textBlock, IDrawContext drawContext)
        {
            if (builder == null) builder = new StringBuilder();

            var font = textBlock.Font ?? textBlock.Screen.Font;
            if (font == null) return;

            var stretch = textBlock.FontStretch;
            var padding = textBlock.Padding;
            var fColor = textBlock.ForegroundColor;
            var bColor = textBlock.BackgroundColor;
            var outlineWidth = textBlock.TextOutlineWidth;
            var hAlign = textBlock.TextHorizontalAlignment;
            var vAlign = textBlock.TextVerticalAlignment;
            var shadowOffset = textBlock.ShadowOffset;

            var bounds = new Rect(textBlock.RenderSize);
            bounds.Height = textBlock.WrappedText.MaxMeasuredHeight;

            var wrappedText = textBlock.WrappedText;
            for (int i = 0; i < wrappedText.LineCount; i++)
            {
                // 行の文字列を取得します。
                wrappedText.GetLineText(i, builder);

                // 空行は文字列描画をスキップします。
                if (builder.Length != 0)
                {
                    // 影を描画します。
                    if (shadowOffset.X != 0 || shadowOffset.Y != 0)
                    {
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            shadowOffset);
                    }

                    // 文字枠を描画します。
                    if (0 < outlineWidth)
                    {
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            new Vector2(-outlineWidth, -outlineWidth));
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            new Vector2(-outlineWidth, outlineWidth));
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            new Vector2(outlineWidth, -outlineWidth));
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            new Vector2(outlineWidth, outlineWidth));
                    }

                    // 文字を描画します。
                    drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, fColor, padding);
                }

                // 描画領域を次の行の位置へ進めます。
                bounds.Y += textBlock.WrappedText.MaxMeasuredHeight;
                // 描画対象の領域を完全に越える行は描画しません。
                if (textBlock.RenderSize.Height <= bounds.Y) break;
            }
        }
Exemple #38
0
        /// <summary>
        /// Draw centred text
        /// </summary>
        /// <param name="context">The graphics context to draw on</param>
        /// <param name="text">The text to draw</param>
        /// <param name="point">The point to centre the text around</param>
        protected void DrawCentredText(IDrawContext context, string text, Point point)
        {
            (int left, int top, int width, int height) = context.GetPixelExtents(text, false, false);
            double x = point.X - (width / 2 + left);
            double y = point.Y - (height / 2 + top);

            context.MoveTo(x, y);
            context.DrawText(text, false, false);
        }
Exemple #39
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            if (Texture != null)
            {
                drawContext.DrawTexture(new Rect(Vector2.Zero, RenderSize), Texture, BackgroundColor);
            }
        }
Exemple #40
0
        public override void Draw(IDrawContext drawContext)
        {
            drawContext.Canvas
            .Draw(moveToSampleArea, false, Pixel.Default);

            drawContext.TextSystem
            .DrawCenter(0, -10, numberSample1.ToString("N0"))
            .DrawCenter(0, 0, numberSample2.ToString("N0"));
        }
Exemple #41
0
 public void Draw(IDrawContext drawContext, TileDefinition tileDefinition, Rectangle destination)
 {
     drawContext.DrawImage(new DrawImageParams
     {
         Texture = this.Texture,
         Source = tileDefinition.Rectangle,
         Destination = destination,
     });
 }
        public virtual void Draw(Control control, IDrawContext drawContext)
        {
            var window = control as Window;

            if (WindowShadowSpriteSheet != null && window.ShadowOffset != Vector2.Zero)
                DrawWindow(window, drawContext, WindowShadowSpriteSheet, Color.White, window.ShadowOffset);

            if (WindowSpriteSheet != null)
                DrawWindow(window, drawContext, WindowSpriteSheet, Color.White, Vector2.Zero);
        }
Exemple #43
0
 protected void SetSampler(IDrawContext drawContext)
 {
     if (this.UseLinearSampler.HasValue)
     {
         if (this.UseLinearSampler.Value)
             drawContext.UseLinearSampler();
         else
             drawContext.UsePointSampler();
     }
 }
        public override int Draw(IDrawContext drawContext, Transform transform)
        {
            if (this.Sprite != null && this.IsVisible)
            {
                var newTransform = new SpriteTransform(transform, this.Position, this.Rotation, this.Scale, this.Color);

                return this.Sprite.Draw(drawContext, newTransform);
            }

            return 0;
        }
        void DrawText(TextBlock textBlock, IDrawContext drawContext)
        {
            var font = textBlock.Font ?? textBlock.Screen.Font;
            if (font == null) return;

            // 文字色を白として描画します。
            drawContext.DrawString(
                new Rect(textBlock.RenderSize), font, textBlock.Text, textBlock.FontStretch,
                textBlock.TextHorizontalAlignment, textBlock.TextVerticalAlignment,
                Color.White, textBlock.Padding);
        }
        public override void Draw(IDrawContext drawContext, DrawingLayer drawingLayer)
        {
            var topLeft = new Vector(this.x, this.y);
            var topRight = new Vector(this.x + this.width, this.y);
            var bottomLeft = new Vector(this.x, this.y + this.height);
            var bottomRight = new Vector(this.x + this.width, this.y + this.height);

            this.DrawLine(drawContext, drawingLayer, topLeft, topRight, this.LineWidth, this.Color);
            this.DrawLine(drawContext, drawingLayer, topRight, bottomRight, this.LineWidth, this.Color);
            this.DrawLine(drawContext, drawingLayer, bottomRight, bottomLeft, this.LineWidth, this.Color);
            this.DrawLine(drawContext, drawingLayer, bottomLeft, topLeft, this.LineWidth, this.Color);
        }
        public override int Draw(IDrawContext drawContext, Transform transform)
        {
            if (this.CameraMode == GameFramework.Cameras.CameraMode.Follow
                && drawContext.Camera.ZoomFactor > 1)
            {
                drawContext.UseLinearSampler();
                drawContext.DrawPreDrawn(this);
                return 0;
            }

            return base.Draw(drawContext, transform);
        }
        public override int Draw(IDrawContext drawContext, Transform transform)
        {
            this.SetSampler(drawContext);

            drawContext.DrawImage(new DrawImageParams
            {
                Texture = this.Texture,
                Destination = new Rectangle(this.Rectangle)
            });

            return 1;
        }
Exemple #49
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            if (stringBuilder.Length == 0) return;

            var font = Font ?? Screen.Font;
            if (font == null) return;

            // TODO: 面倒なのでキャレットをそのまま文字連結していますが、本当はダメ。
            drawContext.DrawString(
                new Rect(RenderSize), font, stringBuilder.ToString() + "|", FontStretch,
                HorizontalAlignment.Left, VerticalAlignment.Top,
                ForegroundColor, Padding);
        }
        public virtual void Draw(Control control, IDrawContext drawContext)
        {
            var textBlock = control as TextBlock;
            if (textBlock == null) return;
            if (string.IsNullOrEmpty(textBlock.Text)) return;

            if (textBlock.TextWrapping == TextWrapping.Wrap)
            {
                DrawWrappedText(textBlock, drawContext);
            }
            else
            {
                DrawText(textBlock, drawContext);
            }
        }
        public int Draw(IDrawContext drawContext, Transform transform)
        {
            var x = this.configuration.DisplayLocation == DiagnosticDisplayLocation.Left
                ? LeftMargin
                : drawContext.Camera.Viewport.Width - RightMargin;

            var currentY = FirstLineY;

            foreach (var line in this.finalLines)
            {
                this.DrawLine(drawContext, new Vector(x, currentY), line);
                currentY += LineHeight;
            }

            return this.finalLines.Count;
        }
Exemple #52
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            var bounds = new Rect(0, 0, RenderSize.Width, RenderSize.Height);
            using (var draw3d = drawContext.BeginDraw3D())
            {
                using (var localViewport = drawContext.BeginViewport(bounds))
                {
                    using (var localClipping = drawContext.BeginNewClip(bounds))
                    {
                        ViewModel.Draw();
                    }
                }
            }
        }
        protected void DrawLine(IDrawContext drawContext, DrawingLayer drawingLayer, Vector fromVector, Vector toVector, int width, Color color)
        {
            var finalFrom = fromVector
                .Scale(drawContext.Camera.ZoomFactor)
                .Translate(drawContext.Camera.GetSceneTranslationVector(drawingLayer.ParallaxScrollingVector));

            var finalTo = toVector
                .Scale(drawContext.Camera.ZoomFactor)
                .Translate(drawContext.Camera.GetSceneTranslationVector(drawingLayer.ParallaxScrollingVector));

            var param = new DrawLineParams
            {
                VectorFrom = finalFrom,
                VectorTo = finalTo,
                Width = width * drawContext.Camera.ZoomFactor,
                Color = color
            };

            drawContext.DrawLine(param);
        }
        public override int Draw(IDrawContext drawContext, Transform transform)
        {
            this.SetSampler(drawContext);

            this.drawnElementsLastFrame = 0;

            if (this.CameraMode == CameraMode.Follow)
            {
                transform = new SpriteTransform(transform, scale: drawContext.Camera.ZoomFactor,
                    translation: drawContext.Camera.GetSceneTranslationVector(this.ParallaxScrollingVector));
            }

            transform = new SpriteTransform(transform, this.Offset);

            foreach (var sprite in this.Sprites.Where(s => s.IsVisible))
            {
                this.drawnElementsLastFrame += sprite.Draw(drawContext, transform);
            }

            return this.drawnElementsLastFrame;
        }
        public override void Draw(IDrawContext drawContext, DrawingLayer drawingLayer)
        {
            var finalText = this.Parameters != null ? string.Format(this.Text, this.Parameters) : this.Text;
            var finalZoomFactor = drawingLayer.CameraMode == CameraMode.Fix ? 1.0f : drawContext.Camera.ZoomFactor;
            var finalVector = drawingLayer.CameraMode == CameraMode.Fix
                ? this.Position
                : this.Position
                    .Scale(drawContext.Camera.ZoomFactor)
                    .Translate(drawContext.Camera.GetSceneTranslationVector(drawingLayer.ParallaxScrollingVector));

            var param = new DrawStringParams
            {
                Text = finalText,
                Vector = finalVector,
                ZoomFactor = finalZoomFactor,
                DrawingFont = this.DrawingFont,
                Color = this.Color
            };

            drawContext.DrawString(param);
        }
        void DrawText(TextBlock textBlock, IDrawContext drawContext)
        {
            var font = textBlock.Font ?? textBlock.Screen.Font;
            if (font == null) return;

            var text = textBlock.Text;
            var stretch = textBlock.FontStretch;
            var padding = textBlock.Padding;
            var fColor = textBlock.ForegroundColor;
            var bColor = textBlock.BackgroundColor;
            var bounds = new Rect(textBlock.RenderSize);
            var outlineWidth = textBlock.TextOutlineWidth;
            var hAlign = textBlock.TextHorizontalAlignment;
            var vAlign = textBlock.TextVerticalAlignment;

            // 影を描画します。
            var shadowOffset = textBlock.ShadowOffset;
            if (shadowOffset.X != 0 || shadowOffset.Y != 0)
            {
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    shadowOffset);
            }

            // 文字枠を描画します。
            if (0 < outlineWidth)
            {
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    new Vector2(-outlineWidth, -outlineWidth));
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    new Vector2(-outlineWidth, outlineWidth));
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    new Vector2(outlineWidth, -outlineWidth));
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    new Vector2(outlineWidth, outlineWidth));
            }

            // 文字を描画します。
            drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, fColor, padding);
        }
        // I/F
        public virtual void Draw(Control control, IDrawContext drawContext)
        {
            if (control.Focused)
            {
                if (FocusTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), FocusTexture, FocusColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), FocusColor);
                }
            }

            if (control.MouseOver)
            {
                if (MouseOverTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), MouseOverTexture, MouseOverColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), MouseOverColor);
                }
            }

            var listBoxItem = control as ListBoxItem;
            if (listBoxItem != null && listBoxItem.IsSelected)
            {
                if (SelectionTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), SelectionTexture, SelectionColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), SelectionColor);
                }
            }
        }
Exemple #58
0
        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);
                }
            }
        }
 private void DrawLine(IDrawContext drawContext, Vector position, string text)
 {
     drawContext.DrawString(new DrawStringParams
     {
         Text = text,
         Vector = position,
         DrawingFont = this.font,
         Color = Color.White,
         ZoomFactor = 1.0f
     });
 }
Exemple #60
0
        public override int Draw(IDrawContext drawContext, Transform transform)
        {
            this.SetSampler(drawContext);

            this.drawnElementsLastFrame = 0;

            for (var i = 0; i < this.MapSize.Width; i++)
                for (var j = 0; j < this.MapSize.Height; j++)
                {
                    if (this.map[i, j].ShouldDraw)
                    {
                        var hexDistance = this.HexSize.Width - (this.HexSize.Width - this.TopEdgeLength) / 2;
                        var halfHeight = this.HexSize.Height / 2;

                        var rectangle = new Rectangle(
                            this.Offset.X + i * hexDistance,
                            this.Offset.Y + j * this.HexSize.Height + (i % 2 == 1 ? halfHeight : 0),
                            this.HexSize.Width, this.HexSize.Height);

                        var destination = rectangle
                            .Scale(drawContext.Camera.ZoomFactor)
                            .Translate(drawContext.Camera.GetSceneTranslationVector(this.ParallaxScrollingVector));

                        if (drawContext.Camera.Viewport.IsVisible(destination))
                        {
                            this.map[i, j].Draw(drawContext, destination);
                            this.drawnElementsLastFrame++;
                        }
                    }
                }

            return this.drawnElementsLastFrame;
        }