/// <summary>
		/// Shows the new writing system properties dialog.
		/// </summary>
		/// <param name="owner">The owner.</param>
		/// <param name="cache">The cache.</param>
		/// <param name="wsManager">The ws manager.</param>
		/// <param name="wsContainer">The ws container.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// <param name="app">The app.</param>
		/// <param name="stylesheet">The stylesheet.</param>
		/// <param name="displayRelatedWss">if set to <c>true</c> related writing systems will be displayed.</param>
		/// <param name="defaultName">The default language name for the new writing system.</param>
		/// <param name="newWritingSystems">The new writing systems.</param>
		/// <returns></returns>
		public static bool ShowNewDialog(Form owner, FdoCache cache, IWritingSystemManager wsManager,
			IWritingSystemContainer wsContainer, IHelpTopicProvider helpTopicProvider, IApp app,
			IVwStylesheet stylesheet, bool displayRelatedWss, string defaultName,
			out IEnumerable<IWritingSystem> newWritingSystems)
		{
			newWritingSystems = null;
			LanguageSubtag languageSubtag;

			using (new WaitCursor(owner))
			using (var dlg = new LanguageSelectionDlg(wsManager, helpTopicProvider))
			{
				dlg.Text = FwCoreDlgs.kstidLanguageSelectionNewWsCaption;
				dlg.DefaultLanguageName = defaultName;

				if (dlg.ShowDialog(owner) != DialogResult.OK)
					return false;

				languageSubtag = dlg.LanguageSubtag;
			}

			using (new WaitCursor(owner))
			using (var wsPropsDlg = new WritingSystemPropertiesDialog(cache, wsManager, wsContainer, helpTopicProvider, app, stylesheet))
			{
				wsPropsDlg.SetupDialog(languageSubtag, displayRelatedWss);

				if (wsPropsDlg.ShowDialog(owner) == DialogResult.OK)
				{
					newWritingSystems = wsPropsDlg.NewWritingSystems;
					return true;
				}
			}
			return false;
		}
Example #2
0
		public override void FixtureSetup()
		{
			base.FixtureSetup();
			m_wsManager = new PalasoWritingSystemManager();

			// setup English ws.
			IWritingSystem enWs;
			m_wsManager.GetOrSet("en", out enWs);
			m_hvoEnglishWs = enWs.Handle;
		}
		public void FixtureSetup()
		{
			m_wsManager = new PalasoWritingSystemManager();
			IWritingSystem enWs;
			m_wsManager.GetOrSet("en", out enWs);
			m_enWs = enWs.Handle;
			IWritingSystem frWs;
			m_wsManager.GetOrSet("fr", out frWs);
			m_frWs = frWs.Handle;
			m_tsf = TsStrFactoryClass.Create();
		}
Example #4
0
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			SetupTestModel(Resources.TextCacheModel_xml);

			m_sda = new RealDataCache();
			m_sda.MetaDataCache = MetaDataCache.CreateMetaDataCache("TestModel.xml");
			//m_cache.ParaContentsFlid = kflidParaContents;
			//m_cache.ParaPropertiesFlid = kflidParaProperties;
			//m_cache.TextParagraphsFlid = kflidTextParas;

			Debug.Assert(m_wsManager == null);
			m_wsManager = Cache.ServiceLocator.GetInstance<IWritingSystemManager>();
			m_sda.WritingSystemFactory = m_wsManager;

			m_wsAnal = Cache.DefaultAnalWs;

			m_wsVern = Cache.DefaultVernWs;

			//IWritingSystem deWs;
			//m_wsManager.GetOrSet("de", out deWs);
			//m_wsDeu = deWs.Handle;

			//m_wsManager.UserWs = m_wsEng;
			//m_wsUser = m_wsManager.UserWs;

			m_tsf = TsStrFactoryClass.Create();

			m_hvoLexDb = m_sda.MakeNewObject(kclsidLexDb, 0, -1, -1);

			kflidLexDb_Entries = m_sda.MetaDataCache.GetFieldId("LexDb", "Entries", false);
			kflidEntry_Form = m_sda.MetaDataCache.GetFieldId("Entry", "Form", false);
			kflidEntry_Summary = m_sda.MetaDataCache.GetFieldId("Entry", "Summary", false);

			m_hvoKick = m_sda.MakeNewObject(kclsidEntry, m_hvoLexDb, kflidLexDb_Entries, 0);
			m_sda.SetMultiStringAlt(m_hvoKick, kflidEntry_Form, m_wsVern, m_tsf.MakeString("kick", m_wsVern));
			m_sda.SetString(m_hvoKick, kflidEntry_Summary, m_tsf.MakeString("strike with foot", m_wsAnal));

			var keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["layout"] = new[] { "class", "type", "name", "choiceGuid" };
			keyAttrs["group"] = new[] { "label" };
			keyAttrs["part"] = new[] { "ref" };
			var layoutInventory = new Inventory("*.fwlayout", "/LayoutInventory/*", keyAttrs, "test", "nowhere");
			layoutInventory.LoadElements(Resources.Layouts_xml, 1);

			keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["part"] = new[] { "id" };

			var partInventory = new Inventory("*Parts.xml", "/PartInventory/bin/*", keyAttrs, "test", "nowhere");
			partInventory.LoadElements(Resources.Parts_xml, 1);

			m_layouts = new LayoutCache(m_sda.MetaDataCache, layoutInventory, partInventory);
		}
