Example #1
0
        public void EvaluateSelectedItem(xmlmessage mymessage,int casenumber)
        {
            //button lock
            if (myTvWishes.ButtonActive)
            {
                myTvWishes.StatusLabel(PluginGuiLocalizeStrings.Get(1200));  //Waiting for old process to finish   "Previous Operation Is Still Running"
                return;
            }
            myTvWishes.ButtonActive = true; //lock buttons


            try
            {
                int tvMessageindex = mymessage.unfiltered_index;
                Log.Debug("tvMessageindex filtered=" + _focusedMessage.ToString());
                Log.Debug("tvMessageindex unfiltered=" + tvMessageindex.ToString());


                
                //possible bug can cause exception!!!!!!!!!!!!!!!!
                TvWish mywish = myTvWishes.RetrieveById(mymessage.tvwishid);

                //TvWish mywish = myTvWishes.GetAtTvWishId(myTvWishes.FocusedWishIndex);

                // find out if schedule exists for selected item
                Schedule foundSchedule = null;
                foreach (Schedule myschedule in Schedule.ListAll())
                {
                    if ((mymessage.title == myschedule.ProgramName) && (mymessage.channel_id == myschedule.IdChannel) && (mymessage.start == myschedule.StartTime) && (mymessage.end == myschedule.EndTime))
                    {
                        foundSchedule = myschedule;
                        Log.Debug("Schedule found title=" + foundSchedule.ProgramName);
                        break;
                    }
                }

                Recording foundRecording = null;
                foreach (Recording myrecording in Recording.ListAll())
                {
                    //if ((mymessages.GetTvMessageFilteredAtIndex(myfacade.SelectedListItemIndex).title == myrecording.Title) && (mymessages.GetTvMessageFilteredAtIndex(myfacade.SelectedListItemIndex).channel_id == myrecording.IdChannel) && (mymessages.GetTvMessageFilteredAtIndex(myfacade.SelectedListItemIndex).start == myrecording.StartTime) && (mymessages.GetTvMessageFilteredAtIndex(myfacade.SelectedListItemIndex).end == myrecording.EndTime))
                    if (mymessage.recordingid == myrecording.IdRecording.ToString())
                    {
                        foundRecording = myrecording;
                        break;
                    }
                }

                if (foundRecording != null)
                    Log.Debug("found Recording ID=" + mymessage.recordingid.ToString() + "  title=" + foundRecording.Title + " at " + foundRecording.StartTime.ToString());




                IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();

                switch (casenumber)
                {

                    case (int)MenuItems.GotoTv: //Goto Tv main screen

                        try
                        {
                            if (workflowManager.NavigatePopModel(TV_GUI_MODEL_ID))
                            {// do nothing

                            }
                            else
                            {
                                workflowManager.NavigatePopToState(HOME_GUI_STATE_ID, true);
                                workflowManager.NavigatePush(TV_GUI_STATE_ID);
                            }
                        }
                        catch
                        {
                            Log.Error("Workflow navigation to TV failed");
                        }





                        break;

                    case (int)MenuItems.CreateTvWishEmail://Create TvWish with Title in Email Mode
                        try
                        {
                            string parameter = Main_GUI.SkinCommands.NEWTVWISH_EMAIL.ToString() + "//";
                            parameter += "TITLE=" + mymessage.title;
                            Log.Debug("LIST: parameter=" + parameter);

                            if (Main_GUI.Instance == null)
                            {
                                Log.Error("Fatal Error: Main_GUI instance did not exist in Result_GUI case2 - going back");
                                return;
                            }
                            Main_GUI.Instance.Parameter = parameter;
                            Main_GUI.Instance.TvWishListQuickMenu = true;
                            if (PreviousModel == EDIT_GUI_MODEL_ID_STR)
                            {
                                workflowManager.NavigatePop(2); //2 stages to main
                            }
                            else
                            {
                                workflowManager.NavigatePop(1);//1 stage to main
                            }

                        }
                        catch (Exception exc)
                        {
                            Log.Error("Create Tvwish with Title failed - Exception error " + exc.Message);
                        }

                        break;

                    case (int)MenuItems.CreateTvWishViewOnly://Create TvWish with Title in ViewOnly Mode
                        try
                        {
                            string parameter = Main_GUI.SkinCommands.NEWTVWISH_VIEWONLY.ToString() + "//";
                            parameter += "TITLE=" + mymessage.title;
                            Log.Debug("LIST: parameter=" + parameter);

                            if (Main_GUI.Instance == null)
                            {
                                Log.Error("Fatal Error: Main_GUI instance did not exist in Result_GUI case2 - going back");
                                return;
                            }
                            Main_GUI.Instance.Parameter = parameter;
                            Main_GUI.Instance.TvWishListQuickMenu = true;
                            if (PreviousModel == EDIT_GUI_MODEL_ID_STR)
                            {
                                workflowManager.NavigatePop(2); //2 stages to main
                            }
                            else //must be main
                            {
                                workflowManager.NavigatePop(1);//1 stage to main
                            }
                        }
                        catch (Exception exc)
                        {
                            Log.Error("Create Tvwish with Title failed - Exception error " + exc.Message);
                        }

                        break;

                    case (int)MenuItems.CreateTvWishAllEmail: //Create TvWish with All in Email Mode

                        try
                        {
                            string parameter = Main_GUI.SkinCommands.NEWTVWISH_ALL_EMAIL.ToString() + "//";

                            parameter += "TITLE=" + mymessage.title + "//";
                            parameter += "CHANNEL=" + mymessage.channel + "//";
                            parameter += "EPISODEPART=" + mymessage.EpisodePart + "//";
                            parameter += "EPISODENAME=" + mymessage.EpisodeName + "//";
                            parameter += "SERIESNUMBER=" + mymessage.SeriesNum + "//";
                            parameter += "EPISODENUMBER=" + mymessage.EpisodeNum;

                            Log.Debug("LIST: parameter=" + parameter);

                            if (Main_GUI.Instance == null)
                            {
                                Log.Error("Fatal Error: Main_GUI instance did not exist in Result_GUI case2 - going back");
                                return;
                            }
                            Main_GUI.Instance.Parameter = parameter;
                            Main_GUI.Instance.TvWishListQuickMenu = true;
                            if (PreviousModel == EDIT_GUI_MODEL_ID_STR)
                            {
                                workflowManager.NavigatePop(2); //2 stages to main
                            }
                            else
                            {
                                workflowManager.NavigatePop(1);//1 stage to main
                            }
                        }
                        catch (Exception exc)
                        {
                            Log.Error("Create Tvwish with All failed - Exception error " + exc.Message);
                        }
                        break;

                    case (int)MenuItems.CreateTvWishAllViewOnly: //Create TvWish with All in ViewOnly Mode

                        try
                        {
                            string parameter = Main_GUI.SkinCommands.NEWTVWISH_ALL_VIEWONLY.ToString() + "//";

                            parameter += "TITLE=" + mymessage.title + "//";
                            parameter += "CHANNEL=" + mymessage.channel + "//";
                            parameter += "EPISODEPART=" + mymessage.EpisodePart + "//";
                            parameter += "EPISODENAME=" + mymessage.EpisodeName + "//";
                            parameter += "SERIESNUMBER=" + mymessage.SeriesNum + "//";
                            parameter += "EPISODENUMBER=" + mymessage.EpisodeNum;

                            Log.Debug("LIST: parameter=" + parameter);

                            if (Main_GUI.Instance == null)
                            {
                                Log.Error("Fatal Error: Main_GUI instance did not exist in Result_GUI case2 - going back");
                                return;
                            }
                            Main_GUI.Instance.Parameter = parameter;
                            Main_GUI.Instance.TvWishListQuickMenu = true;
                            if (PreviousModel == EDIT_GUI_MODEL_ID_STR)
                            {
                                workflowManager.NavigatePop(2); //2 stages to main
                            }
                            else
                            {
                                workflowManager.NavigatePop(1);//1 stage to main
                            }
                        }
                        catch (Exception exc)
                        {
                            Log.Error("Create Tvwish with All failed - Exception error " + exc.Message);
                        }
                        break;

                    case (int)MenuItems.DeleteMessage: //Deletemessage

                        try
                        {
                            mymessages.DeleteTvMessageAt(tvMessageindex);
                            myTvWishes.UpdateCounters(mymessages.ListAllTvMessages());
                            UpdateListItems();
                            myTvWishes.MyMessageBox(4400, 3604);   //Info, message has been deleted                            
                        }
                        catch (Exception exc)
                        {
                            Log.Error("Deleting message failed  - Exception error " + exc.Message);
                            myTvWishes.MyMessageBox(4305, 3605);   //Error, deleting message failed
                        }
                        break;


                    case (int)MenuItems.DeleteSchedule: //Delete Schedule
                        if (foundSchedule != null) //delete schedule and found item
                        {
                            try
                            {
                                foundSchedule.Delete();
                                Log.Debug("Schedule deleted");
                                mymessages.DeleteTvMessageAt(tvMessageindex);
                                myTvWishes.UpdateCounters(mymessages.ListAllTvMessages());
                                UpdateListItems();
                                myTvWishes.MyMessageBox(4400, 3602);   //Info, Schedule has been deleted                            
                            }
                            catch (Exception exc)
                            {
                                Log.Error("Schedule deleting failed  - Exception error " + exc.Message);
                                myTvWishes.MyMessageBox(4305, 3603);   //Error, Deleting Schedule failed
                            }
                        }
                        break;

                    case (int)MenuItems.Schedule: //Schedule

                        try
                        {
                            if ((_focusedMessage >= 0) && (mymessages.ListAllTvMessagesFiltered().Count > 0))
                            {
                                // messagetext = mymessages.FormatMessage(mymessages.TvMessagesFiltered[_focused], _TextBoxFormat);

                                Log.Debug("Before Schedule added - Count=" + Schedule.ListAll().Count.ToString());

                                Schedule schedule = layer.AddSchedule(mymessage.channel_id, mymessage.title, mymessage.start, mymessage.end, 0);
                                

                                if (mywish == null)
                                {
                                    int prerecord = 5;
                                    int postrecord = 10;
                                    try
                                    {
                                        prerecord = Convert.ToInt32(myTvWishes.DefaultValues[(int)TvWishEntries.prerecord]);
                                        postrecord = Convert.ToInt32(myTvWishes.DefaultValues[(int)TvWishEntries.postrecord]);

                                    }
                                    catch (Exception exc)
                                    {
                                        Log.Debug("More: Manual schedule prerecord or postrecord could not be evaluated - Exception error " + exc.Message);
                                    }

                                    schedule.PreRecordInterval = prerecord;
                                    schedule.PostRecordInterval = postrecord;
                                }
                                else //use tvwish parameters
                                {
                                    schedule.MaxAirings = mywish.i_keepepisodes;
                                    schedule.KeepDate = mywish.D_keepuntil;
                                    if (mywish.i_keepuntil > 0)
                                    {
                                        schedule.KeepDate = DateTime.Now.AddDays(mywish.i_keepuntil);
                                        Log.Debug("Keepdate based on " + mywish.i_keepuntil.ToString() + " days changed to " + schedule.KeepDate.ToString());
                                    }

                                    schedule.KeepMethod = mywish.i_keepmethod;
                                    schedule.PostRecordInterval = mywish.i_postrecord;
                                    schedule.PreRecordInterval = mywish.i_prerecord;
                                    schedule.Priority = mywish.i_priority;
                                    schedule.RecommendedCard = mywish.i_recommendedcard;
                                    schedule.Series = mywish.b_series;
                                    //add manual recording message of type scheduled
                                }

                                schedule.Persist();
                                Log.Debug("Schedule added");
                                Log.Debug("Schedule added - Count="+Schedule.ListAll().Count.ToString());
                                // Old Bug: must not generate new message for manual scheduling  (or use -1 for tvwishid)
                                //string message = "TvWishList did schedule the program";
                                //mymessages.addmessage(schedule, message, mywish.t_action, mywish.name, (int)XmlMessages.MessageEvents.SCHEDULE_FOUND, mywish.tvwishid);
                                //myTvWishes.UpdateCounters(mymessages.ListAllTvMessages());
                                //UpdateListItems();
                                myTvWishes.MyMessageBox(4400, 3600);   //Info, Schedule succeeded
                            }
                        }
                        catch (Exception exc)
                        {
                            Log.Debug("Schedule adding failed  - Exception error " + exc.Message);
                            myTvWishes.MyMessageBox(4305, 3601);   //Error, Schedule adding failed
                        }
                        break;

                    case (int)MenuItems.DeleteRecording: //Delete recording
                        if (foundRecording != null) //delete recording and found item
                        {
                            IDialogManager mydialog = ServiceRegistration.Get<IDialogManager>();
                            Guid mydialogId = mydialog.ShowDialog(PluginGuiLocalizeStrings.Get(4401), PluginGuiLocalizeStrings.Get(3608).Replace(@"\n",string.Empty)+" "+mymessage.filename, DialogType.YesNoDialog, false, DialogButtonType.No);
                            DialogCloseWatcher dialogCloseWatcher = new DialogCloseWatcher(this, mydialogId, dialogResult =>
                            { //this is watching the result of the dialog box and displaying in the Status label of the screen (do not forget to dispose)
                                if (dialogResult.ToString() == DialogButtonType.Yes.ToString())
                                {
                                    try
                                    {
                                        try
                                        {
                                            File.Delete(mymessage.filename);
                                            Log.Info("File deleted: " + mymessage.filename);
                                        }
                                        catch { }//do nothing
                                        //MessageBox.Show("File deleted: " + mymessage.message);
                                        
                                        Log.Debug("tvMessageindex=" + tvMessageindex);
                                        Log.Debug("mymessages.ListAllTvMessages().Count=" + mymessages.ListAllTvMessages().Count.ToString());
                                        Log.Debug("mymessages.ListAllTvMessagesFiltered().Count=" + mymessages.ListAllTvMessagesFiltered().Count.ToString());
                                        xmlmessage mydeletedmessage = mymessages.GetTvMessageAtIndex(tvMessageindex); //this is the unfiltered index
                                        mydeletedmessage.type = MessageType.Deleted.ToString();
                                        mydeletedmessage.message = String.Format(PluginGuiLocalizeStrings.Get(3651));  //File has been deleted;
                                        mydeletedmessage.created = DateTime.Now;
                                        mymessages.ReplaceTvMessageAtIndex(tvMessageindex, mydeletedmessage);
                                        //mymessages.DeleteTvMessageAt(tvMessageindex);

                                        Log.Debug("Delete Message modified");


                                        //mymessages.DeleteTvMessageAt(tvMessageindex);
                                        foundRecording.Delete();
                                        Log.Debug("Recording deleted");
                                        myTvWishes.UpdateCounters(mymessages.ListAllTvMessages());
                                        Log.Debug("Counters updated");
                                        UpdateListItems();
                                        myTvWishes.MyMessageBox(4400, 3606);   //Info, Recording has been deleted  




                                    }
                                    catch (Exception exc)
                                    {
                                        Log.Error("Recording deleting failed  - Exception error " + exc.Message);
                                        myTvWishes.MyMessageBox(4305, 3607);   //Error, Deleting recording failed
                                    }
                                }
                                 
                                return;
                            });

                        }//end delete recording



                        break;



                    case (int)MenuItems.GotoVideo:  //Goto Videos
                        try
                        {
                            if (workflowManager.NavigatePopModel(VIDEO_GUI_MODEL_ID))
                            {// do nothing

                            }
                            else
                            {
                                workflowManager.NavigatePopToState(HOME_GUI_STATE_ID, true);
                                workflowManager.NavigatePush(VIDEO_GUI_STATE_ID);
                            }
                        }
                        catch
                        {
                            Log.Error("Workflow navigation to Videos failed");
                        }

                        break;



                    case (int)MenuItems.Prerecord:  //prerecord
                        _dialogMenuItemList2.Clear();

                        DialogHeader = PluginGuiLocalizeStrings.Get(2808);  //Prerecord

                        string[] allItemStrings = new string[] { "0", "5", "8", "10", "15", "30", PluginGuiLocalizeStrings.Get(4102) }; //Custom
                        foreach (string itemstring in allItemStrings)
                        {
                            ListItem mydialogitem2 = new ListItem();
                            mydialogitem2.SetLabel("Name", itemstring);
                            mydialogitem2.Command = new MethodDelegateCommand(() =>
                            {
                                if (mydialogitem2.Labels["Name"].ToString() == PluginGuiLocalizeStrings.Get(4102)) //Custom
                                {
                                    IScreenManager mycommandscreenManager = ServiceRegistration.Get<IScreenManager>();
                                    mycommandscreenManager.CloseTopmostDialog();
                                    InputHeader = PluginGuiLocalizeStrings.Get(2808); //Prerecord
                                    mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                    InputTextBoxSkin = mywish.prerecord;
                                    try
                                    {
                                        int k = Convert.ToInt32(InputTextBoxSkin);
                                        //Log.Debug("k=" + k.ToString());
                                    }
                                    catch //do nothing and use default
                                    {
                                        InputTextBoxSkin = "5";
                                    }
                                    mywish.prerecord = InputTextBoxSkin;

                                    myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                    ScreenManager.ShowDialog(TVWISHLIST_RESULT_INPUT_TEXTBOX_SCREEN);
                                }
                                else
                                {
                                    mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                    mywish.prerecord = mydialogitem2.Labels["Name"].ToString();
                                    Log.Debug("ItemProcessing(int caseSelection):   mywish.prerecord=" + mywish.prerecord);
                                    myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                    Log.Debug("ItemProcessing(int caseSelection):   mywish.prerecord=" + mywish.prerecord);



                                    IScreenManager mycommandscreenManager = ServiceRegistration.Get<IScreenManager>();
                                    mycommandscreenManager.CloseTopmostDialog();
                                    UpdateListItems();

                                    

                                    //SelectedItemChangedprocessing();
                                    Thread mainDialogThread = new Thread(StartMainDialogThread);
                                    mainDialogThread.Start();
                                }

                                

                                //Thread myselectthread = new Thread(SelectItemUpdate);
                                //myselectthread.Start();
                            });
                            _dialogMenuItemList2.Add(mydialogitem2);
                        }
                        //update for dialog skin
                        DialogMenuItemList2.FireChange();
                        //will now call a dialogbox with a given menu            
                        ScreenManager.ShowDialog(TVWISHLIST_RESULT_DIALOG_MENU_SCREEN2);
                        break;



                    case (int)MenuItems.Postrecord:  //postrecord
                        _dialogMenuItemList2.Clear();

                        DialogHeader = PluginGuiLocalizeStrings.Get(2809);  //Postrecord

                        allItemStrings = new string[] { "0", "5", "8", "10", "15", "30", PluginGuiLocalizeStrings.Get(4102) }; //Custom
                        foreach (string itemstring in allItemStrings)
                        {
                            ListItem mydialogitem2 = new ListItem();
                            mydialogitem2.SetLabel("Name", itemstring);
                            mydialogitem2.Command = new MethodDelegateCommand(() =>
                            {
                                if (mydialogitem2.Labels["Name"].ToString() == PluginGuiLocalizeStrings.Get(4102)) //Custom
                                {
                                    IScreenManager mycommandscreenManager = ServiceRegistration.Get<IScreenManager>();
                                    mycommandscreenManager.CloseTopmostDialog();
                                    InputHeader = PluginGuiLocalizeStrings.Get(2809); //Postrecord
                                    mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                    InputTextBoxSkin = mywish.postrecord;
                                    try
                                    {
                                        int k = Convert.ToInt32(InputTextBoxSkin);
                                        //Log.Debug("k=" + k.ToString());
                                    }
                                    catch //do nothing and use default
                                    {
                                        InputTextBoxSkin = "5";
                                    }
                                    mywish.postrecord = InputTextBoxSkin;

                                    myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                    ScreenManager.ShowDialog(TVWISHLIST_RESULT_INPUT_TEXTBOX_SCREEN);
                                }
                                else
                                {
                                    mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                    mywish.postrecord = mydialogitem2.Labels["Name"].ToString();
                                    Log.Debug("ItemProcessing(int caseSelection):   mywish.postrecord=" + mywish.postrecord);
                                    myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                    Log.Debug("ItemProcessing(int caseSelection):   mywish.postrecord=" + mywish.postrecord);



                                    IScreenManager mycommandscreenManager = ServiceRegistration.Get<IScreenManager>();
                                    mycommandscreenManager.CloseTopmostDialog();
                                    UpdateListItems();



                                    //SelectedItemChangedprocessing();
                                    Thread mainDialogThread = new Thread(StartMainDialogThread);
                                    mainDialogThread.Start();
                                }



                                //Thread myselectthread = new Thread(SelectItemUpdate);
                                //myselectthread.Start();
                            });
                            _dialogMenuItemList2.Add(mydialogitem2);
                        }
                        //update for dialog skin
                        DialogMenuItemList2.FireChange();
                        //will now call a dialogbox with a given menu            
                        ScreenManager.ShowDialog(TVWISHLIST_RESULT_DIALOG_MENU_SCREEN2);
                        break;


                    case (int)MenuItems.Keepuntil:  //keepuntil
                        _dialogMenuItemList2.Clear();
                         
                        DialogHeader = PluginGuiLocalizeStrings.Get(2815); //Keep Until

                        for (int i = 0; i <= 6; i++)
                        {
                            ListItem mydialogitem = new ListItem();
                            mydialogitem.SetLabel("Name", PluginGuiLocalizeStrings.Get(i + 2900));//Always
                            mydialogitem.SetLabel("Index", i.ToString());
                            mydialogitem.Command = new MethodDelegateCommand(() =>
                            {
                                int index = Convert.ToInt32(mydialogitem.Labels["Index"].ToString());
                                Log.Debug("keepuntil index = " + index.ToString());
                                if (index == 0) //Always
                                {
                                    mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                    mywish.keepuntil = PluginGuiLocalizeStrings.Get(2900); //Always
                                    myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                    UpdateListItems();
                                    //myselectthread = new Thread(SelectItemUpdate);
                                    //myselectthread.Start();
                                }
                                else if (index == 1) //days after recording
                                {
                                    DialogHeader = PluginGuiLocalizeStrings.Get(2901);  // Days After Recording

                                    _dialogMenuItemList3.Clear();
                                    allItemStrings = new string[] { "3", "5", "7", "10", "15", "30", PluginGuiLocalizeStrings.Get(4102) }; //Custom
                                    foreach (string itemstring in allItemStrings)
                                    {
                                        ListItem mydialogitem2 = new ListItem();
                                        mydialogitem2.SetLabel("Name", itemstring);
                                        Log.Debug("mydialogitem2=" + mydialogitem2.Labels["Name"].ToString());
                                        mydialogitem2.Command = new MethodDelegateCommand(() =>
                                        {
                                            Log.Debug("mydialogitem2.Labels[Name].ToString()=" + mydialogitem2.Labels["Name"].ToString());
                                            if (mydialogitem2.Labels["Name"].ToString() == PluginGuiLocalizeStrings.Get(4102)) //Custom
                                            {
                                                InputHeader = PluginGuiLocalizeStrings.Get(2901); // Days After Recording
                                                InputTextBoxSkin = "";
                                                KeepuntilCode = 2920; //days after recording
                                                CaseSelection = (int)TvWishEntries.keepuntil;
                                                ScreenManager.ShowDialog(TVWISHLIST_RESULT_INPUT_TEXTBOX_SCREEN);
                                            }
                                            else
                                            {
                                                mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                                int j = Convert.ToInt32(mydialogitem2.Labels["Name"].ToString());
                                                string newvalue = String.Format(PluginGuiLocalizeStrings.Get(2920), j);
                                                Log.Debug("newvalue=" + newvalue);
                                                mywish.keepuntil = newvalue;
                                                myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                            }

                                            IScreenManager mycommandscreenManager2 = ServiceRegistration.Get<IScreenManager>();
                                            mycommandscreenManager2.CloseTopmostDialog();
                                            UpdateListItems();
                                            //myselectthread = new Thread(SelectItemUpdate);
                                            //myselectthread.Start();
                                        });
                                        _dialogMenuItemList3.Add(mydialogitem2);
                                    }
                                    //update for dialog skin
                                    DialogMenuItemList3.FireChange();
                                    //will now call a dialogbox with a given menu            
                                    ScreenManager.ShowDialog(TVWISHLIST_RESULT_DIALOG_MENU_SCREEN3);

                                }//days after recording

                                else if (index == 2) //weeks after recording
                                {
                                    _dialogMenuItemList3.Clear();

                                    DialogHeader = PluginGuiLocalizeStrings.Get(2902);  // Weeks After Recording

                                    allItemStrings = new string[] { "3", "5", "7", "10", "15", "30", PluginGuiLocalizeStrings.Get(4102) }; //Custom
                                    foreach (string itemstring in allItemStrings)
                                    {
                                        ListItem mydialogitem2 = new ListItem();
                                        mydialogitem2.SetLabel("Name", itemstring);
                                        mydialogitem2.Command = new MethodDelegateCommand(() =>
                                        {
                                            if (mydialogitem2.Labels["Name"].ToString() == PluginGuiLocalizeStrings.Get(4102)) //Custom
                                            {
                                                InputHeader = PluginGuiLocalizeStrings.Get(2902);  // Weeks After Recording
                                                InputTextBoxSkin = "";
                                                KeepuntilCode = 2921; //weeks after recording
                                                CaseSelection = (int)TvWishEntries.keepuntil;
                                                ScreenManager.ShowDialog(TVWISHLIST_RESULT_INPUT_TEXTBOX_SCREEN);
                                            }
                                            else
                                            {
                                                mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                                int j = Convert.ToInt32(mydialogitem2.Labels["Name"].ToString());
                                                string newvalue = String.Format(PluginGuiLocalizeStrings.Get(2921), j); //weeks
                                                mywish.keepuntil = newvalue;
                                                myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                            }

                                            IScreenManager mycommandscreenManager2 = ServiceRegistration.Get<IScreenManager>();
                                            mycommandscreenManager2.CloseTopmostDialog();
                                            UpdateListItems();
                                            //myselectthread = new Thread(SelectItemUpdate);
                                            //myselectthread.Start();
                                        });
                                        _dialogMenuItemList3.Add(mydialogitem2);
                                    }
                                    //update for dialog skin
                                    DialogMenuItemList3.FireChange();
                                    //will now call a dialogbox with a given menu            
                                    ScreenManager.ShowDialog(TVWISHLIST_RESULT_DIALOG_MENU_SCREEN3);

                                }//weeks after recording
                                else if (index == 3) //months after recording
                                {
                                    _dialogMenuItemList3.Clear();

                                    DialogHeader = PluginGuiLocalizeStrings.Get(2903);  // Months After Recording

                                    allItemStrings = new string[] { "3", "5", "7", "10", "15", "30", PluginGuiLocalizeStrings.Get(4102) }; //Custom
                                    foreach (string itemstring in allItemStrings)
                                    {
                                        ListItem mydialogitem2 = new ListItem();
                                        mydialogitem2.SetLabel("Name", itemstring);
                                        mydialogitem2.Command = new MethodDelegateCommand(() =>
                                        {
                                            if (mydialogitem2.Labels["Name"].ToString() == PluginGuiLocalizeStrings.Get(4102)) //Custom
                                            {
                                                InputHeader = PluginGuiLocalizeStrings.Get(2903);  // Months After Recording
                                                InputTextBoxSkin = "";
                                                KeepuntilCode = 2922; //months after recording
                                                CaseSelection = (int)TvWishEntries.keepuntil;
                                                ScreenManager.ShowDialog(TVWISHLIST_RESULT_INPUT_TEXTBOX_SCREEN);
                                            }
                                            else
                                            {
                                                mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                                int j = Convert.ToInt32(mydialogitem2.Labels["Name"].ToString());
                                                string newvalue = String.Format(PluginGuiLocalizeStrings.Get(2922), j); //months
                                                mywish.keepuntil = newvalue;
                                                myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                            }

                                            IScreenManager mycommandscreenManager2 = ServiceRegistration.Get<IScreenManager>();
                                            mycommandscreenManager2.CloseTopmostDialog();
                                            UpdateListItems();
                                            //myselectthread = new Thread(SelectItemUpdate);
                                            //myselectthread.Start();
                                        });
                                        _dialogMenuItemList3.Add(mydialogitem2);
                                    }
                                    //update for dialog skin
                                    DialogMenuItemList3.FireChange();
                                    //will now call a dialogbox with a given menu            
                                    ScreenManager.ShowDialog(TVWISHLIST_RESULT_DIALOG_MENU_SCREEN3);

                                }//months after recording
                                else if (index == 4) //date
                                {
                                    InputHeader = PluginGuiLocalizeStrings.Get(2815) + " " + PluginGuiLocalizeStrings.Get(2923); //Keep Until date format
                                    InputTextBoxSkin = mywish.keepuntil;
                                    CaseSelection = (int)TvWishEntries.skip;// cheat with skip
                                    ScreenManager.ShowDialog(TVWISHLIST_RESULT_INPUT_TEXTBOX_SCREEN);
                                }
                                else if (index == 5) //until watched
                                {
                                    mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                    mywish.keepuntil = PluginGuiLocalizeStrings.Get(2905); //watched
                                    myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                    UpdateListItems();
                                    //myselectthread = new Thread(SelectItemUpdate);
                                    //myselectthread.Start();
                                }
                                else if (index == 6) //until space needed
                                {
                                    mywish = myTvWishes.GetAtIndex(myTvWishes.FocusedWishIndex);
                                    mywish.keepuntil = PluginGuiLocalizeStrings.Get(2906); //Space                                 
                                    myTvWishes.ReplaceAtIndex(myTvWishes.FocusedWishIndex, mywish);
                                    UpdateListItems();
                                    //myselectthread = new Thread(SelectItemUpdate);
                                    //myselectthread.Start();
                                }
                                Log.Debug("mywish.keepuntil=" + mywish.keepuntil);

                                IScreenManager mycommandscreenManager = ServiceRegistration.Get<IScreenManager>();
                                mycommandscreenManager.CloseTopmostDialog();
                                Log.Debug("First Dialog is closed");

                            });
                            _dialogMenuItemList2.Add(mydialogitem);
                        }
                        //update for dialog skin
                        DialogMenuItemList2.FireChange();
                        //will now call a dialogbox with a given menu            
                        ScreenManager.ShowDialog(TVWISHLIST_RESULT_DIALOG_MENU_SCREEN2);

                        //final check:
                        Log.Debug("Before final check mywish.keepuntil=" + mywish.keepuntil);
                        string checkedstring = PluginGuiLocalizeStrings.Get(4101);//defaultvalue
                        string errormessage = "";
                        int days = 0;
                        int keepMethod = 0;
                        DateTime mydate = DateTime.Now;
                        myTvWishes.ReverseTvWishLanguageTranslation(ref mywish);
                        myTvWishes.ConvertString2KeepUntil(mywish.keepuntil, ref checkedstring, ref keepMethod, ref days, ref mydate, ref errormessage);
                        myTvWishes.TvWishLanguageTranslation(ref mywish);
                        Log.Debug("After final check mywish.keepuntil=" + mywish.keepuntil);
                        break;


                        
                }
                 
            }
            catch (Exception exc)
            {
                Log.Error("[TVWishListMP GUI_List]:ItemSelected failed exception: " + exc.Message);
            }

            myTvWishes.ButtonActive = false; //unlock buttons
        }
		void HandleCustomContextMenuEntry(Sites.ContextMenuEntry entry)
		{
			ServiceRegistration.Get<IScreenManager>().CloseTopmostDialog();
			switch (entry.Action)
			{
				case Sites.ContextMenuEntry.UIAction.Execute:
					ExecuteCustomContextMenuEntry(entry);
					break;
				case Sites.ContextMenuEntry.UIAction.GetText:
					//todo: show input dialog and execute when confirmed
					//entry.UserInputText = text;
					//ExecuteCustomContextMenuEntry(entry);
					break;
				case Sites.ContextMenuEntry.UIAction.PromptYesNo:
					var dialogHandleId = ServiceRegistration.Get<IDialogManager>().ShowDialog(entry.DisplayText, entry.PromptText, DialogType.YesNoDialog, false, DialogButtonType.No);
					var dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, (dialogResult) =>
					{
						if (dialogResult == DialogResult.Yes)
						{
							ExecuteCustomContextMenuEntry(entry);
						}
					});
					break;
				case Sites.ContextMenuEntry.UIAction.ShowList:
					var menuItems = new ItemsList();
					foreach (var item in entry.SubEntries)
					{
						var listItem = new ListItem(Consts.KEY_NAME, item.DisplayText);
						listItem.AdditionalProperties.Add(Consts.KEY_MEDIA_ITEM, item);
						menuItems.Add(listItem);
					}
					ServiceRegistration.Get<IWorkflowManager>().NavigatePushTransient(
						WorkflowState.CreateTransientState("CustomContextItems", entry.DisplayText, true, "ovsDialogGenericItems", false, WorkflowType.Dialog),
						new NavigationContextConfig()
						{
							AdditionalContextVariables = new Dictionary<string, object>
							{
								{ Constants.CONTEXT_VAR_ITEMS, menuItems },
								{ Constants.CONTEXT_VAR_COMMAND, new CommandContainer<ListItem>((li)=>HandleCustomContextMenuEntry(li.AdditionalProperties[Consts.KEY_MEDIA_ITEM] as Sites.ContextMenuEntry)) }
							}
						});

					break;
			}
		}
