public void ShowXUnit() { Marks.Clear(); canvasTimeLine.Children.Clear(); maxDimention = LynxTime.getMaxCrossUnit(XShowBeginTime, XShowEndTime); FirstTopUnitTime = XShowBeginTime.getPastTime(maxDimention); LastTopUnitTime = XShowEndTime.getNextTime(maxDimention); TimeUnitNum = LynxTime.getUnitNum(FirstTopUnitTime, LastTopUnitTime, maxDimention); long stepUnitNum = Convert.ToInt64(Math.Ceiling(TimeUnitNum / (double)SubNum)); LynxTime pastTime = FirstTopUnitTime; ShowLabel(FirstTopUnitTime, maxDimention); for (int i = 1; i < SubNum; i++) { LynxTime lt = new LynxTime(FirstTopUnitTime); lt.AddTimeSpan(stepUnitNum * i, maxDimention); ShowLabel(lt, maxDimention); LastTopUnitTime = lt; double w = getLynxTimeWidth(pastTime, lt); if (w > MinSpace) { ShowXUnit(pastTime, lt, LynxTime.getLowTimeDim(maxDimention)); } pastTime = lt; } ShowLabel(LastTopUnitTime, maxDimention); //LastTopUnitTime = FirstTopUnitTime + (LastTopUnitTime)XShowEndTime.getNextTime(maxDimention); //ShowXUnit(XShowBeginTime, XShowEndTime, canvasTimeLine.Width); }
void ShowLabel(LynxTime ltime, TimeDimention ctd) { string TimeText = ltime.getTopFormatStr(ctd); //string ShortStr = LynxTime.getShortExpressStr(ltime); if (Marks.ContainsValue(ltime)) { return; } double lleft = getLynxTimeXValue(ltime); if (!Marks.ContainsKey(lleft)) { Marks.Add(lleft, ltime); LynxTime lt = new LynxTime(ltime); TextBlock l = new TextBlock(); l.FontSize = 10; l.Foreground = new SolidColorBrush(Colors.Blue); l.Text = TimeText; ToolTipService.SetToolTip(l, ltime.getTimeString()); Canvas.SetLeft(l, lleft); Canvas.SetTop(l, 0); l.Tag = ltime; canvasTimeLine.Children.Add(l); ll.Add(l); } }
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 buttonGo_Click(object sender, RoutedEventArgs e) { DateTime dt = Convert.ToDateTime(textBoxCurrentSelect.Text); LynxTime lt = new LynxTime(dt); setLynxTimeAtCenter(lt); if (!canvasTimeLine.Children.Contains(CurrentTimeLine)) { canvasTimeLine.Children.Add(CurrentTimeLine); } Canvas.SetLeft(CurrentTimeLine, canvasTimeLine.Width / 2); if (timeLineChanged != null) { timeLineChanged(Canvas.GetLeft(canvasTimeLine), canvasTimeLine.Width, BeginTime, EndTime - BeginTime); } foreach (Panel p in SynchronizationPanelList) { foreach (FrameworkElement f in p.Children) { if (f is ITimeLineControl) { SynchronizationControl(f as ITimeLineControl); } } } }
void ZoomInScale(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) { SynchronizationControl(u as ITimeLineControl); } //Canvas.SetLeft(u, Canvas.GetLeft(u) * (1 + zoomFraction/2)); //u.Width = u.Width * (1 + zoomFraction); } } } }
int SubNum = 3; //每次的下一级别分割区域 public void ShowXUnit(LynxTime bt, LynxTime et, TimeDimention ct) { //TimeDimention cDimention = LynxTime.getMaxCrossUnit(XShowBeginTime, XShowEndTime); //FirstTopUnitTime = XShowBeginTime.getPastTime(cDimention); //LastTopUnitTime = XShowEndTime.getNextTime(cDimention); long tn = LynxTime.getUnitNum(bt, et, ct); if (tn < 2) { return; } long stepUnitNum = Convert.ToInt64(Math.Ceiling(tn / (double)SubNum)); LynxTime pastTime = bt; //ShowLabel(pastTime, maxDimention); for (int i = 1; i < SubNum; i++) { LynxTime lt = new LynxTime(bt); lt.AddTimeSpan(stepUnitNum * i, ct); ShowLabel(lt, ct); double sw = getLynxTimeWidth(pastTime, lt); if (sw > MinSpace) { ShowXUnit(pastTime, lt, LynxTime.getLowTimeDim(maxDimention)); } pastTime = lt; } }
void ts_timeChanged(object sender, LynxTime Time) { Value = Time; if (timeChanged != null) { timeChanged(this, Time); } }
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 object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (TargetTimeLine == null) { return(0); } LynxTime lt = value as LynxTime; return(TargetTimeLine.getLynxTimeWidth(lt)); }
public LynxDateTimeEdit() { this.InitializeComponent(); Value = new LynxTime(); ts.timeChanged += new TimeChanged(ts_timeChanged); p = Parent as Panel; popup1.Child = ts; textBlock1.DataContext = this; }
public void ReadTimeValue(LynxTime t) { LynxTimeValue = new LynxTime(t); lynxUpDownHour.LongValue = t.Hour; lynxUpDownMinute.LongValue = t.Minute; lynxUpDownSecond.LongValue = t.Second; lynxUpDownMS.LongValue = t.Millisecond; lynxUpDownYear.LongValue = LynxTimeValue.Year; lynxUpDownMonth.LongValue = LynxTimeValue.Month; lynxUpDownDay.LongValue = LynxTimeValue.Day; ShowWeekDay(); }
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(); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (TargetTimeLine == null) { return(null); } double d = System.Convert.ToDouble(value); LynxTime lt = TargetTimeLine.getLynxTimeValue(d); if (BaseTime != null) { lt = lt - BaseTime; } return(lt); }
Line CurrentTimeLine = new Line();//当前时间 void setCurrentTime(double x) { if (!canvasTimeLine.Children.Contains(CurrentTimeLine)) { canvasTimeLine.Children.Add(CurrentTimeLine); CurrentTimeLine.Stroke = new SolidColorBrush(Colors.Orange); CurrentTimeLine.StrokeThickness = 3; } Canvas.SetLeft(CurrentTimeLine, x); //CurrentTimeLine.X1 = CurrentTimeLine.X2 = x; //double sv = XShowBeginTime.getDoubleValue() + (XShowEndTime.getDoubleValue() - XShowBeginTime.getDoubleValue()) * x / canvasTimeLine.Width; //ToolTipService.SetToolTip(CurrentTimeLine, SelectedTime.ToString()); SelectedTime = getLynxTimeValue(x); this.textBoxCurrentSelect.Text = SelectedTime.getDateTime().ToString(); }
void ShowWeekDay() { textBlockWeekDay.Text = LynxTime.getWeekDay(Convert.ToInt64(lynxUpDownYear.LongValue), Convert.ToInt32(lynxUpDownMonth.LongValue), Convert.ToInt32(lynxUpDownDay.LongValue)); }
private void lynxUpDownMonth_valueChanged(object sender, LUpDownValueChangeArgs e) { lynxUpDownDay.LongMax = LynxTime.getMonthMaxDay(Convert.ToInt32(lynxUpDownYear.LongValue), Convert.ToInt32(lynxUpDownMonth.LongValue)); lynxUpDownDay.LongMin = 1; ShowWeekDay(); }
public LynxTime getLynxTimeValue(double x) //从位置获取时间 { LynxTime d = (XShowEndTime - XShowBeginTime) * x / canvasTimeLine.Width + XShowBeginTime; return(d); }
public double getLynxTimeXValue(LynxTime d)//从时间获取位置 { return((d - XShowBeginTime).getDoubleValue() / (XShowEndTime - XShowBeginTime).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 void SynchronizationControl(FrameworkElement fe, LynxTime Begin, LynxTime End) { fe.Width = getLynxTimeWidth(Begin, End); Canvas.SetLeft(fe, getLynxTimeXValue(Begin)); }
public double getLynxTimeWidth(LynxTime TimeLong)//时间差获取间隔 { LynxTime d = XShowEndTime - XShowBeginTime; return(Math.Abs(Convert.ToDouble(TimeLong.getDoubleValue()) / d.getDoubleValue()) * canvasTimeLine.Width); }
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 LynxTime getLynxTimeSpan(double sp, double ep)//从区间折算时间间隔 { LynxTime d = (XShowEndTime - XShowBeginTime) * ((ep - sp) / canvasTimeLine.Width); return(d); }