Example #5
0
        public static LfMultiParagraph GetCustomStTextValuesAsLfMultiPara(IStText obj, int flid,
			IWritingSystemManager wsManager, IFwMetaDataCache metaDataCacheAccessor, int fallbackWs)
        {
            if (obj == null || obj.ParagraphsOS == null || obj.ParagraphsOS.Count == 0) return null;
            var result = new LfMultiParagraph();
            result.Paragraphs = obj.ParagraphsOS.OfType<IStTxtPara>().Where(para => para.Contents != null).Select(para => FdoParaToLfPara(para, wsManager)).ToList();
            // StText objects in FDO have a single primary writing system, unlike MultiString or MultiUnicode objects
            int fieldWs = metaDataCacheAccessor.GetFieldWs(flid);
            string wsStr = wsManager.GetStrFromWs(fieldWs);
            if (wsStr == null) wsStr = wsManager.GetStrFromWs(fallbackWs);
            result.InputSystem = wsStr;
            return result;
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set up some dummy styles for testing purposes
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			m_stylesheet = new TestFwStylesheet();
			m_wsManager = new PalasoWritingSystemManager();

			// English
			IWritingSystem enWs;
			m_wsManager.GetOrSet("en", out enWs);
			m_hvoEnglishWs = enWs.Handle;
			Assert.IsTrue(m_hvoEnglishWs > 0, "Should have gotten an hvo for the English WS");
			// German
			IWritingSystem deWs;
			m_wsManager.GetOrSet("de", out deWs);
			m_hvoGermanWs = deWs.Handle;
			Assert.IsTrue(m_hvoGermanWs > 0, "Should have gotten an hvo for the German WS");
			Assert.IsTrue(m_hvoEnglishWs != m_hvoGermanWs, "Writing systems should have different IDs");

			// Create a couple of styles
			int hvoStyle = m_stylesheet.MakeNewStyle();
			ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
			propsBldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Arial");
			m_stylesheet.PutStyle("StyleA", "bla", hvoStyle, 0, hvoStyle, 1, false, false,
				propsBldr.GetTextProps());

			hvoStyle = m_stylesheet.MakeNewStyle();
			propsBldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Times New Roman");
			m_stylesheet.PutStyle("StyleB", "bla", hvoStyle, 0, hvoStyle, 1, false, false,
				propsBldr.GetTextProps());

			// Override the font size for each writing system and each style.
			List<FontOverride> fontOverrides = new List<FontOverride>(2);
			FontOverride fo;
			fo.writingSystem = m_hvoEnglishWs;
			fo.fontSize = 21;
			fontOverrides.Add(fo);
			fo.writingSystem = m_hvoGermanWs;
			fo.fontSize = 13;
			fontOverrides.Add(fo);
			m_stylesheet.OverrideFontsForWritingSystems("StyleA", fontOverrides);

			fontOverrides.Clear();
			fo.writingSystem = m_hvoEnglishWs;
			fo.fontSize = 20;
			fontOverrides.Add(fo);
			fo.writingSystem = m_hvoGermanWs;
			fo.fontSize = 56;
			fontOverrides.Add(fo);
			m_stylesheet.OverrideFontsForWritingSystems("StyleB", fontOverrides);
		}
Example #7
0
		public LiftExporter(FdoCache cache)
		{
			m_cache = cache;
			m_mdc = cache.MetaDataCacheAccessor as IFwMetaDataCacheManaged;
			Debug.Assert(m_mdc != null);
			m_sda = m_cache.DomainDataByFlid as ISilDataAccessManaged;
			Debug.Assert(m_sda != null);
			m_repoCmPossibilityLists = m_cache.ServiceLocator.GetInstance<ICmPossibilityListRepository>();

			m_wsEn = cache.WritingSystemFactory.GetWsFromStr("en");
			if (m_wsEn == 0)
				m_wsEn = cache.DefaultUserWs;
			m_wsManager = cache.ServiceLocator.WritingSystemManager;
			m_wsBestAnalVern = (int)SpecialWritingSystemCodes.BestAnalysisOrVernacular;
		}
		public void FixtureSetup()
		{
			m_DebugProcs = new DebugProcs();
			RegistryHelper.CompanyName = "SIL";

			Icu.InitIcuDataDir();
			m_wsManager = new PalasoWritingSystemManager();

			IWritingSystem enWs;
			m_wsManager.GetOrSet("en", out enWs);
			m_enWs = enWs.Handle;

			IWritingSystem esWs;
			m_wsManager.GetOrSet("es", out esWs);
			m_esWs = esWs.Handle;
		}
Example #9
0
		/// <summary>
		/// Initialize the data values for this dialog.
		/// </summary>
		public void Init(FdoCache cache, Mediator mediator)
		{
			m_cache = cache;
			m_mediator = mediator;
			m_mdc = cache.MetaDataCacheAccessor as IFwMetaDataCacheManaged;
			m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
			lblMappingLanguagesInstructions.Text = String.Format(m_sFmtEncCnvLabel, cache.ProjectId.Name);

			m_tbDatabaseFileName.Text = m_mediator.PropertyTable.GetStringProperty("DataNotebookImportDb", String.Empty);
			m_tbProjectFileName.Text = m_mediator.PropertyTable.GetStringProperty("DataNotebookImportPrj", String.Empty);
			m_tbSettingsFileName.Text = m_mediator.PropertyTable.GetStringProperty("DataNotebookImportMap", String.Empty);
			if (String.IsNullOrEmpty(m_tbSettingsFileName.Text) || m_tbSettingsFileName.Text == m_sStdImportMap)
			{
				m_tbSettingsFileName.Text = m_sStdImportMap;
				if (!String.IsNullOrEmpty(m_tbDatabaseFileName.Text))

				{
					m_tbSaveAsFileName.Text = Path.Combine(Path.GetDirectoryName(m_tbDatabaseFileName.Text),
						Path.GetFileNameWithoutExtension(m_tbDatabaseFileName.Text) + "-import-settings.map");
				}
			}
			else
			{
				m_tbSaveAsFileName.Text = m_tbSettingsFileName.Text;
				m_fDirtySettings = false;
			}
			m_stylesheet = AnthroStyleSheetFromMediator(mediator);
			if (m_stylesheet == null)
			{
				FwStyleSheet styles = new FwStyleSheet();
				styles.Init(m_cache, m_cache.LangProject.Hvo, LangProjectTags.kflidStyles);
				m_stylesheet = styles;
			}
			ShowSaveButtonOrNot();
		}
