Exemplo n.º 1
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 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_menuHandler != null)
					m_menuHandler.Dispose();
			}

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

			base.Dispose(disposing);
		}
Exemplo n.º 2
0
        /// <summary>
        /// factory method which creates the correct subclass based on the XML parameters
        /// </summary>
        /// <param name="inflAffixTemplateCtrl"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static InflAffixTemplateMenuHandler Create(InflAffixTemplateControl inflAffixTemplateCtrl, XmlNode configuration)
        {
            InflAffixTemplateMenuHandler h = null;

            if (configuration != null)
            {
                XmlNode node = configuration.SelectSingleNode("menuHandler");
                if (node != null)
                {
                    h = (InflAffixTemplateMenuHandler)SIL.Utils.DynamicLoader.CreateObject(node);
                }
            }
            if (h == null)                              //no class specified, so just returned a generic InflAffixTemplateControl
            {
                h = new InflAffixTemplateMenuHandler();
            }
            h.InflAffixTemplate = inflAffixTemplateCtrl;
            return(h);
        }
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 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_menuHandler != null)
                {
                    m_menuHandler.Dispose();
                }
            }

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

            base.Dispose(disposing);
        }
Exemplo n.º 4
0
		/// <summary>
		/// Therefore this method, called once we have a cache and object, is our first chance to
		/// actually create the embedded control.
		/// </summary>
		public override void FinishInit()
		{
			CheckDisposed();
			IWritingSystemContainer wsContainer = Cache.ServiceLocator.WritingSystems;
			bool fVernRTL = wsContainer.DefaultVernacularWritingSystem.RightToLeftScript;
			bool fAnalRTL = wsContainer.DefaultAnalysisWritingSystem.RightToLeftScript;
			System.Xml.XmlAttribute xa = ConfigurationNode.Attributes["layout"];
			// To properly fix LT-6239, we need to consider all four mixtures of directionality
			// involving the vernacular (table) and analysis (slot name) writing systems.
			// These four possibilities are marked RTL, LTRinRTL, RTLinLTR, and <nothing>.
			if (fVernRTL && fAnalRTL)
			{
				if (xa.Value.EndsWith("RTLinLTR") || xa.Value.EndsWith("LTRinRTL"))
					xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
				if (!xa.Value.EndsWith("RTL"))
					xa.Value += "RTL";		// both vern and anal are RTL
			}
			else if (fVernRTL && !fAnalRTL)
			{
				if (xa.Value.EndsWith("RTLinLTR"))
					xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
				else if (xa.Value.EndsWith("RTL") && !xa.Value.EndsWith("LTRinRTL"))
					xa.Value = xa.Value.Substring(0, xa.Value.Length - 3);
				if (!xa.Value.EndsWith("LTRinRTL"))
					xa.Value += "LTRinRTL";		// LTR anal name in RTL vern table
			}
			else if (!fVernRTL && fAnalRTL)
			{
				if (xa.Value.EndsWith("LTRinRTL"))
					xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
				else if (xa.Value.EndsWith("RTL"))
					xa.Value = xa.Value.Substring(0, xa.Value.Length - 3);
				if (!xa.Value.EndsWith("RTLinLTR"))
					xa.Value += "RTLinLTR";		// RTL anal name in LTR vern table
			}
			else
			{
				if (xa.Value.EndsWith("RTLinLTR") || xa.Value.EndsWith("LTRinRTL"))
					xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
				else if (xa.Value.EndsWith("RTL"))
					xa.Value = xa.Value.Substring(0, xa.Value.Length - 3);
				// both vern and anal are LTR (unmarked case)
			}
			var ctrl = new InflAffixTemplateControl((FdoCache)Mediator.PropertyTable.GetValue("cache"),
				Object.Hvo, ConfigurationNode, StringTbl);
			Control = ctrl;
			m_menuHandler = InflAffixTemplateMenuHandler.Create(ctrl, ConfigurationNode);
#if !Want
			m_menuHandler.Init(Mediator, null);
#else
			m_menuHandler.Init(null, null);
#endif
			ctrl.SetContextMenuHandler(m_menuHandler.ShowSliceContextMenu);
			ctrl.Mediator = Mediator;
			ctrl.SetStringTableValues(Mediator.StringTbl);
			if (ctrl.RootBox == null)
				ctrl.MakeRoot();
		}
