A "Combo" list box is one that can launch itself as a stand-alone, yet modal window, like the drop-down list in a Combo. It can also be used for other drop-down lists, for example, from an icon button. It is displayed using the Launch method. It is automatically hidden if the user clicks outside it (and the click is absorbed in the process). The item the user is hovering over is highlighted.
Inheritance: FwListBox, IComboList, IDropDownBox
Ejemplo n.º 1
0
		public PossibilityAutoComplete(FdoCache cache, Mediator mediator, ICmPossibilityList list, Control control,
			string displayNameProperty, string displayWs)
		{
			m_cache = cache;
			m_mediator = mediator;
			m_control = control;
			m_displayNameProperty = displayNameProperty;
			m_displayWs = displayWs;

			m_listBox = new ComboListBox {DropDownStyle = ComboBoxStyle.DropDownList, ActivateOnShow = false};
			m_listBox.SelectedIndexChanged += HandleSelectedIndexChanged;
			m_listBox.SameItemSelected += HandleSameItemSelected;
			m_listBox.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			m_listBox.WritingSystemFactory = cache.WritingSystemFactory;
			m_searcher = new StringSearcher<ICmPossibility>(SearchType.Prefix, cache.ServiceLocator.WritingSystemManager);
			m_possibilities = new List<ICmPossibility>();
			var stack = new Stack<ICmPossibility>(list.PossibilitiesOS);
			while (stack.Count > 0)
			{
				ICmPossibility poss = stack.Pop();
				m_possibilities.Add(poss);
				foreach (ICmPossibility child in poss.SubPossibilitiesOS)
					stack.Push(child);
			}

			m_control.KeyDown += HandleKeyDown;
			m_control.KeyPress += HandleKeyPress;
		}
Ejemplo n.º 2
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"></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_comboListbox = null; // It is disposed of elsewhere.

			m_isDisposed = true;
		}
Ejemplo n.º 3
0
		private bool m_fGotMouseDown; // true after a mouse down occurs anywhere at all.

		/// <summary>Constructor for filter object</summary>
		public FwComboMessageFilter(ComboListBox comboListbox)
		{
			m_comboListbox = comboListbox;
		}