Example #10
0
		public void Setup()
		{
			// Create the following:
			// - part and layout inventories
			// - metadata cache
			// - DataAccess cache
			// - collection of columns to display.

			// We want a MetaDataCache that knows about
			// - LexEntry.Senses, Msas, CitationForm, Bibliography, Etymology
			// - LexSense.SemanticDomains, SenseType, Status, gloss
			// - CmPossibility Name, abbr
			// - MoMorphSynAnalysis
			// - MoStemMsa
			// - MoDerivationalMsa
			string m_sTestPath = Path.Combine(FwDirectoryFinder.SourceDirectory,
				Path.Combine("Common",
				Path.Combine("Controls",
				Path.Combine("XMLViews",
				Path.Combine("XMLViewsTests", "SampleCm.xml")))));
			m_mdc = MetaDataCache.CreateMetaDataCache(m_sTestPath);

			// We want ISilDataAccess with:
			// - LexEntry (1) with no senses and one MSA (2)
			// - LexEntry (4) with one sense (5) and no MSA
			// - LexEntry (6) with three senses (7, 8, 9) and two MSAs (10, 11)
			// - sense(5) with no semantic domains
			// - senses with one SD (7->30, 8->31)
			// - sense with three SDs, one the same as the first (9->30, 31, 32)
			// - MoStemMsa (2, 11)
			// - MoDerivationalMsa (10)
			m_cda = VwCacheDaClass.Create();
			m_sda = m_cda as ISilDataAccess;
			m_wsManager = new PalasoWritingSystemManager();
			m_sda.WritingSystemFactory = m_wsManager;
			var parser = new SimpleDataParser(m_mdc, m_cda);

			parser.Parse(Path.Combine(FwDirectoryFinder.SourceDirectory,
				Path.Combine("Common",
				Path.Combine("Controls",
				Path.Combine("XMLViews",
				Path.Combine("XMLViewsTests", "SampleData.xml"))))));
			int wsEn = m_wsManager.GetWsFromStr("en");
			// These are mainly to check out the parser.
			Assert.AreEqual(3, m_sda.get_ObjectProp(2, 23011), "part of speech of an MoStemMsa");
			Assert.AreEqual(2, m_sda.get_VecItem(1, 2009, 0), "owned msa");
			Assert.AreEqual("noun", m_sda.get_MultiStringAlt(3, 7003, wsEn).Text, "got ms property");
			Assert.AreEqual(9, m_sda.get_VecItem(6, 2010, 2), "3rd sense");
			Assert.AreEqual(31, m_sda.get_VecItem(9, 21016, 1), "2nd semantic domain");

			// Columns includes
			// - CitationForm (string inside span)
			// - Bibliography (string not in span)
			// - Sense glosses (string in para in seq, nested in column element)
			// - Semantic domains (pair of strings in para in seq in seq, using layout refs)
			// - MSAs (simplified, but polymorphic with one having <choice> and one <obj> to CmPossibility
			XmlDocument docColumns = new XmlDocument();
			docColumns.Load(Path.Combine(FwDirectoryFinder.SourceDirectory,
				Path.Combine("Common",
				Path.Combine("Controls",
				Path.Combine("XMLViews",
				Path.Combine("XMLViewsTests", "TestColumns.xml"))))));
			m_columnList = docColumns.DocumentElement.ChildNodes;

			// Parts just has what those columns need.
			string partDirectory = Path.Combine(FwDirectoryFinder.SourceDirectory,
				Path.Combine("Common",
				Path.Combine("Controls",
				Path.Combine("XMLViews", "XMLViewsTests"))));
			Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["layout"] = new string[] { "class", "type", "name" };
			keyAttrs["group"] = new string[] { "label" };
			keyAttrs["part"] = new string[] { "ref" };


			// Currently there are no specialized layout files that match.
			m_layoutInventory = new Inventory(new string[] { partDirectory },
				"*.fwlayout", "/LayoutInventory/*", keyAttrs, "TestManyOneBrowse", "ProjectPath");

			keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["part"] = new string[] { "id" };

			m_partInventory = new Inventory(new string[] { partDirectory },
				"TestParts.xml", "/PartInventory/bin/*", keyAttrs, "TestManyOneBrowse", "ProjectPath");
			m_layouts = new LayoutCache(m_mdc, m_layoutInventory, m_partInventory);
		}
Example #11
0
        /// <summary>
        /// Turn a custom StText field into a BsonDocument suitable for storing in Mongo. Returns
        /// </summary>
        /// <returns>A BsonDocument with the following structure:
        /// { "ws": "en",
        ///   "paras": [ { "guid": "123", "styleName": "normal", "contents": "First paragraph" },
        ///              { "guid": "456", "styleName": "italic", "contents": "Second paragraph" } ] }
        /// </returns>
        /// <param name="obj">StText whose contents we want.</param>
        /// <param name="flid">Field ID for this custom StText field (used to get correct writing system for this StText).</param>
        /// <param name="wsManager">IWritingSystemManager object from FDO, used to get writing system names from integer IDs.</param>
        /// <param name="metaDataCacheAccessor">Meta data cache accessor from FDO, used to get the integer ID of this field's writing system.</param>
        /// <param name="fallbackWs">Writing system to fall back to if we can't figure it out any other way (usually the default user ws).</param>
        public static BsonValue GetCustomStTextValues(IStText obj, int flid,
			IWritingSystemManager wsManager, IFwMetaDataCache metaDataCacheAccessor, int fallbackWs)
        {
            LfMultiParagraph result = GetCustomStTextValuesAsLfMultiPara(obj, flid, wsManager, metaDataCacheAccessor, fallbackWs);
            return result.ToBsonDocument();
        }
		public void FixtureSetup()
		{
			m_wsManager = new PalasoWritingSystemManager();
			m_comparer = new TsStringComparer(m_wsManager.Create("en"));
			m_tssFact = TsStrFactoryClass.Create();
		}
Example #13
0
 public void FixtureSetup()
 {
     m_wsManager = new PalasoWritingSystemManager();
     m_comparer  = new TsStringComparer(m_wsManager.Create("en"));
     m_tssFact   = TsStrFactoryClass.Create();
 }
		private static void CheckStringWsIds(IWritingSystemManager wsManager, DomainObjectDTO dto)
		{
			XElement objElem = XElement.Parse(dto.Xml);
			foreach (XElement elem in objElem.Descendants())
			{
				switch (elem.Name.LocalName)
				{
					case "Run":
					case "AStr":
					case "AUni":
						XAttribute wsAttr = elem.Attribute("ws");
						if (wsAttr != null)
							Assert.IsTrue(wsManager.Exists(wsAttr.Value));
						break;
				}
			}
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="T:WritingSystemPropertiesDialog"/> class.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="wsManager">The ws manager.</param>
		/// <param name="wsContainer">The ws container.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// <param name="app">The app.</param>
		/// <param name="stylesheet">The stylesheet.</param>
		public WritingSystemPropertiesDialog(FdoCache cache, IWritingSystemManager wsManager, IWritingSystemContainer wsContainer,
			IHelpTopicProvider helpTopicProvider, IApp app, IVwStylesheet stylesheet) : this()
		{
			m_cache = cache;
			m_wsManager = wsManager;
			m_wsContainer = wsContainer;
			m_helpTopicProvider = helpTopicProvider;
			m_app = app;
			m_stylesheet = stylesheet;
		}
Example #16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="InterlinVc"/> class.
		/// </summary>
		/// <remarks>We use the default analysis writing system as the default, even though
		/// this view displays data in multiple writing systems. It's pretty arbitrary in this
		/// case, but we need a valid WS because if we get an ORC, we have to create a Ts String
		/// using some writing system.</remarks>
		/// <param name="cache">The cache.</param>
		/// ------------------------------------------------------------------------------------
		public InterlinVc(FdoCache cache) : base(cache.DefaultAnalWs)
		{
			Cache = cache;
			m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
			m_segRepository = m_cache.ServiceLocator.GetInstance<ISegmentRepository>();
			m_coRepository = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>();
			m_wmbRepository = m_cache.ServiceLocator.GetInstance<IWfiMorphBundleRepository>();
			m_analRepository = m_cache.ServiceLocator.GetInstance<IWfiAnalysisRepository>();
			StTxtParaRepository = m_cache.ServiceLocator.GetInstance<IStTxtParaRepository>();
			m_wsAnalysis = cache.DefaultAnalWs;
			m_wsUi = cache.LanguageWritingSystemFactoryAccessor.UserWs;
			Decorator = new InterlinViewDataCache(m_cache);
			PreferredVernWs = cache.DefaultVernWs;
			m_selfFlid = m_cache.MetaDataCacheAccessor.GetFieldId2(CmObjectTags.kClassId, "Self", false);
			m_tssMissingGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis);
			m_tssMissingGlossPrepend = m_tsf.MakeString(ITextStrings.ksStars + MorphServices.kDefaultSeparatorLexEntryInflTypeGlossAffix, m_wsAnalysis);
			m_tssMissingGlossAppend = m_tsf.MakeString(MorphServices.kDefaultSeparatorLexEntryInflTypeGlossAffix + ITextStrings.ksStars, m_wsAnalysis);
			m_tssMissingSense = m_tssMissingGloss;
			m_tssMissingMsa = m_tssMissingGloss;
			m_tssMissingAnalysisPos = m_tssMissingGloss;
			m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis);
			m_WsList = new WsListManager(m_cache);
			m_tssEmptyPara = m_tsf.MakeString(ITextStrings.ksEmptyPara, m_wsAnalysis);
			m_tssSpace = m_tsf.MakeString(" ", m_wsAnalysis);
			m_msaVc = new MoMorphSynAnalysisUi.MsaVc(m_cache);
			m_vernWss = WritingSystemServices.GetAllWritingSystems(m_cache, "all vernacular",
				null, 0, 0);
			// This usually gets overridden, but ensures default behavior if not.
			m_lineChoices = InterlinLineChoices.DefaultChoices(m_cache.LangProject,
				WritingSystemServices.kwsVernInParagraph, WritingSystemServices.kwsAnal);
			// This used to be a constant but was made variables with dummy virtual handlers so that
			// ClearInfoAbout can clear them out.
			// load guesses
			ktagSegmentForms = SegmentTags.kflidAnalyses;
			GetSegmentLevelTags(cache);
			LangProjectHvo = m_cache.LangProject.Hvo;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="ToolsOptionsDlgDummy"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ToolsOptionsDlgDummy(IApp app, IHelpTopicProvider helpTopicProvider, IWritingSystemManager wsManager) :
			base(app, helpTopicProvider, wsManager)
		{
		}
