/// <summary> /// Constructor. /// </summary> public MSAPopupTreeManager(PopupTree popupTree, FdoCache cache, ICmPossibilityList list, int ws, bool useAbbr, Mediator mediator, Form parent) : base(popupTree, cache, list, ws, useAbbr, parent) { m_mediator = mediator; LoadStrings(); }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { int tagNamePOS = UseAbbr ? CmPossibilityTags.kflidAbbreviation : CmPossibilityTags.kflidName; List<HvoTreeNode> relevantPartsOfSpeech = new List<HvoTreeNode>(); GatherPartsOfSpeech(Cache, List.Hvo, CmPossibilityListTags.kflidPossibilities, CmPossibilityTags.kflidSubPossibilities, PartOfSpeechTags.kflidInflectionClasses, tagNamePOS, WritingSystem, relevantPartsOfSpeech); relevantPartsOfSpeech.Sort(); int tagNameClass = UseAbbr ? MoInflClassTags.kflidAbbreviation : MoInflClassTags.kflidName; TreeNode match = null; foreach(HvoTreeNode item in relevantPartsOfSpeech) { popupTree.Nodes.Add(item); TreeNode match1 = AddNodes(item.Nodes, item.Hvo, PartOfSpeechTags.kflidInflectionClasses, MoInflClassTags.kflidSubclasses, hvoTarget, tagNameClass); if (match1 != null) match = match1; } return match; }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { int tagNamePOS = UseAbbr ? (int)CmPossibility.CmPossibilityTags.kflidAbbreviation : (int)CmPossibility.CmPossibilityTags.kflidName; List<HvoTreeNode> relevantPartsOfSpeech = new List<HvoTreeNode>(); InflectionClassPopupTreeManager.GatherPartsOfSpeech(Cache, List.Hvo, (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities, (int)CmPossibility.CmPossibilityTags.kflidSubPossibilities, (int)PartOfSpeech.PartOfSpeechTags.kflidInflectableFeats, tagNamePOS, WritingSystem, relevantPartsOfSpeech); relevantPartsOfSpeech.Sort(); TreeNode match = null; foreach(HvoTreeNode item in relevantPartsOfSpeech) { popupTree.Nodes.Add(item); IPartOfSpeech pos = (IPartOfSpeech)PartOfSpeech.CreateFromDBObject(Cache, item.Hvo, false); foreach(IFsFeatStruc fs in pos.ReferenceFormsOC) { // Note: beware of using fs.ShortName. That can be // absolutely EMPTY (if the user has turned off the 'Show Abbreviation as its label' // field for both the feature category and value). // ChooserName shows the short name if it is non-empty, otherwise the long name. HvoTreeNode node = new HvoTreeNode(fs.ChooserNameTS, fs.Hvo); item.Nodes.Add(node); if (fs.Hvo == hvoTarget) match = node; } item.Nodes.Add(new HvoTreeNode(Cache.MakeUserTss(LexTextControls.ksChooseInflFeats), kMore)); } return match; }
/// <summary> /// Constructor. /// </summary> public PopupTreeManager(PopupTree popupTree, FdoCache cache, Mediator mediator, ICmPossibilityList list, int ws, bool useAbbr, Form parent) { m_popupTree = popupTree; Init(cache, mediator, list, ws, useAbbr, parent); popupTree.BeforeSelect += m_treeCombo_BeforeSelect; popupTree.AfterSelect += m_treeCombo_AfterSelect; popupTree.PopupTreeClosed += popupTree_PopupTreeClosed; }
/// <summary> /// Constructor. /// </summary> public PopupTreeManager(PopupTree popupTree, FdoCache cache, ICmPossibilityList list, int ws, bool useAbbr, Form parent) { m_popupTree = popupTree; Init(cache, list, ws, useAbbr, parent); popupTree.BeforeSelect += new TreeViewCancelEventHandler(m_treeCombo_BeforeSelect); popupTree.AfterSelect += new TreeViewEventHandler(m_treeCombo_AfterSelect); popupTree.PopupTreeClosed += new TreeViewEventHandler(popupTree_PopupTreeClosed); }
/// <summary> /// Creates the drop down box. /// </summary> /// <returns></returns> protected override IDropDownBox CreateDropDownBox() { // Create the list. var popupTree = new PopupTree { TabStopControl = m_comboTextBox }; popupTree.AfterSelect += m_tree_AfterSelect; popupTree.BeforeSelect += m_popupTree_BeforeSelect; popupTree.Load += m_tree_Load; popupTree.PopupTreeClosed += m_popupTree_PopupTreeClosed; return popupTree; }
/// <summary> /// Creates the drop down box. /// </summary> /// <returns></returns> protected override IDropDownBox CreateDropDownBox() { // Create the list. var popupTree = new PopupTree(); popupTree.TabStopControl = m_comboTextBox; //m_tree.SelectedIndexChanged += new EventHandler(m_listBox_SelectedIndexChanged); //m_listBox.SameItemSelected += new EventHandler(m_listBox_SameItemSelected); popupTree.AfterSelect += m_tree_AfterSelect; popupTree.BeforeSelect += m_popupTree_BeforeSelect; popupTree.Load += m_tree_Load; popupTree.PopupTreeClosed += m_popupTree_PopupTreeClosed; return popupTree; }
/// <summary> /// Creates the drop down box. /// </summary> /// <returns></returns> protected override IDropDownBox CreateDropDownBox() { // Create the list. var popupTree = new PopupTree(); popupTree.TabStopControl = m_comboTextBox; //m_tree.SelectedIndexChanged += new EventHandler(m_listBox_SelectedIndexChanged); //m_listBox.SameItemSelected += new EventHandler(m_listBox_SameItemSelected); popupTree.AfterSelect += m_tree_AfterSelect; popupTree.BeforeSelect += m_popupTree_BeforeSelect; popupTree.Load += m_tree_Load; popupTree.PopupTreeClosed += m_popupTree_PopupTreeClosed; return(popupTree); }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { int tagName = UseAbbr ? CmPossibilityTags.kflidAbbreviation : CmPossibilityTags.kflidName; popupTree.Sorted = Sorted; TreeNode match = null; if (List != null) match = AddNodes(popupTree.Nodes, List.Hvo, CmPossibilityListTags.kflidPossibilities, hvoTarget, tagName); var empty = AddAnyItem(popupTree); if (hvoTarget == 0) match = empty; return match; }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { TreeNode match = null; // We need a way to store feature structures the user has chosen during this session. // We use an annotation to do this. foreach (ICmBaseAnnotation cba in m_annotations) { IFsFeatStruc fs = cba.FeaturesOA; if (fs == null || fs.IsEmpty) continue; if (cba.BeginObjectRA != null) continue; // is not one of the feature structures created via the phon feat chooser HvoTreeNode node = new HvoTreeNode(fs.LongNameTSS, fs.Hvo); popupTree.Nodes.Add(node); if (fs.Hvo == hvoTarget) match = node; } if (ClosedFeature != null) { var sortedVaues = from v in ClosedFeature.ValuesOC orderby v.Abbreviation.BestAnalysisAlternative.Text select v; foreach (var closedValue in sortedVaues) { HvoTreeNode node = new HvoTreeNode(closedValue.Abbreviation.BestAnalysisAlternative, closedValue.Hvo); popupTree.Nodes.Add(node); if (closedValue.Hvo == hvoTarget) match = node; } } popupTree.Nodes.Add(new HvoTreeNode( Cache.TsStrFactory.MakeString(LexTextControls.ksRemoveThisFeature, Cache.WritingSystemFactory.UserWs), kRemoveThisFeature)); /* Trying this now without using the phonological feature chooser; if users ask for it, will reconsider. * popupTree.Nodes.Add(new HvoTreeNode( Cache.TsStrFactory.MakeString(LexTextControls.ksChoosePhonFeats, Cache.WritingSystemFactory.UserWs), kChoosePhonologicaFeatures));*/ return match; }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) { return; } if (disposing) { // Dispose managed resources here. } // Dispose unmanaged resources here, whether disposing is true or false. m_popupTree = null; // It is disposed of elsewhere. m_isDisposed = true; }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { int tagName = UseAbbr ? CmPossibilityTags.kflidAbbreviation : CmPossibilityTags.kflidName; popupTree.Sorted = true; TreeNode match = null; if (List != null) match = AddNodes(popupTree.Nodes, List.Hvo, CmPossibilityListTags.kflidPossibilities, hvoTarget, tagName); popupTree.Sorted = false; // Add two special nodes used to: // 1. Set the value to 'empty', or // 2. Launch the new Grammatical Category Catalog dlg. AddTimberLine(popupTree); var empty = m_fNotSureIsAny ? AddAnyItem(popupTree) : AddNotSureItem(popupTree); if (hvoTarget == 0) match = empty; AddMoreItem(popupTree); return match; }
/// <summary> /// Constructor. /// </summary> public POSPopupTreeManager(PopupTree popupTree, FdoCache cache, ICmPossibilityList list, int ws, bool useAbbr, Mediator mediator, Form parent) : base(popupTree, cache, mediator, list, ws, useAbbr, parent) { }
/// <summary> /// /// </summary> /// <param name="popupTree"></param> /// <param name="hvoTarget"></param> /// <returns>the node matching hvoTarget, if found</returns> protected TreeNode AddPossibilityListItems(PopupTree popupTree, int hvoTarget) { int tagName = UseAbbr ? (int)CmPossibility.CmPossibilityTags.kflidAbbreviation : (int)CmPossibility.CmPossibilityTags.kflidName; TreeNode match = null; try { // detect whether this possibility list is (to be) sorted. popupTree.Sorted = List.IsSorted; match = AddNodes(popupTree.Nodes, List.Hvo, (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities, hvoTarget, tagName); } finally { // now allow subsequent items to get added, but not necessarily sorted. popupTree.Sorted = false; } return match; }
/// <summary> /// Add an 'Any' item to the menu. If the current target is zero, it will be selected. /// It is saved as m_kEmptyNode. Also returns the new node. /// </summary> /// <param name="popupTree"></param> /// <param name="hvoTarget"></param> /// <returns></returns> protected TreeNode AddAnyItem(PopupTree popupTree) { HvoTreeNode empty = new HvoTreeNode( Cache.TsStrFactory.MakeString(LexTextControls.ksAny, Cache.WritingSystemFactory.UserWs), kEmpty); popupTree.Nodes.Add(empty); m_kEmptyNode = empty; return empty; }
/// <summary>Constructor for filter object</summary> public FwPopupMessageFilter(PopupTree popupTree) { m_popupTree = popupTree; }
/// <summary> /// Add a 'More...' item to the tree. Subclass is responsible to implement. /// </summary> /// <param name="popupTree"></param> protected void AddMoreItem(PopupTree popupTree) { popupTree.Nodes.Add(new HvoTreeNode(Cache.MakeUserTss(LexTextControls.ksMore_), kMore)); }
/// <summary>Constructor for filter object</summary> public FwPopupMessageFilter(PopupTree popupTree) { m_popupTree = popupTree; }
public override void SetupCombo() { CheckDisposed(); m_tree = new PopupTree(); // Try a bigger size here only for Sandbox POS editing (GordonM) [LT-7529] // Enhance: It would be better to know what size we need for the data, // but it gets displayed before we know what data goes in it! // PopupTree.DefaultSize was (120, 200) m_tree.Size = new Size(180, 220); m_tree.Load += new EventHandler(m_tree_Load); // Handle AfterSelect events through POSPopupTreeManager in m_tree_Load(). }
/// <summary> /// NOTE that this implementation IGNORES hvoTarget and selects the MSA indicated by the sense. /// </summary> /// <param name="popupTree"></param> /// <param name="hvoTarget"></param> /// <returns></returns> protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { Debug.Assert(m_sense != null); hvoTarget = m_sense.MorphoSyntaxAnalysisRA == null ? 0 : m_sense.MorphoSyntaxAnalysisRA.Hvo; TreeNode match = null; ITsStrFactory tsf = Cache.TsStrFactory; bool fStem = m_sense.GetDesiredMsaType() == MsaType.kStem; if (fStem /*m_sense.Entry.MorphoSyntaxAnalysesOC.Count != 0*/) { // We want the order to be: // 1. current msa items // 2. possible Parts of Speech // 3. "not sure" items // We also want the Parts of Speech to be sorted, but not the whole tree. // First add the part of speech items (which may be a tree...). int tagName = CmPossibilityTags.kflidName; // make sure they are sorted popupTree.Sorted = true; AddNodes(popupTree.Nodes, List.Hvo, CmPossibilityListTags.kflidPossibilities, 0, tagName); // reset the sorted flag - we only want the parts of speech to be sorted. popupTree.Sorted = false; // Remember the (sorted) nodes in an array (so we can use the AddRange() method). TreeNode[] posArray = new TreeNode[popupTree.Nodes.Count]; popupTree.Nodes.CopyTo(posArray, 0); // now clear out the nodes so we can get the order we want popupTree.Nodes.Clear(); // Add the existing MSA items for the sense's owning entry. foreach (var msa in m_sense.Entry.MorphoSyntaxAnalysesOC) { HvoTreeNode node = AddTreeNodeForMsa(popupTree, tsf, msa); if (msa.Hvo == hvoTarget) match = node; } AddTimberLine(popupTree); // now add the sorted parts of speech popupTree.Nodes.AddRange(posArray); AddTimberLine(popupTree); // 1. "<Not Sure>" to produce a negligible Msa reference. // 2. "More..." command to launch category chooser dialog. TreeNode empty = AddNotSureItem(popupTree); if (match == null) match = empty; AddMoreItem(popupTree); } else { int cMsa = m_sense.Entry.MorphoSyntaxAnalysesOC.Count; if (cMsa == 0) { // 1. "<Not Sure>" to produce a negligible Msa reference. // 2. "Specify..." command. //Debug.Assert(hvoTarget == 0); match = AddNotSureItem(popupTree); popupTree.Nodes.Add(new HvoTreeNode(Cache.TsStrFactory.MakeString(m_sSpecifyGramFunc, Cache.WritingSystemFactory.UserWs), kCreate)); } else { // 1. Show the current Msa at the top. // 2. "Modify ..." command. // 3. Show other existing Msas next (if any). // 4. <Not Sure> to produce a negligible Msa reference. // 5. "Specify different..." command. hvoTarget = 0; // We should always have an MSA assigned to every sense, but sometimes this // hasn't happened. Don't crash if the data isn't quite correct. See FWR-3090. if (m_sense.MorphoSyntaxAnalysisRA != null) hvoTarget = m_sense.MorphoSyntaxAnalysisRA.Hvo; if (hvoTarget != 0) { ITsString tssLabel = m_sense.MorphoSyntaxAnalysisRA.InterlinearNameTSS; HvoTreeNode node = new HvoTreeNode(tssLabel, hvoTarget); popupTree.Nodes.Add(node); match = node; popupTree.Nodes.Add(new HvoTreeNode(Cache.TsStrFactory.MakeString(m_sModifyGramFunc, Cache.WritingSystemFactory.UserWs), kModify)); AddTimberLine(popupTree); } int cMsaExtra = 0; foreach (var msa in m_sense.Entry.MorphoSyntaxAnalysesOC) { if (msa.Hvo == hvoTarget) continue; ITsString tssLabel = msa.InterlinearNameTSS; HvoTreeNode node = new HvoTreeNode(tssLabel, msa.Hvo); popupTree.Nodes.Add(node); ++cMsaExtra; } if (cMsaExtra > 0) AddTimberLine(popupTree); // Per final decision on LT-5084, don't want <not sure> for affixes. //TreeNode empty = AddNotSureItem(popupTree, hvoTarget); //if (match == null) // match = empty; popupTree.Nodes.Add(new HvoTreeNode(Cache.TsStrFactory.MakeString(m_sSpecifyDifferent, Cache.WritingSystemFactory.UserWs), kCreate)); } } return match; }
/// <summary> /// Add the --- line to the popup (use if adding any 'extra' items). /// </summary> /// <param name="popupTree"></param> protected void AddTimberLine(PopupTree popupTree) { popupTree.Nodes.Add(new HvoTreeNode(Cache.TsStrFactory.MakeString(TimberLine, Cache.WritingSystemFactory.UserWs), kLine)); }
protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget) { TreeNode match1 = AddPossibilityListItems(popupTree, hvoTarget); TreeNode match2 = AppendAdditionalItems(popupTree, hvoTarget); return match1 ?? match2; }
/// <summary> /// Add the --- line to the popup (use if adding any 'extra' items). /// </summary> /// <param name="popupTree"></param> protected void AddTimberLine(PopupTree popupTree) { popupTree.Nodes.Add(new HvoTreeNode(Cache.MakeUserTss(TimberLine), kLine)); }
/// <summary> /// Add a 'not sure' item to the menu. If the current target is zero, it will be selected. /// It is saved as m_kEmptyNode. Also returns the new node. /// </summary> /// <param name="popupTree"></param> /// <param name="hvoTarget"></param> /// <returns></returns> protected TreeNode AddNotSureItem(PopupTree popupTree, int hvoTarget) { HvoTreeNode empty = new HvoTreeNode(Cache.MakeUserTss(LexTextControls.ks_NotSure_), kEmpty); popupTree.Nodes.Add(empty); m_kEmptyNode = empty; return empty; }
/// <summary> /// Make all the menu items. May well call things like AddTimberline, AddNotSureItem, AddMoreItem. /// </summary> /// <param name="popupTree"></param> /// <param name="hvoTarget"></param> /// <returns></returns> protected abstract TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget);
/// <summary> /// Construct one. /// </summary> public TreeCombo() { this.SuspendLayout(); // Set this box's own properties (first, as we use some of them in figuring the // size of other things). // Make and install the ComboTextBox m_comboTextBox = new ComboTextBox(this); m_comboTextBox.AccessibleName = "TextBox"; m_comboTextBox.Dock = DockStyle.Fill; m_comboTextBox.Visible = true; // Don't allow typing or pasting into the text box: see LT-6595. m_comboTextBox.ReadOnlyView = true; // These two lines causes us to get a notification when the string gets changed, // so we can fire our TextChanged event. m_sda = m_comboTextBox.DataAccess; m_sda.AddNotification(this); m_comboTextBox.MouseDown += new MouseEventHandler(m_comboTextBox_MouseDown); m_comboTextBox.KeyPress += new KeyPressEventHandler(m_comboTextBox_KeyPress); m_comboTextBox.KeyDown += new KeyEventHandler(m_comboTextBox_KeyDown); m_comboTextBox.GotFocus += new EventHandler(m_comboTextBox_GotFocus); m_comboTextBox.LostFocus += new EventHandler(m_comboTextBox_LostFocus); m_textBoxPanel = new Panel(); m_textBoxPanel.AccessibleName = "TextBoxPanel"; m_textBoxPanel.Dock = DockStyle.Fill; m_textBoxPanel.BackColor = Color.Transparent; m_textBoxPanel.Controls.Add(m_comboTextBox); this.Controls.Add(m_textBoxPanel); // Make and install the button that pops up the list. m_button = new DropDownButton(this); m_button.AccessibleName = "DropDownButton"; m_button.Dock = DockStyle.Right; // Enhance JohnT: Left if RTL language? //m_button.FlatStyle = FlatStyle.Flat; // no raised edges etc for this button. m_button.MouseDown += new MouseEventHandler(m_button_MouseDown); m_button.GotFocus += new EventHandler(m_button_GotFocus); m_button.LostFocus += new EventHandler(m_button_LostFocus); m_button.TabStop = false; m_buttonPanel = new Panel(); m_buttonPanel.AccessibleName = "DropDownButtonPanel"; m_buttonPanel.Dock = DockStyle.Right; m_buttonPanel.BackColor = Color.Transparent; m_buttonPanel.Controls.Add(m_button); this.Controls.Add(m_buttonPanel); HasBorder = true; Padding = new Padding(Application.RenderWithVisualStyles ? 2 : 1); base.BackColor = SystemColors.Window; m_buttonPanel.Width = m_button.PreferredWidth + m_buttonPanel.Padding.Horizontal; // Create the list. m_popupTree = new PopupTree(); m_popupTree.TabStopControl = m_comboTextBox; //m_tree.SelectedIndexChanged += new EventHandler(m_listBox_SelectedIndexChanged); //m_listBox.SameItemSelected += new EventHandler(m_listBox_SameItemSelected); m_popupTree.AfterSelect += new TreeViewEventHandler(m_tree_AfterSelect); m_popupTree.BeforeSelect += new TreeViewCancelEventHandler(m_popupTree_BeforeSelect); m_popupTree.Load += new EventHandler(m_tree_Load); m_popupTree.PopupTreeClosed += new TreeViewEventHandler(m_popupTree_PopupTreeClosed); m_popupTree.VisibleChanged += new EventHandler(m_popupTree_VisibleChanged); this.ResumeLayout(); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. if (m_pOSPopupTreeManager != null) { m_pOSPopupTreeManager.AfterSelect -= new TreeViewEventHandler(m_pOSPopupTreeManager_AfterSelect); m_pOSPopupTreeManager.Dispose(); } if (m_tree != null) { m_tree.Load -= new EventHandler(m_tree_Load); m_tree.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_pOSPopupTreeManager = null; m_tree = null; base.Dispose(disposing); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; // m_sda COM object block removed due to crash in Finializer thread LT-6124 if (disposing) { if (m_button != null) { m_button.MouseDown -= new MouseEventHandler(m_button_MouseDown); m_button.GotFocus -= new EventHandler(m_button_GotFocus); m_button.LostFocus -= new EventHandler(m_button_LostFocus); } if (m_sda != null) m_sda.RemoveNotification(this); if (m_comboTextBox != null) { m_comboTextBox.KeyPress -= new KeyPressEventHandler(m_comboTextBox_KeyPress); m_comboTextBox.KeyDown -= new KeyEventHandler(m_comboTextBox_KeyDown); m_comboTextBox.MouseDown -= new MouseEventHandler(m_comboTextBox_MouseDown); m_comboTextBox.GotFocus -= new EventHandler(m_comboTextBox_GotFocus); m_comboTextBox.LostFocus -= new EventHandler(m_comboTextBox_LostFocus); } if (m_popupTree != null) { m_popupTree.AfterSelect -= new TreeViewEventHandler(m_tree_AfterSelect); m_popupTree.BeforeSelect -= new TreeViewCancelEventHandler(m_popupTree_BeforeSelect); m_popupTree.Load -= new EventHandler(m_tree_Load); m_popupTree.VisibleChanged -= new EventHandler(m_popupTree_VisibleChanged); } if (m_popupTree != null && !m_popupTree.IsDisposed) m_popupTree.Dispose(); } m_button = null; // So OnLayout knows to do nothing. m_comboTextBox = null; m_popupTree = null; m_sda = null; base.Dispose(disposing); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { // Dispose managed resources here. if (m_treeCombo != null && !m_treeCombo.IsDisposed) { m_treeCombo.BeforeSelect -= new TreeViewCancelEventHandler(m_treeCombo_BeforeSelect); m_treeCombo.AfterSelect -= new TreeViewEventHandler(m_treeCombo_AfterSelect); if (m_treeCombo.Tree != null) m_treeCombo.Tree.PopupTreeClosed -= new TreeViewEventHandler(popupTree_PopupTreeClosed); // We only manage m_treeCombo, so it gets disposed elsewhere. } if (m_popupTree != null) { m_popupTree.BeforeSelect -= new TreeViewCancelEventHandler(m_treeCombo_BeforeSelect); m_popupTree.AfterSelect -= new TreeViewEventHandler(m_treeCombo_AfterSelect); m_popupTree.PopupTreeClosed -= new TreeViewEventHandler(popupTree_PopupTreeClosed); // We only manage m_popupTree, so it gets disposed elsewhere. } } // Dispose unmanaged resources here, whether disposing is true or false. m_lastConfirmedNode = null; m_kEmptyNode = null; m_treeCombo = null; m_popupTree = null; m_parent = null; m_cache = null; m_list = null; m_isDisposed = true; }
/// <summary> /// override to add additional nodes to popupTree (e.g. AddNotSureItem, AddTimberline) /// </summary> protected virtual TreeNode AppendAdditionalItems(PopupTree popupTree, int hvoTarget) { return null; // subclasses override. }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + " ******************"); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { // Dispose managed resources here. } // Dispose unmanaged resources here, whether disposing is true or false. m_popupTree = null; // It is disposed of elsewhere. m_isDisposed = true; }
/// <summary> /// Select the specified menu item in the tree. /// </summary> /// <param name="item"></param> /// <param name="popupTree"></param> protected void SelectChosenItem(TreeNode item, PopupTree popupTree) { CheckDisposed(); if (item != null) { // Simulate a mouse click so that TextBox gets updated. popupTree.SelectByAction = TreeViewAction.ByMouse; popupTree.SelectedNode = item; } }
private HvoTreeNode AddTreeNodeForMsa(PopupTree popupTree, ITsStrFactory tsf, IMoMorphSynAnalysis msa) { // JohnT: as described in LT-4633, a stem can be given an allomorph that // is an affix. So we need some sort of way to handle this. //Debug.Assert(msa is MoStemMsa); ITsString tssLabel = msa.InterlinearNameTSS; if (msa is IMoStemMsa && (msa as IMoStemMsa).PartOfSpeechRA == null) tssLabel = tsf.MakeString( m_sUnknown, Cache.ServiceLocator.WritingSystemManager.UserWs); var node = new HvoTreeNode(tssLabel, msa.Hvo); popupTree.Nodes.Add(node); return node; }
/// <summary> /// Construct one. /// </summary> public TreeCombo() { this.SuspendLayout(); // Set this box's own properties (first, as we use some of them in figuring the // size of other things). // Make and install the ComboTextBox m_comboTextBox = new ComboTextBox(this); m_comboTextBox.AccessibleName = "TextBox"; m_comboTextBox.Dock = DockStyle.Fill; m_comboTextBox.Visible = true; // Don't allow typing or pasting into the text box: see LT-6595. m_comboTextBox.ReadOnlyView = true; // These two lines causes us to get a notification when the string gets changed, // so we can fire our TextChanged event. m_sda = m_comboTextBox.DataAccess; m_sda.AddNotification(this); m_comboTextBox.MouseDown += new MouseEventHandler(m_comboTextBox_MouseDown); m_comboTextBox.KeyPress += new KeyPressEventHandler(m_comboTextBox_KeyPress); m_comboTextBox.KeyDown += new KeyEventHandler(m_comboTextBox_KeyDown); m_comboTextBox.GotFocus += new EventHandler(m_comboTextBox_GotFocus); m_comboTextBox.LostFocus += new EventHandler(m_comboTextBox_LostFocus); m_textBoxPanel = new Panel(); m_textBoxPanel.AccessibleName = "TextBoxPanel"; m_textBoxPanel.Dock = DockStyle.Fill; m_textBoxPanel.BackColor = Color.Transparent; m_textBoxPanel.Controls.Add(m_comboTextBox); this.Controls.Add(m_textBoxPanel); // Make and install the button that pops up the list. m_button = new DropDownButton(this); m_button.AccessibleName = "DropDownButton"; m_button.Dock = DockStyle.Right; // Enhance JohnT: Left if RTL language? //m_button.FlatStyle = FlatStyle.Flat; // no raised edges etc for this button. m_button.MouseDown += new MouseEventHandler(m_button_MouseDown); m_button.GotFocus += new EventHandler(m_button_GotFocus); m_button.LostFocus += new EventHandler(m_button_LostFocus); m_button.TabStop = false; m_buttonPanel = new Panel(); m_buttonPanel.AccessibleName = "DropDownButtonPanel"; m_buttonPanel.Dock = DockStyle.Right; m_buttonPanel.BackColor = Color.Transparent; m_buttonPanel.Controls.Add(m_button); this.Controls.Add(m_buttonPanel); HasBorder = true; Padding = new Padding(Application.RenderWithVisualStyles ? 2 : 1); base.BackColor = SystemColors.Window; m_buttonPanel.Width = m_button.PreferredWidth + m_buttonPanel.Padding.Horizontal; // Create the list. m_popupTree = new PopupTree(); m_popupTree.TabStopControl = m_comboTextBox; //m_tree.SelectedIndexChanged += new EventHandler(m_listBox_SelectedIndexChanged); //m_listBox.SameItemSelected += new EventHandler(m_listBox_SameItemSelected); m_popupTree.AfterSelect += new TreeViewEventHandler(m_tree_AfterSelect); m_popupTree.BeforeSelect += new TreeViewCancelEventHandler(m_popupTree_BeforeSelect); m_popupTree.Load += new EventHandler(m_tree_Load); m_popupTree.PopupTreeClosed += new TreeViewEventHandler(m_popupTree_PopupTreeClosed); m_popupTree.VisibleChanged += new EventHandler(m_popupTree_VisibleChanged); this.ResumeLayout(); }