示例#1
0
 /// <summary>
 /// Sets the CollisionDetectionManager.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="collisionDetectionManager">The CollisionDetectionManager.</param>
 public static void SetCollisionDetectionManager(DependencyObject element, CollisionDetectionManager collisionDetectionManager)
 {
     element.SetValue(GraphBase.CollisionDetectionManagerProperty, collisionDetectionManager);
 }
示例#2
0
        /// <summary>
        /// Draws the graph.
        /// </summary>
        /// <param name="panel">The panel.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="panelNumber">The panel number.</param>        
        protected override void DrawPanel(PanelWrapper panel, long offset, int panelNumber)
        {
            if (null == this.VisibleWindow || !this.IsInitialized)
            {
                return;
            }

            this.CurrentWorkingPanelCallback = panelNumber;
            this.DynamicTopAxisLayer = ((Grid)panel.Children[0]).FindName(DynamicTopAxisLayerElementName) as Canvas;
            this.DynamicPlotLayerViewport = ((Grid)panel.Children[0]).FindName(DynamicPlotLayerViewportElementName) as Canvas;
            this.DynamicPlotLayerViewport.SizeChanged += new SizeChangedEventHandler(this.DynamicPlotLayerViewport_SizeChanged);

            this.DynamicPlotLayer = ((Grid)panel.Children[0]).FindName(DynamicPlotLayerElementName) as Canvas;
            this.DynamicTopAxisLayerViewport = ((Grid)panel.Children[0]).FindName(DynamicTopAxisLayerViewportElementName) as Canvas;
            this.MinimizedPlotLayer = ((Grid)panel.Children[0]).FindName(MinimizedPlotLayerElementName) as Canvas;

            this.DynamicPlotLayer.Visibility = this.Minimized ? Visibility.Collapsed : Visibility.Visible;
            if (this.MinimizedPlotLayer != null)
            {
                this.MinimizedPlotLayer.Visibility = this.Minimized ? Visibility.Visible : Visibility.Collapsed;
            }

            CollisionDetectionManager collisionDetectionManager = new CollisionDetectionManager();
            GraphBase.SetCollisionDetectionManager(panel, collisionDetectionManager);
            GraphBase.SetCollisionDetectionManager(this.DynamicPlotLayer, collisionDetectionManager);

            // need to increment the currentWindowStartDate by figuring out the amount of time a 
            // window/page represents, and times that by the number of pages we are from the start.
            // we do this by figuring out the ticks for a window.
            // we then multiply this by the number in the offset.
            long ticks = 0;
            long totalTicks = 0;
            try
            {
                if (null != this.VisibleWindow)
                {
                    ticks = checked(this.VisibleWindow.Ticks * offset);
                    totalTicks = checked(this.AxisStartDate.Ticks + ticks);
                }
            }
            catch (System.OverflowException e)
            {
                // style update.
                if (null != e)
                {
                    totalTicks = DateTime.MaxValue.Ticks + 1;
                }
            }

            ////it is possible to configure the Graph so that we try to go to a date that is beyond that
            ////that can be represented. e.g Window size is 10 years, and goto some huge page offset.
            ////if we do try that, then do nothing.

            if (totalTicks <= DateTime.MaxValue.Ticks)
            {
                this.CurrentWindowStartDate = this.AxisStartDate.AddTicks(ticks);
                panel.StartDate = this.CurrentWindowStartDate;
                panel.EndDate = panel.StartDate.AddTicks(this.VisibleWindow.Ticks);
                this.DynamicPlotLayer.Children.Clear();
                this.DynamicTopAxisLayer.Children.Clear();                

                // when we draw the graph, we want to plot first because the overlap 
                // detection does not want to have grid lines to worry about.
                if (this.DataContext != null)
                {
                    this.InvalidDateSelected = false;

                    DateTime tempDate = this.CurrentWindowStartDate.AddTicks(this.VisibleWindow.Ticks);
                    IEnumerable enumerable = this.GetFilteredData(this.CurrentWindowStartDate, tempDate);
                    if (enumerable != null)
                    {
                        this.DrawFilteredTimeGraph(enumerable, panel);
                    }
                    else
                    {
                        this.DrawTimeGraph();
                    }
                }

                this.DrawTimeXAxis(offset);
            }            
        }
    // Use this for initialization
    void Start()
    {
        collisionDetectionManager = new CollisionDetectionManager();

        PassSceneObjects();
    }