private void comboBox_WT_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_WT.SelectedItem != null) { var templateName = comboBox_WT.SelectedItem.ToString(); Options.WordTemplate = WordTemplates.GetTemplatePath(templateName); } }
public OptionsForm() { InitializeComponent(); comboBox_GUI.DataSource = Enum.GetValues(typeof(SolverGUI)); //comboBox_WT.DataSource = Enum.GetValues(typeof(WordTemplateType)); var dict = WordTemplates.GetWordTemplateFiles(ProjectPaths.D_WordTemplate); comboBox_WT.DataSource = dict.Keys.ToArray(); this.comboBox_GUI.SelectedIndexChanged += new System.EventHandler(this.comboBox_GUI_SelectedIndexChanged); this.comboBox_WT.SelectedIndexChanged += new System.EventHandler(this.comboBox_WT_SelectedIndexChanged);; refeshOF(); }
public virtual void SetTemplates(IEnumerable <string> titlesToBe) { Contract.Requires(titlesToBe != null); // шаблоны уникальны без учета регистра Contract.Ensures(WordTemplates.GroupBy(x => x.Title.ToLowerInvariant()).Count() == WordTemplates.Count()); var wasTitles = this.WordTemplates.Select(x => x.Title).ToList(); titlesToBe = titlesToBe.Distinct(StringComparer.OrdinalIgnoreCase); var toAdd = new HashSet <string>(titlesToBe); toAdd.ExceptWith(wasTitles); var toRemove = new HashSet <string>(wasTitles); toRemove.ExceptWith(titlesToBe); var templatesToRem = new List <WordTemplate>(); var templatesToAdd = new List <WordTemplate>(); // убираем ненужные foreach (var item in toRemove) { var old = wordTemplates.FirstOrDefault(x => x.Title == item); templatesToRem.Add(old); } // добавляем новые foreach (var item in toAdd) { var n = new WordTemplate(item, this); templatesToAdd.Add(n); } foreach (var item in templatesToRem) { wordTemplates.Remove(item); } foreach (var item in templatesToAdd) { wordTemplates.Add(item); } if (templatesToRem.Count > 0 || templatesToAdd.Count > 0) { OnWordTemplatesChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } }
public virtual IEnumerable <string> GetOrderedTemplateTitles() { return(WordTemplates.Select(x => x.Title).OrderBy(x => x)); }