Example #18
0
 /// <summary>
 /// Gets all distinct writing systems (local and global) from the writing system manager. Local writing systems
 /// take priority over global writing systems.
 /// </summary>
 /// <param name="wsManager">The ws manager.</param>
 /// <returns></returns>
 public static IEnumerable <IWritingSystem> GetAllDistinctWritingSystems(IWritingSystemManager wsManager)
 {
     return(wsManager.LocalWritingSystems.Concat(wsManager.GlobalWritingSystems.Except(wsManager.LocalWritingSystems,
                                                                                       new WsIdEqualityComparer())));
 }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="LanguageSelectionDlg"/> class.
		/// </summary>
		/// <param name="wsManager">The writing system manager.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public LanguageSelectionDlg(IWritingSystemManager wsManager,
			IHelpTopicProvider helpTopicProvider) : this()
		{
			m_helpTopicProvider = helpTopicProvider;
			m_languageSetup.WritingSystemManager = wsManager;
		}
Example #20
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Constructs a new instance of the <see cref="FwNewLangProject"/> class.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public FwNewLangProject()
		{
			Logger.WriteEvent("Opening New Language Project dialog");
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			AccessibleName = GetType().Name;
			m_wsManager = new PalasoWritingSystemManager(new GlobalFileWritingSystemStore());
#if __MonoCS__
			FixLabelFont(m_lblTip);
			FixLabelFont(m_lblAnalysisWrtSys);
			FixLabelFont(m_lblVernacularWrtSys);
			FixLabelFont(m_lblProjectName);
			FixLabelFont(m_lblSpecifyWrtSys);
#endif
		}
