public static PlaylistVM CreatePlaylist(Window owner)
        {
            try
            {
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(AppSettings.Culture);

                DialogText dlg = new DialogText();
                dlg.Init(Properties.Resources.Playlist_Name + " ", "");
                dlg.Owner = owner;
                bool? res = dlg.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    if (string.IsNullOrEmpty(dlg.EnteredText))
                    {
                        Utils.ShowErrorMessage(Properties.Resources.Playlist_NameBlank);
                        return null;
                    }

                    JMMServerBinary.Contract_Playlist pl = new JMMServerBinary.Contract_Playlist();
                    pl.DefaultPlayOrder = (int)PlaylistPlayOrder.Sequential;
                    pl.PlaylistItems = "";
                    pl.PlaylistName = dlg.EnteredText;
                    pl.PlayUnwatched = 1;
                    pl.PlayWatched = 0;
                    JMMServerBinary.Contract_Playlist_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SavePlaylist(pl);

                    if (!string.IsNullOrEmpty(resp.ErrorMessage))
                    {
                        Utils.ShowErrorMessage(resp.ErrorMessage);
                        return null;
                    }

                    // refresh data
                    PlaylistHelperVM.Instance.RefreshData();

                    PlaylistVM plRet = new PlaylistVM(resp.Playlist);
                    return plRet;
                }

                return null;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
                return null;
            }
        }
示例#2
0
		void btnNewScript_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				DialogText dlg = new DialogText();
				dlg.Init("Enter script name: ", "");
				dlg.Owner = Window.GetWindow(this);
				bool? res = dlg.ShowDialog();
				if (res.HasValue && res.Value)
				{
					if (string.IsNullOrEmpty(dlg.EnteredText))
					{
						Utils.ShowErrorMessage("Please enter a script name");
						return;
					}

					JMMServerBinary.Contract_RenameScript script = new JMMServerBinary.Contract_RenameScript();
					script.IsEnabledOnImport = 0;
					script.Script = "";
					script.ScriptName = dlg.EnteredText;
					JMMServerBinary.Contract_RenameScript_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SaveRenameScript(script);

					if (!string.IsNullOrEmpty(resp.ErrorMessage))
					{
						Utils.ShowErrorMessage(resp.ErrorMessage);
						return;
					}

					RenameScriptVM plRet = new RenameScriptVM(resp.RenameScript);
					defaultScriptID = plRet.RenameScriptID;

					// refresh data
					RefreshScripts();
				}

			}
			catch (Exception ex)
			{
				Utils.ShowErrorMessage(ex);
			}
		}
示例#3
0
		public static PlaylistVM CreatePlaylist(Window owner)
		{
			try
			{
				DialogText dlg = new DialogText();
				dlg.Init("Enter playlist name: ", "");
				dlg.Owner = owner;
				bool? res = dlg.ShowDialog();
				if (res.HasValue && res.Value)
				{
					if (string.IsNullOrEmpty(dlg.EnteredText))
					{
						Utils.ShowErrorMessage("Please enter a playlist name");
						return null;
					}

					JMMServerBinary.Contract_Playlist pl = new JMMServerBinary.Contract_Playlist();
					pl.DefaultPlayOrder = (int)PlaylistPlayOrder.Sequential;
					pl.PlaylistItems = "";
					pl.PlaylistName = dlg.EnteredText;
					pl.PlayUnwatched = 1;
					pl.PlayWatched = 0;
					JMMServerBinary.Contract_Playlist_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SavePlaylist(pl);

					if (!string.IsNullOrEmpty(resp.ErrorMessage))
					{
						Utils.ShowErrorMessage(resp.ErrorMessage);
						return null;
					}

					// refresh data
					PlaylistHelperVM.Instance.RefreshData();

					PlaylistVM plRet = new PlaylistVM(resp.Playlist);
					return plRet;
				}

				return null;
			}
			catch (Exception ex)
			{
				Utils.ShowErrorMessage(ex);
				return null;
			}
		}