Example #3
0
 protected void ReleaseModelData()
 {
   _mediaTypeChoiceMenuItems = null;
   _playMenuItems = null;
   if (_dialogCloseWatcher != null)
   {
     _dialogCloseWatcher.Dispose();
     _dialogCloseWatcher = null;
   }
 }
Example #4
0
        public void DialogThread()
        {
            Log.Debug(" DialogThread started");
            //dialogwindow
            Thread.Sleep(200);
            Log.Debug("Before OkDialog"); //not waiting for the dialog -> use a DialogCloseWatcher for that
            IDialogManager mydialog = ServiceRegistration.Get<IDialogManager>();
            Guid mydialogId = mydialog.ShowDialog(_dialogheader, _dialogtext, DialogType.OkDialog, false, DialogButtonType.Ok);
            Log.Debug("After OkDialog"); //not waiting for the dialog -> use a DialogCloseWatcher for that

            if (_textNumber == 4306) //4306: TvWishList MediaPortal Plugin Does Not Match To TvWishList TV Server Plugin
            {
                dialogCloseWatcher = new DialogCloseWatcher(this, mydialogId, dialogResult =>
                { //this is watching the result of the dialog box and displaying in the Status label of the screen (do not forget to dispose)
                    IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
                    workflowManager.NavigatePop(1); //same as escape (takes one entry from the stack)
                    return;
                });
            }
            else if (_textNumber == 4311) //4311: Tv wish list is being processed by another process<br>Try again later<br>If the other process hangs reboot the system or stop the tv server manually
            {
                dialogCloseWatcher = new DialogCloseWatcher(this, mydialogId, dialogResult =>
                { //this is watching the result of the dialog box and displaying in the Status label of the screen (do not forget to dispose)
                    IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
                    workflowManager.NavigatePop(1); //same as escape (takes one entry from the stack)
                    return;
                });
            }          
            else
            {
                //do nothing
            }

            _textNumber = 0;
            _headerNumber = 0;
            Log.Debug(" DialogThread finished");

        }
