コード例 #1
0
ファイル: TVSeriesPlugin.cs プロジェクト: MichelZ/MP-TVSeries
        public ReturnCode ChooseFromSelectionSync(ChooseFromSelectionDescriptor descriptor)
        {
            try
            {
                IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                m_selected = null;
                if (dlg == null)
                    return ReturnCode.Cancel;

                dlg.Reset();
                if (descriptor.m_sItemToMatchLabel.Length == 0)
                    dlg.SetHeading(descriptor.m_sTitle);
                else
                    dlg.SetHeading(descriptor.m_sItemToMatchLabel + " " + descriptor.m_sItemToMatch);

                GUIListItem pItem = null;

                if (descriptor.m_sbtnSkipLabel.Length > 0)
                {
                    pItem = new GUIListItem(Translation.CFS_Skip);
                    dlg.Add(pItem);
                    pItem.ItemId = 0;

                }
                if (descriptor.m_sbtnIgnoreLabel.Length > 0)
                {
                    pItem = new GUIListItem(Translation.CFS_Skip_Never_Ask_Again);
                    dlg.Add(pItem);
                    pItem.ItemId = 1;
                }

                if (descriptor.m_List.Count == 0)
                {
                    pItem = new GUIListItem(Translation.CFS_No_Results_Found);
                    dlg.Add(pItem);
                    pItem.ItemId = 2;
                }
                else
                {
                    int nCount = 0;
                    foreach (CItem item in descriptor.m_List)
                    {
                        pItem = new GUIListItem(item.m_sName);
                        dlg.Add(pItem);
                        pItem.ItemId = 10 + nCount;
                        nCount++;
                    }
                }

                dlg.DoModal(GUIWindowManager.ActiveWindow);
                if (dlg.SelectedId == -1)
                {
                    return ReturnCode.Cancel;
                }
                else
                {
                    if (dlg.SelectedId == 1)
                    {
                        return ReturnCode.Ignore;
                    }
                    else if (dlg.SelectedId >= 10)
                    {
                        CItem DlgSelected = descriptor.m_List[dlg.SelectedId - 10];
                        m_selected = new CItem(descriptor.m_sItemToMatch, String.Empty, DlgSelected.m_Tag);
                        return ReturnCode.OK;
                    }
                    else
                        return ReturnCode.Cancel;
                }
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("The ChooseFromSelection Method has generated an error: " + ex.Message);
                m_selected = null;
                return ReturnCode.Cancel;
            }
            finally
            {
                this.m_Facade.Focus = true;
            }
        }
コード例 #2
0
ファイル: TVSeriesPlugin.cs プロジェクト: MichelZ/MP-TVSeries
        public ReturnCode ChooseFromSelection(ChooseFromSelectionDescriptor descriptor, out CItem selected)
        {
            if (this.m_Facade == null)
            {
                selected = null;
                return ReturnCode.NotReady;
            }

            ReturnCode returnCode;
            if (m_localControlForInvoke.InvokeRequired)
            {
                returnCode = (ReturnCode)m_localControlForInvoke.Invoke(new ChooseFromSelectionDelegate(ChooseFromSelectionSync), new Object[] { descriptor });
            }
            else
                returnCode = ChooseFromSelectionSync(descriptor);
            selected = m_selected;
            return returnCode;
        }
コード例 #3
0
 private bool useRadioMethod(Feedback.ChooseFromSelectionDescriptor descriptor)
 {
     return(descriptor.m_useRadioToSelect && descriptor.m_List.Count <= maxItemsForRadioMode);
 }
