コード例 #1
0
ファイル: EditRingtone.xaml.cs プロジェクト: Setuber/Ringify
        private void Button_Ringify_Click2(object sender, RoutedEventArgs e)
        {
            string strMsg = string.Empty;
            int trimStart = (int)Slider.RangeStart;
            int trimEnd = (int)Slider.RangeEnd;

            try
            {
                if (Song != null &&
                    Song.Trim(new TimeSpan(trimStart * 1000 * 1000 * 10 + 1000), new TimeSpan(trimEnd * 1000 * 1000 * 10), "RINGIFY_RINGTONE.mp3"))
                {
                    // Call the Save Reingtone Chooser
                    IsolatedStorageFile Store = IsolatedStorageFile.GetUserStoreForApplication();
                    if (Store.FileExists("RINGIFY_RINGTONE.mp3"))
                    {
                        MP3File Test = new MP3File();
                        Test.Initialize("RINGIFY_RINGTONE.mp3");

                        if (Test.Size < 1048576)
                        {
                            saveRingtoneChooser.Source = new Uri("isostore:/" + "RINGIFY_RINGTONE.mp3");
                            // Hard-coded name of the test sound file in the project
                            saveRingtoneChooser.DisplayName = TextBox_SongTitle.Text;
                            saveRingtoneChooser.Show();
                        }
                        else
                        {
                            MessageBox.Show("File Too Large [" + Test.Size + "].\nPlease shorten the Ringtone clip and try again.");
                            TextBlock_Error.Text = "File Too Large! [" + Test.Size + "]";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debugger.Trace(ex);
            }

            Debugger.Trace(strMsg);
        }
コード例 #2
0
ファイル: EditRingtone.xaml.cs プロジェクト: Setuber/Ringify
        private void LoadSong(SongInfo i_Song)
        {
            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                progressBar1.Visibility = System.Windows.Visibility.Collapsed;
                TextBox_SongTitle.IsEnabled = true;
                Slider.IsEnabled = true;
                //slider2.IsEnabled = true;
                Button_PlayPause.IsEnabled = true;
                Button_Ringify.IsEnabled = true;
                Button_Cancel.IsEnabled = true;

                //Load Song
                WavFile WAV = new WavFile();
                MP3File MP3 = new MP3File();

                if (WAV.Initialize(Strings.Directory_Songs + "/" + App.ViewModel.SelectedSong.SongTitle))
                {
                    Song = WAV;
                }
                else if (MP3.Initialize(Strings.Directory_Songs + "/" + App.ViewModel.SelectedSong.SongTitle))
                {
                    Song = MP3;
                    if (MP3.m_MetaData != null && MP3.m_MetaData.m_Image != null)
                    {
                        BitmapImage Test = new BitmapImage();
                        Test.SetSource(MP3.m_MetaData.m_Image);
                        image1.Source = Test;
                        //image1.Visibility = System.Windows.Visibility.Visible;
                    }
                }
                else
                {
                    MessageBox.Show("The selected song is not supported as a Ringtone at the current time.");
                    Debugger.Trace("Unknown file format");
                }

                if (Song != null)
                {
                    string SongLength = Song.Length.Minutes + ":" + Song.Length.Seconds;
                    TextBlock_SongLength.Text = SongLength;
                    TextBox_EndPosition.Text = SongLength;
                    Slider.Maximum =  Song.Length.TotalSeconds;
                    Slider.RangeEnd = 39;
                }
                else
                {
                    NavigationService.GoBack();
                }
            });
        }
コード例 #3
0
ファイル: EditRingtone.xaml.cs プロジェクト: Setuber/Ringify
        private void MakeRingtone(object sender, TaskEventArgs e)
        {
            MP3File Test = new MP3File();
            Test.Initialize("RINGIFY_RINGTONE.mp3");

            if (e.TaskResult == TaskResult.OK)
            {
                MessageBox.Show("Your Ringtone was created!\n\nThe Ringtone is now listed in\n[Settings] -> [Ringtones + Sounds]\n under the Rintones selector.");
                Debugger.Trace("Save Completed");
            }
            else if (e.TaskResult == TaskResult.Cancel)
            {
                Debugger.Trace("Save Cancelled");
                if (e.Error != null)
                {
                    MessageBox.Show(e.Error.Message);
                    //TextBlock_Error.Text = e.Error.Message;

                    Debugger.Trace(e.Error);
                    Debugger.Trace("FILE_SIZE [" + Test.Size + "]");
                }
            }
            else if (e.TaskResult == TaskResult.None)
            {
                TextBlock_Error.Text = "None!";
                Debugger.Trace("None");
                if (e.Error != null)
                {
                    TextBlock_Error.Text = e.Error.Message;
                    Debugger.Trace(e.Error);
                }
            }

            TextBlock_Error.Text += "FILE_SIZE [" + Test.Size + "]";
        }
コード例 #4
0
ファイル: EditRingtone.xaml.cs プロジェクト: Setuber/Ringify
        private void ControlMedia(object sender, RoutedEventArgs e)
        {
            Button B = (Button)sender;
            if ((string)B.Content == "Preview")
            {
                IsolatedStorageFile Store = IsolatedStorageFile.GetUserStoreForApplication();
                int trimStart = (int)Slider.RangeStart;
                int trimEnd = (int)Slider.RangeEnd;
                if (Song != null &&
                    Song.Trim(new TimeSpan(trimStart * 1000 * 1000 * 10), new TimeSpan(trimEnd * 1000 * 1000 * 10), "RINGIFY_RINGTONE.mp3"))
                {
                    // Call the Save Reingtone Chooser
                    if (Store.FileExists("RINGIFY_RINGTONE.mp3"))
                    {
                        MP3File Test = new MP3File();
                        Test.Initialize("RINGIFY_RINGTONE.mp3");

                        using (IsolatedStorageFileStream stream = Store.OpenFile("RINGIFY_RINGTONE.mp3", FileMode.Open))
                        {
                            //media.Source = new Uri("isostore:/" + App.ViewModel.SelectedSong.SongTitle);

                            media.SetSource(stream);
                        }
                    }
                }
            }
            else
            {
                StopSong();
            }
        }