Example #21
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="ToolsOptionsDialog"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ToolsOptionsDialog(IApp app, IHelpTopicProvider helpTopicProvider,
			IWritingSystemManager wsManager) : this()
		{
			m_app = app;
			m_helpTopicProvider = helpTopicProvider;
			m_wsManager = wsManager;

			// Get registry settings for the "Draft View" tab of the dialog.
			m_chkPromptEmptyParas.Checked = Options.ShowEmptyParagraphPromptsSetting;
			m_chkMarkerlessFootnoteIcons.Checked = Options.ShowMarkerlessIconsSetting;
			m_chkShowFormatMarks.Checked = Options.ShowFormatMarksSetting;
			m_chkSynchFootnoteScroll.Checked = Options.FootnoteSynchronousScrollingSetting;

			// Load strings and get registry settings for the "Styles" tab of the dialog.
			// check the radio button for the "show these styles" buttons
			switch(Options.ShowTheseStylesSetting)
			{
				case Options.ShowTheseStyles.All:
					rdoAllStyles.Checked = true;
					break;
				case Options.ShowTheseStyles.Basic:
					rdoBasicStyles.Checked = true;
					break;
				case Options.ShowTheseStyles.Custom:
					rdoCustomList.Checked = true;
					break;
			}
			// enable/disable the custom style controls
			rdoCustomList_CheckedChanged(rdoCustomList, null);
			// add style levels for Styles tab
			cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelBasic"));
			cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelIntermediate"));
			cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelAdvanced"));
			cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelExpert"));
			// set the style level combo box selection
			switch(Options.ShowStyleLevelSetting)
			{
				case Options.StyleLevel.Basic:
					cboStyleLevel.SelectedIndex = 0;
					break;
				case Options.StyleLevel.Intermediate:
					cboStyleLevel.SelectedIndex = 1;
					break;
				case Options.StyleLevel.Advanced:
					cboStyleLevel.SelectedIndex = 2;
					break;
				case Options.StyleLevel.Expert:
					cboStyleLevel.SelectedIndex = 3;
					break;
			}
			chkShowUserDefined.Checked = Options.ShowUserDefinedStylesSetting;

			// Get registry settings for the "General" tab of the dialog.
			m_chkStartLibronixWithTE.Checked = Options.AutoStartLibronix;
			m_cboMeasurement.SelectedIndex = FwRegistrySettings.MeasurementUnitSetting;

			// Configure the same way as Flex for consistency.  (See FWR-1997.)
			string sUserWs = m_wsManager.UserWritingSystem.Id;
			m_userInterfaceChooser.Init(sUserWs);

			// Use the following code block to set the checked values for experimental features.
#if DEBUG
			m_cboExperimentalFeatures.SetItemChecked(kVerticalDraftView, Options.UseVerticalDraftView);
#endif
			m_origInterLinearBTValue = Options.UseInterlinearBackTranslation;
			m_cboExperimentalFeatures.SetItemChecked(kInterlinearBackTranslation, m_origInterLinearBTValue);
			m_cboExperimentalFeatures.SetItemChecked(kXhtmlExport, Options.UseXhtmlExport);
			m_cboExperimentalFeatures.SetItemChecked(kTranslateUnsQuestions, Options.ShowTranslateUnsQuestions);
#if !DEBUG
			// The vertical view is only available in Debug mode
			m_cboExperimentalFeatures.Items.RemoveAt(kVerticalDraftView);
#endif
			// Execute this block if there are no experimental features (or none we want the user to see in a release build).
			//{
			//    m_cboExperimentalFeatures.Visible = false;
			//    m_lblNoTestFeatures.Visible = true;
			//}
		}
		protected InterlinearExporter(FdoCache cache, XmlWriter writer, ICmObject objRoot,
			InterlinLineChoices lineChoices, InterlinVc vc)
			: base(null, cache.MainCacheAccessor, objRoot.Hvo)
		{
			m_cache = cache;
			m_writer = writer;
			m_flidStTextTitle = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Title", false);
			m_flidStTextSource = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Source", false);
			m_vc = vc;
			SetTextTitleAndMetadata(objRoot as IStText);

			// Get morphtype information that we need later.  (plus stuff we don't...)  See LT-8288.
			IMoMorphType mmtStem;
			IMoMorphType mmtPrefix;
			IMoMorphType mmtSuffix;
			IMoMorphType mmtInfix;
			IMoMorphType mmtBoundStem;
			IMoMorphType mmtSimulfix;
			IMoMorphType mmtSuprafix;
			m_cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetMajorMorphTypes(
				out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
				out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic,
				out mmtSimulfix, out mmtSuprafix);

			m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
			m_repoObj = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>();
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="StringSearcher&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="wsManager">The writing system store.</param>
 public StringSearcher(SearchType type, IWritingSystemManager wsManager)
 {
     m_type      = type;
     m_wsManager = wsManager;
 }
Example #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UsfmStyFileAccessor"/> class.
 /// </summary>
 /// <param name="defaultRightToLeft">if set to <c>true</c> [default right to left].</param>
 /// <param name="wsManager">The writing system manager.</param>
 public UsfmStyFileAccessor(bool defaultRightToLeft, IWritingSystemManager wsManager)
     : base(ScrStyleNames.Normal, wsManager)
 {
     m_defaultRightToLeft = defaultRightToLeft;
 }
		/// <summary>
		/// Sets up the fixture.
		/// </summary>
		public override void FixtureSetup()
		{
			base.FixtureSetup();
			m_wsManager = new PalasoWritingSystemManager();
		}
Example #26
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ToolsOptionsDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ToolsOptionsDialog(IApp app, IHelpTopicProvider helpTopicProvider,
                                  IWritingSystemManager wsManager) : this()
        {
            m_app = app;
            m_helpTopicProvider = helpTopicProvider;
            m_wsManager         = wsManager;

            // Get registry settings for the "Draft View" tab of the dialog.
            m_chkPromptEmptyParas.Checked        = Options.ShowEmptyParagraphPromptsSetting;
            m_chkMarkerlessFootnoteIcons.Checked = Options.ShowMarkerlessIconsSetting;
            m_chkShowFormatMarks.Checked         = Options.ShowFormatMarksSetting;
            m_chkSynchFootnoteScroll.Checked     = Options.FootnoteSynchronousScrollingSetting;

            // Load strings and get registry settings for the "Styles" tab of the dialog.
            // check the radio button for the "show these styles" buttons
            switch (Options.ShowTheseStylesSetting)
            {
            case Options.ShowTheseStyles.All:
                rdoAllStyles.Checked = true;
                break;

            case Options.ShowTheseStyles.Basic:
                rdoBasicStyles.Checked = true;
                break;

            case Options.ShowTheseStyles.Custom:
                rdoCustomList.Checked = true;
                break;
            }
            // enable/disable the custom style controls
            rdoCustomList_CheckedChanged(rdoCustomList, null);
            // add style levels for Styles tab
            cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelBasic"));
            cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelIntermediate"));
            cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelAdvanced"));
            cboStyleLevel.Items.Add(DlgResources.ResourceString("kstidStyleLevelExpert"));
            // set the style level combo box selection
            switch (Options.ShowStyleLevelSetting)
            {
            case Options.StyleLevel.Basic:
                cboStyleLevel.SelectedIndex = 0;
                break;

            case Options.StyleLevel.Intermediate:
                cboStyleLevel.SelectedIndex = 1;
                break;

            case Options.StyleLevel.Advanced:
                cboStyleLevel.SelectedIndex = 2;
                break;

            case Options.StyleLevel.Expert:
                cboStyleLevel.SelectedIndex = 3;
                break;
            }
            chkShowUserDefined.Checked = Options.ShowUserDefinedStylesSetting;

            // Get registry settings for the "General" tab of the dialog.
            m_chkStartLibronixWithTE.Checked = Options.AutoStartLibronix;
            m_cboMeasurement.SelectedIndex   = FwRegistrySettings.MeasurementUnitSetting;

            // Configure the same way as Flex for consistency.  (See FWR-1997.)
            string sUserWs = m_wsManager.UserWritingSystem.Id;

            m_userInterfaceChooser.Init(sUserWs);

            // Use the following code block to set the checked values for experimental features.
#if DEBUG
            m_cboExperimentalFeatures.SetItemChecked(kVerticalDraftView, Options.UseVerticalDraftView);
#endif
            m_origInterLinearBTValue = Options.UseInterlinearBackTranslation;
            m_cboExperimentalFeatures.SetItemChecked(kInterlinearBackTranslation, m_origInterLinearBTValue);
            m_cboExperimentalFeatures.SetItemChecked(kXhtmlExport, Options.UseXhtmlExport);
            m_cboExperimentalFeatures.SetItemChecked(kTranslateUnsQuestions, Options.ShowTranslateUnsQuestions);
#if !DEBUG
            // The vertical view is only available in Debug mode
            m_cboExperimentalFeatures.Items.RemoveAt(kVerticalDraftView);
#endif
            // Execute this block if there are no experimental features (or none we want the user to see in a release build).
            //{
            //    m_cboExperimentalFeatures.Visible = false;
            //    m_lblNoTestFeatures.Visible = true;
            //}
        }
 /// <summary>
 /// Sets up the fixture.
 /// </summary>
 public override void FixtureSetup()
 {
     base.FixtureSetup();
     m_wsManager = new PalasoWritingSystemManager();
 }
		/// <summary></summary>
		public DummyWritingSystem(IWritingSystemManager manager, string identifier)
		{
			m_wsManager = manager;
			m_id = identifier;
			m_hvo = s_hvoGen++;
		}
Example #29
0
 /// <summary></summary>
 public DummyWritingSystem(IWritingSystemManager manager, string identifier)
 {
     m_wsManager = manager;
     m_id        = identifier;
     m_hvo       = s_hvoGen++;
 }
        public void Setup()
        {
            // Create the following:
            // - part and layout inventories
            // - metadata cache
            // - DataAccess cache
            // - collection of columns to display.

            // We want a MetaDataCache that knows about
            // - LexEntry.Senses, Msas, CitationForm, Bibliography, Etymology
            // - LexSense.SemanticDomains, SenseType, Status, gloss
            // - CmPossibility Name, abbr
            // - MoMorphSynAnalysis
            // - MoStemMsa
            // - MoDerivationalMsa
            string m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory,
                                              Path.Combine("Common",
                                                           Path.Combine("Controls",
                                                                        Path.Combine("XMLViews",
                                                                                     Path.Combine("XMLViewsTests", "SampleCm.xml")))));

            m_mdc = MetaDataCache.CreateMetaDataCache(m_sTestPath);

            // We want ISilDataAccess with:
            // - LexEntry (1) with no senses and one MSA (2)
            // - LexEntry (4) with one sense (5) and no MSA
            // - LexEntry (6) with three senses (7, 8, 9) and two MSAs (10, 11)
            // - sense(5) with no semantic domains
            // - senses with one SD (7->30, 8->31)
            // - sense with three SDs, one the same as the first (9->30, 31, 32)
            // - MoStemMsa (2, 11)
            // - MoDerivationalMsa (10)
            m_cda       = VwCacheDaClass.Create();
            m_sda       = m_cda as ISilDataAccess;
            m_wsManager = new PalasoWritingSystemManager();
            m_sda.WritingSystemFactory = m_wsManager;
            var parser = new SimpleDataParser(m_mdc, m_cda);

            parser.Parse(Path.Combine(DirectoryFinder.FwSourceDirectory,
                                      Path.Combine("Common",
                                                   Path.Combine("Controls",
                                                                Path.Combine("XMLViews",
                                                                             Path.Combine("XMLViewsTests", "SampleData.xml"))))));
            int wsEn = m_wsManager.GetWsFromStr("en");

            // These are mainly to check out the parser.
            Assert.AreEqual(3, m_sda.get_ObjectProp(2, 23011), "part of speech of an MoStemMsa");
            Assert.AreEqual(2, m_sda.get_VecItem(1, 2009, 0), "owned msa");
            Assert.AreEqual("noun", m_sda.get_MultiStringAlt(3, 7003, wsEn).Text, "got ms property");
            Assert.AreEqual(9, m_sda.get_VecItem(6, 2010, 2), "3rd sense");
            Assert.AreEqual(31, m_sda.get_VecItem(9, 21016, 1), "2nd semantic domain");

            // Columns includes
            // - CitationForm (string inside span)
            // - Bibliography (string not in span)
            // - Sense glosses (string in para in seq, nested in column element)
            // - Semantic domains (pair of strings in para in seq in seq, using layout refs)
            // - MSAs (simplified, but polymorphic with one having <choice> and one <obj> to CmPossibility
            XmlDocument docColumns = new XmlDocument();

            docColumns.Load(Path.Combine(DirectoryFinder.FwSourceDirectory,
                                         Path.Combine("Common",
                                                      Path.Combine("Controls",
                                                                   Path.Combine("XMLViews",
                                                                                Path.Combine("XMLViewsTests", "TestColumns.xml"))))));
            m_columnList = docColumns.DocumentElement.ChildNodes;

            // Parts just has what those columns need.
            string partDirectory = Path.Combine(DirectoryFinder.FwSourceDirectory,
                                                Path.Combine("Common",
                                                             Path.Combine("Controls",
                                                                          Path.Combine("XMLViews", "XMLViewsTests"))));
            Dictionary <string, string[]> keyAttrs = new Dictionary <string, string[]>();

            keyAttrs["layout"] = new string[] { "class", "type", "name" };
            keyAttrs["group"]  = new string[] { "label" };
            keyAttrs["part"]   = new string[] { "ref" };


            // Currently there are no specialized layout files that match.
            m_layoutInventory = new Inventory(new string[] { partDirectory },
                                              "*.fwlayout", "/LayoutInventory/*", keyAttrs, "TestManyOneBrowse", "ProjectPath");

            keyAttrs         = new Dictionary <string, string[]>();
            keyAttrs["part"] = new string[] { "id" };

            m_partInventory = new Inventory(new string[] { partDirectory },
                                            "TestParts.xml", "/PartInventory/bin/*", keyAttrs, "TestManyOneBrowse", "ProjectPath");
            m_layouts = new LayoutCache(m_mdc, m_layoutInventory, m_partInventory);
        }