コード例 #4
0
        const int maxItemsForRadioMode = 6; // doesn't scale to above 6 items

        public ChooseFromSelectionDialog(Feedback.ChooseFromSelectionDescriptor descriptor)
        {
            m_descriptor = descriptor;
            InitializeComponent();
            useRadioMode            = useRadioMethod(descriptor);
            Text                    = descriptor.m_sTitle;
            label_ToMatch.Text      = descriptor.m_sItemToMatchLabel;
            textbox_ToMatch.Text    = descriptor.m_sItemToMatch;
            textbox_ToMatch.Enabled = descriptor.m_allowAlter;
            label_Choices.Text      = descriptor.m_sListLabel;
            origTitle               = this.Text;


            if (descriptor.m_sbtnOKLabel.Length == 0)
            {
                button_OK.Visible = false;
            }
            else
            {
                button_OK.Visible = true;
                button_OK.Text    = descriptor.m_sbtnOKLabel;
            }

            if (descriptor.m_sbtnCancelLabel.Length == 0)
            {
                button_Cancel.Visible = false;
            }
            else
            {
                button_Cancel.Visible = true;
                button_Cancel.Text    = descriptor.m_sbtnCancelLabel;
            }

            if (descriptor.m_sbtnIgnoreLabel.Length == 0)
            {
                button_Ignore.Visible = false;
            }
            else
            {
                button_Ignore.Visible = true;
                button_Ignore.Text    = descriptor.m_sbtnIgnoreLabel;
            }

            if (!useRadioMode)
            {
                setRadiosVisibility(false);
                listbox_Choices.Visible = true;
                foreach (Feedback.CItem item in descriptor.m_List)
                {
                    listbox_Choices.Items.Add(item);
                }
                if (listbox_Choices.Items.Count > 0)
                {
                    listbox_Choices.SelectedIndex = 0;
                }
            }
            else
            {
                setRadiosVisibility(true);
                listbox_Choices.Visible = false;

                if (descriptor.m_List.Count > 0)
                {
                    radOption1.Text    = descriptor.m_List[0].ToString();
                    radOption1.Checked = true; // default
                }
                else
                {
                    radOption1.Visible = false;
                }
                if (descriptor.m_List.Count > 1)
                {
                    radOption2.Text = descriptor.m_List[1].ToString();
                }
                else
                {
                    radOption2.Visible = false;
                }
                if (descriptor.m_List.Count > 2)
                {
                    radOption3.Text = descriptor.m_List[2].ToString();
                }
                else
                {
                    radOption3.Visible = false;
                }
                if (descriptor.m_List.Count > 3)
                {
                    radOption4.Text = descriptor.m_List[3].ToString();
                }
                else
                {
                    radOption4.Visible = false;
                }
                if (descriptor.m_List.Count > 4)
                {
                    radOption5.Text = descriptor.m_List[4].ToString();
                }
                else
                {
                    radOption5.Visible = false;
                }
                if (descriptor.m_List.Count > 5)
                {
                    radOption6.Text = descriptor.m_List[5].ToString();
                }
                else
                {
                    radOption6.Visible = false;
                }
            }
        }
コード例 #5
0
        const int maxItemsForRadioMode = 6; // doesn't scale to above 6 items

        public ChooseFromSelectionDialog(Feedback.ChooseFromSelectionDescriptor descriptor)
        {
            m_descriptor = descriptor;
            InitializeComponent();
            useRadioMode = useRadioMethod(descriptor);
            Text = descriptor.m_sTitle;
            label_ToMatch.Text = descriptor.m_sItemToMatchLabel;
            textbox_ToMatch.Text = descriptor.m_sItemToMatch;
            textbox_ToMatch.Enabled = descriptor.m_allowAlter;
            label_Choices.Text = descriptor.m_sListLabel;
            origTitle = this.Text;


            if (descriptor.m_sbtnOKLabel.Length == 0)
                button_OK.Visible = false;
            else
            {
                button_OK.Visible = true;
                button_OK.Text = descriptor.m_sbtnOKLabel;
            }

            if (descriptor.m_sbtnCancelLabel.Length == 0)
                button_Cancel.Visible = false;
            else
            {
                button_Cancel.Visible = true;
                button_Cancel.Text = descriptor.m_sbtnCancelLabel;
            }

            if (descriptor.m_sbtnIgnoreLabel.Length == 0)
                button_Ignore.Visible = false;
            else
            {
                button_Ignore.Visible = true;
                button_Ignore.Text = descriptor.m_sbtnIgnoreLabel;
            }

            if (!useRadioMode)
            {
                setRadiosVisibility(false);
                listbox_Choices.Visible = true;
                foreach (Feedback.CItem item in descriptor.m_List)
                {
                    listbox_Choices.Items.Add(item);
                }
                if (listbox_Choices.Items.Count > 0)
                    listbox_Choices.SelectedIndex = 0;
            }
            else
            {
                setRadiosVisibility(true);
                listbox_Choices.Visible = false;

                if (descriptor.m_List.Count > 0)
                {
                    radOption1.Text = descriptor.m_List[0].ToString();
                    radOption1.Checked = true; // default
                }
                else radOption1.Visible = false;
                if (descriptor.m_List.Count > 1) radOption2.Text = descriptor.m_List[1].ToString();
                else radOption2.Visible = false;
                if (descriptor.m_List.Count > 2) radOption3.Text = descriptor.m_List[2].ToString();
                else radOption3.Visible = false;
                if (descriptor.m_List.Count > 3) radOption4.Text = descriptor.m_List[3].ToString();
                else radOption4.Visible = false;
                if (descriptor.m_List.Count > 4) radOption5.Text = descriptor.m_List[4].ToString();
                else radOption5.Visible = false;
                if (descriptor.m_List.Count > 5) radOption6.Text = descriptor.m_List[5].ToString();
                else radOption6.Visible = false;
            }
        }