Exemplo n.º 1
0
        private void ScrollToHorizontalOffset(double newX)
        {
            double deltaX      = TimelineOffsetX - newX;
            double canvasWidth = TimelineCanvas.ActualWidth;
            //Move Dates
            int j = DateControls.Count;

            for (int i = 0; i < j; i++)
            {
                Control con       = DateControls.ElementAt(i);
                double  leftStart = Canvas.GetLeft(con);
                double  leftEnd   = leftStart + deltaX;
                if (leftEnd >= (canvasWidth + DateOffset))
                {
                    DateControls.Remove(con);
                    DateControls.AddFirst(con);
                    startDate = startDate - new TimeSpan(1, 0, 0, 0);
                    string displayString = startDate.Month + "/" + startDate.Day;
                    TextPropertyExtension.SetTextSource(con, displayString);

                    double nextLeft = Canvas.GetLeft(DateControls.ElementAt(1));
                    Canvas.SetLeft(con, nextLeft - DateOffset);
                }
                else if (leftEnd <= (-DateOffset))
                {
                    DateControls.Remove(con);
                    DateControls.AddLast(con);

                    startDate = startDate + new TimeSpan(1, 0, 0, 0);
                    DateTime newDate       = startDate + new TimeSpan(GetDateCount - 1, 0, 0, 0);
                    string   displayString = newDate.Month + "/" + newDate.Day;
                    TextPropertyExtension.SetTextSource(con, displayString);

                    double nextLeft = Canvas.GetLeft(DateControls.ElementAt(DateControls.Count - 2));
                    Canvas.SetLeft(con, nextLeft + DateOffset);
                    i--;
                    j--;
                }
                else
                {
                    Canvas.SetLeft(con, leftEnd);
                }

                if (startDate == vm.GetCreationDate() &&
                    Canvas.GetLeft(con) <= hInitialOff)
                {
                    reachedStart = true;
                }
            }


            //Move blocks
            double newPhaseX = Canvas.GetLeft(PhaseChunksParent) + deltaX;

            Canvas.SetLeft(PhaseChunksParent, newPhaseX);

            //Adjust tooltips

            TimelineOffsetX = newX;
        }
Exemplo n.º 2
0
        private void InitializeTimeline()
        {
            //Init dates
            startDate = vm.GetCreationDate();
            ControlTemplate dateTemplate = (ControlTemplate)TryFindResource("DateTemplate");
            CultureInfo     culture      = new CultureInfo("en-US");

            for (int i = 0; i < GetDateCount; i++)
            {
                Control dateControlInst = new Control();
                dateControlInst.Template = dateTemplate;
                TimeSpan addedDay      = new TimeSpan(i, 0, 0, 0);
                DateTime newDay        = startDate + addedDay;
                string   displayString = newDay.Month + "/" + newDay.Day;
                if (i == 0)
                {
                    startDateDisplayString = displayString;
                }
                TextPropertyExtension.SetTextSource(dateControlInst, displayString);
                TimelineCanvas.Children.Add(dateControlInst);
                Canvas.SetTop(dateControlInst, 10);
                Canvas.SetLeft(dateControlInst, (DateOffset * i) + hOff + hInitialOff);
                DateControls.AddLast(dateControlInst);
            }

            // Phase blocks
            InitPhaseBlocks();
        }