コード例 #1
0
        public GraphBackground(SimpleShader2D shaderProgram)
        {
            _uniformTransform = shaderProgram.UniformTransform;
            _uniformColor     = shaderProgram.UniformColor;

            _selectionBlock = new GLSLVertexBuffer <Vector2>();
            _selectionBlock.SetAttributeInfo(shaderProgram.AttributeCoord2D, 2);
            _selectionData = new Vector2[4];

            _selectionData[0] = new Vector2(0, -1);
            _selectionData[1] = new Vector2(0, 1);
            _selectionData[2] = new Vector2(1, -1);
            _selectionData[3] = new Vector2(1, 1);

            _selectionBlock.BindData(_selectionData, BufferUsageHint.StaticDraw);

            SelectorColor  = Color4.LightSkyBlue;
            SelectionColor = Color4.LightGray;
            _shiftMatrix   = Matrix4.Identity;
            _XShift        = 0;

            _lastMousePosition = new Point(0, 0);
            Enabled            = true;

            MarkList = new MarkList();
        }
コード例 #2
0
 /// <summary>
 /// Binds data to the front and back buffers. If the front buffer is empty, writes to front buffer. Otherwise writes to back buffer.
 /// </summary>
 /// <param name="data">The GraphData object to bind</param>
 public void BindData(GraphData data)
 {
     if (_frontData == null)
     {
         _frontData = data.VertexData.ToArray();
         _frontBuffer.BindData(_frontData);
     }
     else
     {
         _backData = data.VertexData.ToArray();
         _backBuffer.BindData(_backData);
     }
 }
