public SectionPage()
        {
            this.InitializeComponent();

            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
            this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
        }
 public instList()
 {
     this.InitializeComponent();
     //DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
     this.navigationHelper = new NavigationHelper(this);
     this.navigationHelper.LoadState += navigationHelper_LoadState;
     this.navigationHelper.SaveState += navigationHelper_SaveState;
     // HardwareButtons.BackPressed += HardwareButtons_BackPressed;
     list = new List<ItemInstrument> { new ItemInstrument("Bass", "/Assets/Instruments/Vertical/bass.png"), new ItemInstrument("Darbuka", "/Assets/Instruments/Vertical/darbuka.png"), new ItemInstrument("Drums", "/Assets/Instruments/Vertical/drums.png"), new ItemInstrument("Guitar", "/Assets/Instruments/Vertical/guitar.png"), new ItemInstrument("Oud", "/Assets/Instruments/Vertical/oud.png"), new ItemInstrument("Piano", "/Assets/Instruments/Vertical/piano.png"), new ItemInstrument("Oud Maqam", "/Assets/Instruments/Vertical/oud.png") };
     InstruList.ItemsSource = list;
     InstruList.DataContext = list;
 }
Esempio n. 3
0
        public HubPage()
        {
            this.InitializeComponent();

            // Hub is only supported in Portrait orientation
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;

            this.NavigationCacheMode = NavigationCacheMode.Required;

            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
            this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
        }
        public Keyboard()
        {
            this.InitializeComponent();
            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += navigationHelper_LoadState;
            this.navigationHelper.SaveState += navigationHelper_SaveState;

            //keyboard

            Loaded += delegate
            {
                // access ActualWidth and ActualHeight here
                double ActualWidth = NoteButton2.ActualWidth * 0.5;
                double BlackKeysWidth = NoteButton2.ActualWidth * 0.8;

                NoteButtonB1.Width = BlackKeysWidth;
                NoteButtonB2.Width = BlackKeysWidth;
                NoteButtonB3.Width = BlackKeysWidth;
                NoteButtonB4.Width = BlackKeysWidth;
                NoteButtonB5.Width = BlackKeysWidth;
                NoteButtonB6.Width = BlackKeysWidth;
                NoteButtonB7.Width = BlackKeysWidth;
                NoteButtonB8.Width = BlackKeysWidth;
                NoteButtonB9.Width = BlackKeysWidth;
                NoteButtonB10.Width = BlackKeysWidth;

                blackKeys.Margin = new Thickness(ActualWidth, 0, -ActualWidth, 0);

            };

            layerName.GotFocus += (sender, ee) =>
            {
                layerName.Text = "";
            };

            if (SharedInformations.isInstTry)
            {
                PlayStopButton.Visibility = Visibility.Collapsed;
                RecordButton.Visibility = Visibility.Collapsed;
                SaveLayerButton.Visibility = Visibility.Collapsed;
                cmdBar.Visibility = Visibility.Collapsed;
                LayerProgressTime.Visibility = Visibility.Collapsed;
                pageTitle.Text = SharedInformations.SelectedInstrument.Title;
            }
            else
            {
                layer = new ItemLayer(SharedInformations.SelectedProject.Title, layerName.Text, "/Assets/Instruments/Wide/" + SharedInformations.SelectedInstrument.Title.ToLower() + ".png", true, new List<RecordedNote>(), SharedInformations.SelectedInstrument.Title, 4);
                pageTitle.Text = "Keyboard";

                LayerProgressTime.Maximum = layerTimeLengthInMilliSeconds = GetLayerTimeLengthInMilliSeconds();

                playTimer = new DispatcherTimer();
                playTimer.Interval = TimeSpan.FromMilliseconds(30);
                playTimer.Tick += (sen, ev) =>
                {
                    var notes = layer.recordedNotes.Where(n => n.time >= playTime && n.time < playTime + 30);
                    foreach (RecordedNote recordedNote in notes)
                    {
                        MusicReader.PlayNote(recordedNote.note);
                    }

                    //if the cursor exceeds the length of the whole track
                    if (playTime >= layerTimeLengthInMilliSeconds)
                    {
                        //the cursor returns to the start of the track (-30 and increases with 30 = 0) to replay it
                        playTime = -30;
                    }
                    //increasing the cursor with 30 ms
                    playTime += 30;

                    //updating the value of the progress bar
                    LayerProgressTime.Value = playTime;
                };

                recordTimer = new DispatcherTimer();
                recordTimer.Interval = TimeSpan.FromMilliseconds(30);
                recordTimer.Tick += (sen, ev) =>
                {
                    if (recordTime >= layerTimeLengthInMilliSeconds)
                    {
                        recording = false;
                        recordTimer.Stop();
                        recordTime = 0;
                        LayerProgressTime.Value = 0;
                    }
                    recordTime += 30;

                    LayerProgressTime.Value = recordTime;
                };

                layer.recordedNotes = new List<RecordedNote>();

                LayerProgressTime.Visibility = Visibility.Visible;
                PlayStopButton.Visibility = Visibility.Visible;
                RecordButton.Visibility = Visibility.Visible;
                SaveLayerButton.Visibility = Visibility.Visible;

                cmdBar.Visibility = Visibility.Visible;
            }

            if (SharedInformations.SelectedInstrument.Title.Equals("Drums") || SharedInformations.SelectedInstrument.Title.Equals("Darbuka"))
            {
                mpc.Visibility = Visibility.Visible;
                pianoKeys.Visibility = Visibility.Collapsed;
                blackKeys.Visibility = Visibility.Collapsed;

                notes = new Dictionary<String, String>();

                notes.Add("mpc1", "Assets/" + SharedInformations.SelectedInstrument.Title + "1.wav");
                notes.Add("mpc2", "Assets/" + SharedInformations.SelectedInstrument.Title + "2.wav");
                notes.Add("mpc3", "Assets/" + SharedInformations.SelectedInstrument.Title + "3.wav");
                notes.Add("mpc4", "Assets/" + SharedInformations.SelectedInstrument.Title + "4.wav");
                notes.Add("mpc5", "Assets/" + SharedInformations.SelectedInstrument.Title + "5.wav");
                notes.Add("mpc6", "Assets/" + SharedInformations.SelectedInstrument.Title + "6.wav");
                notes.Add("mpc7", "Assets/" + SharedInformations.SelectedInstrument.Title + "7.wav");
                notes.Add("mpc8", "Assets/" + SharedInformations.SelectedInstrument.Title + "8.wav");
                MusicReader.FillNotes(SharedInformations.SelectedInstrument.Title, false);
            }
            else
            {
                mpc.Visibility = Visibility.Collapsed;
                pianoKeys.Visibility = Visibility.Visible;
                blackKeys.Visibility = Visibility.Visible;

                notes = new Dictionary<String, String>();

                notes.Add("NoteButton1", "Assets/" + SharedInformations.SelectedInstrument.Title + "1.wav");
                notes.Add("NoteButton2", "Assets/" + SharedInformations.SelectedInstrument.Title + "2.wav");
                notes.Add("NoteButton3", "Assets/" + SharedInformations.SelectedInstrument.Title + "3.wav");
                notes.Add("NoteButton4", "Assets/" + SharedInformations.SelectedInstrument.Title + "4.wav");
                notes.Add("NoteButton5", "Assets/" + SharedInformations.SelectedInstrument.Title + "5.wav");
                notes.Add("NoteButton6", "Assets/" + SharedInformations.SelectedInstrument.Title + "6.wav");
                notes.Add("NoteButton7", "Assets/" + SharedInformations.SelectedInstrument.Title + "7.wav");
                notes.Add("NoteButton8", "Assets/" + SharedInformations.SelectedInstrument.Title + "8.wav");
                notes.Add("NoteButton9", "Assets/" + SharedInformations.SelectedInstrument.Title + "9.wav");
                notes.Add("NoteButton10", "Assets/" + SharedInformations.SelectedInstrument.Title + "10.wav");
                notes.Add("NoteButton11", "Assets/" + SharedInformations.SelectedInstrument.Title + "11.wav");
                notes.Add("NoteButton12", "Assets/" + SharedInformations.SelectedInstrument.Title + "12.wav");
                notes.Add("NoteButton13", "Assets/" + SharedInformations.SelectedInstrument.Title + "13.wav");
                notes.Add("NoteButton14", "Assets/" + SharedInformations.SelectedInstrument.Title + "14.wav");
                notes.Add("NoteButtonB1", "Assets/" + SharedInformations.SelectedInstrument.Title + "_1.wav");
                notes.Add("NoteButtonB2", "Assets/" + SharedInformations.SelectedInstrument.Title + "_2.wav");
                notes.Add("NoteButtonB3", "Assets/" + SharedInformations.SelectedInstrument.Title + "_3.wav");
                notes.Add("NoteButtonB4", "Assets/" + SharedInformations.SelectedInstrument.Title + "_4.wav");
                notes.Add("NoteButtonB5", "Assets/" + SharedInformations.SelectedInstrument.Title + "_5.wav");
                notes.Add("NoteButtonB6", "Assets/" + SharedInformations.SelectedInstrument.Title + "_6.wav");
                notes.Add("NoteButtonB7", "Assets/" + SharedInformations.SelectedInstrument.Title + "_7.wav");
                notes.Add("NoteButtonB8", "Assets/" + SharedInformations.SelectedInstrument.Title + "_8.wav");
                notes.Add("NoteButtonB9", "Assets/" + SharedInformations.SelectedInstrument.Title + "_9.wav");
                notes.Add("NoteButtonB10", "Assets/" + SharedInformations.SelectedInstrument.Title + "_10.wav");
                MusicReader.FillNotes(SharedInformations.SelectedInstrument.Title, true);

            }

            //Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
            //Window.Current.CoreWindow.KeyUp += CoreWindow_KeyUp;
        }
