Ejemplo n.º 1
0
        /// <summary>
        /// Draws ticks below the nodes to represent the seconds of each timeline interval
        /// </summary>
        /// <param name="beginDate">begin date of a timeline period</param>
        /// <param name="endDate"> end date of a timeline period</param>
        private void AddTicks(DateTime beginDate, DateTime endDate)
        {
            TimelinePanel timelinePanel = MakeTimelinePanel(beginDate, endDate);

            AddTicksBar(beginDate, endDate);
            int timePeriod = (int)endDate.Subtract(beginDate).TotalSeconds;

            for (int i = 0; i < timePeriod; i++)
            {
                Line tick = new Line();
                tick.Stroke          = Brushes.Black;
                tick.X1              = 10;
                tick.X2              = 10;
                tick.Y1              = 0;
                tick.Y2              = 20;
                tick.StrokeThickness = 1;

                TimelinePanel.SetDate(tick, beginDate);
                timelinePanel.Children.Add(tick);
                beginDate = beginDate.AddSeconds(1);
            }
            Ticks.Children.Add(timelinePanel);

            Line separationLine = MakeTimelineSeparatingLine();

            separationLine.Visibility = Visibility.Hidden; // Hidden since this line is added only for proper spacing
            Ticks.Children.Add(separationLine);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws a line to connect a node to a timeline
        /// </summary>
        /// <param name="timelinePanel">timeline panel to hold and position connection lines</param>
        /// <param name="eventTime">time used as position for where to draw a connecting line</param>
        private void ConnectNodeToTimeline(TimelinePanel timelinePanel, DateTime eventTime)
        {
            Line connectorLine = new Line();

            connectorLine.Stroke          = Brushes.LightSteelBlue;
            connectorLine.X1              = 10;
            connectorLine.X2              = 10;
            connectorLine.Y1              = 0;
            connectorLine.Y2              = 15;
            connectorLine.StrokeThickness = 1;

            TimelinePanel.SetDate(connectorLine, eventTime);
            timelinePanel.Children.Add(connectorLine);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a timeline with the given events and adds it to the UI.
        /// </summary>
        /// <param name="nodesCluster">list of events that belong in 1 timeline</param>
        private void AddTimeline(List <Node.Node> nodesCluster)
        {
            DateTime beginDate = DateTimeRoundDown(nodesCluster[0].aEvent.EventTime, maxRealTimeSpan);
            DateTime endDate   = beginDate.AddMinutes(1);

            TimelinePanel timelinePanel = MakeTimelinePanel(beginDate, endDate);
            TimelinePanel blockPanel    = MakeBlockPanel(beginDate, endDate);

            List <StackedNodes> stackedNodesList = GetStackedNodes(nodesCluster);

            // Add all nodes that stack onto a timeline
            foreach (StackedNodes stackedNode in stackedNodesList)
            {
                stackedNode.Click      += DotPress;
                stackedNode.MouseEnter += HoverStackedNodes;
                stackedNode.MouseLeave += HoverStackedNodes;
                stackedNode.Style       = (Style)Resources["StackedNode"];
                TimelinePanel.SetDate(stackedNode, stackedNode.events[0].EventTime);
                stackedNode.Content = stackedNode.events.Count.ToString();
                allNodes.Add(stackedNode);
                timelinePanel.Children.Add(stackedNode);
                ConnectNodeToTimeline(timelinePanel, stackedNode.events[0].EventTime);

                // Adds invisible blocks as padding for a nice vertical allignment.
                int       numBlocksNeeded = maxStackedNodes - stackedNode.nodes.Count;
                TextBlock alignmentBlock  = new TextBlock
                {
                    Style      = (Style)Resources["TimelineBlock"],
                    Visibility = Visibility.Collapsed,
                    Height     = numBlocksNeeded * 70
                };

                stackedNode.alignmentBlock = alignmentBlock;
                TimelinePanel.SetDate(stackedNode.alignmentBlock, stackedNode.nodes[0].GetBlockTime());
                blockPanel.Children.Add(stackedNode.alignmentBlock);

                // Adds the actual node blocks
                foreach (Node.Node node in stackedNode.nodes)
                {
                    node.IsChecked   = false;
                    node.block.Style = (Style)Resources["TimelineBlock"];
                    TimelinePanel.SetDate(node.block, node.GetBlockTime());
                    blockPanel.Children.Add(node.block);
                }
            }
            // Add all other nodes onto a timeline
            foreach (Node.Node node in nodesCluster)
            {
                node.MouseEnter -= HoverNode;
                node.MouseLeave -= HoverNode;
                node.MouseEnter += HoverNode;
                node.MouseLeave += HoverNode;
                TimelinePanel.SetDate(node, node.aEvent.EventTime);
                allNodes.Add(node);
                timelinePanel.Children.Add(node);
                ConnectNodeToTimeline(timelinePanel, node.aEvent.EventTime);

                // Adds invisible block as padding for a nice vertical allignment.
                TextBlock alignmentBlock = new TextBlock
                {
                    Style      = (Style)Resources["TimelineBlock"],
                    Visibility = Visibility.Collapsed,
                    Height     = (maxStackedNodes - 1) * 70
                };

                node.alignmentBlock = alignmentBlock;
                TimelinePanel.SetDate(node.alignmentBlock, node.GetBlockTime());
                blockPanel.Children.Add(node.alignmentBlock);


                // Adds the actual node blocks
                node.IsChecked   = false;
                node.block.Style = (Style)Resources["TimelineBlock"];
                TimelinePanel.SetDate(node.block, node.GetBlockTime());
                blockPanel.Children.Add(node.block);
            }

            Timelines.Children.Add(timelinePanel);

            Blocks.Children.Add(blockPanel);
            Line separationLine  = MakeTimelineSeparatingLine();
            Line blockSeperation = MakeBlockPanelSeparation();

            Blocks.Children.Add(blockSeperation);
            Timelines.Children.Add(separationLine);
            AddTicks(beginDate, endDate);
            AddTimeStamp(beginDate, endDate);
        }