Example #1
0
        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;
            }
        }
Example #2
0
        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);
        }
Example #3
0
        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;
            }
        }