public void addTourEvent(timelineInfo timelineInfoStruct, TourEvent tourEvent, ScatterView timelineSV, double beginTime, double duration)
        {
            ScatterViewItem currentSVI = new ScatterViewItem();
            currentSVI.MinWidth = 10; // don't want it to disappear, but still need it to be touchable (even if resolution is as low as 1024 x 768)
            currentSVI.MinHeight = 10;
            currentSVI.Width = duration * (timelineWidth / timelineLength);
            currentSVI.Height = timelineHeight - 7;
            currentSVI.Background = new SolidColorBrush(Colors.Transparent);
            currentSVI.Orientation = 0;
            currentSVI.CanRotate = false;
            currentSVI.Deceleration = double.NaN; // disables inertia
            currentSVI.Center = new Point((beginTime * (timelineWidth / timelineLength)) + (currentSVI.Width / 2), (timelineHeight / 2) - 2);
            currentSVI.Opacity = .7;
            currentSVI.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(tourEventSVI_ContainerManipulationCompleted);
            currentSVI.PreviewTouchUp += new EventHandler<TouchEventArgs>(tourEventSVI_PreviewTouchUp);
            currentSVI.PreviewMouseUp += new MouseButtonEventHandler(tourEventSVI_PreviewTouchUp);
            currentSVI.PreviewMouseDown += tourEventSVI_PreviewMouseDown;

            DependencyPropertyDescriptor dpd1 = DependencyPropertyDescriptor.FromProperty(ScatterViewItem.CenterProperty, typeof(ScatterViewItem));
            dpd1.AddValueChanged(currentSVI, tourEventCenterChanged);

            tourEventInfo currentAnimInfo = new tourEventInfo();
            currentAnimInfo.timelineInfoStruct = timelineInfoStruct;
            currentAnimInfo.beginTime = beginTime;
            currentAnimInfo.tourEvent = tourEvent;
            currentAnimInfo.centerY = (timelineHeight / 2) - 2;
            currentAnimInfo.centerX = (beginTime * (timelineWidth / timelineLength)) + (currentSVI.Width / 2);
            currentAnimInfo.originalLoc = beginTime * (timelineWidth / timelineLength);
            Rectangle r = new Rectangle();
            r.Width = currentSVI.Width;
            r.Height = currentSVI.Height;
            Timeline timeline = timelineInfoStruct.timeline;
            if (tourEvent != null)
            {
                LinearGradientBrush fadeInBrush = new LinearGradientBrush();
                fadeInBrush.StartPoint = new Point(0, 0);
                fadeInBrush.EndPoint = new Point(1, 0);
                fadeInBrush.GradientStops.Add(new GradientStop(Colors.Transparent, 0.0));
                fadeInBrush.GradientStops.Add(new GradientStop((Color)System.Windows.Media.ColorConverter.ConvertFromString("#245c4f"), 0.7));
                fadeInBrush.GradientStops.Add(new GradientStop((Color)System.Windows.Media.ColorConverter.ConvertFromString("#245c4f"), 1.0));
                LinearGradientBrush fadeOutBrush = new LinearGradientBrush();
                fadeOutBrush.StartPoint = new Point(0, 0);
                fadeOutBrush.EndPoint = new Point(1, 0);
                fadeOutBrush.GradientStops.Add(new GradientStop(Colors.Transparent, 1.0));
                fadeOutBrush.GradientStops.Add(new GradientStop((Color)System.Windows.Media.ColorConverter.ConvertFromString("#245c4f"), 0.0));
                fadeOutBrush.GradientStops.Add(new GradientStop((Color)System.Windows.Media.ColorConverter.ConvertFromString("#245c4f"), 0.3));
                switch (tourEvent.type)
                {

                    case TourEvent.Type.fadeInMedia:
                        tourSystem.registerDockableItem((tourEvent as FadeInMediaEvent).media, timeline);
                        r.Fill = fadeInBrush;
                        break;
                    case TourEvent.Type.fadeOutMedia:
                        tourSystem.registerDockableItem((tourEvent as FadeOutMediaEvent).media, timeline);
                        r.Fill = fadeOutBrush;
                        break;
                    case TourEvent.Type.zoomMedia:
                        tourSystem.registerDockableItem((tourEvent as ZoomMediaEvent).media, timeline);
                        r.Fill = (Brush)(new BrushConverter().ConvertFrom("#245c4f"));
                        break;
                    case TourEvent.Type.fadeInPath:
                        r.Fill = fadeInBrush;
                        break;
                    case TourEvent.Type.fadeOutPath:
                        r.Fill = fadeOutBrush;
                        break;
                    case TourEvent.Type.fadeInHighlight:
                        r.Fill = fadeInBrush;
                        break;
                    case TourEvent.Type.fadeOutHighlight:
                        r.Fill = fadeOutBrush;
                        break;
                    case TourEvent.Type.zoomMSI:
                        tourSystem.registerMSI((tourEvent as ZoomMSIEvent).msi, timeline);
                        r.Fill = (Brush)(new BrushConverter().ConvertFrom("#245c4f"));
                        break;
                    default:
                        r.Fill = (Brush)(new BrushConverter().ConvertFrom("#245c4f"));
                        break;

                }
            }
            else
            {
                r.Fill = (Brush)(new BrushConverter().ConvertFrom("#245c4f"));
            }
            currentSVI.Content = r;

            currentAnimInfo.r = r;
            currentSVI.Tag = currentAnimInfo;
            if (tourEvent == null)
                currentSVI.IsManipulationEnabled = false;
            currentSVI.PreviewMouseWheel +=new MouseWheelEventHandler(currentSVI_PreviewMouseWheel);
            currentSVI.SizeChanged += new SizeChangedEventHandler(tourEventSVI_SizeChanged);

            timelineSV.Items.Add(currentSVI);
        }
        void mainCanvas_PreviewTouchUp(object sender, TouchEventArgs e)
        {
            bool found = false;

            bool mainSelected = false;
            foreach (timelineInfo i in timeLineList)
            {
                tourSystem.StopDrawingHighlight();
                tourSystem.StopDrawingPath();
                e.GetType();
                if (e.TouchDevice.GetPosition(mainCanvas).Y > i.pos && e.TouchDevice.GetPosition(mainCanvas).Y < i.pos + timelineHeight)
                {

                    found = true;
                    highlightTL(i.pos);
                    highlightData = i;
                    TourTL curTL = (TourTL)highlightData.timeline;
                    if (curTL.type == TourTLType.artwork) mainSelected = true;
                    if (curTL.type != TourTLType.highlight && curTL.type != TourTLType.path)
                    {
                        setButtonEnabled(eraseButton, false);
                        opacitySlider.IsEnabled = false;
                        opacitySlider.Opacity = 0.4;
                    }
                    else
                    {
                        if (curTL.type == TourTLType.highlight)
                        {
                            opacitySlider.IsEnabled = true;
                            opacitySlider.Opacity = 1;
                        }
                        else
                        {
                            opacitySlider.IsEnabled = false;
                            opacitySlider.Opacity = 0.4;
                        }
                        setButtonEnabled(eraseButton, true);
                    }

                    i.lengthSV.IsHitTestVisible = true;
                    EnableDrawingIfNeeded();
                    eraseButton.Content = "Erase";
                    break;
                }
            }

            if (!found)
            {
                removeTLHighlight();
                setButtonEnabled(removeComponentButton, false);
                setButtonEnabled(renameTimelineButton, false);
            }
            else
            {
                setButtonEnabled(removeComponentButton, true);
                setButtonEnabled(renameTimelineButton, true);
                if (mainSelected)
                {
                    setButtonEnabled(removeComponentButton, false);
                }
            }
            EnableDrawingIfNeeded();
        }
        public timelineInfo addTimeline(Timeline timeline, BiDictionary<double, TourEvent> tourTL_dict, String title, double pos)
        {
            timelineInfo current = new timelineInfo();
            current.pos = pos + 3;

            current.timeline = timeline;
            current.tourTL_dict = tourTL_dict;

            current.title = title;
            current.titlebox = new TextBox();
            current.titlebox.Text = title;
            current.titlebox.Height = timelineHeight - 3;
            current.titlebox.Width = textWidth;
            current.titlebox.BorderThickness = new Thickness(0);
            current.titlebox.FontSize = 20;
            current.titlebox.Tag = current;
            current.titlebox.Background = (Brush)(new BrushConverter().ConvertFrom("#093024"));
            current.titlebox.Foreground = Brushes.White;
            current.titlebox.IsHitTestVisible=false;
            titleCanvas.Children.Add(current.titlebox);
            Canvas.SetTop(current.titlebox, pos + 3);

            current.lengthSV = new ScatterView();
            current.lengthSV.Width = timelineWidth;
            current.lengthSV.Height = timelineHeight - 3;
            current.lengthSV.Background = Brushes.White;
            current.lengthSV.IsHitTestVisible = false;

            leftRightCanvas.Children.Add(current.lengthSV);

            Canvas.SetTop(current.lengthSV, pos + 3);

            timeLineList.Add(current);

            return current;
        }
        public void addAudioEvent(timelineInfo timelineInfoStruct, TourEvent tourEvent, ScatterView timelineSV, double beginTime, double duration)
        {
            ScatterViewItem currentSVI = new ScatterViewItem();
            currentSVI.MinWidth = 10; // don't want it to disappear, but still need it to be touchable (even if resolution is as low as 1024 x 768)
            currentSVI.MinHeight = 10;
            currentSVI.Width = duration * (timelineWidth / timelineLength);
            currentSVI.Height = timelineHeight - 7;
            currentSVI.Background = new SolidColorBrush(Colors.Transparent);
            currentSVI.Orientation = 0;
            currentSVI.CanRotate = false;
            currentSVI.Deceleration = double.NaN; // disables inertia
            currentSVI.Center = new Point((beginTime * (timelineWidth / timelineLength)) + (currentSVI.Width / 2), (timelineHeight / 2) - 2);
            currentSVI.Opacity = .7;
            currentSVI.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(tourAudioEventSVI_ContainerManipulationCompleted);
            currentSVI.PreviewTouchUp += new EventHandler<TouchEventArgs>(tourEventSVI_PreviewTouchUp);
            currentSVI.PreviewMouseUp += new MouseButtonEventHandler(tourEventSVI_PreviewTouchUp);

            currentSVI.PreviewTouchUp += new EventHandler<TouchEventArgs>(tourAudioEventSVI_PreviewTouchUp);
            currentSVI.PreviewMouseUp += new MouseButtonEventHandler(tourAudioEventSVI_PreviewTouchUp);
            currentSVI.SizeChanged += new SizeChangedEventHandler(tourEventSVI_SizeChanged);
            currentSVI.PreviewMouseWheel += new MouseWheelEventHandler(currentAudioSVI_PreviewMouseWheel);
            DependencyPropertyDescriptor dpd1 = DependencyPropertyDescriptor.FromProperty(ScatterViewItem.CenterProperty, typeof(ScatterViewItem));
            dpd1.AddValueChanged(currentSVI, tourAudioEventCenterChanged);

            tourEventInfo currentAnimInfo = new tourEventInfo();
            currentAnimInfo.timelineInfoStruct = timelineInfoStruct;
            currentAnimInfo.beginTime = beginTime;
            currentAnimInfo.tourEvent = tourEvent;
            currentAnimInfo.centerY = (timelineHeight / 2) - 2;
            currentAnimInfo.centerX = (beginTime * (timelineWidth / timelineLength)) + (currentSVI.Width / 2);
            currentAnimInfo.originalLoc = beginTime * (timelineWidth / timelineLength);
            Rectangle r = new Rectangle();
            r.Width = currentSVI.Width;
            r.Height = currentSVI.Height;

            r.Fill = (Brush)(new BrushConverter().ConvertFrom("#245c4f"));

            currentSVI.Content = r;

            currentAnimInfo.r = r;
            currentSVI.Tag = currentAnimInfo;

            timelineSV.Items.Add(currentSVI);
        }