コード例 #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.
                VectorReferenceLauncher vrl = Control as VectorReferenceLauncher;
                if (vrl != null)
                {
                    vrl.ViewSizeChanged += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged);
                    VectorReferenceView view = (VectorReferenceView)vrl.MainControl;
                    view.ViewSizeChanged += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged);
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.

            base.Dispose(disposing);
        }
コード例 #2
0
        /// <summary>
        /// Handle changes in the size of the underlying view.
        /// </summary>
        protected void OnViewSizeChanged(object sender, FwViewSizeEventArgs e)
        {
            // For now, just handle changes in the height.
            VectorReferenceLauncher vrl  = (VectorReferenceLauncher)this.Control;
            VectorReferenceView     view = (VectorReferenceView)vrl.MainControl;
            int hMin = ContainingDataTree.GetMinFieldHeight();
            int h1   = view.RootBox.Height;

            Debug.Assert(e.Height == h1);
            int hOld = TreeNode.Height;
            int hNew = Math.Max(h1, hMin) + 3;

            if (hNew != hOld)
            {
                this.Height = hNew - 1;
                // JohnT: don't know why we need this, vrl is the slice's control and is supposed to
                // be docked to fill the slice. But if we don't do it, there are cases where
                // narrowing the window makes the slice higher but not the embedded control.
                // The tree node is also supposed to be docked, but again, if we don't do this
                // then the tree node doesn't fill the height of the window, and clicks at the
                // bottom of it may not work.
                TreeNode.Height = hNew - 1;
                vrl.Height      = hNew - 1;
                // This seems to be really not needed, the view height is docked to the launcher's.
//				view.Height = hNew - 1;
            }
        }
コード例 #3
0
        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            if (this.Width == m_dxLastWidth)
            {
                return;
            }
            m_dxLastWidth = Width;             // BEFORE doing anything, actions below may trigger recursive call.
            VectorReferenceLauncher vrl  = (VectorReferenceLauncher)this.Control;
            VectorReferenceView     view = (VectorReferenceView)vrl.MainControl;

            view.PerformLayout();
            int h1   = view.RootBox.Height;
            int hNew = Math.Max(h1, ContainingDataTree.GetMinFieldHeight()) + 3;

            if (hNew != this.Height)
            {
                this.Height = hNew;
            }
        }
コード例 #4
0
        protected override void SetupControls(IPersistenceProvider persistenceProvider,
                                              Mediator mediator, StringTable stringTbl)
        {
            VectorReferenceLauncher vrl = new VectorReferenceLauncher();

            vrl.Initialize(m_cache, m_obj, m_flid, m_fieldName, persistenceProvider, mediator,
                           DisplayNameProperty,
                           BestWsName);      // TODO: Get better default 'best ws'.
            vrl.ConfigurationNode = ConfigurationNode;
            this.Control          = vrl;
            vrl.ViewSizeChanged  += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged);
            VectorReferenceView view = (VectorReferenceView)vrl.MainControl;

            view.ViewSizeChanged += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged);
            // We don't want to be visible until later, since otherwise we get a temporary
            // display in the wrong place with the wrong size that serves only to annoy the
            // user.  See LT-1518 "The drawing of the DataTree for Lexicon/Advanced Edit draws
            // some initial invalid controls."  Becoming visible when we set the width and
            // height seems to delay things enough to avoid this visual clutter.
            vrl.Visible = false;
        }
コード例 #5
0
//		// Overhaul Aug 05: want all Window backgrounds in Detail controls.
//		/// <summary>
//		/// This is passed the color that the XDE specified, if any, otherwise null.
//		/// The default is to use the normal window color for editable text.
//		/// Subclasses which know they should have a different default should
//		/// override this method, but normally should use the specified color if not
//		/// null.
//		/// </summary>
//		/// <param name="clr"></param>
//		public override void OverrideBackColor(String backColorName)
//		{
//			CheckDisposed();
//
//			if (this.Control == null)
//				return;
//			VectorReferenceLauncher vrl = (VectorReferenceLauncher)this.Control;
//			vrl.BackColor = System.Drawing.SystemColors.Control;
//		}

        public override void RegisterWithContextHelper()
        {
            CheckDisposed();
            if (this.Control != null)
            {
                Mediator mediator = this.Mediator;
                if (mediator != null)                 // paranoia and unit testing
                {
                    StringTable tbl = null;
                    if (mediator.HasStringTable)
                    {
                        tbl = mediator.StringTbl;
                    }
                    string caption = XmlUtils.GetLocalizedAttributeValue(tbl,
                                                                         ConfigurationNode, "label", "");
                    VectorReferenceLauncher vrl = (VectorReferenceLauncher)this.Control;
                    mediator.SendMessage("RegisterHelpTargetWithId",
                                         new object[] { vrl.Controls[1], caption, HelpId }, false);
                    mediator.SendMessage("RegisterHelpTargetWithId",
                                         new object[] { vrl.Controls[0], caption, HelpId, "Button" }, false);
                }
            }
        }
