コード例 #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
 protected virtual void OnViewDidUnload()
 {
     SelectedBar.RemoveFromSuperview();
     DataSource     = null;
     WeakDataSource = null;
     Delegate       = null;
     WeakDelegate   = null;
     _selectedBar   = null;
     LabelFont      = null;
 }
コード例 #3
0
        private void InitialiseKeyboardAccelerators()
        {
            RecordButton.KeyboardAccelerators.Add(new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.R
            });
            PlayButton.KeyboardAccelerators.Add(new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.P
            });
            StopButton.KeyboardAccelerators.Add(new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.S
            });
            SaveButton.KeyboardAccelerators.Add(new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.S, Modifiers = Windows.System.VirtualKeyModifiers.Control
            });
            LoadButton.KeyboardAccelerators.Add(new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.O, Modifiers = Windows.System.VirtualKeyModifiers.Control
            });

            var copy = new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.C, Modifiers = Windows.System.VirtualKeyModifiers.Control
            };

            copy.Invoked += (s, e) =>
            {
                e.Handled = true;
                if (SelectedBar != null && SelectedBar.Model != null && SelectedBar.Model.Buffer != null)
                {
                    var dataPackage = new DataPackage
                    {
                        RequestedOperation = DataPackageOperation.Copy
                    };
                    dataPackage.SetData("PCM", SelectedBar.Model.Buffer);
                    Clipboard.SetContent(dataPackage);
                }
            };
            KeyboardAccelerators.Add(copy);

            var paste = new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.V, Modifiers = Windows.System.VirtualKeyModifiers.Control
            };

            paste.Invoked += async(s, e) =>
            {
                e.Handled = true;
                if (SelectedBar != null && SelectedBar.Model != null)
                {
                    if (SelectedBar.Model.Buffer == null)
                    {
                        SelectedBar.Model.SetBuffer(new float[Song.SamplesPerBar]);
                    }

                    var content = Clipboard.GetContent();
                    if (content.AvailableFormats.Contains("PCM"))
                    {
                        var data = await content.GetDataAsync("PCM");

                        SelectedBar.Model.SetBuffer(data as float[]);
                        SelectedBar.Update();
                    }
                }
            };
            KeyboardAccelerators.Add(paste);

            var delete = new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.Delete
            };

            delete.Invoked += (s, e) =>
            {
                e.Handled = true;
                if (SelectedBar != null && SelectedBar.Model != null)
                {
                    SelectedBar.Model.SetEmpty();
                    SelectedBar.Update();
                }
            };
            KeyboardAccelerators.Add(delete);

            var left = new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.Left
            };

            left.Invoked += (s, e) =>
            {
                e.Handled = true;
                if (SelectedBar != null)
                {
                    int column = Grid.GetColumn(SelectedBar);
                    int row    = Grid.GetRow(SelectedBar);
                    if (row >= 0 && column >= 0)
                    {
                        var selected = BarGrid.GetChildAt <UI.Bar>(row, column - 1);
                        if (selected != null)
                        {
                            selected.Select();
                        }
                    }
                }
            };
            KeyboardAccelerators.Add(left);

            var right = new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.Right
            };

            right.Invoked += (s, e) =>
            {
                e.Handled = true;
                if (SelectedBar != null)
                {
                    int column = Grid.GetColumn(SelectedBar);
                    int row    = Grid.GetRow(SelectedBar);
                    if (row >= 0 && column >= 0)
                    {
                        var selected = BarGrid.GetChildAt <UI.Bar>(row, column + 1);
                        if (selected != null)
                        {
                            selected.Select();
                        }
                    }
                }
            };
            KeyboardAccelerators.Add(right);

            var up = new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.Up
            };

            up.Invoked += (s, e) =>
            {
                e.Handled = true;
                if (SelectedBar != null)
                {
                    int column = Grid.GetColumn(SelectedBar);
                    int row    = Grid.GetRow(SelectedBar);
                    if (row >= 0 && column >= 0)
                    {
                        var selected = BarGrid.GetChildAt <UI.Bar>(row - 1, column);
                        if (selected != null)
                        {
                            selected.Select();
                        }
                    }
                }
            };
            KeyboardAccelerators.Add(up);

            var down = new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.Down
            };

            down.Invoked += (s, e) =>
            {
                e.Handled = true;
                if (SelectedBar != null)
                {
                    int column = Grid.GetColumn(SelectedBar);
                    int row    = Grid.GetRow(SelectedBar);
                    if (row >= 0 && column >= 0)
                    {
                        var selected = BarGrid.GetChildAt <UI.Bar>(row + 1, column);
                        if (selected != null)
                        {
                            selected.Select();
                        }
                    }
                }
            };
            KeyboardAccelerators.Add(down);

            var save = new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.S, Modifiers = Windows.System.VirtualKeyModifiers.Control
            };

            save.Invoked += (s, e) =>
            {
                e.Handled = true;
                Save();
            };
            KeyboardAccelerators.Add(save);

            var console = new KeyboardAccelerator {
                Key = Windows.System.VirtualKey.O, Modifiers = Windows.System.VirtualKeyModifiers.Control
            };

            console.Invoked += (s, e) =>
            {
                e.Handled = true;
                ToggleOutputwindow();
            };
            KeyboardAccelerators.Add(console);
        }