コード例 #3
0
        public void Generate(CanvasData data)
        {
            Debug.Assert(data.RenderUnit != FrameNodeLevel.Root); //cannot render at the root level

            var start = data.StartTime;
            var end   = data.EndTime;

            MajorOffsets.Clear();
            MinorOffsets.Clear();

            DateTime currMajor, currMinor, tmp;

            switch (data.RenderUnit)
            {
            case FrameNodeLevel.Year:
            case FrameNodeLevel.Month:
                currMinor = new DateTime(start.Year, 1, 1);
                tmp       = new DateTime(end.Year, 1, 1);
                if (end != tmp)
                {
                    end = tmp.AddYears(1);
                }

                while (currMinor <= end)
                {
                    MinorOffsets.Add(CanvasManager.TimeToOffset(currMinor));
                    currMinor = currMinor.AddYears(1);
                }
                MinorTickLevel = FrameNodeLevel.Year;
                break;

            case FrameNodeLevel.Day:
                currMajor = new DateTime(start.Year, 1, 1);
                currMinor = currMajor;     // end of first month
                tmp       = new DateTime(end.Year, 1, 1);
                if (end != tmp)
                {
                    end = tmp.AddYears(1);
                }

                while (currMajor <= end)
                {
                    MajorOffsets.Add(CanvasManager.TimeToOffset(currMajor));
                    currMajor = currMajor.AddYears(1);
                    while (currMinor < currMajor)
                    {
                        MinorOffsets.Add(CanvasManager.TimeToOffset(currMinor));
                        currMinor = currMinor.AddMonths(1);
                    }
                }
                MinorTickLevel = FrameNodeLevel.Month;
                break;

            case FrameNodeLevel.Hour:
                currMajor = new DateTime(start.Year, start.Month, 1);
                currMinor = currMajor;     // 2nd day
                tmp       = new DateTime(end.Year, end.Month, 1);
                if (end != tmp)
                {
                    end = tmp.AddMonths(1);
                }

                while (currMajor <= end)
                {
                    MajorOffsets.Add(CanvasManager.TimeToOffset(currMajor));
                    currMajor = currMajor.AddMonths(1);
                    while (currMinor < currMajor)
                    {
                        MinorOffsets.Add(CanvasManager.TimeToOffset(currMinor));
                        currMinor = currMinor.AddDays(1);
                    }
                }
                MinorTickLevel = FrameNodeLevel.Day;
                break;

            case FrameNodeLevel.PartHour:
                currMajor = new DateTime(start.Year, start.Month, start.Day);
                currMinor = currMajor;     // 2nd day
                tmp       = new DateTime(end.Year, end.Month, end.Day);
                if (end != tmp)
                {
                    end = tmp.AddDays(1);
                }

                while (currMajor <= end)
                {
                    MajorOffsets.Add(CanvasManager.TimeToOffset(currMajor));
                    currMajor = currMajor.AddDays(1);
                    while (currMinor < currMajor)
                    {
                        MinorOffsets.Add(CanvasManager.TimeToOffset(currMinor));
                        currMinor = currMinor.AddHours(1);
                    }
                }
                MinorTickLevel = FrameNodeLevel.Hour;
                break;

            case FrameNodeLevel.Minute:
                currMajor = new DateTime(start.Year, start.Month, start.Day, start.Hour, 0, 0);
                currMinor = currMajor;     // 2nd day
                tmp       = new DateTime(end.Year, end.Month, end.Day, start.Hour, 0, 0);
                if (end != tmp)
                {
                    end = tmp.AddHours(1);
                }

                while (currMajor <= end)
                {
                    MajorOffsets.Add(CanvasManager.TimeToOffset(currMajor));
                    currMajor = currMajor.AddHours(1);
                    while (currMinor < currMajor)
                    {
                        MinorOffsets.Add(CanvasManager.TimeToOffset(currMinor));
                        currMinor = currMinor.AddMinutes(10);
                    }
                }
                MinorTickLevel = FrameNodeLevel.PartHour;
                break;

            case FrameNodeLevel.Second:
                currMajor = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute - (start.Minute % 5), 0);
                currMinor = currMajor;     // 2nd day
                tmp       = new DateTime(end.Year, end.Month, end.Day, end.Hour, end.Minute - (start.Minute % 5), 0);
                if (end != tmp)
                {
                    end = tmp.AddMinutes(5);
                }

                while (currMajor <= end)
                {
                    MajorOffsets.Add(CanvasManager.TimeToOffset(currMajor));
                    currMajor = data.DisplayUnit == FrameNodeLevel.Minute ? currMajor.AddMinutes(1) : currMajor.AddMinutes(5);
                    while (currMinor < currMajor)
                    {
                        MinorOffsets.Add(CanvasManager.TimeToOffset(currMinor));
                        currMinor = data.DisplayUnit == FrameNodeLevel.Minute ? currMinor.AddSeconds(1) : currMinor.AddMinutes(1);
                    }
                }
                MinorTickLevel = FrameNodeLevel.Minute;
                break;

            default:
                throw new ArgumentOutOfRangeException("axisMajorLevel");
            }

            //generate major axis
            if (MajorOffsets.Count > 0)
            {
                _majorTick = new Vector2[MajorOffsets.Count * 2];
                _majorGrid = new Vector2[MajorOffsets.Count * 2];

                for (int k = 0; k < MajorOffsets.Count; k++)
                {
                    _majorTick[k * 2] = new Vector2(MajorOffsets[k], 0);
                    _majorGrid[k * 2] = new Vector2(MajorOffsets[k], 0);

                    _majorTick[k * 2 + 1] = new Vector2(MajorOffsets[k], -CanvasManager.TickSize * 2 * CanvasManager.PixelSize.X);
                    _majorGrid[k * 2 + 1] = new Vector2(MajorOffsets[k], 2);
                }

                _tickMajorBuffer.BindData(_majorTick);
                _gridMajorBuffer.BindData(_majorGrid);
            }
            else
            {
                _majorTick = null;
            }

            //generate minor axis if possible
            if (MinorOffsets.Count > 0)
            {
                _minorTick = new Vector2[MinorOffsets.Count * 2];
                _minorGrid = new Vector2[MinorOffsets.Count * 2];

                for (int k = 0; k < MinorOffsets.Count; k++)
                {
                    _minorTick[k * 2] = new Vector2(MinorOffsets[k], 0);
                    _minorGrid[k * 2] = new Vector2(MinorOffsets[k], 0);

                    _minorTick[k * 2 + 1] = new Vector2(MinorOffsets[k],
                                                        -(CanvasManager.TickSize * 2) * MinorTickScale * CanvasManager.PixelSize.X);
                    _minorGrid[k * 2 + 1] = new Vector2(MinorOffsets[k], 2);
                }
                _tickMinorBuffer.BindData(_minorTick);
                _gridMinorBuffer.BindData(_minorGrid);
            }
            else
            {
                _minorTick = null;
            }
        }