コード例 #6
0
		protected override void SetupControls(IPersistenceProvider persistenceProvider,
			Mediator mediator, StringTable stringTbl)
		{
			VectorReferenceLauncher vrl = new VectorReferenceLauncher();
			vrl.Initialize(m_cache, m_obj, m_flid, m_fieldName, persistenceProvider, mediator,
				DisplayNameProperty,
				BestWsName); // TODO: Get better default 'best ws'.
			vrl.ConfigurationNode = ConfigurationNode;
			this.Control = vrl;
			vrl.ViewSizeChanged += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged);
			VectorReferenceView view = (VectorReferenceView)vrl.MainControl;
			view.ViewSizeChanged += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged);
			// We don't want to be visible until later, since otherwise we get a temporary
			// display in the wrong place with the wrong size that serves only to annoy the
			// user.  See LT-1518 "The drawing of the DataTree for Lexicon/Advanced Edit draws
			// some initial invalid controls."  Becoming visible when we set the width and
			// height seems to delay things enough to avoid this visual clutter.
			vrl.Visible = false;
		}
コード例 #7
0
        /// <summary>
        /// Handle interaction between POS and Slot ptoeprties for a inflectional affix MSA.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// If the new value is zero, then set the Slot prop to zero.
        /// If the new value is not zero, then make sure the Slot prop is valid.
        ///		If the current slot is not legal for the new POS value, then set it to zero.
        ///		Otherwise leave the slot value alone.
        /// </remarks>
        protected void OnReferenceChanged(object sender, SIL.FieldWorks.Common.Utils.FwObjectSelectionEventArgs e)
        {
            Debug.Assert(sender is AtomicReferenceLauncher);
            AtomicReferenceLauncher source = (AtomicReferenceLauncher)sender;

            Debug.Assert(Control == source);
            Debug.Assert(Object is MoInflAffMsa);

            int idxSender = Parent.Controls.IndexOf(this);

            int   otherFlid  = (int)MoInflAffMsa.MoInflAffMsaTags.kflidSlots;
            Slice otherSlice = null;
            int   idxOther;

            // Try to get the Slots slice.
            // Check for slices before this one.
            if (idxSender > 0)
            {
                idxOther = idxSender - 1;
                while (idxOther >= 0 &&
                       (otherSlice == null ||
                        (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object)))
                {
                    otherSlice = (Slice)Parent.Controls[idxOther--];
                    if (otherSlice is ReferenceVectorSlice && (otherSlice as ReferenceVectorSlice).Flid == otherFlid)
                    {
                        break;
                    }
                    otherSlice = null;
                }
            }

            // Check for following slices, if we didn't get one earlier.
            if (otherSlice == null && idxSender < Parent.Controls.Count)
            {
                idxOther = idxSender + 1;
                while (idxOther < Parent.Controls.Count &&
                       (otherSlice == null ||
                        (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object)))
                {
                    otherSlice = (Slice)Parent.Controls[idxOther++];
                    if (otherSlice is ReferenceVectorSlice && (otherSlice as ReferenceVectorSlice).Flid == otherFlid)
                    {
                        break;
                    }
                    otherSlice = null;
                }
            }

            VectorReferenceLauncher otherControl = null;

            if (otherSlice != null)
            {
                Debug.Assert((otherSlice as ReferenceVectorSlice).Flid == otherFlid);
                Debug.Assert(otherSlice.Object == Object);
                otherControl = otherSlice.Control as VectorReferenceLauncher;
                Debug.Assert(otherControl != null);
            }

            MoInflAffMsa msa     = Object as MoInflAffMsa;
            int          slotHvo = 0;

            if (msa.SlotsRC.Count > 0)
            {
                int[] hvos = msa.SlotsRC.HvoArray;
                slotHvo = hvos[0];
            }
            if (e.Hvo == 0 || slotHvo > 0)
            {
                IPartOfSpeech pos     = msa.PartOfSpeechRA;
                List <int>    slotIDs = new List <int>();
                if (pos != null)
                {
                    slotIDs = pos.AllAffixSlotIDs;
                }
                bool clearSlot = ((e.Hvo == 0) ||
                                  (!slotIDs.Contains(slotHvo)));
                if (clearSlot)
                {
                    if (otherControl == null)
                    {
                        msa.ClearAllSlots();                         // The slot slice is not showing, so directly set the object's Slot property.
                    }
                    else
                    {
                        otherControl.AddItem(0);                         // Reset it using the other slice, so it gets refreshed.
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Handle interaction between POS and Slot ptoeprties for a inflectional affix MSA.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// If the new value is zero, then set the Slot prop to zero.
        /// If the new value is not zero, then make sure the Slot prop is valid.
        ///		If the current slot is not legal for the new POS value, then set it to zero.
        ///		Otherwise leave the slot value alone.
        /// </remarks>
        protected void OnReferenceChanged(object sender, FwObjectSelectionEventArgs e)
        {
            Debug.Assert(sender is AtomicReferenceLauncher);
            var source = (AtomicReferenceLauncher)sender;

            Debug.Assert(Control == source);
            Debug.Assert(Object is IMoInflAffMsa);

            int idxSender = ContainingDataTree.Slices.IndexOf(this);

            int   otherFlid  = MoInflAffMsaTags.kflidSlots;
            Slice otherSlice = null;
            int   idxOther;

            // Try to get the Slots slice.
            // Check for slices before this one.
            if (idxSender > 0)
            {
                idxOther = idxSender - 1;
                while (idxOther >= 0 &&
                       (otherSlice == null ||
                        (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object)))
                {
                    otherSlice = ContainingDataTree.Slices[idxOther--];
                    if (otherSlice is ReferenceVectorSlice && (otherSlice as ReferenceVectorSlice).Flid == otherFlid)
                    {
                        break;
                    }
                    otherSlice = null;
                }
            }

            // Check for following slices, if we didn't get one earlier.
            if (otherSlice == null && idxSender < ContainingDataTree.Slices.Count)
            {
                idxOther = idxSender + 1;
                while (idxOther < ContainingDataTree.Slices.Count &&
                       (otherSlice == null ||
                        (otherSlice.Indent == Indent && idxOther > 0 && otherSlice.Object == Object)))
                {
                    otherSlice = ContainingDataTree.Slices[idxOther++];
                    if (otherSlice is ReferenceVectorSlice && (otherSlice as ReferenceVectorSlice).Flid == otherFlid)
                    {
                        break;
                    }
                    otherSlice = null;
                }
            }

            VectorReferenceLauncher otherControl = null;

            if (otherSlice != null)
            {
                Debug.Assert(otherSlice.Flid == otherFlid);
                Debug.Assert(otherSlice.Object == Object);
                otherControl = otherSlice.Control as VectorReferenceLauncher;
                Debug.Assert(otherControl != null);
            }

            var msa = Object as IMoInflAffMsa;
            IMoInflAffixSlot slot = null;

            if (msa.SlotsRC.Count > 0)
            {
                slot = msa.SlotsRC.First();
            }
            if (e.Hvo == 0 || slot != null)
            {
                var  pos       = msa.PartOfSpeechRA;
                var  slots     = pos != null ? pos.AllAffixSlots : Enumerable.Empty <IMoInflAffixSlot>();
                bool clearSlot = e.Hvo == 0 || !slots.Contains(slot);
                if (clearSlot)
                {
                    if (otherControl == null)
                    {
                        msa.SlotsRC.Clear();                         // The slot slice is not showing, so directly set the object's Slot property.
                    }
                    else
                    {
                        otherControl.AddItem(null);                         // Reset it using the other slice, so it gets refreshed.
                    }
                }
            }
        }