Example #31
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolsOptionsDlgDummy"/> class.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ToolsOptionsDlgDummy(IApp app, IHelpTopicProvider helpTopicProvider, IWritingSystemManager wsManager) :
     base(app, helpTopicProvider, wsManager)
 {
 }
Example #32
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets required and optional information that describes the files being submitted in
        /// the RAMP package. METS = Metadata Encoding & Transmission Standard
        /// (see http://www.loc.gov/METS/).
        /// </summary>
        /// <param name="model">Object provided by SIL.Archiving for setting application
        /// specific archiving information.</param>
        /// <param name="fieldWorksVersion">Fieldworks version to display.</param>
        /// <param name="cache"></param>
        /// <returns>A list of JSON encoded pairs that describe the information in the RAMP
        /// package.</returns>
        /// ------------------------------------------------------------------------------------
        private void AddMetsPairs(RampArchivingDlgViewModel model, string fieldWorksVersion, FdoCache cache)
        {
            IWritingSystemManager wsManager = cache.ServiceLocator.GetInstance <IWritingSystemManager>();
            var wsDefaultVern = wsManager.Get(cache.DefaultVernWs);
            var vernIso3Code  = wsDefaultVern.GetIso3Code();

            model.SetScholarlyWorkType(ScholarlyWorkType.PrimaryData);

            // use year range for CreationDate if possible
            GetCreateDateRange(cache);
            var yearStart = m_earliest.Year;
            var yearEnd   = m_latest.Year;

            if (yearEnd > yearStart)
            {
                model.SetCreationDate(yearStart, yearEnd);
            }
            else
            {
                model.SetCreationDate(m_earliest);
            }

            model.SetModifiedDate(cache.LangProject.DateModified);

            if (!string.IsNullOrEmpty(vernIso3Code))
            {
                model.SetSubjectLanguage(vernIso3Code, wsDefaultVern.LanguageName);
            }

            var  contentLanguages     = new List <ArchivingLanguage>();
            var  softwareRequirements = new HashSet <string>();
            bool fWsUsesKeyman        = false;

            softwareRequirements.Add(string.Format("FieldWorks Language Explorer, Version {0} or later", fieldWorksVersion));

            foreach (var ws in cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Union(
                         cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems).Union(
                         cache.ServiceLocator.WritingSystems.CurrentPronunciationWritingSystems))
            {
                var iso3Code = ws.GetIso3Code();

                if (!string.IsNullOrEmpty(iso3Code))
                {
                    contentLanguages.Add(new ArchivingLanguage(iso3Code, ws.LanguageSubtag.Name));
                }

                if (!string.IsNullOrEmpty(ws.DefaultFontName))
                {
                    softwareRequirements.Add(ws.DefaultFontName);
                }
                fWsUsesKeyman |= DoesWritingSystemUseKeyman(ws);
            }

            if (fWsUsesKeyman)
            {
                softwareRequirements.Add("Keyman");
            }

            model.SetContentLanguages(contentLanguages);
            model.SetSoftwareRequirements(softwareRequirements);

            SilDomain domains          = SilDomain.Linguistics;
            var       cNotebookRecords = cache.LangProject.ResearchNotebookOA.AllRecords.Count();

            if (cNotebookRecords > 0)
            {
                domains |= SilDomain.Anthropology;
                domains |= SilDomain.Anth_Ethnography;                 // Data notebook data is considered a (partial) ethnography.
            }

            var cLexicalEntries = cache.LangProject.LexDbOA.Entries.Count();

            if (cLexicalEntries > 0)
            {
                domains |= SilDomain.Ling_Lexicon;
            }

            // Determine if there are any interlinearized texts
            if (cache.ServiceLocator.GetInstance <IWfiAnalysisRepository>().AllInstances().Any(a => a.OccurrencesInTexts.Any() &&
                                                                                               a.GetAgentOpinion(cache.LangProject.DefaultUserAgent) == Opinions.approves))
            {
                domains |= SilDomain.Ling_InterlinearizedText;
            }

            var cTexts = cache.LangProject.Texts.Count();

            if (cTexts > 0)
            {
                domains |= SilDomain.Ling_Text;
            }

            /* TODO: If files to include in archive includes a Lift file, set the correct schema */
            //if (filesToArchive.Contains( FwFileExtensions.ksLexiconInterchangeFormat )
            //	model.SetSchemaConformance("LIFT");

            /* TODO: If files to include in archive includes a grammar sketch, set the correct subdomain */
            //if (filesToArchive.Contains(...)
            //	domains |= SilDomain.Ling_GrammaticalDescription;

            model.SetDomains(domains);

            // get the information for DatasetExtent
            var          datasetExtent = new StringBuilder();
            const string delimiter     = "; ";

            if (cNotebookRecords > 0)
            {
                datasetExtent.AppendLineFormat("{0} Notebook record{1}", new object[] { cNotebookRecords, (cNotebookRecords == 1) ? "" : "s" }, delimiter);
            }

            if (cLexicalEntries > 0)
            {
                datasetExtent.AppendLineFormat("{0} Lexical entr{1}", new object[] { cLexicalEntries, (cLexicalEntries == 1) ? "y" : "ies" }, delimiter);
            }

            if (cTexts > 0)
            {
                datasetExtent.AppendLineFormat("{0} Text{1}", new object[] { cTexts, (cTexts == 1) ? "" : "s" }, delimiter);
            }

            if (datasetExtent.Length > 0)
            {
                model.SetDatasetExtent(datasetExtent + ".");
            }
        }
Example #33
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="XDumper"/> class.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public XDumper(FdoCache cache)
		{
			m_cache = cache;
			m_mdc = m_cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>();
			m_cmObjectRepository = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>();
			m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
			m_wsContainer = m_cache.ServiceLocator.WritingSystems;
		}
		private static void CheckWsProperty(IEnumerable<DomainObjectDTO> dtos, IWritingSystemManager wsManager)
		{
			foreach (DomainObjectDTO dto in dtos)
			{
				XElement elem = XElement.Parse(dto.Xml);
				Assert.IsTrue(wsManager.Exists((string) elem.Element("WritingSystem")));
			}
		}
Example #35
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="ValidCharactersDlg"/> class.
		/// </summary>
		/// <param name="cache">The cache. Can be <c>null</c> if called from New Project
		/// dialog.</param>
		/// <param name="wsContainer">The FDO writing system container. Can't be
		/// <c>null</c>.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// <param name="app">The app.</param>
		/// <param name="ws">The language definition of the writing system for which this
		/// dialog is setting the valid characters. Can not be <c>null</c>.</param>
		/// <param name="wsName">The name of the writing system for which this dialog is setting
		/// the valid characters. Can not be <c>null</c> or <c>String.Empty</c>.</param>
		/// ------------------------------------------------------------------------------------
		public ValidCharactersDlg(FdoCache cache, IWritingSystemContainer wsContainer,
			IHelpTopicProvider helpTopicProvider, IApp app, IWritingSystem ws, string wsName) : this()
		{
			m_ws = ws;
			m_helpTopicProvider = helpTopicProvider;
			m_app = app;
			if (string.IsNullOrEmpty(wsName))
				throw new ArgumentException("Parameter must not be null or empty.", "wsName");

			if (cache != null)
				m_wsManager = cache.ServiceLocator.WritingSystemManager;

			m_chrPropEng = LgIcuCharPropEngineClass.Create();

			m_lblWsName.Text = string.Format(m_lblWsName.Text, wsName);

			// TE-6839: Temporarily remove Unicode tab (not yet implemented).
			tabCtrlAddFrom.TabPages.Remove(tabCtrlAddFrom.TabPages[kiTabUnicode]);

			m_fntForSpecialChar = new Font(SystemFonts.IconTitleFont.FontFamily, 8f);
			Font fnt = new Font(m_ws.DefaultFontName, 16);

			// Review - each of the following Font property set causes LoadCharsFromFont
			// to be executed which is an expensive operation as it pinvokes GetGlyphIndices
			// repeatedly.
			chrGridWordForming.Font = fnt;
			chrGridNumbers.Font = fnt;
			chrGridOther.Font = fnt;
			txtManualCharEntry.Font = fnt;
			txtFirstChar.Font = fnt;
			txtLastChar.Font = fnt;

			lblFirstCharCode.Top = txtFirstChar.Bottom + 5;
			lblLastCharCode.Top = txtLastChar.Bottom + 5;
			lblFirstChar.Top = txtFirstChar.Top +
				(txtFirstChar.Height - lblFirstChar.Height) / 2;
			lblLastChar.Top = txtLastChar.Top +
				(txtLastChar.Height - lblLastChar.Height) / 2;

			fnt = new Font(m_ws.DefaultFontName, 12);
			colChar.DefaultCellStyle.Font = fnt;

			tabData.Controls.Remove(gridCharInventory);
			var gridcol = gridCharInventory.Columns[3];
			m_chkBoxColHdrHandler = new CheckBoxColumnHeaderHandler(gridcol);
			m_chkBoxColHdrHandler.Label = gridcol.HeaderText;
			gridcol.HeaderText = String.Empty;

			contextCtrl.Initialize(cache, wsContainer, m_ws, m_app, fnt, gridCharInventory);
			contextCtrl.Dock = DockStyle.Fill;
			contextCtrl.CheckToRun = CharContextCtrl.CheckType.Characters;
			contextCtrl.ListValidator = RemoveInvalidCharacters;

			colChar.HeaderCell.SortGlyphDirection = SortOrder.Ascending;
			gridCharInventory.AutoGenerateColumns = false;

			colStatus.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;

			m_validCharsGridMngr.Init(chrGridWordForming, chrGridOther, chrGridNumbers, m_ws, m_app);
			m_validCharsGridMngr.CharacterGridGotFocus += HandleCharGridGotFocus;
			m_validCharsGridMngr.CharacterGridSelectionChanged += HandleCharGridSelChange;
		}