Esempio n. 5
0
 public ItemPage()
 {
     this.InitializeComponent();
     this.navigationHelper = new NavigationHelper(this);
     this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
 }
        public LayersList()
        {
            this.InitializeComponent();
            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += navigationHelper_LoadState;
            this.navigationHelper.SaveState += navigationHelper_SaveState;

            deleteNo.Click += (sender, ee) =>
            {
                if (StandardPopup.IsOpen) { StandardPopup.IsOpen = false; }

            };

            deleteYes.Click += (sender, ee) =>
            {
                IsolatedStorageHelper.DeleteObject(Headers.Layer + SharedInformations.SelectedProject.Title + ((ee.OriginalSource as Button).DataContext as ItemLayer).Title);
                SharedInformations.SelectedProject.Layers = IsolatedStorageHelper.GetAllObjects<ItemLayer>(Headers.Layer + SharedInformations.SelectedProject.Title);
                InstruList.ItemsSource = SharedInformations.SelectedProject.Layers;
                InstruList.DataContext = SharedInformations.SelectedProject.Layers;
                if (SharedInformations.SelectedProject.Layers.Capacity > 0) whenEmpty.Visibility = Visibility.Collapsed; else whenEmpty.Visibility = Visibility.Visible;

                if (StandardPopup.IsOpen) { StandardPopup.IsOpen = false; }
            };
            SharedInformations.SelectedProject.Layers = IsolatedStorageHelper.GetAllObjects<ItemLayer>(Headers.Layer + SharedInformations.SelectedProject.Title);
            InstruList.ItemsSource = SharedInformations.SelectedProject.Layers;
            InstruList.DataContext = SharedInformations.SelectedProject.Layers;
               // HardwareButtons.BackPressed += HardwareButtons_BackPressed;
            if (SharedInformations.SelectedProject.Layers.Capacity > 0) whenEmpty.Visibility = Visibility.Collapsed; else whenEmpty.Visibility = Visibility.Visible;

            //set max of progressbar
            TrackProgressTime.Maximum = trackTimeLengthInMilliSeconds = GetTrackTimeLengthInMilliSeconds();

            //setting the player timer
            playTimer = new DispatcherTimer();
            playTimer.Interval = TimeSpan.FromMilliseconds(30);
            playTimer.Tick += (sen, ev) =>
            {
                //browsing all the layers
                foreach (ItemLayer layer in SharedInformations.SelectedProject.Layers)
                {
                    //only if enabled
                    if (layer.IsEnabled)
                    {//extracting notes which should be played now (between the time handled by the cursor and the time after 30 ms)
                        var noteList = layer.recordedNotes.Where(n => n.time >= playTime && n.time < playTime + 30);
                        //browsing the list of the extracted notes
                        foreach (RecordedNote recordedNote in noteList)
                        {

                            MusicReader.PlayNote(recordedNote.note);
                        }
                    }
                }

                //if the cursor exceeds the length of the whole track
                if (playTime >= trackTimeLengthInMilliSeconds)
                {
                    ///the cursor returns to the start of the track (-30 and increases with 30 = 0) to replay it
                    playTime = -30;
                }
                //increasing the cursor with 30 ms
                playTime += 30;

                //updating the value of the progress bar
                TrackProgressTime.Value = playTime;
            };
        }