private void layer_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            //Update the layer that was changed
            TimelineLayerView layer = (TimelineLayerView)sender;

            layer.UpdateInterface();
        }
        private void UpdateLayer(TimelineLayerView layer)
        {
            //Updates the given layer

            //set the pan and scale factors
            layer.Pan         = Pan;
            layer.ScaleFactor = ScaleFactor;
        }
        public void AddLayer(TimelineLayerView layer)
        {
            //Add it to the list
            layers.Add(layer);

            //Set the layer's alignment
            layer.HorizontalAlignment = HorizontalAlignment.Stretch;
            layer.VerticalAlignment   = VerticalAlignment.Stretch;
            layer.Margin = new Thickness(0);

            //Create a new row in the grid for the layer
            if (layerGrid.RowDefinitions.Count < layers.Count)
            {
                layerGrid.RowDefinitions.Add(new RowDefinition());
            }

            int rowIndex = layerGrid.RowDefinitions.Count - 1;

            layerGrid.RowDefinitions[rowIndex].MinHeight = 0;

            //Put the layer in the grid
            Grid.SetColumn(layer, 0);
            Grid.SetRow(layer, rowIndex);
            layerGrid.Children.Add(layer);

            //Add a splitter
            layerGrid.RowDefinitions.Add(new RowDefinition());

            GridSplitter splitter = new GridSplitter();

            splitter.Height              = 5;
            splitter.VerticalAlignment   = VerticalAlignment.Bottom;
            splitter.HorizontalAlignment = HorizontalAlignment.Stretch;

            splitter.ResizeBehavior  = GridResizeBehavior.BasedOnAlignment;
            splitter.ResizeDirection = GridResizeDirection.Rows;

            //splitter.Style = Resources["DarkGridSplitterStyle"] as Style;

            Grid.SetColumn(splitter, 0);
            Grid.SetRow(splitter, rowIndex);
            layerGrid.Children.Add(splitter);

            //Subscribe to the layer's events.
            layer.SizeChanged  += layer_SizeChanged;
            layer.entryResized += layer_entryResized;

            //Update this layer
            UpdateLayer(layer);
        }
        public TimelineEntryControl(TimelineEntry timelineEntry, TimelineLayerView parentLayerView)
        {
            this.timelineEntry   = timelineEntry;
            this.parentLayerView = parentLayerView;

            InitializeComponent();

            //Initialize the drag monitors
            leftHandleDragMonitor               = new MouseDragMonitor(leftHandle, MouseButton.Left);
            leftHandleDragMonitor.DragMoved    += LeftHandleDragMonitor_DragMoved;
            leftHandleDragMonitor.DragReleased += LeftHandleDragMonitor_DragReleased;

            rightHandleDragMonitor               = new MouseDragMonitor(rightHandle, MouseButton.Left);
            rightHandleDragMonitor.DragMoved    += RightHandleDragMonitor_DragMoved;
            rightHandleDragMonitor.DragReleased += RightHandleDragMonitor_DragReleased;

            moveDragMonitor               = new MouseDragMonitor(visibleRectangle, MouseButton.Left);
            moveDragMonitor.DragMoved    += MoveDragMonitor_DragMoved;
            moveDragMonitor.DragReleased += MoveDragMonitor_DragReleased;
        }
        public MainWindow()
        {
            InitializeComponent();

            //Subscribe to the timeline pan watcher so we can be informed when the user pans
            timelinePanWatcher            = new MouseDragMonitor(timelineView, MouseButton.Middle);
            timelinePanWatcher.DragMoved += TimelinePanWatcher_DragMoved;

            //Set up the timeline view
            TimelineLayerView layerA = new TimelineLayerView();
            TimelineLayerView layerB = new TimelineLayerView();

            timelineView.AddLayer(layerA);
            timelineView.AddLayer(layerB);

            layerA.AddEntry(new TimelineEntry("0-10", 0, 10, null));
            layerB.AddEntry(new TimelineEntry("0-10", 0, 10, null));

            layerA.AddEntry(new TimelineEntry("20-25", 20, 25, null));
            layerB.AddEntry(new TimelineEntry("20-25", 20, 25, null));
        }