Example #1
0
        public void FindBestSearchResult(ComboBox cbResults, string SearchString)
        {
            RelationProvider provider = RelationProvider.GetCurrentProvider();

            cbResults.SelectedIndex = 0;
            //Restore previously selected result
            if (provider.SelectedResults.ContainsKey(SearchString) && cbResults.Items.Contains(provider.SelectedResults[SearchString]))
            {
                cbResults.SelectedIndex = cbResults.Items.IndexOf(provider.SelectedResults[SearchString]);
            }
            else
            {
                List <string> languages = new List <string>(Helper.ReadProperties(Config.Languages));
                if (languages.Count > 0)
                {
                    //get a list of matching results with correct language, then use shortest one
                    int minlength = Int32.MaxValue;
                    int pos       = 0;
                    for (int j = 0; j < cbResults.Items.Count; j++)
                    {
                        string str = cbResults.Items[j].ToString();
                        if (Regex.IsMatch(str, languages[0]))
                        {
                            if (str.Length < minlength)
                            {
                                minlength = str.Length;
                                pos       = j;
                            }
                        }
                    }
                    cbResults.SelectedIndex = pos;
                }
            }
        }
Example #2
0
        public void SearchButtonClicked(object sender, EventArgs e)
        {
            //note: this starts at 0, even though the gui placement starts at 1
            int      row           = Int32.Parse(((Control)sender).Name.Substring(((Control)sender).Name.Length - 2));
            TextBox  SearchBox     = (TextBox)tableLayoutPanel1.Controls["TextBox " + row];
            ComboBox ProviderBox   = (ComboBox)tableLayoutPanel1.Controls["ComboBox Providers " + row];
            Label    ShownameLabel = (Label)tableLayoutPanel1.Controls["Label " + row];

            DataGenerator.ParsedSearch Search = DataGenerator.Search(RelationProvider.GetProviderByName(ProviderBox.SelectedItem.ToString()), SearchBox.Text, ShownameLabel.Text);
            ComboBox cbResults = (ComboBox)tableLayoutPanel1.Controls["ComboBox " + row];

            cbResults.Items.Clear();
            RelationProvider provider = RelationProvider.GetCurrentProvider();

            if (Search.Results != null && Search.Results.Count != 0)
            {
                foreach (string s in Search.Results.Keys)
                {
                    cbResults.Items.Add(s);
                }
                FindBestSearchResult(cbResults, Search.SearchString);
            }
            else
            {
                cbResults.Items.Add("No results found");
                cbResults.SelectedIndex = 0;
            }
            Results[row] = Search;
        }
Example #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            RelationProvider provider = RelationProvider.GetCurrentProvider();

            for (int i = 0; i < Results.Count; i++)
            {
                ComboBox cbResults = (ComboBox)tableLayoutPanel1.Controls["ComboBox " + i];
                TextBox  SearchBox = (TextBox)tableLayoutPanel1.Controls["TextBox " + i];
                Results[i].SelectedResult = cbResults.SelectedItem.ToString();
                if (SearchBox.Text != "No results found")
                {
                    if (provider.SelectedResults.ContainsKey(SearchBox.Text))
                    {
                        provider.SelectedResults[SearchBox.Text] = cbResults.SelectedItem.ToString();
                    }
                    else
                    {
                        provider.SelectedResults.Add(SearchBox.Text, cbResults.SelectedItem.ToString());
                    }
                }
            }
            this.DialogResult = DialogResult.OK;
            Close();
        }
