Пример #1
0
        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
        public static VM_Playlist CreatePlaylist(Window owner)
        {
            try
            {
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(AppSettings.Culture);

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

                    Playlist pl = new Playlist
                    {
                        DefaultPlayOrder = (int)PlaylistPlayOrder.Sequential,
                        PlaylistItems    = "",
                        PlaylistName     = dlg.EnteredText,
                        PlayUnwatched    = 1,
                        PlayWatched      = 0
                    };
                    CL_Response <Playlist> resp = VM_ShokoServer.Instance.ShokoServices.SavePlaylist(pl);

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

                    // refresh data
                    Instance.RefreshData();
                    return((VM_Playlist)resp.Result);
                }

                return(null);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
                return(null);
            }
        }
Пример #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);
            }
        }
Пример #4
0
        void btnNewScript_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DialogText dlg = new DialogText();
                dlg.Init(JMMClient.Properties.Resources.Rename_EnterScriptName, "");
                dlg.Owner = Window.GetWindow(this);
                bool?res = dlg.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    if (string.IsNullOrEmpty(dlg.EnteredText))
                    {
                        Utils.ShowErrorMessage(JMMClient.Properties.Resources.Rename_BlankScript);
                        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);
            }
        }
        void btnNewScript_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DialogText dlg = new DialogText();
                dlg.Init(Shoko.Commons.Properties.Resources.Rename_EnterScriptName, "");
                dlg.Owner = Window.GetWindow(this);
                bool?res = dlg.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    if (string.IsNullOrEmpty(dlg.EnteredText))
                    {
                        Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.Rename_BlankScript);
                        return;
                    }

                    RenameScript script = new RenameScript();
                    script.IsEnabledOnImport = 0;
                    script.Script            = "";
                    script.ScriptName        = dlg.EnteredText;
                    script.RenamerType       = "Legacy";
                    CL_Response <RenameScript> resp = VM_ShokoServer.Instance.ShokoServices.SaveRenameScript(script);

                    if (!string.IsNullOrEmpty(resp.ErrorMessage))
                    {
                        Utils.ShowErrorMessage(resp.ErrorMessage);
                        return;
                    }
                    defaultScriptID = resp.Result.RenameScriptID;
                    // refresh data
                    RefreshScripts();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }