private void MakeFeatureStructure(FeatureStructureTreeView tv, IFsFeatStruc featStruct) { using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg()) { foreach (IFsFeatureSpecification spec in featStruct.FeatureSpecsOC) { featStruct.FeatureSpecsOC.Remove(spec); } dlg.SetDlgInfo(Cache, null, featStruct, MoStemMsaTags.kflidMsFeatures); dlg.UpdateFeatureStructure(tv.Nodes); } }
public void PopulateTreeFromFeatureSystem() { // Set up sample data IFsFeatStruc featStruct; ILangProject lp = CreateFeatureSystem(out featStruct); // Set up the xml fs description XmlDocument doc = new XmlDocument(); string sFileDir = Path.Combine(SIL.FieldWorks.Common.FwUtils.DirectoryFinder.FwSourceDirectory, Path.Combine(@"FDO", Path.Combine(@"FDOTests", @"TestData"))); string sFile = Path.Combine(sFileDir, "FeatureSystem2.xml"); doc.Load(sFile); XmlNode itemNeut = doc.SelectSingleNode("//item[@id='vNeut']"); // Add some complex features IFsFeatureSystem msfs = lp.MsFeatureSystemOA; msfs.AddFeatureFromXml(itemNeut); // Now add a feature that differs only in value XmlNode itemFem = doc.SelectSingleNode("//item[@id='vFem']"); msfs.AddFeatureFromXml(itemFem); // Now add another feature to the complex one XmlNode item1st = doc.SelectSingleNode("//item[@id='v1']"); msfs.AddFeatureFromXml(item1st); // now get a simple, top-level closed feature sFile = Path.Combine(sFileDir, "FeatureSystem3.xml"); doc.Load(sFile); XmlNode itemImpfv = doc.SelectSingleNode("//item[@id='vImpfv']"); msfs.AddFeatureFromXml(itemImpfv); XmlNode itemCont = doc.SelectSingleNode("//item[@id='vCont']"); msfs.AddFeatureFromXml(itemCont); using (var dlg = new FeatureSystemInflectionFeatureListDlg()) { ILexEntryInflType cobj = Cache.ServiceLocator.GetInstance <ILexEntryInflTypeFactory>().Create(); lp.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(cobj); dlg.SetDlgInfo(Cache, (Mediator)null, cobj, 0); // load some feature system values into treeview FeatureStructureTreeView tv = dlg.TreeView; Assert.AreEqual(2, tv.Nodes.Count, "Count of top level nodes in tree view"); TreeNodeCollection col = tv.Nodes[0].Nodes; Assert.AreEqual(3, col.Count, "Count of first level nodes in tree view"); } }
public void LoadInflectableFeats() { // Set up sample data IFsFeatStruc featStruct; using (FeatureStructureTreeView tv = SetUpSampleData(out featStruct)) { // load some feature structure values into treeview LoadFeatureValuesIntoTreeview(tv, featStruct); // Make feature structure based on values in treeview MakeFeatureStructure(tv, featStruct); TestFeatureStructureContent(featStruct); } }
private void LoadFeatureValuesIntoTreeview(FeatureStructureTreeView tv, IFsFeatStruc featStruct) { TreeNodeCollection col; tv.PopulateTreeFromFeatureStructure(featStruct); Assert.AreEqual(1, tv.Nodes.Count, "Count of top level after feature structure"); col = tv.Nodes[0].Nodes; Assert.AreEqual(2, col.Count, "Count of first level nodes in tree view"); foreach (TreeNode node in col) { TreeNodeCollection col2 = node.Nodes; if (node.Text == "gender") { Assert.AreEqual(2, col2.Count, "Count of second level nodes in tree view"); } if (node.Text == "person") { Assert.AreEqual(1, col2.Count, "Count of second level nodes in tree view"); } } }
private FeatureStructureTreeView SetUpSampleData(out IFsFeatStruc featStruct) { ILangProject lp = CreateFeatureSystem(out featStruct); // load some feature system values into treeview IPartOfSpeech pos = lp.PartsOfSpeechOA.PossibilitiesOS[0] as IPartOfSpeech; FeatureStructureTreeView tv = new FeatureStructureTreeView(); tv.PopulateTreeFromInflectableFeats(pos.InflectableFeatsRC); Assert.AreEqual(1, tv.Nodes.Count, "Count of top level nodes in tree view"); TreeNodeCollection col = tv.Nodes[0].Nodes; Assert.AreEqual(1, col.Count, "Count of first level nodes in tree view"); foreach (TreeNode node in col) { TreeNodeCollection col2 = node.Nodes; Assert.AreEqual(2, col2.Count, "Count of second level nodes in tree view"); if (node.PrevNode == null) { node.Checked = true; } } return(tv); }
private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MsaInflectionFeatureListDlg)); this.labelPrompt = new System.Windows.Forms.Label(); this.m_imageList = new System.Windows.Forms.ImageList(this.components); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_bnHelp = new System.Windows.Forms.Button(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.m_imageListPictures = new System.Windows.Forms.ImageList(this.components); this.m_tvMsaFeatureList = new SIL.FieldWorks.LexText.Controls.FeatureStructureTreeView(this.components); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // labelPrompt // resources.ApplyResources(this.labelPrompt, "labelPrompt"); this.labelPrompt.Name = "labelPrompt"; // // m_imageList // this.m_imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("m_imageList.ImageStream"))); this.m_imageList.TransparentColor = System.Drawing.Color.Transparent; this.m_imageList.Images.SetKeyName(0, ""); this.m_imageList.Images.SetKeyName(1, ""); this.m_imageList.Images.SetKeyName(2, ""); // // m_btnOK // resources.ApplyResources(this.m_btnOK, "m_btnOK"); this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Name = "m_btnOK"; // // m_btnCancel // resources.ApplyResources(this.m_btnCancel, "m_btnCancel"); this.m_btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.m_btnCancel.Name = "m_btnCancel"; // // m_bnHelp // resources.ApplyResources(this.m_bnHelp, "m_bnHelp"); this.m_bnHelp.Name = "m_bnHelp"; this.m_bnHelp.Click += new System.EventHandler(this.m_bnHelp_Click); // // pictureBox1 // resources.ApplyResources(this.pictureBox1, "pictureBox1"); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.TabStop = false; // // linkLabel1 // resources.ApplyResources(this.linkLabel1, "linkLabel1"); this.linkLabel1.Name = "linkLabel1"; this.linkLabel1.TabStop = true; this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); // // m_imageListPictures // this.m_imageListPictures.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("m_imageListPictures.ImageStream"))); this.m_imageListPictures.TransparentColor = System.Drawing.Color.Magenta; this.m_imageListPictures.Images.SetKeyName(0, ""); // // m_tvMsaFeatureList // resources.ApplyResources(this.m_tvMsaFeatureList, "m_tvMsaFeatureList"); this.m_tvMsaFeatureList.FullRowSelect = true; this.m_tvMsaFeatureList.HideSelection = false; this.m_tvMsaFeatureList.Name = "m_tvMsaFeatureList"; // // MsaInflectionFeatureListDlg // this.AcceptButton = this.m_btnOK; resources.ApplyResources(this, "$this"); this.CancelButton = this.m_btnCancel; this.Controls.Add(this.linkLabel1); this.Controls.Add(this.pictureBox1); this.Controls.Add(this.m_bnHelp); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.labelPrompt); this.Controls.Add(this.m_tvMsaFeatureList); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "MsaInflectionFeatureListDlg"; this.ShowInTaskbar = false; this.Closing += new System.ComponentModel.CancelEventHandler(this.MsaInflectionFeatureListDlg_Closing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MsaInflectionFeatureListDlg)); this.labelPrompt = new System.Windows.Forms.Label(); this.m_imageList = new System.Windows.Forms.ImageList(this.components); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_bnHelp = new System.Windows.Forms.Button(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.m_imageListPictures = new System.Windows.Forms.ImageList(this.components); this.m_tvMsaFeatureList = new SIL.FieldWorks.LexText.Controls.FeatureStructureTreeView(this.components); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // labelPrompt // resources.ApplyResources(this.labelPrompt, "labelPrompt"); this.labelPrompt.Name = "labelPrompt"; // // m_imageList // this.m_imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("m_imageList.ImageStream"))); this.m_imageList.TransparentColor = System.Drawing.Color.Transparent; this.m_imageList.Images.SetKeyName(0, ""); this.m_imageList.Images.SetKeyName(1, ""); this.m_imageList.Images.SetKeyName(2, ""); // // m_btnOK // resources.ApplyResources(this.m_btnOK, "m_btnOK"); this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Name = "m_btnOK"; // // m_btnCancel // resources.ApplyResources(this.m_btnCancel, "m_btnCancel"); this.m_btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.m_btnCancel.Name = "m_btnCancel"; // // m_bnHelp // resources.ApplyResources(this.m_bnHelp, "m_bnHelp"); this.m_bnHelp.Name = "m_bnHelp"; this.m_bnHelp.Click += new System.EventHandler(this.m_bnHelp_Click); // // pictureBox1 // resources.ApplyResources(this.pictureBox1, "pictureBox1"); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.TabStop = false; // // linkLabel1 // resources.ApplyResources(this.linkLabel1, "linkLabel1"); this.linkLabel1.Name = "linkLabel1"; this.linkLabel1.TabStop = true; this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); // // m_imageListPictures // this.m_imageListPictures.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("m_imageListPictures.ImageStream"))); this.m_imageListPictures.TransparentColor = System.Drawing.Color.Magenta; this.m_imageListPictures.Images.SetKeyName(0, ""); // // m_tvMsaFeatureList // resources.ApplyResources(this.m_tvMsaFeatureList, "m_tvMsaFeatureList"); this.m_tvMsaFeatureList.FullRowSelect = true; this.m_tvMsaFeatureList.HideSelection = false; this.m_tvMsaFeatureList.Name = "m_tvMsaFeatureList"; // // MsaInflectionFeatureListDlg // this.AcceptButton = this.m_btnOK; resources.ApplyResources(this, "$this"); this.CancelButton = this.m_btnCancel; this.Controls.Add(this.linkLabel1); this.Controls.Add(this.pictureBox1); this.Controls.Add(this.m_bnHelp); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.labelPrompt); this.Controls.Add(this.m_tvMsaFeatureList); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "MsaInflectionFeatureListDlg"; this.ShowInTaskbar = false; this.Closing += new System.ComponentModel.CancelEventHandler(this.MsaInflectionFeatureListDlg_Closing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); }
private FeatureStructureTreeView SetUpSampleData(out IFsFeatStruc featStruct) { ILangProject lp = CreateFeatureSystem(out featStruct); // load some feature system values into treeview IPartOfSpeech pos = (IPartOfSpeech)lp.PartsOfSpeechOA.PossibilitiesOS.FirstItem; FeatureStructureTreeView tv = new FeatureStructureTreeView(); tv.PopulateTreeFromInflectableFeats(pos.InflectableFeatsRC); Assert.AreEqual(1, tv.Nodes.Count, "Count of top level nodes in tree view"); TreeNodeCollection col = tv.Nodes[0].Nodes; Assert.AreEqual(1, col.Count, "Count of first level nodes in tree view"); foreach (TreeNode node in col) { TreeNodeCollection col2 = node.Nodes; Assert.AreEqual(2, col2.Count, "Count of second level nodes in tree view"); if (node.PrevNode == null) node.Checked = true; } return tv; }
private void LoadFeatureValuesIntoTreeview(FeatureStructureTreeView tv, IFsFeatStruc featStruct) { TreeNodeCollection col; tv.PopulateTreeFromFeatureStructure(featStruct); Assert.AreEqual(1, tv.Nodes.Count, "Count of top level after feature structure"); col = tv.Nodes[0].Nodes; Assert.AreEqual(2, col.Count, "Count of first level nodes in tree view"); foreach (TreeNode node in col) { TreeNodeCollection col2 = node.Nodes; if (node.Text == "gender") Assert.AreEqual(2, col2.Count, "Count of second level nodes in tree view"); if (node.Text == "person") Assert.AreEqual(1, col2.Count, "Count of second level nodes in tree view"); } }
private void MakeFeatureStructure(FeatureStructureTreeView tv, IFsFeatStruc featStruct) { using (MsaInflectionFeatureListDlg dlg = new MsaInflectionFeatureListDlg()) { foreach (IFsFeatureSpecification spec in featStruct.FeatureSpecsOC) featStruct.FeatureSpecsOC.Remove(spec); dlg.SetDlgInfo(Cache, null, featStruct); dlg.UpdateFeatureStructure(tv.Nodes); } }