Example #4
0
        /// <summary>
        /// Initialization, sets all values from Config file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Configuration_Load(object sender, EventArgs e)
        {
            //Get some strings
            txtReplace.Text     = Helper.ReadProperty(Config.InvalidCharReplace);
            nudSearchDepth.Text = Helper.ReadProperty(Config.MaxDepth);
            txtIgnoreFiles.Text = Helper.ReadProperty(Config.IgnoreFiles);
            txtDestination.Text = Helper.ReadProperty(Config.DestinationDirectory);

            //Get multiline strings
            txtExtensions.Text = "";
            foreach (string s in Helper.ReadProperties(Config.Extensions))
            {
                txtExtensions.Text += s.ToLower() + Environment.NewLine;
            }
            if (txtExtensions.Text.Length > 0)
            {
                txtExtensions.Text = txtExtensions.Text.Substring(0, txtExtensions.Text.Length - Environment.NewLine.Length);
            }

            txtSubs.Text = "";
            foreach (string s in Helper.ReadProperties(Config.SubtitleExtensions))
            {
                txtSubs.Text += s.ToLower() + Environment.NewLine;
            }
            if (txtSubs.Text.Length > 0)
            {
                txtSubs.Text = txtSubs.Text.Substring(0, txtSubs.Text.Length - Environment.NewLine.Length);
            }

            txtPattern.Text = "";
            foreach (string s in Helper.ReadProperties(Config.EpIdentifier))
            {
                txtPattern.Text += s + Environment.NewLine;
            }
            if (txtPattern.Text.Length > 0)
            {
                txtPattern.Text = txtPattern.Text.Substring(0, txtPattern.Text.Length - Environment.NewLine.Length);
            }

            txtStringReplace.Text = "";
            foreach (string s in Helper.ReadProperties(Config.Replace))
            {
                txtStringReplace.Text += s + Environment.NewLine;
            }
            if (txtStringReplace.Text.Length > 0)
            {
                txtStringReplace.Text = txtStringReplace.Text.Substring(0, txtStringReplace.Text.Length - Environment.NewLine.Length);
            }

            txtTags.Text = "";
            foreach (string s in Helper.ReadProperties(Config.Tags))
            {
                txtTags.Text += s + Environment.NewLine;
            }
            if (txtTags.Text.Length > 0)
            {
                txtTags.Text = txtTags.Text.Substring(0, txtTags.Text.Length - Environment.NewLine.Length);
            }

            txtExtract.Text = "";
            foreach (string s in Helper.ReadProperties(Config.Extract))
            {
                txtExtract.Text += s + Environment.NewLine;
            }
            if (txtExtract.Text.Length > 0)
            {
                txtExtract.Text = txtExtract.Text.Substring(0, txtExtract.Text.Length - Environment.NewLine.Length);
            }

            //Get some enums
            cbLogfile.SelectedIndex       = (int)(Helper.ReadEnum <Logging.LogLevel>(Config.LogFileLevel));
            cbLogwindow.SelectedIndex     = (int)(Helper.ReadEnum <Logging.LogLevel>(Config.LogTextBoxLevel));
            cbLogmessagebox.SelectedIndex = (int)(Helper.ReadEnum <Logging.LogLevel>(Config.LogMessageBoxLevel));

            cbUmlaut.SelectedIndex = (int)Helper.ReadEnum <InfoEntry.UmlautAction>(Config.Umlaute) - 1;
            cbCase.SelectedIndex   = (int)Helper.ReadEnum <InfoEntry.Case>(Config.Case) - 1;

            //Get some ints
            nudTimeout.Value = Helper.ReadInt(Config.Timeout);

            //Get some bools
            chkCreateDirectoryStructure.Checked = Helper.ReadBool(Config.CreateDirectoryStructure);
            chkDeleteEmptyFolders.Checked       = Helper.ReadBool(Config.DeleteEmptyFolders);
            chkDeleteAllEmptyFolders.Checked    = Helper.ReadBool(Config.DeleteAllEmptyFolders);
            chkUseSeasonSubdirs.Checked         = Helper.ReadBool(Config.UseSeasonSubDir);
            chkResize.Checked = Helper.ReadBool(Config.ResizeColumns);
            chkFindMissingEpisodes.Checked = Helper.ReadBool(Config.FindMissingEpisodes);
            chkDeleteSampleFiles.Checked   = Helper.ReadBool(Config.DeleteSampleFiles);

            //relation provider combobox
            cbProviders.Items.AddRange(RelationProvider.ProviderNames);

            //Languages
            List <string> Languages = new List <string>(Helper.ReadProperties(Config.Languages));

            foreach (string lang in Languages)
            {
                cbLanguage.Items.Add(lang.Substring(0, lang.IndexOf("|")));
            }
            if (Languages.Count > 0)
            {
                cbLanguage.SelectedIndex = 0;
            }

            string LastProvider = Helper.ReadProperty(Config.LastProvider);

            if (LastProvider == null)
            {
                LastProvider = "";
            }
            cbProviders.SelectedIndex = Math.Max(0, cbProviders.Items.IndexOf(LastProvider));
            RelationProvider provider = RelationProvider.GetCurrentProvider();

            if (provider == null)
            {
                Logger.Instance.LogMessage("No relation provider found/selected", LogLevel.ERROR);
                return;
            }
            Helper.WriteProperty(Config.LastProvider, cbProviders.Text);
        }
