Exemple #1
0
        private void BarRemoved(Core.Model.Bar bar)
        {
            var ui = BarGrid.GetChildren <UI.Bar>().Single(b => b.Model == bar);

            BarGrid.Children.Remove(ui);
            AddLog("Bar removed");
        }
Exemple #2
0
 private void ChangeBarGridAnima(ref double oldOne, double newOne)
 {
     if (!isNative)
     {
         return;
     }
     if (!isMobileAnimaCompleted)
     {
         return;
     }
     if (newOne - oldOne < -20 && BarGrid.Visibility == Visibility.Collapsed)
     {
         isMobileAnimaCompleted = false;
         BarGrid.SetVisibility(true);
         Scroll.ViewChanged -= Scroll_ViewChanged;
         BtnStackSlideIn.Begin();
     }
     else if (newOne - oldOne > 20 && BarGrid.Visibility == Visibility.Visible)
     {
         isMobileAnimaCompleted = false;
         Scroll.ViewChanged    -= Scroll_ViewChanged;
         BtnStackSlideOut.Begin();
     }
     oldOne = newOne;
 }
Exemple #3
0
        private async void SetWebViewSourceAsync(Uri uri)
        {
            try {
                var result = htmlReturn = await DoubanWebProcess.GetMDoubanResponseAsync(
                    path : uri.ToString(),
                    host : "m.douban.com",
                    reffer : "https://m.douban.com/");

                var doc = new HtmlDocument();
                doc.LoadHtml(result);
                var shouldNative = IfCanGetContent(doc.DocumentNode);
                if (shouldNative)
                {
                    WebView.NavigateToString(GetContent(doc.DocumentNode));
                    SetTitleAndDescForShare(doc);
                    SetAuthorGrid();
                }
                else
                {
                    WebView.Source = uri;
                    BarGrid.SetVisibility(false);
                    isNative = false;
                }
            } catch {
                WebView.Source = uri;
            }
        }
Exemple #4
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");
        }
Exemple #5
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);
        }
Exemple #6
0
 private void DoublAnimationOut_Completed(object sender, object e)
 {
     BarGrid.SetVisibility(false);
     Scroll.ViewChanged    += Scroll_ViewChanged;
     isMobileAnimaCompleted = true;
 }