Example #5
0
 protected void CheckPlayMenuInternal(MediaItem item)
 {
   IPlayerContextManager pcm = ServiceRegistration.Get<IPlayerContextManager>();
   int numOpen = pcm.NumActivePlayerContexts;
   if (numOpen == 0)
   {
     // Asynchronously leave the current workflow state because we're called from a workflow model method
     IThreadPool threadPool = ServiceRegistration.Get<IThreadPool>();
     threadPool.Add(() =>
       {
         LeaveCheckQueryPlayActionSingleItemState();
         CheckResumeAction(item);
       });
     return;
   }
   _playMenuItems = new ItemsList();
   AVType avType = pcm.GetTypeOfMediaItem(item);
   int numAudio = pcm.GetPlayerContextsByAVType(AVType.Audio).Count();
   int numVideo = pcm.GetPlayerContextsByAVType(AVType.Video).Count();
   switch (avType)
   {
     case AVType.Audio:
       {
         ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_AUDIO_ITEM)
           {
               Command = new MethodDelegateCommand(() =>
                 {
                   LeaveCheckQueryPlayActionSingleItemState();
                   CheckResumeAction(item);
                 })
           };
         _playMenuItems.Add(playItem);
         if (numAudio > 0)
         {
           ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_AUDIO_ITEM)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionSingleItemState();
                     PlayOrEnqueueItem(item, false, PlayerContextConcurrencyMode.None);
                   })
             };
           _playMenuItems.Add(enqueueItem);
         }
         if (numVideo > 0)
         {
           ListItem playItemConcurrently = new ListItem(Consts.KEY_NAME, Consts.RES_MUTE_VIDEO_PLAY_AUDIO_ITEM)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionSingleItemState();
                     PlayOrEnqueueItem(item, true, PlayerContextConcurrencyMode.ConcurrentVideo);
                   })
             };
           _playMenuItems.Add(playItemConcurrently);
         }
       }
       break;
     case AVType.Video:
       {
         ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEM)
           {
               Command = new MethodDelegateCommand(() =>
                 {
                   LeaveCheckQueryPlayActionSingleItemState();
                   CheckResumeAction(item);
                 })
           };
         _playMenuItems.Add(playItem);
         if (numVideo > 0)
         {
           ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_VIDEO_IMAGE_ITEM)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionSingleItemState();
                     PlayOrEnqueueItem(item, false, PlayerContextConcurrencyMode.None);
                   })
             };
           _playMenuItems.Add(enqueueItem);
         }
         if (numAudio > 0)
         {
           ListItem playItem_A = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEM_MUTED_CONCURRENT_AUDIO)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionSingleItemState();
                     PlayOrEnqueueItem(item, true, PlayerContextConcurrencyMode.ConcurrentAudio);
                   })
             };
           _playMenuItems.Add(playItem_A);
         }
         if (numVideo > 0)
         {
           ListItem playItem_V = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEM_PIP)
             {
                 Command = new MethodDelegateCommand(() =>
                   {
                     LeaveCheckQueryPlayActionSingleItemState();
                     PlayOrEnqueueItem(item, true, PlayerContextConcurrencyMode.ConcurrentVideo);
                   })
             };
           _playMenuItems.Add(playItem_V);
         }
       }
       break;
     default:
       {
         IDialogManager dialogManager = ServiceRegistration.Get<IDialogManager>();
         Guid dialogHandleId = dialogManager.ShowDialog(Consts.RES_SYSTEM_INFORMATION, Consts.RES_CANNOT_PLAY_ITEM_DIALOG_TEXT,
             DialogType.OkDialog, false, DialogButtonType.Ok);
         _dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, dialogResult => LeaveCheckQueryPlayActionSingleItemState());
       }
       break;
   }
   IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>();
   screenManager.ShowDialog(Consts.DIALOG_PLAY_MENU, (dialogName, dialogInstanceId) =>
       LeaveCheckQueryPlayActionSingleItemState());
 }
