예제 #1
0
        private void AddExistingDefinitionsAndSuggestions(List <WritingSystemTreeItem> items)
        {
            var x = new List <IWritingSystemDefinition>(_setupModel.WritingSystemDefinitions);

            var systemsOfSameLanguage = x.GroupBy(def => def.LanguageName);

            foreach (var defsOfSameLanguage in systemsOfSameLanguage)
            {
                WritingSystemTreeItem    parent;
                IWritingSystemDefinition itemToUseForSuggestions;
                if (OneWritingSystemIsASuitableParent(defsOfSameLanguage))
                {
                    var primaryDefinition = ChooseMainDefinitionOfLanguage(defsOfSameLanguage);
                    parent          = MakeExistingDefinitionItem(primaryDefinition);
                    parent.Children = new List <WritingSystemTreeItem>(from def in defsOfSameLanguage
                                                                       where def != primaryDefinition
                                                                       select MakeExistingDefinitionItem(def));
                    itemToUseForSuggestions = primaryDefinition;
                }
                else
                {
                    parent          = new GroupTreeItem(defsOfSameLanguage.First().LanguageName);
                    parent.Children = new List <WritingSystemTreeItem>(from def in defsOfSameLanguage
                                                                       select MakeExistingDefinitionItem(def));
                    itemToUseForSuggestions = defsOfSameLanguage.First();                    //unprincipled
                }

                if (Suggestor != null)
                {
                    foreach (
                        IWritingSystemDefinitionSuggestion suggestion in
                        Suggestor.GetSuggestions(itemToUseForSuggestions, defsOfSameLanguage))
                    {
                        var treeItem = new WritingSystemCreationTreeItem(suggestion, OnClickAddCertainDefinition);
                        parent.Children.Add(treeItem);
                    }
                }

                if (itemToUseForSuggestions.Language == "qaa")
                {
                    var treeItem = new WritingSystemRenameUnlistedLanguageTreeItem(item => _setupModel.RenameIsoCode(itemToUseForSuggestions));
                    parent.Children.Add(treeItem);
                }

                items.Add(parent);
            }
        }
		private void AddExistingDefinitionsAndSuggestions(List<WritingSystemTreeItem> items)
		{
			var x = new List<IWritingSystemDefinition>(_setupModel.WritingSystemDefinitions);

			var systemsOfSameLanguage = x.GroupBy(def=>def.LanguageName);

			foreach (var defsOfSameLanguage in systemsOfSameLanguage)
			{
				WritingSystemTreeItem parent;
				IWritingSystemDefinition itemToUseForSuggestions;
				if (OneWritingSystemIsASuitableParent(defsOfSameLanguage))
				{
					var primaryDefinition = ChooseMainDefinitionOfLanguage(defsOfSameLanguage);
					parent = MakeExistingDefinitionItem(primaryDefinition);
					parent.Children = new List<WritingSystemTreeItem>(from def in defsOfSameLanguage
									where def != primaryDefinition
									select MakeExistingDefinitionItem(def));
					itemToUseForSuggestions = primaryDefinition;
				}
				else
				{
					parent = new GroupTreeItem(defsOfSameLanguage.First().LanguageName);
					parent.Children = new List<WritingSystemTreeItem>(from def in defsOfSameLanguage
									select MakeExistingDefinitionItem(def));
					itemToUseForSuggestions = defsOfSameLanguage.First();//unprincipled
				}

				if (Suggestor != null)
				{
					foreach (
						IWritingSystemDefinitionSuggestion suggestion in
							Suggestor.GetSuggestions(itemToUseForSuggestions, defsOfSameLanguage))
					{
						var treeItem = new WritingSystemCreationTreeItem(suggestion, OnClickAddCertainDefinition);
						parent.Children.Add(treeItem);
					}
				}

				if (itemToUseForSuggestions.Language == "qaa")
				{
					var treeItem = new WritingSystemRenameUnlistedLanguageTreeItem(item => _setupModel.RenameIsoCode(itemToUseForSuggestions));
					parent.Children.Add(treeItem);
				}

				items.Add(parent);
			}
		}