Example #1
0
        private void RenderCanvas_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Input.MousePosition = e.Location;
            bool updateSurface = false;

            if (Input.IsDrag)
            {
                double deltaPixel = e.X - Input.DragPosition.X;

                double deltaUnit = scroll.PixelToUnitLength(deltaPixel);
                scroll.ViewUnit.Left -= deltaUnit;
                scroll.ViewUnit.Normalize();

                UpdateBar();
                updateSurface = true;

                Input.DragPosition = e.Location;
            }
            else if (Input.IsMeasure)
            {
                Input.MeasureInterval.Finish = scroll.PixelToTime(e.X).Start;
                updateSurface = true;
            }
            else
            {
                ThreadRow row = GetRow(e.Y);
                if (row != null)
                {
                    row.OnMouseMove(new Point(e.X, e.Y - row.Offset), scroll);
                }

                updateSurface = true;
            }

            if (updateSurface)
            {
                UpdateSurface();
            }
        }
Example #2
0
        public override void Render(DirectX.DirectXCanvas canvas, ThreadScroll scroll)
        {
            SharpDX.Matrix world = SharpDX.Matrix.Scaling((float)scroll.Zoom, (float)((Height - 2.0 * RenderParams.BaseMargin) / scroll.Height), 1.0f);
            world.TranslationVector = new SharpDX.Vector3(-(float)(scroll.ViewUnit.Left * scroll.Zoom), (float)((Offset + 1.0 * RenderParams.BaseMargin) / scroll.Height), 0.0f);

            if (Mesh != null)
            {
                Mesh.World = world;
                canvas.Draw(Mesh);
            }

            if (FilterMesh != null)
            {
                FilterMesh.World = world;
                canvas.Draw(FilterMesh);
            }

            if (SyncMesh != null)
            {
                SyncMesh.World = world;
                canvas.Draw(SyncMesh);
            }

            if (CallstackMeshPolys != null && CallstackMeshLines != null && scroll.DrawCallstacks)
            {
                double unitWidth  = scroll.PixelToUnitLength(CallstackMarkerSize * 0.5);
                double unitHeight = (CallstackMarkerSize / RenderParams.BaseHeight) / MaxDepth;
                double offset     = (CallstackMarkerOffset / RenderParams.BaseHeight) / MaxDepth;

                Data.Utils.ForEachInsideInterval(EventData.Callstacks, scroll.ViewTime, callstack =>
                {
                    double center = scroll.TimeToUnit(callstack);

                    Point a = new Point(center - unitWidth, offset);
                    Point b = new Point(center, offset + unitHeight);
                    Point c = new Point(center + unitWidth, offset);

                    CallstackMeshPolys.AddTri(a, b, c, (callstack.Reason == CallStackReason.AutoSample) ? CallstackColor : SystemCallstackColor);
                    CallstackMeshLines.AddTri(a, b, c, Colors.Black);
                });

                CallstackMeshPolys.Update(canvas.RenderDevice);
                CallstackMeshLines.Update(canvas.RenderDevice);

                CallstackMeshPolys.World = world;
                CallstackMeshLines.World = world;

                canvas.DrawLater(CallstackMeshPolys);
                canvas.DrawLater(CallstackMeshLines);
            }

            Data.Utils.ForEachInsideInterval(EventData.Events, scroll.ViewTime, frame =>
            {
                frame.CategoriesTree.ForEachChild((node, level) =>
                {
                    Entry entry         = (node as EventNode).Entry;
                    Interval intervalPx = scroll.TimeToPixel(entry);

                    if (intervalPx.Width < TextDrawThreshold || intervalPx.Right < 0.0)
                    {
                        return(false);
                    }

                    if (intervalPx.Left < 0.0)
                    {
                        intervalPx.Width += intervalPx.Left;
                        intervalPx.Left   = 0.0;
                    }

                    double lum  = DirectX.Utils.GetLuminance(entry.Description.Color);
                    Color color = lum < 0.33 ? Colors.White : Colors.Black;

                    canvas.Text.Draw(new Point(intervalPx.Left + TextDrawOffset, Offset + level * RenderParams.BaseHeight),
                                     entry.Description.Name,
                                     color,
                                     TextAlignment.Left,
                                     intervalPx.Width - TextDrawOffset);

                    return(true);
                });
            });
        }