Example #6
0
        public void ButtonTvServerLoadSettings()
        {
            IDialogManager mydialog = ServiceRegistration.Get<IDialogManager>();
            Guid mydialogId = mydialog.ShowDialog(WARNING_RESOURCE, LOAD_QUESTION_RESOURCE, DialogType.YesNoDialog, false, DialogButtonType.Yes);

            DialogCloseWatcher dialogCloseWatcher = new DialogCloseWatcher(this, mydialogId, dialogResult =>
            { //this is watching the result of the dialog box and displaying in the Status label of the screen (do not forget to dispose)
                Log.Debug("dialogResult.ToString()=" + dialogResult.ToString());

                if (dialogResult.ToString() == DialogButtonType.Yes.ToString())
                {
                    try
                    {
                        LoadSettingsFromTvServer();
                        mydialog.ShowDialog(INFO_RESOURCE, LOAD_COMPLETE_RESOURCE, DialogType.OkDialog, false, DialogButtonType.Ok);
                    }
                    catch (Exception exc)
                    {
                        Log.Debug("[TVWishListMP2] buttonTvserverLoad_Click: Error LoadSettings: Exception " + exc.Message);
                        mydialog.ShowDialog(ERROR_RESOURCE, LOAD_ERROR_RESOURCE, DialogType.OkDialog, false, DialogButtonType.Ok);
                    }
                }
                return;
            });
        }
 public void RemoveAllSites()
 {
     if (SitesList.Count > 0)
     {
         var dialogHandleId = ServiceRegistration.Get<IDialogManager>().ShowDialog(LocalizationHelper.Translate("[OnlineVideos.RemoveAllFromMySites]") + "?", "", DialogType.YesNoDialog, false, DialogButtonType.No);
         _dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, (dialogResult) =>
         {
             if (dialogResult == DialogResult.Yes)
             {
                 bool needRefresh = false;
                 foreach (var siteToRemove in SitesList)
                 {
                     SiteSettings localSite = null;
                     var localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(((OnlineSiteViewModel)siteToRemove).Site.Name, out localSite);
                     if (localSiteIndex >= 0)
                     {
                         OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex);
                         needRefresh = true;
                     }
                 }
                 if (needRefresh)
                 {
                     OnlineVideoSettings.Instance.SaveSites();
                     newDataSaved = true;
                     GetFilteredAndSortedSites();
                 }
             }
         });
     }
 }
 protected void ReleaseModelData()
 {
     Emulators = null;
     CurrentProfiles = null;
     Reset();
     pathBrowserHandler.Dispose();
     if (confirmDeleteCloseWatcher != null)
     {
         confirmDeleteCloseWatcher.Dispose();
         confirmDeleteCloseWatcher = null;
     }
 }
 void confirmEmulatorDelete(Emulator emulator)
 {
     IDialogManager dialogManager = ServiceRegistration.Get<IDialogManager>();
     Guid dialogHandle = dialogManager.ShowDialog(emulator.Title, "[Emulators.Dialogs.ConfirmDelete]", DialogType.YesNoDialog, false, DialogButtonType.No);
     confirmDeleteCloseWatcher = new DialogCloseWatcher(this, dialogHandle, dialogResult => 
     {
         if (dialogResult == DialogResult.Yes)
             emulator.Delete();
     });
 }