2015-12-14 23 views
1

我已經制作了一個靜態DateTime範圍的面板,並希望繼續縮放功能,這是動態更改範圍時間。如何使c#winforms基於日期時間值的動態縮放時間軸面板

我曾試圖在互聯網上四處看看,但發現有關放大到面板(沒有DateTime的動態範圍值)。

有沒有人知道如何在C#winforms中做到這一點?或者,如果有人知道有關它的任何參考資料,它會很棒嗎?

只是想更清楚,這裏是例子: 這是我目前的時間線面板,在20秒的時間間隔:

Timeline with 20 seconds range DateTime

例如,如果我在的區間放大它04:21:30和04:21:50,時間間隔應該更小,(例如2秒)。

回答

0

既然有人投票贊成我的問題,我會給出我的案子的答案。 最後,我使用了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 
    } 
} 

如果你想討論它的細節,不要猶豫發表評論。乾杯!