FwListBox is a simulation of a regular Windows.Forms.ListBox. It has much the same interface, though not all events and properties are yet supported. There are two main differences: (1) It is implemented using FieldWorks Views, and hence can render Graphite fonts properly. (2) Item labels can be TsStrings, in which case, formatting of items can vary based on the properties of string runs. To get this behavior, you can (a) Let the items actually be ITsStrings. (b) Let the items implement the SIL.FieldWorks.FDO.ITssValue interface, which has just one property, public ITsString AsTss {get;} You must also pass your writing system factory to the FwListBox (set the WritingSystemFactory property). Otherwise, the combo box will not be able to interpret the writing systems of any TsStrings it is asked to display. It will improve performance to do this even if you are not using TsString data.
Inheritance: System.Windows.Forms.Panel, IFWDisposable, IVwNotifyChange
Exemplo n.º 1
0
		public void Remove_CollectionWithSingleElement_CollectionShouldBeEmpty()
		{
			using (var listBox = new FwListBox())
			{
				using (var collection = new FwListBox.ObjectCollection(listBox))
				{
					ITsString testString = TsStringHelper.MakeTSS("test", m_hvoEnglishWs);
					collection.Add(testString);

					// The Test
					collection.Remove(testString);

					Assert.AreEqual(0, collection.Count);
					Assert.IsFalse(collection.Contains(testString));
				}
			}
		}
Exemplo n.º 2
0
		public void Add_EmptyObjectCollection_CollectionContainsSingleElement()
		{

			using (var listBox = new FwListBox())
			{

				using (var collection = new FwListBox.ObjectCollection(listBox))
				{
					ITsString testString = TsStringHelper.MakeTSS("test", m_hvoEnglishWs);

					// The Test
					collection.Add(testString);

					Assert.AreEqual(1, collection.Count);
					Assert.IsTrue(collection.Contains(testString));
				}
			}
	}
Exemplo n.º 3
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, "****************** " + GetType().Name + " 'disposing' is false. ******************");
				// Must not be run more than once.
				if (m_isDisposed)
					return;

				if (disposing)
				{
					// Dispose managed resources here.
					Clear();
				}

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

				m_isDisposed = true;
			}
Exemplo n.º 4
0
			/// ------------------------------------------------------------------------------------
			/// <summary>
			/// Construct with supplied initial items.
			/// </summary>
			/// <param name="owner"></param>
			/// <param name="values"></param>
			/// ------------------------------------------------------------------------------------
			public ObjectCollection(FwListBox owner, ObjectCollection values)
			{
				m_list = new ArrayList(values);
				m_owner = owner;
			}
Exemplo n.º 5
0
			/// ------------------------------------------------------------------------------------
			/// <summary>
			/// Construct empty.
			/// </summary>
			/// <param name="owner"></param>
			/// ------------------------------------------------------------------------------------
			public ObjectCollection(FwListBox owner)
			{
				m_list = new ArrayList();
				m_owner = owner;
			}
Exemplo n.º 6
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;

			base.Dispose(disposing);

			if (disposing)
			{
				// Cleanup managed stuff here.
				if (m_vc != null)
					m_vc.Dispose();
			}
			// Cleanup unmanaged stuff here.
			m_DataAccess = null;
			if (m_CacheDa != null)
			{
				m_CacheDa.ClearAllData();
				if (Marshal.IsComObject(m_CacheDa))
					Marshal.ReleaseComObject(m_CacheDa);
				m_CacheDa = null;
			}
			m_owner = null; // It will get disposed on its own, if it hasn't been already.
			m_vc = null;
		}
Exemplo n.º 7
0
		/// <summary>
		/// Constructor
		/// </summary>
		internal InnerFwListBox(FwListBox owner)
		{
			m_owner = owner;
			m_CacheDa = VwCacheDaClass.Create();
			m_DataAccess = (ISilDataAccess)m_CacheDa;
			// So many things blow up so badly if we don't have one of these that I finally decided to just
			// make one, even though it won't always, perhaps not often, be the one we want.
			m_wsf = LgWritingSystemFactoryClass.Create();
			m_DataAccess.WritingSystemFactory = WritingSystemFactory;
			this.VScroll = true;
			this.AutoScroll = true;
		}
Exemplo n.º 8
0
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Cleanup managed stuff here.
				if (m_cacheDa != null)
					m_cacheDa.ClearAllData();
			}
			// Cleanup unmanaged stuff here.
			m_dataAccess = null;
			if (m_cacheDa != null)
			{
				if (Marshal.IsComObject(m_cacheDa))
					Marshal.ReleaseComObject(m_cacheDa);
				m_cacheDa = null;
			}
			m_owner = null; // It will get disposed on its own, if it hasn't been already.
			m_vc = null;

			base.Dispose(disposing);
		}
Exemplo n.º 9
0
		public void IsHighlighted_CollectionWithSingleElement_ReturnsTrue()
		{
			using (var listBox = new FwListBox())
			{
					using (var innerFwListBox = new InnerFwListBox(listBox))
					{
						ITsString testString1 = TsStringHelper.MakeTSS("test1", m_hvoEnglishWs);
						listBox.Items.Add(testString1);
						innerFwListBox.MakeRoot();
						listBox.HighlightedIndex = 0;

						// The Test
						Assert.AreEqual(true, innerFwListBox.IsHighlighted(0));
					}
			}
		}
Exemplo n.º 10
0
		public void IsHighlighted_EmptyFwListBox_ReturnsFalse()
		{
			using (var listBox = new FwListBox())
			{
				using (var innerFwListBox = new InnerFwListBox(listBox))
				{
					// The Test
					Assert.AreEqual(false, innerFwListBox.IsHighlighted(0));
				}
			}
		}
Exemplo n.º 11
0
		public void SetShowHighlight_EmptyFwListBox_ShouldBeSetToFalse()
		{
			using (var listBox = new FwListBox())
			{
				using (var innerFwListBox = new InnerFwListBox(listBox))
				{
					// The Test
					innerFwListBox.ShowHighlight = false;
					Assert.AreEqual(false, innerFwListBox.ShowHighlight);
				}
			}
		}
Exemplo n.º 12
0
		public void ShowHighlight_EmptyFwListBox_ReturnsTrue()
		{
			using (var listBox = new FwListBox())
			{
				using (var innerFwListBox = new InnerFwListBox(listBox))
				{
					// The Test
					Assert.AreEqual(true, innerFwListBox.ShowHighlight);
				}
			}
		}
Exemplo n.º 13
0
		public void WritingSystemCode_EmptyFwListBox_DoesNotThrowException()
		{
			using (var listBox = new FwListBox())
			{
				using (var innerFwListBox = new InnerFwListBox(listBox))
				{
					// The Test
					Assert.GreaterOrEqual(innerFwListBox.WritingSystemCode, 0);
				}
			}
		}
Exemplo n.º 14
0
		public void SetIndex_CollectionWithSingleElement_ValueShouldHaveChanged()
		{
			using (var listBox = new FwListBox())
			{
				using (var collection = new FwListBox.ObjectCollection(listBox))
				{
					ITsString testString1 = TsStringHelper.MakeTSS("test1", m_hvoEnglishWs);
					ITsString testString2 = TsStringHelper.MakeTSS("test2", m_hvoEnglishWs);
					collection.Add(testString1);

					// The Test
					collection[0] = testString2;

					Assert.AreEqual(1, collection.Count);
					Assert.IsFalse(collection.Contains(testString1));
					Assert.IsTrue(collection.Contains(testString2));
				}
			}
		}