示例#1
0
 private void button_apply_Click(object sender, EventArgs e)
 {
     // close window, set return code & data so main form can get the filter.
     filter = new NFO_Filter();
     filter.setPropertyList(getFilterProperties());
     filter.name  = filterName;
     DialogResult = DialogResult.OK;
     this.Close();
 }
示例#2
0
        private void displayFilter(NFO_Filter f)
        {
            // first move everything to available, so we can then move only what is needed back to the filter.
            allItemsAvailable();
            List <string> properties = f.getPropertyList();

            foreach (string s in properties)
            {
                FilterItem item;
                if (filterItems.TryGetValue(s, out item) == true)
                {
                    item.makeInUse();
                }
            }
        }
示例#3
0
        public FilterForm(NFO_Filter currentFilter)
        {
            InitializeComponent();

            filterFiles = new Dictionary <string, NFO_Filter_File>();
            filterItems = new Dictionary <string, FilterItem>();
            filterItems.Add(NFOConstants.Title, new NFO_Helper.FilterItem(NFOConstants.Title, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.OriginalTitle, new NFO_Helper.FilterItem(NFOConstants.OriginalTitle, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Year, new NFO_Helper.FilterItem(NFOConstants.Year, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Tagline, new NFO_Helper.FilterItem(NFOConstants.Tagline, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Rating, new NFO_Helper.FilterItem(NFOConstants.Rating, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Outline, new NFO_Helper.FilterItem(NFOConstants.Outline, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Runtime, new NFO_Helper.FilterItem(NFOConstants.Runtime, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Id, new NFO_Helper.FilterItem(NFOConstants.Id, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Trailer, new NFO_Helper.FilterItem(NFOConstants.Trailer, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Genres, new NFO_Helper.FilterItem(NFOConstants.Genres, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Director, new NFO_Helper.FilterItem(NFOConstants.Director, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Actors, new NFO_Helper.FilterItem(NFOConstants.Actors, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Set, new NFO_Helper.FilterItem(NFOConstants.Set, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Votes, new NFO_Helper.FilterItem(NFOConstants.Votes, this.listBox_available, this.listBox_filter));
            filterItems.Add(NFOConstants.Thumb, new NFO_Helper.FilterItem(NFOConstants.Thumb, this.listBox_available, this.listBox_filter));

            button_up.Text   = char.ConvertFromUtf32(708);
            button_down.Text = char.ConvertFromUtf32(709);

            comboBox_filterselect.Items.Insert(0, AppConstants.DefaultNfoFilterName);

            // prepare any filter files that have been previously used.
            string listStr = global::NFO_Helper.Settings.Default.KnownFilterFilenames;

            if (String.IsNullOrEmpty(listStr) == false)
            {
                string   validTokens = "";
                char[]   delims      = { ';' };
                string[] tokens      = listStr.Split(delims);
                foreach (string token in tokens)
                {
                    NFO_Filter_File file = new NFO_Filter_File();
                    file.fileName = token;
                    try
                    {
                        file.parseFile(token);
                    }
                    catch (NfoReadWriteException)
                    {
                        continue;
                    }

                    NFO_Filter_File temp = null;
                    if (filterFiles.TryGetValue(file.filter.name, out temp) == true)
                    {
                        // skip this one, there is one with this name already present.
                        continue;
                    }
                    else
                    {
                        filterFiles.Add(file.filter.name, file);
                        comboBox_filterselect.Items.Add(file.filter.name);
                        if (String.IsNullOrEmpty(validTokens) == false)
                        {
                            validTokens += ";";
                        }
                        validTokens += file.fileName;
                    }
                }
                if (String.Compare(listStr, validTokens) != 0)
                {
                    // at least one of the tokens was not used! update the config!
                    global::NFO_Helper.Settings.Default.KnownFilterFilenames = validTokens;
                    global::NFO_Helper.Settings.Default.Save();
                }
            }

            if (String.Compare(currentFilter.name, AppConstants.DefaultNfoFilterName) == 0)
            {
                comboBox_filterselect.SelectedIndex = 0;
                // changing selected index will update filter.
            }
            else if (String.Compare(currentFilter.name, AppConstants.TempNfoFilterName) == 0)
            {
                // we will not set a selection, so we must update the display manually.
                displayFilter(currentFilter);
                filterName     = AppConstants.TempNfoFilterName;
                filterFileName = null;
            }
            else
            {
                // find this one in the combobox & set that as the selection.
                int index = 0;
                foreach (string item in comboBox_filterselect.Items)
                {
                    if (item == currentFilter.name)
                    {
                        comboBox_filterselect.SelectedIndex = index;
                        // changing selected index will update filter.
                        break;
                    }
                    index++;
                }
            }
            // Note: setting the combobox selection will trigger the display to be updated with the contents of that filter.
        }