Example #36
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleInfoTable"/> class.
 /// </summary>
 /// <param name="normalStyleName">the name of the normal style</param>
 /// <param name="wsManager">The Writing System Factory (needed to resolve magic font names
 /// to real ones)</param>
 /// ------------------------------------------------------------------------------------
 public StyleInfoTable(string normalStyleName, IWritingSystemManager wsManager)
 {
     m_wsManager       = wsManager;
     m_normalStyleName = normalStyleName;
 }
Example #37
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			Debug.WriteLineIf(!disposing, "********** Missing Dispose() call for " + GetType().Name + ". **********");
			if (disposing)
			{
				if (m_openFileDialog != null)
					m_openFileDialog.Dispose();

				if (m_fDisposeWsManager)
				{
					var disposable = m_wsManager as IDisposable;
					if (disposable != null)
						disposable.Dispose();
					m_wsManager = null;
				}
				if (m_fntForSpecialChar != null)
				{
					m_fntForSpecialChar.Dispose();
					m_fntForSpecialChar = null;
				}
				if (m_validCharsGridMngr != null)
					m_validCharsGridMngr.Dispose();
				if (m_chkBoxColHdrHandler != null)
					m_chkBoxColHdrHandler.Dispose();
				if (m_chrPropEng != null && Marshal.IsComObject(m_chrPropEng))
				{
					Marshal.ReleaseComObject(m_chrPropEng);
					m_chrPropEng = null;
				}
				if (m_openFileDialog != null)
					m_openFileDialog.Dispose();
				if (components != null)
					components.Dispose();
			}

			m_openFileDialog = null;
			m_validCharsGridMngr = null;
			m_chkBoxColHdrHandler = null;
			m_inventoryCharComparer = null;
			m_openFileDialog = null;

			base.Dispose(disposing);

		}
Example #38
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Retrieve named checking parameter value.
        /// Checks use this to get their setup information.
        /// </summary>
        /// <param name="key">Parameter name</param>
        /// <returns>Parameter value</returns>
        /// ------------------------------------------------------------------------------------
        public string GetParameterValue(string key)
        {
            IWritingSystemManager wsManager = m_cache.ServiceLocator.WritingSystemManager;
            int            hvoWs            = m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.Handle;
            IWritingSystem ws = wsManager.Get(hvoWs);

            if (key.Contains("ValidCharacters"))
            {
                return(GetValidCharactersList(key, ws));
            }

            switch (key)
            {
            case "PoeticStyles":
                return(GetPoeticStyles());

            case "Versification Scheme":
                return(m_scr.Versification.ToString());

            case "IntroductionOutlineStyles":
                //REVIEW: Do we need this? return "Intro_List_Item1";
                return(string.Empty);

            case "PunctCheckLevel":
                return("Intermediate");

            case "PunctWhitespaceChar":
                return(m_punctWhitespaceChar.Substring(0, 1));

            case "MatchedPairs":
                return(ws.MatchedPairs);

            case "PunctuationPatterns":
                return(ws.PunctuationPatterns);

            case "SentenceFinalPunctuation":
                return(GetSentenceFinalPunctuation(ws, m_cache.ServiceLocator.UnicodeCharProps));

            case "QuotationMarkInfo":
                return(ws.QuotationMarks);

            case "StylesInfo":
                return((StyleInfo != null) ? StyleInfo.XmlString : null);

            case "DefaultWritingSystemName":
                return(ws.DisplayLabel);

            case "Verse Bridge":
                return(m_scr.BridgeForWs(hvoWs));

            case "Script Digit Zero":
                return(m_scr.UseScriptDigits ? ((char)m_scr.ScriptDigitZero).ToString() : "0");

            case "Sub-verse Letter A":
                return("a");                        // TODO (TE-8593): Support sub-verse letters for non-Roman text

            case "Sub-verse Letter B":
                return("b");                        // TODO (TE-8593): Support sub-verse letters for non-Roman text

            default:
                string value;
                return((m_checkingParameters.TryGetValue(key, out value)) ? value : string.Empty);
            }
        }
Example #39
0
			/// <summary>
			/// Constructor using an XmlNode from the settings file.
			/// </summary>
			public EncConverterChoice(XmlNode xnConverter, IWritingSystemManager wsManager)
				: this(XmlUtils.GetManditoryAttributeValue(xnConverter, "ws"),
				XmlUtils.GetOptionalAttributeValue(xnConverter, "converter", null), wsManager)
			{
			}
Example #40
0
		/// <summary>
		/// Initializes a new instance of the <see cref="UsfmStyFileAccessor"/> class.
		/// </summary>
		/// <param name="defaultRightToLeft">if set to <c>true</c> [default right to left].</param>
		/// <param name="wsManager">The writing system manager.</param>
		public UsfmStyFileAccessor(bool defaultRightToLeft, IWritingSystemManager wsManager)
			: base(ScrStyleNames.Normal, wsManager)
		{
			m_defaultRightToLeft = defaultRightToLeft;
		}
Example #41
0
			/// <summary>
			/// Constructor using the writing system identifier and Converter name explicitly.
			/// </summary>
			public EncConverterChoice(string sWs, string sConverter, IWritingSystemManager wsManager)
			{
				m_sConverter = sConverter;
				if (String.IsNullOrEmpty(m_sConverter))
					m_sConverter = Sfm2Xml.STATICS.AlreadyInUnicode;
				wsManager.GetOrSet(sWs, out m_ws);
			}
Example #42
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="LanguageSelectionDlg"/> class.
 /// </summary>
 /// <param name="wsManager">The writing system manager.</param>
 /// <param name="helpTopicProvider">The help topic provider.</param>
 /// ------------------------------------------------------------------------------------
 public LanguageSelectionDlg(IWritingSystemManager wsManager,
                             IHelpTopicProvider helpTopicProvider) : this()
 {
     m_helpTopicProvider = helpTopicProvider;
     m_languageSetup.WritingSystemManager = wsManager;
 }
Example #43
0
		public void Teardown()
		{
			if (Marshal.IsComObject(m_cda))
			{
				Marshal.ReleaseComObject(m_cda);
			}
			m_cda = null;

			if (Marshal.IsComObject(m_mdc))
			{
				Marshal.ReleaseComObject(m_mdc);
			}
			m_mdc = null;

			if (Marshal.IsComObject(m_sda))
			{
				Marshal.ReleaseComObject(m_sda);
			}
			m_sda = null;

			m_layoutInventory = null;
			m_columnList = null;
			m_layouts = null;
			m_partInventory = null;
			m_wsManager = null;
		}