void HandleCustomContextMenuEntry(ContextMenuEntry currentEntry, Category aCategory, VideoInfo aVideo)
        {
            List<KeyValuePair<string, ContextMenuEntry>> dialogOptions = new List<KeyValuePair<string, ContextMenuEntry>>();
            while (true)
            {
                bool execute = currentEntry.Action == ContextMenuEntry.UIAction.Execute;

                if (currentEntry.Action == ContextMenuEntry.UIAction.GetText)
                {
                    SearchDialog dlg = new SearchDialog() { Owner = this };
                    dlg.tbxSearch.Text = currentEntry.UserInputText ?? "";
                    dlg.lblHeading.Text = currentEntry.DisplayText;
                    if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.tbxSearch.Text))
                    {
                        currentEntry.UserInputText = dlg.tbxSearch.Text;
                        execute = true;
                    }
                    else break;
                }
                if (currentEntry.Action == ContextMenuEntry.UIAction.ShowList)
                {
                    PlaybackChoices dlg = new PlaybackChoices() { Owner = this };
                    dlg.lblHeading.Content = currentEntry.DisplayText;
                    dialogOptions.Clear();
                    foreach (var subEntry in currentEntry.SubEntries)
                    {
                        dialogOptions.Add(new KeyValuePair<string, ContextMenuEntry>(subEntry.DisplayText, subEntry));
                    }
                    dlg.lvChoices.ItemsSource = dialogOptions.Select(dO => dO.Key).ToList();
                    dlg.lvChoices.SelectedIndex = 0;
                    if (dlg.ShowDialog() != true)
                        break;
                    else
                        currentEntry = dialogOptions[dlg.lvChoices.SelectedIndex].Value;
                }
                if (execute)
                {
                    waitCursor.Visibility = System.Windows.Visibility.Visible;
                    Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(
                        delegate()
                        {
                            return SelectedSite.ExecuteContextMenuEntry(aCategory, aVideo, currentEntry);
                        },
                        delegate(Gui2UtilConnector.ResultInfo resultInfo)
                        {
                            waitCursor.Visibility = System.Windows.Visibility.Hidden;
                            if (ReactToResult(resultInfo, currentEntry.DisplayText))
                            {
                                if (resultInfo.ResultObject is ContextMenuExecutionResult)
                                {
                                    var cmer = resultInfo.ResultObject as ContextMenuExecutionResult;
                                    if (!string.IsNullOrEmpty(cmer.ExecutionResultMessage))
                                    {
                                        notification.Show(currentEntry.DisplayText, cmer.ExecutionResultMessage);
                                    }
                                    if (cmer.RefreshCurrentItems)
                                    {
                                        CategorySelected(SelectedCategory);
                                    }
                                    if (cmer.ResultItems != null && cmer.ResultItems.Count > 0)
                                    {
                                        DisplaySearchResultItems(currentEntry.DisplayText, cmer.ResultItems);
                                    }
                                }
                            }
                        });
                    break;
                }
            }
        }
        void HandleItemAction()
        {
            var    prop  = lvChoices.SelectedValue as OnlineVideos.Reflection.FieldPropertyDescriptorByRef;
            string value = site.GetConfigValueAsString(prop);

            if (prop.IsBool)
            {
                var dlgTrueFalse = new PlaybackChoices()
                {
                    Owner = this
                };
                dlgTrueFalse.lblHeading.Content      = string.Format("{0}: {1}", site.Settings.Name, prop.DisplayName);
                dlgTrueFalse.lvChoices.ItemsSource   = new string[] { true.ToString(), false.ToString() };
                dlgTrueFalse.lvChoices.SelectedValue = value;
                if (dlgTrueFalse.ShowDialog() == true)
                {
                    if (value != dlgTrueFalse.lvChoices.SelectedValue.ToString())
                    {
                        site.SetConfigValueFromString(prop, dlgTrueFalse.lvChoices.SelectedValue.ToString());
                        changes = true;
                        GenerateOptions(lvChoices.SelectedIndex);
                    }
                }
            }
            else if (prop.IsEnum)
            {
                var dlgEnum = new PlaybackChoices()
                {
                    Owner = this
                };
                dlgEnum.lblHeading.Content      = string.Format("{0}: {1}", site.Settings.Name, prop.DisplayName);
                dlgEnum.lvChoices.ItemsSource   = prop.GetEnumValues();
                dlgEnum.lvChoices.SelectedValue = value;
                if (dlgEnum.ShowDialog() == true)
                {
                    if (value != dlgEnum.lvChoices.SelectedValue.ToString())
                    {
                        site.SetConfigValueFromString(prop, dlgEnum.lvChoices.SelectedValue.ToString());
                        changes = true;
                        GenerateOptions(lvChoices.SelectedIndex);
                    }
                }
            }
            else
            {
                var dlgText = new SearchDialog()
                {
                    Owner = this
                };
                dlgText.tbxSearch.Text  = value ?? "";
                dlgText.lblHeading.Text = string.Format("{0}: {1}", site.Settings.Name, prop.DisplayName);
                if (prop.IsPassword)
                {
                    dlgText.tbxSearch.Visibility  = System.Windows.Visibility.Collapsed;
                    dlgText.tbxPasswrd.Visibility = System.Windows.Visibility.Visible;
                    dlgText.tbxPasswrd.Focus();
                }
                if (dlgText.ShowDialog() == true)
                {
                    var newValue = (prop.IsPassword ? dlgText.tbxPasswrd.Password : dlgText.tbxSearch.Text);
                    if (value != newValue)
                    {
                        try
                        {
                            site.SetConfigValueFromString(prop, newValue);
                            changes = true;
                            GenerateOptions(lvChoices.SelectedIndex);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(this, ex.Message, Translation.Instance.Error);
                        }
                    }
                }
            }
        }
		private void Search_Executed(object sender, ExecutedRoutedEventArgs e)
		{
			SearchDialog dlg = new SearchDialog();
			dlg.Owner = this;
			if (dlg.ShowDialog() == true)
			{
				string search = dlg.tbxSearch.Text;
				if (search.Trim().Length > 0)
				{
					waitCursor.Visibility = System.Windows.Visibility.Visible;
					Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(
						delegate()
						{
							return SelectedSite.Search(search.Trim());
						},
						delegate(Gui2UtilConnector.ResultInfo resultInfo)
						{
							waitCursor.Visibility = System.Windows.Visibility.Hidden;
							if (ReactToResult(resultInfo, Translation.Instance.GettingCategoryVideos))
							{
                                DisplaySearchResultItems(Translation.Instance.SearchResults + " [" + search + "]", resultInfo.ResultObject as List<SearchResultItem>);
							}
						}
					);
				}
			}
		}
 void HandleItemAction()
 {
     var prop = lvChoices.SelectedValue as OnlineVideos.Reflection.FieldPropertyDescriptorByRef;
     string value = site.GetConfigValueAsString(prop);
     if (prop.IsBool)
     {
         var dlgTrueFalse = new PlaybackChoices() { Owner = this };
         dlgTrueFalse.lblHeading.Content = string.Format("{0}: {1}", site.Settings.Name, prop.DisplayName);
         dlgTrueFalse.lvChoices.ItemsSource = new string[] { true.ToString(), false.ToString() };
         dlgTrueFalse.lvChoices.SelectedValue = value;
         if (dlgTrueFalse.ShowDialog() == true)
         {
             if (value != dlgTrueFalse.lvChoices.SelectedValue.ToString())
             {
                 site.SetConfigValueFromString(prop, dlgTrueFalse.lvChoices.SelectedValue.ToString());
                 changes = true;
                 GenerateOptions(lvChoices.SelectedIndex);
             }
         }
     }
     else if (prop.IsEnum)
     {
         var dlgEnum = new PlaybackChoices() { Owner = this };
         dlgEnum.lblHeading.Content = string.Format("{0}: {1}", site.Settings.Name, prop.DisplayName);
         dlgEnum.lvChoices.ItemsSource = prop.GetEnumValues();
         dlgEnum.lvChoices.SelectedValue = value;
         if (dlgEnum.ShowDialog() == true)
         {
             if (value != dlgEnum.lvChoices.SelectedValue.ToString())
             {
                 site.SetConfigValueFromString(prop, dlgEnum.lvChoices.SelectedValue.ToString());
                 changes = true;
                 GenerateOptions(lvChoices.SelectedIndex);
             }
         }
     }
     else
     {
         var dlgText = new SearchDialog() { Owner = this };
         dlgText.tbxSearch.Text = value ?? "";
         dlgText.lblHeading.Text = string.Format("{0}: {1}", site.Settings.Name, prop.DisplayName);
         if (prop.IsPassword)
         {
             dlgText.tbxSearch.Visibility = System.Windows.Visibility.Collapsed;
             dlgText.tbxPasswrd.Visibility = System.Windows.Visibility.Visible;
             dlgText.tbxPasswrd.Focus();
         }
         if (dlgText.ShowDialog() == true)
         {
             var newValue = (prop.IsPassword ? dlgText.tbxPasswrd.Password : dlgText.tbxSearch.Text);
             if (value != newValue)
             {
                 try
                 {
                     site.SetConfigValueFromString(prop, newValue);
                     changes = true;
                     GenerateOptions(lvChoices.SelectedIndex);
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(this, ex.Message, Translation.Instance.Error);
                 }
             }
         }
     }
 }