//public double MaxSpace = 170; #region Zoom void ZoomOutScale(double zoomFraction) { if (zoomFraction > 0.0001 && zoomFraction < 1000.0) { double range = (XShowEndTime.getDoubleValue() - XShowBeginTime.getDoubleValue()) * zoomFraction / 2.0; XShowBeginTime = XShowBeginTime - Convert.ToInt64(range); XShowEndTime = XShowEndTime + Convert.ToInt64(range); canvasTimeLine.Children.Clear(); Marks.Clear(); ll.Clear(); ShowXUnit(); foreach (Panel p in SynchronizationPanelList) { //Canvas.SetLeft(p, Canvas.GetLeft(p) * (1 - zoomFraction / 2)); //p.Width = p.Width * (1 - zoomFraction); foreach (FrameworkElement u in p.Children) { if (u is ITimeLineControl) { //Canvas.SetLeft(u, Canvas.GetLeft(u) * (1 - zoomFraction / 2)); SynchronizationControl(u as ITimeLineControl); //u.Width = u.Width * (1 - zoomFraction); } } } } }
public void setLynxTimeAtCenter(LynxTime lt)//把特定的时间移动到显示的中央 { double TargetX = canvasTimeLine.Width / 2; double HalfTime = (XShowEndTime.getDoubleValue() - XShowBeginTime.getDoubleValue()) / 2; XShowBeginTime.setTime(lt.getDoubleValue() - HalfTime); XShowEndTime.setTime(lt.getDoubleValue() + HalfTime); ShowXUnit(); }
public double getLynxTimeWidth(LynxTime bt, LynxTime et)//时间差获取间隔 { LynxTime v = et - bt; LynxTime d = XShowEndTime - XShowBeginTime; return(Math.Abs(Convert.ToDouble(v.getDoubleValue()) / d.getDoubleValue()) * canvasTimeLine.Width); }
private void canvasTimeLine_PointerMoved(object sender, PointerRoutedEventArgs e) { if (!_IsMouseDown) { return; } double cx = e.GetCurrentPoint(canvasTimeLine).Position.X; double dx = cx - CurrentX; if ((dx < 0.001) && (dx > -0.001)) { return; } CurrentX = cx; double lms = (XShowEndTime - XShowBeginTime).getDoubleValue(); //if (lms == 0) //{ // SilverlightLFC.common.Environment.ShowMessage("Error"); // return; //} DeltaMS = dx / canvasTimeLine.Width * lms; XShowBeginTime = XShowBeginTime - Convert.ToInt64(DeltaMS); XShowEndTime = XShowEndTime - Convert.ToInt64(DeltaMS); //textBox1.Text = lms.ToString(); textBeginTime.Text = XShowBeginTime.getTimeString(); textEndTime.Text = XShowEndTime.getTimeString(); //double UnitWidth = getLynxTimeWidth(maxDimention); //int num = Convert.ToInt32(Math.Ceiling(MaxSpace / UnitWidth)); foreach (FrameworkElement u in canvasTimeLine.Children) { Canvas.SetLeft(u, Canvas.GetLeft(u) + dx); } foreach (Panel p in SynchronizationPanelList) { //Canvas.SetLeft(p, Canvas.GetLeft(p) + dx); foreach (FrameworkElement u in p.Children) { if (u is ITimeLineControl) { Canvas.SetLeft(u, Canvas.GetLeft(u) + dx); } } } if (XShowBeginTime.getDoubleValue() <= FirstTopUnitTime.getDoubleValue()) { LynxTime NFT = new LynxTime(FirstTopUnitTime); NFT.AddTimeSpan(-TimeUnitNum, maxDimention); double uw = getLynxTimeWidth(NFT, FirstTopUnitTime); //ShowLabel(FirstTopUnitTime, maxDimention); ShowLabel(NFT, maxDimention); if (uw > MinSpace) { ShowXUnit(NFT, FirstTopUnitTime, maxDimention); } FirstTopUnitTime = NFT; } if (XShowEndTime.getDoubleValue() >= LastTopUnitTime.getDoubleValue()) { LynxTime NFT = new LynxTime(LastTopUnitTime); NFT.AddTimeSpan(TimeUnitNum, maxDimention); double uw = getLynxTimeWidth(LastTopUnitTime, NFT); //ShowLabel(LastTopUnitTime, maxDimention); ShowLabel(NFT, maxDimention); if (uw > MinSpace) { ShowXUnit(LastTopUnitTime, NFT, maxDimention); } LastTopUnitTime = NFT; } }
public double getLynxTimeWidth(TimeDimention td)//时间差获取间隔对应的宽度 { LynxTime v = LynxTime.getUnitSpan(1, td); return(Math.Abs(Convert.ToDouble(v.getDoubleValue()) / (XShowEndTime.getDoubleValue() - XShowBeginTime.getDoubleValue())) * canvasTimeLine.Width); }
public double getLynxTimeWidth(LynxTime TimeLong)//时间差获取间隔 { LynxTime d = XShowEndTime - XShowBeginTime; return(Math.Abs(Convert.ToDouble(TimeLong.getDoubleValue()) / d.getDoubleValue()) * canvasTimeLine.Width); }
public void setTimeLineWidth(double MinWidth, LynxTime MinLong)//通过确定最小宽度来确定时间线的宽度 { double minw = getLynxTimeWidth(MinLong); if (minw > MinWidth) { return; } canvasTimeLine.Width = (XShowEndTime - XShowBeginTime).getDoubleValue() / MinLong.getDoubleValue() * MinWidth; foreach (Panel p in SynchronizationPanelList) { p.Width = canvasTimeLine.Width; } ShowXUnit(); }