【问题标题】:How to make a dynamic zooming timeline panel based on DateTime value in c# winforms如何在c#winforms中根据DateTime值制作动态缩放时间线面板
【发布时间】:2015-12-14 05:57:48
【问题描述】:

我制作了一个带有静态 DateTime 范围的面板,并希望继续使用动态更改范围时间的缩放功能。

我曾试图在互联网上四处寻找,但只是发现关于缩放到面板(没有 DateTime 的动态范围值)。

有没有人知道如何在 C# winforms 中做到这一点?或者,如果有人知道任何关于它的参考,也许会很棒?

只是想让它更清楚,这是示例: 这是我当前的时间线面板,间隔为 20 秒:

例如,如果我以 04:21:30 和 04:21:50 的间隔进行缩放,时间线间隔应该更小(例如 2 秒)。

【问题讨论】:

    标签: c# winforms datetime zooming timeline


    【解决方案1】:

    由于有人投票并收藏了我的问题,我将给出我的案例的答案。 最后,我使用了MouseDownMouseUp 事件。通过这些事件,我可以计算像素的比例和日期时间。

    这是我的代码的简化版本:

    int PressedCoordinate;
    int ReleasedCoordinate;
    
    private void Mouse_Down(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            int PressedCoordinate = e.X;
            //in this part, calculate the DateTime based on the scale of pixel vs datetime
        }
    }
    
    private void Mouse_Up(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            int ReleasedCoordinate = e.X;
            //in this part, calculate the DateTime based on the scale of pixel vs datetime
            //calculate the range and do the zoom-in logic
        }
    }
    

    如果您想讨论它的细节,请不要犹豫发表评论。干杯!

    【讨论】:

      猜你喜欢
      • 2015-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-11
      • 2011-01-30
      • 2020-01-25
      • 2011-02-02
      • 1970-01-01
      相关资源
      最近更新 更多