public static void ShowDialog(string title, string content) { MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = Orange.MsgBroker.UI_CONTROL.SHOW_TOP_GRID; arg.MsgBody = new DialogMsg(title, content); (Application.Current as App).msgBroker.SendMessage(arg); }
//파일이동 메소드 public bool MoveFile() { if (System.IO.File.Exists(@currPath + fileName + ".mp3")) { string sourceFile = @currPath + fileName + ".mp3"; string destinationFile = @dstPath + fileName + ".mp3"; try { // To move a file or folder to a new location: System.IO.File.Move(sourceFile, destinationFile); } catch (System.IO.IOException e) { MessageBox.Show(e.Message); MessageBox.Show("mp3 파일 이동 실패"); // 작업상태 체크 MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.FINISH_CONVERT_PROGRESS; (Application.Current as App).msgBroker.SendMessage(arg); return(false); } } else { MessageBox.Show("Not exists audio file"); // 작업상태 체크 MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.FINISH_CONVERT_PROGRESS; (Application.Current as App).msgBroker.SendMessage(arg); return(false); } return(true); }
private void HideThisUsercontrol() { MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = Orange.MsgBroker.UI_CONTROL.HIDE_TOP_GRID; (Application.Current as App).msgBroker.SendMessage(arg); }
private void confirm_Click(object sender, RoutedEventArgs e) { MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = Orange.MsgBroker.MESSAGE_MAP.CREATE_FAVORITE_PLAYLIST; if (InputTxb.Text.Trim().Equals("")) { MessageBox.Show("The content is empty"); return; } arg.MsgBody = InputTxb.Text; (Application.Current as App).msgBroker.SendMessage(arg); HideThisUsercontrol(); }
private void createfavoritelist_Click(object sender, System.Windows.RoutedEventArgs e) { if (myPlayListCollection.Count == 0) { MessageBoxOrange.ShowDialog("Warning","Playlist is empty."); return; } MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.SHOW_TOP_GRID; arg.MsgBody = new Create_FavoritePlaylistUserControl(); (Application.Current as App).msgBroker.SendMessage(arg); main_menu.ShowFavoriteList(); DrawerMenu(); }
private void Rename_PlaylistItem_Click(object sender, RoutedEventArgs e) { if (myPlayList.SelectedIndex != -1) { MusicItem item = (MusicItem)myPlayList.SelectedItem; MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.SHOW_TOP_GRID; arg.MsgBody = new rename_usercontrol(item); (Application.Current as App).msgBroker.SendMessage(arg); } }
private void Config_Click(object sender, RoutedEventArgs e) { if(!Properties.Settings.Default.IsFirst) { MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.SHOW_TOP_GRID; arg.MsgBody = new Preferences(); (Application.Current as App).msgBroker.SendMessage(arg); } }
private void Information_Click(object sender, RoutedEventArgs e) { //information_uc.Visibility = Visibility.Visible; if(!Properties.Settings.Default.IsFirst) { MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.SHOW_TOP_GRID; arg.MsgBody = new information_usercontrol(this); (Application.Current as App).msgBroker.SendMessage(arg); } }
private void MP3_Convert_Click(object sender, System.Windows.RoutedEventArgs e) { myPlayList.SelectedItem = (e.OriginalSource as FrameworkElement).DataContext; if (myPlayList.SelectedIndex != -1) { var dialog = new System.Windows.Forms.FolderBrowserDialog(); System.Windows.Forms.DialogResult result = dialog.ShowDialog(); if(result == System.Windows.Forms.DialogResult.OK) { MusicItem item = (MusicItem)myPlayList.SelectedItem; ConvertMP3.PATH = dialog.SelectedPath; //MessageBoxOrange.ShowDialog(path); ConvertMP3.URL = "http://www.youtube.com/watch?v=" + item.url; MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.SHOW_TOP_GRID; arg.MsgBody = new ConvertingProgress(); (Application.Current as App).msgBroker.SendMessage(arg); ConvertMP3.worker(this, ConvertMP3.URL, ConvertMP3.PATH, WKIND.CONVERT); } // string mUrl = "http://www.youtube.com/watch?v="+ item.url; // ConvertMP3.worker(mUrl, ) //MessageBoxOrange.ShowDialog(item.title); //myPlayListCollection.Add(item); } }
// Youtube-dl 사용 함수 public void YoutubDownload() { if (urlPath == null) { MessageBox.Show("URL has not been defined."); return; } string strYOUTUBEDLOut; ProcessStartInfo psiProcInfo = new ProcessStartInfo(); System.IO.StreamReader srYOUTUBEDL; dstPath = SpecificCharChange('\\', '/', dstPath); string strYOUTUBEDLCmd = null; if (kind == WKIND.DOWN) { strYOUTUBEDLCmd = "-f best -o \"" + dstPath + "%(title)s.%(ext)s\" \"" + urlPath + "\""; currPath = dstPath; } else if (kind == WKIND.CONVERT) { currPath = SpecificCharChange('\\', '/', appDataPath); // '\\' -> '/' 로 변환 strYOUTUBEDLCmd = "-f best -o \"" + currPath + "%(title)s.%(ext)s\" --extract-audio --audio-format mp3 \"" + urlPath + "\""; } else { return; } try { psiProcInfo.FileName = "Util/youtube-dl.exe"; psiProcInfo.Arguments = strYOUTUBEDLCmd; psiProcInfo.UseShellExecute = false; psiProcInfo.WindowStyle = ProcessWindowStyle.Hidden; psiProcInfo.RedirectStandardError = true; psiProcInfo.RedirectStandardOutput = true; psiProcInfo.CreateNoWindow = true; prcYOUTUBEDL.StartInfo = psiProcInfo; prcYOUTUBEDL.Start(); srYOUTUBEDL = prcYOUTUBEDL.StandardOutput; int cnt = 0; do { strYOUTUBEDLOut = srYOUTUBEDL.ReadLine(); string download = "[download]"; if (strYOUTUBEDLOut != null && strYOUTUBEDLOut.TrimStart().IndexOf(download) == 0) { if (cnt == 0) { // 확장자포함 이름 추출 if (strYOUTUBEDLOut.TrimStart().IndexOf("downloaded") == strYOUTUBEDLOut.Length - 10) { string text = strYOUTUBEDLOut.TrimStart().Substring(download.Length + 1 + currPath.Length); extraName = text.Substring(0, text.Length - 28); } else { string text = strYOUTUBEDLOut.TrimStart().Substring(download.Length + 14 + currPath.Length); extraName = text.Substring(0, text.Length); } //순수이름 추출 fileName = extraName.Substring(0, extraName.Length - 4); ++cnt; continue; } try { string text = strYOUTUBEDLOut.TrimStart().Substring(download.Length + 1); int pos = text.IndexOf("%"); string currProgress = text.Substring(0, pos); win.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(delegate { // 작업상태 체크 MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.SET_CONVERT_PROGRESS_VALUE; arg.MsgBody = Double.Parse(currProgress); (Application.Current as App).msgBroker.SendMessage(arg); // 프로그래스바 작업 })); } catch (Exception e) { MessageBox.Show(e.Message); } } } while (prcYOUTUBEDL.HasExited == false); } catch (Exception e) { MessageBox.Show(e.Message); } finally { if (kind == WKIND.CONVERT) { win.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { if (MoveFile()) { // 작업상태 체크 MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.FINISH_CONVERT_PROGRESS; (Application.Current as App).msgBroker.SendMessage(arg); // 프로그래스바 작업 } })); } else if (kind == WKIND.DOWN) { if (System.IO.File.Exists(@dstPath + extraName)) { win.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { // 작업상태 체크 MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.FINISH_CONVERT_PROGRESS; (Application.Current as App).msgBroker.SendMessage(arg); // 프로그래스바 작업 })); } else { MessageBox.Show("Not exists video file"); win.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate { // 작업상태 체크 MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg(); arg.MsgOPCode = UI_CONTROL.FINISH_CONVERT_PROGRESS; (Application.Current as App).msgBroker.SendMessage(arg); // 프로그래스바 작업 })); } } } }