Ejemplo n.º 4
0
		/// <summary>
		/// Creates the drop down box.
		/// </summary>
		/// <returns></returns>
		protected override IDropDownBox CreateDropDownBox()
		{
			// Create the list.
			var comboListBox = new ComboListBox();
			comboListBox.LaunchButton = m_button;	// set the button for processing
			comboListBox.SelectedIndexChanged += m_listBox_SelectedIndexChanged;
			comboListBox.SameItemSelected += m_listBox_SameItemSelected;
			comboListBox.TabStopControl = m_comboTextBox;
			return comboListBox;
		}
			private static IComboHandler MakeCombo(IHelpTopicProvider helpTopicProvider,
				int tagComboIcon, SandboxBase sandbox, int hvoMorph, SelLevInfo[] rgvsli, int hvoSelObject)
			{
				IVwRootBox rootb = sandbox.RootBox;
				int hvoSbWord = sandbox.RootWordHvo;
				InterlinComboHandler handler = null;
				CachePair caches = sandbox.Caches;
				switch (tagComboIcon)
				{
					case ktagMorphFormIcon:
						handler = new IhMorphForm();
						break;
					case ktagMorphEntryIcon:
						handler = new IhMorphEntry(helpTopicProvider);
						break;
					case ktagWordPosIcon:
						handler = new IhWordPos();
						break;
					case ktagAnalysisIcon:
						ComboListBox clb2 = new ComboListBox();
						clb2.StyleSheet = sandbox.StyleSheet;
						ChooseAnalysisHandler caHandler = new ChooseAnalysisHandler(
							caches.MainCache, hvoSbWord, sandbox.Analysis, clb2);
						caHandler.Owner = sandbox;
						caHandler.AnalysisChosen += new EventHandler(
							sandbox.Handle_AnalysisChosen);
						caHandler.SetupCombo();
						return caHandler;
					case ktagWordGlossIcon: // line 6, word gloss.
						if (sandbox.ShouldAddWordGlossToLexicon)
						{
							if (hvoMorph == 0)
							{
								// setup the first hvoMorph
								hvoMorph = caches.DataAccess.get_VecItem(kSbWord, ktagSbWordMorphs, 0);
							}
							handler = new IhLexWordGloss(helpTopicProvider);
						}
						else
						{
							handler = new IhWordGloss();
						}
						break;
					default:
						return null;
				}
				// Use the base class handler for most handlers. Override where needed.
				if (!(handler is IhWordPos))
				{
					ComboListBox clb = new ComboListBox();
					handler.m_comboList = clb;
					clb.SelectedIndexChanged += new EventHandler(
						handler.HandleComboSelChange);
					clb.SameItemSelected += new EventHandler(
						handler.HandleComboSelSame);
					// Since we may initialize with TsStrings, need to set WSF.
					handler.m_comboList.WritingSystemFactory =
						caches.MainCache.LanguageWritingSystemFactoryAccessor;
				}
				else
				{
					// REVIEW: Do we need to handle wsf for word POS combo?
				}
				handler.m_caches = caches;
				handler.m_hvoSelObject = hvoSelObject;
				handler.m_hvoSbWord = hvoSbWord;
				handler.m_hvoMorph = hvoMorph;
				handler.m_rgvsli = rgvsli;
				handler.m_rootb = rootb;
				handler.m_wsVern = sandbox.RawWordformWs;
				handler.m_wsAnal = caches.MainCache.DefaultAnalWs;
				handler.m_wsUser = caches.MainCache.DefaultUserWs;
				handler.m_sandbox = sandbox;
				handler.m_fUnderConstruction = true;
				handler.SetupCombo();
				if (handler.m_comboList != null)
					handler.m_comboList.StyleSheet = sandbox.StyleSheet;
				handler.m_fUnderConstruction = false;
				return handler;
			}
		private void LaunchFwContextMenu(Point ptLoc)
		{
			if (m_rgfmi == null || m_rgfmi.Count == 0)
				return;
			m_fConstructingMenu = true;
			if (m_clb == null)
			{
				m_clb = new ComboListBox();
				m_clb.SelectedIndexChanged += new EventHandler(HandleFwMenuSelection);
				m_clb.SameItemSelected += new EventHandler(HandleFwMenuSelection);
				// Since we may initialize with TsStrings, need to set WSF.
				m_clb.WritingSystemFactory = Cache.LanguageWritingSystemFactoryAccessor;
				m_clb.DropDownStyle = ComboBoxStyle.DropDownList; // Prevents direct editing.
				m_clb.StyleSheet = SIL.FieldWorks.Common.Widgets.FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
			}
			m_clb.Items.Clear();
			for (int i = 0; i < m_rgfmi.Count; ++i)
			{
				if (m_rgfmi[i].Enabled)
					m_clb.Items.Add(m_rgfmi[i].Label);
			}
			AdjustListBoxSize();
			m_clb.AdjustSize(500, 400); // these are maximums!
			m_clb.SelectedIndex = 0;
			Rectangle boundsLauncher = new Rectangle(ptLoc, new Size(10,10));
			Rectangle boundsScreen = Screen.GetWorkingArea(m_inflAffixTemplateCtrl);
			m_fConstructingMenu = false;
			m_clb.Launch(boundsLauncher, boundsScreen);
		}
		/// <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_clb != null)
				{
					m_clb.Dispose();
					m_clb = null;
				}
				m_rgfmi = null;
			}

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

			m_isDisposed = true;
		}
Ejemplo n.º 8
0
		/// <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.KeyDown -=new KeyEventHandler(m_button_KeyDown);
					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_comboListBox != null)
				{
					m_comboListBox.SelectedIndexChanged -= new EventHandler(m_listBox_SelectedIndexChanged);
					m_comboListBox.SameItemSelected -= new EventHandler(m_listBox_SameItemSelected);
					m_comboListBox.Form.VisibleChanged -= new EventHandler(Form_VisibleChanged);
					m_comboListBox.Dispose();
				}
			}
			m_sda = null;
			m_button = null;
			m_comboTextBox = null;
			m_comboListBox = null;
			if (m_tssPrevious != null)
			{
				Marshal.ReleaseComObject(m_tssPrevious);
				m_tssPrevious = null;
			}

			base.Dispose(disposing);
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Construct one.
		/// </summary>
		public FwComboBox()
		{
			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;

			// This 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.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);
			m_comboTextBox.TabIndex = 1;
			m_comboTextBox.TabStop = true;

			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.TabStop = false;

			//m_button.FlatStyle = FlatStyle.Flat; // no raised edges etc for this button.
			////			m_button.Click += new EventHandler(m_button_Click);

			m_button.MouseDown += new MouseEventHandler(m_button_MouseDown);
			m_button.KeyDown += new KeyEventHandler(m_button_KeyDown);
			m_button.GotFocus += new EventHandler(m_button_GotFocus);
			m_button.LostFocus += new EventHandler(m_button_LostFocus);

			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_comboListBox = new ComboListBox();
			m_comboListBox.LaunchButton = m_button;	// set the button for processing
			m_comboListBox.SelectedIndexChanged += new EventHandler(m_listBox_SelectedIndexChanged);
			m_comboListBox.SameItemSelected += new EventHandler(m_listBox_SameItemSelected);
			m_comboListBox.Form.VisibleChanged += new EventHandler(Form_VisibleChanged);
			m_comboListBox.TabStopControl = m_comboTextBox;

			this.ResumeLayout();
		}