Exemplo n.º 5
0
        /// <summary>
        /// Therefore this method, called once we have a cache and object, is our first chance to
        /// actually create the embedded control.
        /// </summary>
        public override void FinishInit()
        {
            CheckDisposed();
            bool fVernRTL = Cache.GetBoolProperty(Cache.DefaultVernWs,
                                                  (int)SIL.FieldWorks.FDO.Cellar.LgWritingSystem.LgWritingSystemTags.kflidRightToLeft);
            bool fAnalRTL = Cache.GetBoolProperty(Cache.DefaultAnalWs,
                                                  (int)SIL.FieldWorks.FDO.Cellar.LgWritingSystem.LgWritingSystemTags.kflidRightToLeft);

            System.Xml.XmlAttribute xa = ConfigurationNode.Attributes["layout"];
            // To properly fix LT-6239, we need to consider all four mixtures of directionality
            // involving the vernacular (table) and analysis (slot name) writing systems.
            // These four possibilities are marked RTL, LTRinRTL, RTLinLTR, and <nothing>.
            if (fVernRTL && fAnalRTL)
            {
                if (xa.Value.EndsWith("RTLinLTR") || xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
                }
                if (!xa.Value.EndsWith("RTL"))
                {
                    xa.Value += "RTL";                                  // both vern and anal are RTL
                }
            }
            else if (fVernRTL && !fAnalRTL)
            {
                if (xa.Value.EndsWith("RTLinLTR"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
                }
                else if (xa.Value.EndsWith("RTL") && !xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 3);
                }
                if (!xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value += "LTRinRTL";                             // LTR anal name in RTL vern table
                }
            }
            else if (!fVernRTL && fAnalRTL)
            {
                if (xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
                }
                else if (xa.Value.EndsWith("RTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 3);
                }
                if (!xa.Value.EndsWith("RTLinLTR"))
                {
                    xa.Value += "RTLinLTR";                             // RTL anal name in LTR vern table
                }
            }
            else
            {
                if (xa.Value.EndsWith("RTLinLTR") || xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
                }
                else if (xa.Value.EndsWith("RTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 3);
                }
                // both vern and anal are LTR (unmarked case)
            }
            InflAffixTemplateControl ctrl = new InflAffixTemplateControl((FdoCache)Mediator.PropertyTable.GetValue("cache"),
                                                                         Object.Hvo, ConfigurationNode, StringTbl);

            Control       = ctrl;
            m_menuHandler = InflAffixTemplateMenuHandler.Create(ctrl, ConfigurationNode);
#if !Want
            m_menuHandler.Init(this.Mediator, null);
#else
            m_menuHandler.Init(null, null);
#endif
            ctrl.SetContextMenuHandler(new InflAffixTemplateEventHandler(m_menuHandler.ShowSliceContextMenu));
            ctrl.Mediator = Mediator;
            ctrl.SetStringTableValues(Mediator.StringTbl);
            if (ctrl.RootBox == null)
            {
                ctrl.MakeRoot();
            }
        }
		/// <summary>
		/// factory method which creates the correct subclass based on the XML parameters
		/// </summary>
		/// <param name="inflAffixTemplateCtrl"></param>
		/// <param name="configuration"></param>
		/// <returns></returns>
		public static InflAffixTemplateMenuHandler Create(InflAffixTemplateControl inflAffixTemplateCtrl, XmlNode configuration)
		{
			InflAffixTemplateMenuHandler h = null;
			if(configuration != null)
			{
				XmlNode node = configuration.SelectSingleNode("menuHandler");
				if (node != null)
				{
					h = (InflAffixTemplateMenuHandler) SIL.Utils.DynamicLoader.CreateObject(node);
				}
			}
			if (h == null)			//no class specified, so just returned a generic InflAffixTemplateControl
				h = new InflAffixTemplateMenuHandler();
			h.InflAffixTemplate = (InflAffixTemplateControl) inflAffixTemplateCtrl;
			return h;
		}
Exemplo n.º 7
0
        /// <summary>
        /// Therefore this method, called once we have a cache and object, is our first chance to
        /// actually create the embedded control.
        /// </summary>
        public override void FinishInit()
        {
            CheckDisposed();
            IWritingSystemContainer wsContainer = Cache.ServiceLocator.WritingSystems;
            bool fVernRTL = wsContainer.DefaultVernacularWritingSystem.RightToLeftScript;
            bool fAnalRTL = wsContainer.DefaultAnalysisWritingSystem.RightToLeftScript;

            System.Xml.XmlAttribute xa = ConfigurationNode.Attributes["layout"];
            // To properly fix LT-6239, we need to consider all four mixtures of directionality
            // involving the vernacular (table) and analysis (slot name) writing systems.
            // These four possibilities are marked RTL, LTRinRTL, RTLinLTR, and <nothing>.
            if (fVernRTL && fAnalRTL)
            {
                if (xa.Value.EndsWith("RTLinLTR") || xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
                }
                if (!xa.Value.EndsWith("RTL"))
                {
                    xa.Value += "RTL";                                  // both vern and anal are RTL
                }
            }
            else if (fVernRTL && !fAnalRTL)
            {
                if (xa.Value.EndsWith("RTLinLTR"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
                }
                else if (xa.Value.EndsWith("RTL") && !xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 3);
                }
                if (!xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value += "LTRinRTL";                             // LTR anal name in RTL vern table
                }
            }
            else if (!fVernRTL && fAnalRTL)
            {
                if (xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
                }
                else if (xa.Value.EndsWith("RTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 3);
                }
                if (!xa.Value.EndsWith("RTLinLTR"))
                {
                    xa.Value += "RTLinLTR";                             // RTL anal name in LTR vern table
                }
            }
            else
            {
                if (xa.Value.EndsWith("RTLinLTR") || xa.Value.EndsWith("LTRinRTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 8);
                }
                else if (xa.Value.EndsWith("RTL"))
                {
                    xa.Value = xa.Value.Substring(0, xa.Value.Length - 3);
                }
                // both vern and anal are LTR (unmarked case)
            }
            var ctrl = new InflAffixTemplateControl(m_propertyTable.GetValue <LcmCache>("cache"),
                                                    Object.Hvo, ConfigurationNode);

            Control       = ctrl;
            m_menuHandler = InflAffixTemplateMenuHandler.Create(ctrl, ConfigurationNode);
#if !Want
            m_menuHandler.Init(Mediator, m_propertyTable, null);
#else
            m_menuHandler.Init(null, null);
#endif
            ctrl.SetContextMenuHandler(m_menuHandler.ShowSliceContextMenu);
            ctrl.Mediator = Mediator;
            ctrl.SetStringTableValues();
            if (ctrl.RootBox == null)
            {
                ctrl.MakeRoot();
            }
        }