コード例 #1
0
        private void BarAdded(Core.Model.Bar bar)
        {
            var track = TrackHeaders.GetChildren <UI.Track>().SingleOrDefault(t => t.Model == bar.Track);

            var row    = Grid.GetRow(track);
            var column = bar.Track.Bars.IndexOf(bar);

            while (BarGrid.ColumnDefinitions.Count <= column)
            {
                BarGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(Constants.BarWidth)
                });
            }

            var ui = new UI.Bar(bar, track);

            ui.Selected += (s, b) =>
            {
                SelectedBar?.Deselect();
                SelectedBar = ui;
            };
            bar.Updated += (s, fullUpdate) =>
            {
                ui.FullUpdate = fullUpdate;
                UpdateBars.Enqueue(ui);
            };
            Grid.SetRow(ui, row);
            Grid.SetColumn(ui, column);

            BarGrid.Children.Add(ui);

            AddLog("Bar added");
        }
コード例 #2
0
        private void OnTrackRemoved(Core.Model.Track track)
        {
            Stop();
            var index = TrackHeaders.GetChildren <UI.Track>().Select(x => x.Model).ToList().IndexOf(track);

            TrackHeaders.Children.RemoveAt(index);
            BarGrid.RowDefinitions.RemoveAt(0);

            TrackHeaders.GetChildren <UI.Track>(t => Grid.GetRow(t) > index).ForEach(t => Grid.SetRow(t, Grid.GetRow(t) - 1));
            BarGrid.GetChildren <UI.Bar>(b => Grid.GetRow(b) > index).ForEach(b => Grid.SetRow(b, Grid.GetRow(b) - 1));

            AddLog("Track removed");
        }