Example #5
0
 public RelationController(IOptions<AppSettings> settings)
 {
     this.settings = settings;
     provider = new RelationProvider(settings.Value.MongoUri);
 }
Example #6
0
 public RelationController(IOptions <AppSettings> settings)
 {
     this.settings = settings;
     provider      = new RelationProvider(settings.Value.MongoUri);
 }
Example #7
0
        public ShownameSearch(List <DataGenerator.ParsedSearch> results)
        {
            InitializeComponent();
            Results    = results;
            KeyPreview = true;
            for (int i = 0; i < Results.Count; i++)
            {
                DataGenerator.ParsedSearch ps = Results[i];
                tableLayoutPanel1.RowCount++;
                tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                Label lbl = new Label();
                lbl.Text   = ps.Showname;
                lbl.Name   = "Label " + i;
                lbl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
                tableLayoutPanel1.Controls.Add(lbl, 0, i + 1);
                TextBox tb = new TextBox();
                tb.Text     = ps.Showname;
                tb.Name     = "TextBox " + i;
                tb.Anchor   = AnchorStyles.Left | AnchorStyles.Right;
                tb.KeyDown += new KeyEventHandler(SearchBoxKeyDown);
                tableLayoutPanel1.Controls.Add(tb, 1, i + 1);
                ComboBox cbProviders = new ComboBox();
                cbProviders.DropDownStyle = ComboBoxStyle.DropDownList;
                cbProviders.Name          = "ComboBox Providers " + i;
                cbProviders.Items.AddRange(RelationProvider.ProviderNames);
                cbProviders.Anchor = AnchorStyles.Left | AnchorStyles.Right;
                RelationProvider provider = RelationProvider.GetCurrentProvider();
                cbProviders.SelectedItem = provider.Name;
                tableLayoutPanel1.Controls.Add(cbProviders, 2, i + 1);
                Button btn = new Button();
                btn.Text   = "Search";
                btn.Name   = "Button " + i;
                btn.Anchor = AnchorStyles.Left | AnchorStyles.Right;
                btn.Click += new EventHandler(SearchButtonClicked);
                tableLayoutPanel1.Controls.Add(btn, 3, i + 1);
                ComboBox cb = new ComboBox();
                cb.DropDownStyle = ComboBoxStyle.DropDownList;
                cb.Name          = "ComboBox " + i;
                cb.Sorted        = true;

                if (ps.Results != null && ps.Results.Count != 0)
                {
                    foreach (string key in ps.Results.Keys)
                    {
                        cb.Items.Add(key);
                    }
                    FindBestSearchResult(cb, ps.SearchString);
                }
                else
                {
                    cb.Items.Add("No results found");
                    cb.SelectedIndex = 0;
                }


                cb.Anchor = AnchorStyles.Left | AnchorStyles.Right;
                tableLayoutPanel1.Controls.Add(cb, 4, i + 1);
            }

            //add one more because of stretching
            tableLayoutPanel1.RowCount++;
            if (Settings.Instance.IsMonoCompatibilityMode)
            {
                AutoSize = false;
                Height   = tableLayoutPanel1.Height + 107;
            }
            if (Height > maxHeight)
            {
                AutoSize = false;
                Height   = maxHeight;
                //107 is the height of the dialog minus the table control
                tableLayoutPanel1.AutoSize = false;
                tableLayoutPanel1.Height   = maxHeight - 107;
            }
            BringToFront();
        }