private void FindComboKeyPress(object sender, KeyPressEventArgs e)
        {
            if (m_findDropDown.Items.Count == 2)
            {
                m_findDropDown.Items.RemoveAt(1);
            }

            if (e.KeyChar != '\r' || string.IsNullOrEmpty(m_cboFind.Text))
            {
                return;
            }

            e.Handled = true;

            if (m_cboFind.SelectedIndex < 0)
            {
                m_cboFind.Items.Add(m_cboFind.Text);
            }
            KeyTermsTree tree = (KeyTermsTree)MainPanelContent;

            KeyTermsTree.FindResult result = tree.FindNextMatch(m_cboFind.Text);
            if (result == KeyTermsTree.FindResult.MatchFound)
            {
                m_findDropDown.Hide();
            }
            else
            {
                ToolStripLabel msg = new ToolStripLabel(result == KeyTermsTree.FindResult.NoMatchFound ?
                                                        Properties.Resources.kstidNoMatchFound : Properties.Resources.kstidNoMoreMatches);
                msg.ForeColor = Color.Red;
                m_findDropDown.Items.Add(msg);
            }
        }
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Load settings
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        protected override void OnLoadSettings(RegistryKey key)
        {
            if (key != null)
            {
                KeyTermsTree tree = MainPanelContent as KeyTermsTree;
                if (tree == null)
                {
                    return;
                }

                Guid guid = Guid.Empty;
                try
                {
                    guid = new Guid((string)key.GetValue("SelectedKeyTerm", string.Empty));
                }
                catch
                {
                }
                TreeNode node = tree.FindNode(guid);
                if (node != null)
                {
                    tree.SelectedNode = node;
                }
            }

            base.OnLoadSettings(key);
        }
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Save settings
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        protected override void OnSaveSettings(RegistryKey key)
        {
            KeyTermsTree tree = MainPanelContent as KeyTermsTree;

            if (tree != null && tree.SelectedNode != null && tree.SelectedNode.Tag != null &&
                tree.SelectedNode.Tag is IChkTerm)
            {
                key.SetValue("SelectedKeyTerm", ((IChkTerm)tree.SelectedNode.Tag).Guid);
            }
            base.OnSaveSettings(key);
        }
Example #4
0
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Save settings
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        protected override void OnSaveSettings(RegistryKey key)
        {
            KeyTermsTree tree = Content as KeyTermsTree;

            if (tree != null && tree.SelectedNode != null && tree.SelectedNode.Tag != null &&
                tree.SelectedNode.Tag.GetType() == typeof(int))
            {
                key.SetValue("SelectedKeyTermHvo", (int)tree.SelectedNode.Tag);
            }
            base.OnSaveSettings(key);
        }
Example #5
0
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Load settings
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        protected override void OnLoadSettings(RegistryKey key)
        {
            if (key != null)
            {
                KeyTermsTree tree = Content as KeyTermsTree;
                if (tree == null)
                {
                    return;
                }

                int      hvo  = (int)key.GetValue("SelectedKeyTermHvo", -1);
                TreeNode node = tree.FindNodeWithHvo(hvo);
                if (node != null)
                {
                    tree.SelectedNode = node;
                }
            }

            base.OnLoadSettings(key);
        }
Example #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes this instance.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void Initialize()
		{
			if (m_fShownBefore)
				return;

			// Need to create all the views
			ICmPossibilityList keyTermsList = m_cache.LangProject.KeyTermsList;

			// Create a key terms tree view
			m_ktTree = new KeyTermsTree(DisplayUI);
			m_ktTree.KeyTermsList = keyTermsList;
			m_ktTree.Dock = DockStyle.Fill;
			m_ktTree.AfterSelect += ktTree_AfterSelect;

			base.Initialize();

			if (m_ktTree.Nodes.Count == 0)
				ApplyBookFilterToKeyTermsTree();
		}
Example #7
0
		/// ------------------------------------------------------------------------------------
		/// <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">true to release both managed and unmanaged resources; false to release only unmanaged resources.</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.
				// m_ktTree is added to the Controls collection of the panel and will be
				// disposed there from the base class.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_ktTree = null;

			base.Dispose(disposing);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes this instance.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void Initialize()
		{
			if (m_fShownBefore)
				return;

			// Create a key terms tree view
			m_ktTree = new KeyTermsTree(m_cache.LangProject.KeyTermsList);
			m_ktTree.AfterSelect += ktTree_AfterSelect;
			m_ktTree.GetFontForWs = (ws =>
				{
					if (m_stylesheet == null) // Probably in tests
						return m_ktTree.Font;
					Font f;
					if (!m_wsFonts.TryGetValue(ws, out f))
					{
						f = m_stylesheet.GetUiFontForWritingSystem(ws, 0);
						if (f.FontFamily.Name == m_ktTree.Font.FontFamily.Name)
						{
							// This writing system uses the same font as the control was going to use anyway,
							// so just use that font (this avoids overriding the font size so our UI is more
							// consistent).
							f.Dispose();
							f = m_ktTree.Font;
						}
						m_wsFonts[ws] = f;
					}
					return f;
				});

			base.Initialize();

			if (m_ktTree.Nodes.Count == 0)
				ApplyBookFilterToKeyTermsTree();
		}