public WritingSystemSetup(ILogger logger, IWritingSystemRepository store) : base("set up fonts, keyboards, and sorting", logger, "writingSystems") { InitializeComponent(); store.WritingSystemIdChanged += OnWritingSystemIdChanged; var writingSystemSetupModel = new WritingSystemSetupModel(store); writingSystemSetupModel.WritingSystemSuggestor.SuggestVoice = true; //nb: I (JH) wanted to hide IPA, but then in one week 2 people locally asked for it... writingSystemSetupModel.WritingSystemSuggestor.SuggestIpa = true; writingSystemSetupModel.WritingSystemSuggestor.SuggestDialects = false; // pretty unlikely in WeSay this.SuspendLayout(); _view = new WritingSystemSetupView(writingSystemSetupModel) { LeftColumnWidth = 350, Dock = DockStyle.Fill }; writingSystemSetupModel.AskIfOkToConflateWritingSystems += OnAskIfOkToConflateWritingSystems; writingSystemSetupModel.AskIfOkToDeleteWritingSystems += OnAskIfOkToDeleteWritingSystems; writingSystemSetupModel.ItemAddedOrDeleted += OnWritingSystemAddOrDelete; _view.UserWantsHelpWithDeletingWritingSystems += OnUserWantsHelpWithDeletingWritingSystems; _view.UserWantsHelpWithCustomSorting += OnUserWantsHelpWithCustomSorting; store.WritingSystemDeleted += OnWritingSystemDeleted; store.WritingSystemConflated += OnWritingSystemConflated; Controls.Add(_view); this.ResumeLayout(false); WeSayWordsProject.Project.EditorsSaveNow += OnEditorSaveNow; }
public MultiTextControl(IList <string> writingSystemIds, MultiText multiTextToCopyFormsFrom, string nameForTesting, bool showAnnotationWidget, IWritingSystemRepository allWritingSystems, CommonEnumerations.VisibilitySetting visibility, bool isSpellCheckingEnabled, bool isMultiParagraph, IServiceProvider serviceProvider) : this(allWritingSystems, serviceProvider) { Name = nameForTesting + "-mtc"; _writingSystemsForThisField = new List <IWritingSystemDefinition>(); // foreach (KeyValuePair<string, WritingSystem> pair in allWritingSystems) // { // if (writingSystemIds.Contains(pair.Key)) // { // _writingSystemsForThisField.Add(pair.Value); // } // } foreach (var id in writingSystemIds) { if (allWritingSystems.Contains(id)) //why wouldn't it? { _writingSystemsForThisField.Add(allWritingSystems.Get(id)); } } _showAnnotationWidget = showAnnotationWidget; _visibility = visibility; IsSpellCheckingEnabled = isSpellCheckingEnabled; _isMultiParagraph = isMultiParagraph; BuildBoxes(multiTextToCopyFormsFrom); }
///<summary> /// Constructor. ///</summary> ///<param name="idsInFile"></param> ///<param name="replaceIdsInFile"></param> ///<param name="writingSystemRepository"></param> public static void FindOrphans( IEnumerable<string> idsInFile, IdReplacementStrategy replaceIdsInFile, IWritingSystemRepository writingSystemRepository ) { var originalIds = new List<string>(idsInFile); var updatedIds = new List<string>(idsInFile); foreach (var wsId in originalIds) { // Check if it's in the repo if (writingSystemRepository.Contains(wsId)) { continue; } string newId = wsId; if (writingSystemRepository.WritingSystemIdHasChanged(wsId)) { newId = writingSystemRepository.WritingSystemIdHasChangedTo(wsId); } else { // It's an orphan // Check for the writing system repository compatibility mode if (writingSystemRepository.CompatibilityMode == WritingSystemCompatibility.Flex7V0Compatible) { if (!wsId.StartsWith("x-")) { // Clean it var rfcTagCleaner = new Rfc5646TagCleaner(wsId); rfcTagCleaner.Clean(); newId = rfcTagCleaner.GetCompleteTag(); } } else { // Clean it var rfcTagCleaner = new Rfc5646TagCleaner(wsId); rfcTagCleaner.Clean(); newId = rfcTagCleaner.GetCompleteTag(); } } var conformantWritingSystem = WritingSystemDefinition.Parse(newId); // If it changed, then change if (conformantWritingSystem.Bcp47Tag != wsId) { conformantWritingSystem = WritingSystemDefinition.CreateCopyWithUniqueId(conformantWritingSystem, updatedIds); replaceIdsInFile(wsId, conformantWritingSystem.Bcp47Tag); updatedIds.Remove(wsId); updatedIds.Add(conformantWritingSystem.Bcp47Tag); } // Check if it's in the repo if (writingSystemRepository.Contains(conformantWritingSystem.Bcp47Tag)) { continue; } // It's not in the repo so set it writingSystemRepository.Set(conformantWritingSystem); } writingSystemRepository.Save(); }
public MultiTextControl(IWritingSystemRepository allWritingSystems, IServiceProvider serviceProvider) { if (DesignMode) { AutoSize = false; // NONE OF THE FOLLOWING ACTUALLY WORKS... WISH IT DID Size = new Size(this.Width, 20); CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; //help it be seen BackColor = Color.Maroon; } SuspendLayout(); _allWritingSystems = allWritingSystems; _serviceProvider = serviceProvider; components = new Container(); InitializeComponent(); _inputBoxes = new List <Control>(); //this.BackColor = System.Drawing.Color.Crimson; _writingSystemLabelFont = new Font(FontFamily.GenericSansSerif, 9); if (-1 == WidthForWritingSystemLabels) { //happens when this is from a hand-placed designer piece, //in which case we don't really care about aligning anyhow ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); //ws label } else { ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, WidthForWritingSystemLabels)); } ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); //text ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); //annotation widget ResumeLayout(false); }
public ProjectInfo(string name, string pathToApplicationRootDirectory, string pathToTopLevelDirectory, string pathToLIFT, string pathToExportDirectory, string[] filesBelongingToProject, FileLocater locateFile, IWritingSystemRepository writingSystems, IServiceProvider serviceProvider, // these signatures were to reduce the dependencies on addins that didn't need this stuff object project) // these signatures were to reduce the dependencies on addins that didn't need this stuff { ServiceProvider = serviceProvider; _pathToTopLevelDirectory = pathToTopLevelDirectory; _locateFile = locateFile; _writingSystems = writingSystems; _project = project; _filesBelongingToProject = filesBelongingToProject; _name = name; _pathToApplicationRootDirectory = pathToApplicationRootDirectory; _pathToLIFT = pathToLIFT; _pathToExportDirectory = pathToExportDirectory; }
public virtual void SetUp() { _writingSystem = new WritingSystemDefinition(); RepositoryUnderTest = CreateNewStore(); _writingSystemIdChangedEventArgs = null; _writingSystemDeletedEventArgs = null; _writingSystemConflatedEventArgs = null; }
public WritingSystemTest() { InitializeComponent(); _repository = GlobalWritingSystemRepository.Initialize(MigrationHandler); _wsModel = new WritingSystemSetupModel(_repository); wsPropertiesPanel1.BindToModel(_wsModel); }
public void CreateLdmlWritingSystemDefinitionFile() { IWritingSystemRepository wsCollectionToBeWritten = GetWritingSystemRepository(PathToWritingSystemsFolder); IWritingSystemDefinition ws = CreateDetailedWritingSystem("en"); wsCollectionToBeWritten.Set(ws); wsCollectionToBeWritten.Save(); }
public void Setup() { ErrorReport.IsOkToInteractWithUser = false; ShowOncePerSessionBasedOnExactMessagePolicy.Reset(); _testFilePath = Path.GetTempFileName(); _writingSystemRepository = new LdmlInXmlWritingSystemRepository(); _model = new WritingSystemSetupModel(_writingSystemRepository); }
public static WeSayWordsProject InitializeForTests() { WeSayWordsProject project = new WeSayWordsProject(); try { File.Delete(WeSayWordsProject.PathToPretendLiftFile); } catch (Exception) { } DirectoryInfo projectDirectory = Directory.CreateDirectory(Path.GetDirectoryName(WeSayWordsProject.PathToPretendLiftFile)); string pathToLdmlWsFolder = BasilProject.GetPathToLdmlWritingSystemsFolder(projectDirectory.FullName); if (File.Exists(WeSayWordsProject.PathToPretendWritingSystemPrefs)) { File.Delete(WeSayWordsProject.PathToPretendWritingSystemPrefs); } if (Directory.Exists(pathToLdmlWsFolder)) { Directory.Delete(pathToLdmlWsFolder, true); } Palaso.Lift.Utilities.CreateEmptyLiftFile(WeSayWordsProject.PathToPretendLiftFile, "InitializeForTests()", true); //setup writing systems Directory.CreateDirectory(pathToLdmlWsFolder); IWritingSystemRepository wsc = LdmlInFolderWritingSystemRepository.Initialize( pathToLdmlWsFolder, OnMigrationHandler, OnWritingSystemLoadProblem, WritingSystemCompatibility.Flex7V0Compatible ); IWritingSystemDefinition _ws1 = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.VernacularIdForTest); _ws1.DefaultFontName = "Arial"; _ws1.DefaultFontSize = 30; wsc.Set(_ws1); IWritingSystemDefinition _ws2 = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.AnalysisIdForTest); _ws2.DefaultFontName = new Font(FontFamily.GenericSansSerif, 12).Name; _ws2.DefaultFontSize = new Font(FontFamily.GenericSansSerif, 12).Size; wsc.Set(_ws2); IWritingSystemDefinition _ws3 = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.OtherIdForTest); _ws3.DefaultFontName = "Arial"; _ws3.DefaultFontSize = 15; wsc.Set(_ws3); wsc.Save(); project.SetupProjectDirForTests(WeSayWordsProject.PathToPretendLiftFile); project.BackupMaker = null; //don't bother. Modern tests which might want to check backup won't be using this old approach anyways. return(project); }
public WritingSystemPickerTestForm() { InitializeComponent(); _repository = GlobalWritingSystemRepository.Initialize(null); _wsModel = new WritingSystemSetupModel(_repository); _wsModel.SelectionChanged += _wsModel_SelectionChanged; wsPickerUsingListView1.BindToModel(_wsModel); pickerUsingComboBox1.BindToModel(_wsModel); }
///<summary> /// Constructor. ///</summary> ///<param name="idsInFile"></param> ///<param name="replaceIdsInFile"></param> ///<param name="writingSystemRepository"></param> public static void FindOrphans( IEnumerable <string> idsInFile, IdReplacementStrategy replaceIdsInFile, IWritingSystemRepository writingSystemRepository) { List <string> originalIds = idsInFile.ToList(); List <string> updatedIds = originalIds.ToList(); foreach (string wsId in originalIds) { // Check if it's in the repo if (writingSystemRepository.Contains(wsId)) { continue; } string newId; if (writingSystemRepository.WritingSystemIdHasChanged(wsId)) { newId = writingSystemRepository.WritingSystemIdHasChangedTo(wsId); } else { // It's an orphan // Clean it var rfcTagCleaner = new IetfLanguageTagCleaner(wsId); rfcTagCleaner.Clean(); newId = rfcTagCleaner.GetCompleteTag(); } WritingSystemDefinition conformantWritingSystem; writingSystemRepository.WritingSystemFactory.Create(newId, out conformantWritingSystem); // If it changed, then change if (conformantWritingSystem.LanguageTag != wsId) { conformantWritingSystem.LanguageTag = IetfLanguageTag.ToUniqueLanguageTag( conformantWritingSystem.LanguageTag, updatedIds); replaceIdsInFile(wsId, conformantWritingSystem.LanguageTag); updatedIds.Remove(wsId); updatedIds.Add(conformantWritingSystem.LanguageTag); } // Check if it's in the repo if (writingSystemRepository.Contains(conformantWritingSystem.LanguageTag)) { continue; } // It's not in the repo so set it writingSystemRepository.Set(conformantWritingSystem); } writingSystemRepository.Save(); }
/// <summary> /// Resets any property values that were removed during migration so that they are not lost. /// </summary> public void ResetRemovedProperties(IWritingSystemRepository repo) { foreach (KeyValuePair<string, List<Action<WritingSystemDefinition>>> kvp in _removedPropertiesSetters) { WritingSystemDefinition ws; if (repo.TryGet(kvp.Key, out ws)) { foreach (Action<WritingSystemDefinition> setter in kvp.Value) setter(ws); } } repo.Save(); }
public void Save_WritingSystemReadFromLdmlAndChanged_ChangesSaved() { using (var e = new TestEnvironment()) { e.CreateLdmlWritingSystemDefinitionFile(); IWritingSystemRepository loadedWsCollection = GetWritingSystemRepository(e.PathToWritingSystemsFolder); ((WritingSystemDefinition)loadedWsCollection.Get("en")).Keyboard = "changed"; loadedWsCollection.Save(); IWritingSystemRepository reloadedWsCollection = GetWritingSystemRepository(e.PathToWritingSystemsFolder); TestEnvironment.AssertWritingSystemCollectionsAreEqual(loadedWsCollection, reloadedWsCollection); } }
public void Roundtripping_Works() { using (var e = new TestEnvironment()) { IWritingSystemRepository wsCollectionToBeWritten = GetWritingSystemRepository(e.PathToWritingSystemsFolder); IWritingSystemDefinition ws = TestEnvironment.CreateDetailedWritingSystem("th"); wsCollectionToBeWritten.Set(ws); IWritingSystemDefinition ws2 = TestEnvironment.CreateDetailedWritingSystem("en"); wsCollectionToBeWritten.Set(ws2); wsCollectionToBeWritten.Save(); IWritingSystemRepository loadedWsCollection = GetWritingSystemRepository(e.PathToWritingSystemsFolder); TestEnvironment.AssertWritingSystemCollectionsAreEqual(wsCollectionToBeWritten, loadedWsCollection); } }
///<summary> /// Constructor. ///</summary> ///<param name="idsInFile"></param> ///<param name="replaceIdsInFile"></param> ///<param name="writingSystemRepository"></param> public static void FindOrphans( IEnumerable<string> idsInFile, IdReplacementStrategy replaceIdsInFile, IWritingSystemRepository writingSystemRepository) { List<string> originalIds = idsInFile.ToList(); List<string> updatedIds = originalIds.ToList(); foreach (string wsId in originalIds) { // Check if it's in the repo if (writingSystemRepository.Contains(wsId)) { continue; } string newId; if (writingSystemRepository.WritingSystemIdHasChanged(wsId)) { newId = writingSystemRepository.WritingSystemIdHasChangedTo(wsId); } else { // It's an orphan // Clean it var rfcTagCleaner = new IetfLanguageTagCleaner(wsId); rfcTagCleaner.Clean(); newId = rfcTagCleaner.GetCompleteTag(); } WritingSystemDefinition conformantWritingSystem; writingSystemRepository.WritingSystemFactory.Create(newId, out conformantWritingSystem); // If it changed, then change if (conformantWritingSystem.LanguageTag != wsId) { conformantWritingSystem.LanguageTag = IetfLanguageTag.ToUniqueLanguageTag( conformantWritingSystem.LanguageTag, updatedIds); replaceIdsInFile(wsId, conformantWritingSystem.LanguageTag); updatedIds.Remove(wsId); updatedIds.Add(conformantWritingSystem.LanguageTag); } // Check if it's in the repo if (writingSystemRepository.Contains(conformantWritingSystem.LanguageTag)) continue; // It's not in the repo so set it writingSystemRepository.Set(conformantWritingSystem); } writingSystemRepository.Save(); }
/// <summary> /// Resets any property values that were removed during migration so that they are not lost. /// </summary> public void ResetRemovedProperties(IWritingSystemRepository repo) { foreach (KeyValuePair <string, List <Action <WritingSystemDefinition> > > kvp in _removedPropertiesSetters) { WritingSystemDefinition ws; if (repo.TryGet(kvp.Key, out ws)) { foreach (Action <WritingSystemDefinition> setter in kvp.Value) { setter(ws); } } } repo.Save(); }
private static ViewTemplate MakeMasterInventory() { using (var tempFolder = new TemporaryFolder("ProjectFromViewTemplateTests")) { IWritingSystemRepository w = LdmlInFolderWritingSystemRepository.Initialize( tempFolder.Path, OnWritingSystemMigration, OnWritingSystemLoadProblem, WritingSystemCompatibility.Flex7V0Compatible ); w.Set(WritingSystemDefinition.Parse("aaa")); w.Set(WritingSystemDefinition.Parse("aab")); return(ViewTemplate.MakeMasterTemplate(w)); } }
public void NewerThanEmpty_ReturnsNoneNewer() { var ws1 = new WritingSystemDefinition(); ws1.Language = "en"; RepositoryUnderTest.Set(ws1); IWritingSystemRepository repository = CreateNewStore(); int count = 0; foreach (WritingSystemDefinition ws in repository.WritingSystemsNewerIn(RepositoryUnderTest.AllWritingSystems)) { count++; } Assert.AreEqual(0, count); }
public void Load_OnlyLdmlWritingSystemFilesExist_WritingSystemsAreLoadedFromThoseFiles() { using (var e = new TestEnvironment()) { IWritingSystemRepository wsCollectionToBeWritten = GetWritingSystemRepository(e.PathToWritingSystemsFolder); IWritingSystemDefinition ws = TestEnvironment.CreateDetailedWritingSystem("en"); wsCollectionToBeWritten.Set(ws); IWritingSystemDefinition ws2 = TestEnvironment.CreateDetailedWritingSystem("de"); wsCollectionToBeWritten.Set(ws2); wsCollectionToBeWritten.Save(); IWritingSystemRepository loadedWsCollection = GetWritingSystemRepository(e.PathToWritingSystemsFolder); TestEnvironment.AssertWritingSystemCollectionsAreEqual(wsCollectionToBeWritten, loadedWsCollection); } }
protected void InitWritingSystems() { if (!Directory.Exists(GetPathToLdmlWritingSystemsFolder(ProjectDirectoryPath))) { CopyWritingSystemsFromApplicationCommonDirectoryToNewProject(ProjectDirectoryPath); } if (_writingSystems == null) { _writingSystems = LdmlInFolderWritingSystemRepository.Initialize( GetPathToLdmlWritingSystemsFolder(ProjectDirectoryPath), OnWritingSystemMigration, OnWritingSystemLoadProblem, WritingSystemCompatibility.Flex7V0Compatible ); } }
public static void AssertWritingSystemCollectionsAreEqual(IWritingSystemRepository lhs, IWritingSystemRepository rhs) { foreach (var lhsWritingSystem in lhs.AllWritingSystems) { var rhsWritingSystem = rhs.Get(lhsWritingSystem.Id); Assert.IsTrue(rhs.Contains(lhsWritingSystem.Id)); Assert.AreEqual(lhsWritingSystem.Id, rhsWritingSystem.Id); Assert.AreEqual(lhsWritingSystem.Abbreviation, rhsWritingSystem.Abbreviation); Assert.AreEqual(lhsWritingSystem.DefaultFontName, rhsWritingSystem.DefaultFontName); Assert.AreEqual(lhsWritingSystem.DefaultFontSize, rhsWritingSystem.DefaultFontSize); Assert.AreEqual(lhsWritingSystem.IsVoice, rhsWritingSystem.IsVoice); Assert.AreEqual(lhsWritingSystem.IsUnicodeEncoded, rhsWritingSystem.IsUnicodeEncoded); Assert.AreEqual(((WritingSystemDefinition)lhsWritingSystem).Keyboard, ((WritingSystemDefinition)rhsWritingSystem).Keyboard); Assert.AreEqual(lhsWritingSystem.RightToLeftScript, rhsWritingSystem.RightToLeftScript); Assert.AreEqual(lhsWritingSystem.SortUsing, rhsWritingSystem.SortUsing); Assert.AreEqual(lhsWritingSystem.SortRules, rhsWritingSystem.SortRules); Assert.AreEqual(lhsWritingSystem.SpellCheckingId, rhsWritingSystem.SpellCheckingId); } }
public void NewerThanNewer_ReturnsNoneNewer() { var ws1 = new WritingSystemDefinition(); ws1.Language = "en"; ws1.DateModified = new DateTime(2008, 1, 15); RepositoryUnderTest.Set(ws1); IWritingSystemRepository repository = CreateNewStore(); var ws2 = RepositoryUnderTest.MakeDuplicate(ws1); ws2.DateModified = new DateTime(2008, 1, 16); repository.Set(ws2); int count = 0; foreach (WritingSystemDefinition ws in repository.WritingSystemsNewerIn(RepositoryUnderTest.AllWritingSystems)) { count++; } Assert.AreEqual(0, count); }
public void Write_LoadedWritingSystemIsDeleted_DeletionIsRoundTripped() { using (var e = new TestEnvironment()) { //Write out two writing systems IWritingSystemRepository wsCollectionToBeWritten = GetWritingSystemRepository(e.PathToWritingSystemsFolder); IWritingSystemDefinition ws = TestEnvironment.CreateDetailedWritingSystem("en"); wsCollectionToBeWritten.Set(ws); IWritingSystemDefinition ws2 = TestEnvironment.CreateDetailedWritingSystem("th"); wsCollectionToBeWritten.Set(ws2); wsCollectionToBeWritten.Save(); //load them up again IWritingSystemRepository loadedWsCollection = GetWritingSystemRepository(e.PathToWritingSystemsFolder); loadedWsCollection.Remove(ws.Id); //remove one loadedWsCollection.Save(); //Now check that it hasn't come back! IWritingSystemRepository loadedWsCollection2 = GetWritingSystemRepository(e.PathToWritingSystemsFolder); Assert.IsFalse(loadedWsCollection2.Contains(ws.Id)); } }
/// <summary> /// Creates the presentation model object based off of a single writing system definition. /// This is the easiest form to use if you only want part of the UI elements or only operate on /// one WritingSystemDefiniion /// </summary> public WritingSystemSetupModel(WritingSystemDefinition ws) { if (ws == null) { throw new ArgumentNullException("ws"); } WritingSystemSuggestor = new WritingSystemSuggestor(); _currentWritingSystem = ws; _currentIndex = 0; _writingSystemRepository = null; _writingSystemDefinitions = new List<IWritingSystemDefinition>(1); WritingSystemDefinitions.Add(ws); _deletedWritingSystemDefinitions = null; _usingRepository = false; }
public WritingSystemsInOptionsListFileHelper(IWritingSystemRepository writingSystemRepository, string optionsListFilePath) { _writingSystemRepository = writingSystemRepository; _optionListFilePath = optionsListFilePath; }
public WritingSystemsInLiftFileHelper(IWritingSystemRepository writingSystemRepository, string liftFilePath) { _writingSystemRepository = writingSystemRepository; _liftFilePath = liftFilePath; }
/// <summary> /// Initializes a new instance of the <see cref="WritingSystemManager"/> class. /// </summary> public WritingSystemManager(IWritingSystemRepository <CoreWritingSystemDefinition> wsRepo) { WritingSystemStore = wsRepo; }
///<summary> /// Constructor. ///</summary> ///<param name="idsInFile"></param> ///<param name="replaceIdsInFile"></param> ///<param name="writingSystemRepository"></param> public static void FindOrphans( IEnumerable <string> idsInFile, IdReplacementStrategy replaceIdsInFile, IWritingSystemRepository writingSystemRepository ) { var originalIds = new List <string>(idsInFile); var updatedIds = new List <string>(idsInFile); foreach (var wsId in originalIds) { // Check if it's in the repo if (writingSystemRepository.Contains(wsId)) { continue; } string newId = wsId; if (writingSystemRepository.WritingSystemIdHasChanged(wsId)) { newId = writingSystemRepository.WritingSystemIdHasChangedTo(wsId); } else { // It's an orphan // Check for the writing system repository compatibility mode if (writingSystemRepository.CompatibilityMode == WritingSystemCompatibility.Flex7V0Compatible) { if (!wsId.StartsWith("x-")) { // Clean it var rfcTagCleaner = new Rfc5646TagCleaner(wsId); rfcTagCleaner.Clean(); newId = rfcTagCleaner.GetCompleteTag(); } } else { // Clean it var rfcTagCleaner = new Rfc5646TagCleaner(wsId); rfcTagCleaner.Clean(); newId = rfcTagCleaner.GetCompleteTag(); } } var conformantWritingSystem = WritingSystemDefinition.Parse(newId); // If it changed, then change if (conformantWritingSystem.Bcp47Tag != wsId) { conformantWritingSystem = WritingSystemDefinition.CreateCopyWithUniqueId(conformantWritingSystem, updatedIds); replaceIdsInFile(wsId, conformantWritingSystem.Bcp47Tag); updatedIds.Remove(wsId); updatedIds.Add(conformantWritingSystem.Bcp47Tag); } // Check if it's in the repo if (writingSystemRepository.Contains(conformantWritingSystem.Bcp47Tag)) { continue; } // It's not in the repo so set it writingSystemRepository.Set(conformantWritingSystem); } writingSystemRepository.Save(); }
private void CreateAutoFontsStyleSheet(string path, PublicationFontStyleProvider styleProvider, IWritingSystemRepository writingSystemCollection) { using (var f = File.CreateText(path)) { foreach (var writingSystem in writingSystemCollection.AllWritingSystems) { f.WriteLine(":lang(" + writingSystem.Id + ") {"); f.WriteLine(styleProvider.GetAutoFontsCascadingStyleSheetLinesForWritingSystem(writingSystem)); f.WriteLine("}"); f.WriteLine(); } } }
/* * private List<Parameter> GetParameters(XPathNavigator component) * { * List<Parameter> parameters = new List<Parameter>(); * * if (component.HasChildren) * { * XPathNodeIterator children = component.SelectChildren(string.Empty, string.Empty); * foreach (XPathNavigator child in children) * { * if (child.GetAttribute("UseInConstructor", string.Empty) == "false") * continue; * parameters.Add(GetSimpleParameter(child)); * } * } * return parameters; * } * * private Parameter GetSimpleParameter(XPathNavigator child) * { * * switch (child.GetAttribute("class", string.Empty)) * { * case "": * return new NamedParameter(child.Name, child.Value); * break; * case "string": * return new NamedParameter(child.Name, child.Value); * break; * case "bool": * return new NamedParameter(child.Name, child.ValueAsBoolean); * break; * case "DateTime": * return new NamedParameter(child.Name, child.ValueAsDateTime); * break; * case "double": * return new NamedParameter(child.Name, child.ValueAsDouble); * break; * case "int": * return new NamedParameter(child.Name, child.ValueAsInt); * break; * case "long": * return new NamedParameter(child.Name, child.ValueAsLong); * break; * default: * throw new ConfigurationException("Didn't understand this type of paramter in the config file: '{0}'", child.GetAttribute("class", string.Empty)); * break; * } * } */ // review: this might belong in a nother file... public static IEnumerable <ViewTemplate> CreateViewTemplates(string xmlConfiguration, IWritingSystemRepository writingSystems) { XPathDocument doc = new XPathDocument(new StringReader(xmlConfiguration)); XPathNavigator navigator = doc.CreateNavigator(); navigator = navigator.SelectSingleNode("//components"); if (navigator != null) { bool hasviewTemplate = false; // String.Empty fails on mono 2.4. See http://projects.palaso.org/issues/show/276 XPathNodeIterator componentList = navigator.SelectChildren( "viewTemplate", string.Empty ); ViewTemplate factoryTemplate = ViewTemplate.MakeMasterTemplate(writingSystems); foreach (XPathNavigator component in componentList) { Debug.Assert(component.Name == "viewTemplate"); hasviewTemplate = true; ViewTemplate template = new ViewTemplate(); template.LoadFromString(component.OuterXml); ViewTemplate.UpdateUserViewTemplate(factoryTemplate, template); yield return(template); } Debug.Assert(hasviewTemplate, "Currently, there must be at least 1 viewTemplate in the WeSayConfig file"); } }
public void CreateWritingSystemsForIdsInFileWhereNecassary(IWritingSystemRepository writingSystemRepository) { WritingSystemOrphanFinder.FindOrphans(WritingSystemsInUse, ReplaceWritingSystemId, writingSystemRepository); }
public WritingSystemSetupDialog(IWritingSystemRepository repository) { InitializeComponent(); _model = new WritingSystemSetupModel(repository); _writingSystemSetupView.BindToModel(_model); }
/// <summary> /// omit audio writing systems /// </summary> public IEnumerable <string> GetTextOnlyWritingSystemIds(IWritingSystemRepository writingSystems) { return(writingSystems.TextWritingSystems.Where(ws => _writingSystemIds.Contains(ws.Id)).Select(ws => ws.Id)); }
public BasilProject() { Project = this; _writingSystems = null; UiOptions = new UiConfigurationOptions(); }
/// <summary> /// Creates the presentation model object based off of a writing system store of some sort. /// </summary> public WritingSystemSetupModel(IWritingSystemRepository writingSystemRepository) { if (writingSystemRepository == null) { throw new ArgumentNullException("writingSystemRepository"); } WritingSystemSuggestor = new WritingSystemSuggestor(); _writingSystemRepository = writingSystemRepository; _writingSystemDefinitions = new List<IWritingSystemDefinition>(_writingSystemRepository.AllWritingSystems); _deletedWritingSystemDefinitions = new List<IWritingSystemDefinition>(); _currentIndex = -1; _usingRepository = true; }