Ejemplo n.º 1
0
    public static GrammarItemList SelectGrammars(string assemblyPath, GrammarItemList loadedGrammars) {
      var fromGrammars = LoadGrammars(assemblyPath);
      if (fromGrammars == null)
        return null;
      //fill the listbox and show the form
      fmSelectGrammars form = new fmSelectGrammars();
      var listbox = form.lstGrammars;
      listbox.Sorted = false;
      foreach(GrammarItem item in fromGrammars) {
        listbox.Items.Add(item);
        if (!ContainsGrammar(loadedGrammars, item))
          listbox.SetItemChecked(listbox.Items.Count - 1, true);
      }
      listbox.Sorted = true;

      if (form.ShowDialog() != DialogResult.OK) return null;
      GrammarItemList result = new GrammarItemList();
      for (int i = 0; i < listbox.Items.Count; i++) {
        if (listbox.GetItemChecked(i)) {
          var item = listbox.Items[i] as GrammarItem;
          item._loading = false;
          result.Add(item);
        }
      }
      return result;
    }
Ejemplo n.º 2
0
        public static GrammarItemList SelectGrammars(string assemblyPath, GrammarItemList loadedGrammars)
        {
            var fromGrammars = LoadGrammars(assemblyPath);

            if (fromGrammars == null)
            {
                return(null);
            }
            //fill the listbox and show the form
            fmSelectGrammars form = new fmSelectGrammars();
            var listbox           = form.lstGrammars;

            listbox.Sorted = false;
            foreach (GrammarItem item in fromGrammars)
            {
                listbox.Items.Add(item);
                if (!ContainsGrammar(loadedGrammars, item))
                {
                    listbox.SetItemChecked(listbox.Items.Count - 1, true);
                }
            }
            listbox.Sorted = true;

            if (form.ShowDialog() != DialogResult.OK)
            {
                return(null);
            }
            GrammarItemList result = new GrammarItemList();

            for (int i = 0; i < listbox.Items.Count; i++)
            {
                if (listbox.GetItemChecked(i))
                {
                    var item = listbox.Items[i] as GrammarItem;
                    item._loading = false;
                    result.Add(item);
                }
            }
            return(result);
        }