コード例 #1
0
        /// <summary>
        /// Handle changes in the size of the underlying view.
        /// </summary>
        protected void OnViewSizeChanged(object sender, FwViewSizeEventArgs e)
        {
            // When height is more than one line (e.g., long definition without gloss),
            // this can get called initially before it has a parent.
            if (ContainingDataTree == null)
            {
                return;
            }
            // For now, just handle changes in the height.
            var arl  = (AtomicReferenceLauncher)Control;
            var view = (AtomicReferenceView)arl.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)
            {
                TreeNode.Height = hNew;
                arl.Height      = hNew - 1;
                view.Height     = hNew - 1;
                Height          = hNew;
            }
        }
コード例 #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.
            PhoneEnvReferenceLauncher rl   = (PhoneEnvReferenceLauncher)this.Control;
            PhoneEnvReferenceView     view = (PhoneEnvReferenceView)rl.MainControl;

            if (ContainingDataTree == null)
            {
                return;                 // called too soon, from initial layout before connected.
            }
            int hMin = ContainingDataTree.GetMinFieldHeight();
            int h1   = view.RootBox.Height;

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

            if (hNew != hOld)
            {
                if (TreeNode != null)
                {
                    TreeNode.Height = hNew;
                }
                Height = hNew - 1;
            }
        }
コード例 #3
0
        /// <summary>
        /// This code exactly matches code in ReferenceVectorSlice; could we refactor somehow?
        /// </summary>
        /// <param name="e"></param>
        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.
            ReferenceLauncher rl   = (ReferenceLauncher)this.Control;
            SimpleRootSite    view = (SimpleRootSite)rl.MainControl;

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

            //When the slice is first created view.RootBox.Height is 0 and
            //GetMinFieldHeight returns a constant of 18 so this is too short
            //especially with Arabic scripts  (see LT-7327)
            hNew = Math.Max(hNew, Font.Height) + 3;
            if (hNew != this.Height)
            {
                this.Height = hNew;
            }
        }
コード例 #4
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.
            var vrl  = (VectorReferenceLauncher)Control;
            var 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)
            {
                // JohnT: why all these -1's?
                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;
            }
            if (Height != hNew - 1)
            {
                Height = hNew - 1;
            }
        }
コード例 #5
0
        void SetRefs()
        {
            var fieldName = XmlUtils.GetManditoryAttributeValue(m_configurationNode, "field");
            var refs      = ReflectionHelper.GetProperty(m_obj, fieldName);
            var refsInts  = refs as IEnumerable <int>;

            if (refsInts != null)
            {
                m_refs = (from hvo in refsInts
                          select m_cache.ServiceLocator.GetInstance <ILexReferenceRepository>().GetObject(hvo)).ToList();
            }
            else
            {
                m_refs = new List <ILexReference>();
                IEnumerable refsObjs = refs as IEnumerable;
                if (refsObjs != null)
                {
                    m_refs.AddRange(refsObjs.Cast <ILexReference>());
                }
                else
                {
                    Debug.Fail("LexReferenceSlice could not interpret results from " + fieldName);
                }
            }
            var flid = Cache.MetaDataCacheAccessor.GetFieldId2(m_obj.ClassID, fieldName, true);

            ContainingDataTree.MonitorProp(m_obj.Hvo, flid);
        }
コード例 #6
0
        /// <summary>
        /// Event handler for selection changed in combo box.
        /// </summary>
        /// <param name="sender">Source control</param>
        /// <param name="e"></param>
        protected void SelectionChanged(object sender, EventArgs e)
        {
            Debug.Assert(m_combo != null);
            if (m_combo.DroppedDown)
            {
                return;                 // don't want to update things while the user is manipulating the list. (See FWR-1728.)
            }
            int oldValue = m_cache.DomainDataByFlid.get_IntProp(Object.Hvo, m_flid);
            int newValue = m_combo.SelectedIndex;

            // No sense in setting it to the same value.
            if (oldValue != newValue)
            {
                m_cache.DomainDataByFlid.BeginUndoTask(
                    String.Format(DetailControlsStrings.ksUndoSet, m_fieldName),
                    String.Format(DetailControlsStrings.ksRedoSet, m_fieldName));
                m_cache.DomainDataByFlid.SetInt(Object.Hvo, m_flid, newValue);
                string sideEffectMethod = XmlUtils.GetAttributeValue(m_configurationNode, "sideEffect", null);
                if (!string.IsNullOrEmpty(sideEffectMethod))
                {
                    MethodInfo info = Object.GetType().GetMethod(sideEffectMethod);
                    if (info != null)
                    {
                        info.Invoke(Object, new object[] { oldValue, newValue });
                    }
                }
                m_cache.DomainDataByFlid.EndUndoTask();
                // The changing value may affect the datatree display.  See LT-6539.
                bool fRefresh = XmlUtils.GetOptionalBooleanAttributeValue(m_configurationNode, "refreshDataTreeOnChange", false);
                if (fRefresh)
                {
                    ContainingDataTree.RefreshList(false);
                }
            }
        }
コード例 #7
0
ファイル: ViewSlice.cs プロジェクト: vkarthim/FieldWorks
 /// ------------------------------------------------------------------------------------
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="ea"></param>
 /// ------------------------------------------------------------------------------------
 public void HandleLayoutSizeChanged(object sender, EventArgs ea)
 {
     CheckDisposed();
     SetHeightFromRootBox(RootSite);
     if (ContainingDataTree != null)             // can happen, e.g., during install slice.
     {
         ContainingDataTree.PerformLayout();
     }
 }
コード例 #8
0
 private void ExpandNewNode(IRnRoledPartic roledPartic)
 {
     try
     {
         ContainingDataTree.DeepSuspendLayout();
         XmlNode caller = null;
         if (Key.Length > 1)
         {
             caller = Key[Key.Length - 2] as XmlNode;
         }
         int insPos = IndexInContainer + Record.ParticipantsOC.Count - 1;
         GenerateChildNode(roledPartic, m_configurationNode, caller, Indent, ref insPos, new ArrayList(Key), new ObjSeqHashMap());
         Expansion = DataTree.TreeItemState.ktisExpanded;
     }
     finally
     {
         ContainingDataTree.DeepResumeLayout();
     }
 }
コード例 #9
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.
            AtomicReferenceLauncher arl  = (AtomicReferenceLauncher)this.Control;
            AtomicReferenceView     view = (AtomicReferenceView)arl.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)
            {
                TreeNode.Height = hNew;
                arl.Height      = hNew - 1;
                view.Height     = hNew - 1;
                this.Height     = hNew;
            }
        }
コード例 #10
0
 /// <summary>
 /// Expand this node, which is at position iSlice in its parent.
 /// </summary>
 /// <remarks> I (JH) don't know why this was written to take the index of the slice.
 /// It's just as easy for this class to find its own index.</remarks>
 /// <param name="iSlice"></param>
 public override void Expand(int iSlice)
 {
     CheckDisposed();
     try
     {
         ContainingDataTree.DeepSuspendLayout();
         XmlNode caller = null;
         if (Key.Length > 1)
         {
             caller = Key[Key.Length - 2] as XmlNode;
         }
         int insPos = iSlice + 1;
         GenerateChildren(m_configurationNode, caller, m_obj, Indent, ref insPos, new ArrayList(Key), new ObjSeqHashMap(), false);
         Expansion = DataTree.TreeItemState.ktisExpanded;
     }
     finally
     {
         ContainingDataTree.DeepResumeLayout();
     }
 }
コード例 #11
0
 protected void ExpandNewNode()
 {
     try
     {
         ContainingDataTree.DeepSuspendLayout();
         XmlNode caller = null;
         if (Key.Length > 1)
         {
             caller = Key[Key.Length - 2] as XmlNode;
         }
         int insPos = this.IndexInContainer + m_refs.Count;
         GenerateChildNode(m_refs.Count - 1, m_configurationNode, caller, Indent,
                           ref insPos, new ArrayList(Key), new ObjSeqHashMap());
         Expansion = DataTree.TreeItemState.ktisExpanded;
     }
     finally
     {
         ContainingDataTree.DeepResumeLayout();
     }
 }
コード例 #12
0
        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            if (Width == m_dxLastWidth)
            {
                return;
            }
            m_dxLastWidth = Width;             // BEFORE doing anything, actions below may trigger recursive call.
            var vrl  = (VectorReferenceLauncher)Control;
            var view = (VectorReferenceView)vrl.MainControl;

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

            if (hNew != Height)
            {
                Height = hNew;
            }
        }
コード例 #13
0
 /// <summary>
 /// Expand this node, which is at position iSlice in its parent.
 /// </summary>
 /// <remarks> I (JH) don't know why this was written to take the index of the slice.
 /// It's just as easy for this class to find its own index.</remarks>
 /// <param name="iSlice"></param>
 public override void Expand(int iSlice)
 {
     CheckDisposed();
     try
     {
         ContainingDataTree.DeepSuspendLayout();
         XmlNode caller = null;
         if (Key.Length > 1)
         {
             caller = Key[Key.Length - 2] as XmlNode;
         }
         int insPos = iSlice + 1;
         GenerateChildren(m_configurationNode, caller, m_obj, Indent, ref insPos, new ArrayList(Key), new ObjSeqHashMap());
         Expansion = DataTree.TreeItemState.ktisExpanded;
         // A crude way to force the +/- icon to be redrawn.
         // If this gets flashy, we could figure a smaller region to invalidate.
         ContainingDataTree.Invalidate(true);                  // Invalidates both children.
     }
     finally
     {
         ContainingDataTree.DeepResumeLayout();
     }
 }
コード例 #14
0
            public override Slice BecomeReal(int index)
            {
                CheckDisposed();
                // Figure position relative to parent node
                int parentIndex = index - 1;

                while (ContainingDataTree.Slices[parentIndex] != m_csParent)
                {
                    parentIndex -= 1;
                }
                int            childIndex = index - parentIndex - 1;      // relative to parent
                IConcSliceInfo csi        = (IConcSliceInfo)m_csParent.SliceInfo.ChildAt(childIndex);
                ViewSlice      vs         = new ConcSlice(new ConcView(csi));

                vs.Indent = this.Indent;
                if (csi.Count > 0)
                {
                    vs.Expansion = DataTree.TreeItemState.ktisCollapsed;
                }

                ContainingDataTree.RawSetSlice(index, vs);
                return(vs);
            }
コード例 #15
0
 protected void ExpandNewNode()
 {
     try
     {
         ContainingDataTree.DeepSuspendLayout();
         XmlNode caller = null;
         if (Key.Length > 1)
         {
             caller = Key[Key.Length - 2] as XmlNode;
         }
         int insPos = this.IndexInContainer + m_refs.Count;
         GenerateChildNode(m_refs.Count - 1, m_configurationNode, caller, Indent,
                           ref insPos, new ArrayList(Key), new ObjSeqHashMap());
         Expansion = DataTree.TreeItemState.ktisExpanded;
         // A crude way to force the +/- icon to be redrawn.
         // If this gets flashy, we could figure a smaller region to invalidate.
         ContainingDataTree.Invalidate(true);                  // Invalidates both children.
     }
     finally
     {
         ContainingDataTree.DeepResumeLayout();
     }
 }
コード例 #16
0
        private void m_MSAPopupTreeManager_AfterSelect(object sender, TreeViewEventArgs e)
        {
            // unless we get a mouse click or simulated mouse click (e.g. by ENTER or TAB),
            // do not treat as an actual selection.
            if (m_handlingMessage || e.Action != TreeViewAction.ByMouse)
            {
                return;
            }
            HvoTreeNode htn = e.Node as HvoTreeNode;

            if (htn == null)
            {
                return;
            }

            // Don't try changing values on a deleted object!  See LT-8656 and LT-9119.
            if (!m_cache.VerifyValidObject(m_obj))
            {
                return;
            }

            int hvoSel = htn.Hvo;

            // if hvoSel is negative, then MSAPopupTreeManager's AfterSelect has handled it,
            // except possibly for refresh.
            if (hvoSel < 0)
            {
                ContainingDataTree.RefreshList(false);
                return;
            }
            LexSense sense = m_obj as LexSense;
            // Setting sense.DummyMSA can cause the DataTree to want to refresh.  Don't
            // let this happen until after we're through!  See LT-9713 and LT-9714.
            bool fOldDoNotRefresh = ContainingDataTree.DoNotRefresh;

            try
            {
                m_handlingMessage = true;
                int clidSel = 0;
                if (hvoSel > 0)
                {
                    clidSel = m_cache.GetClassOfObject(hvoSel);
                }
                bool didChange = false;
                if (clidSel == PartOfSpeech.kclsidPartOfSpeech)
                {
                    ContainingDataTree.DoNotRefresh = true;
                    m_cache.BeginUndoTask(
                        String.Format(DetailControlsStrings.ksUndoSet, m_fieldName),
                        String.Format(DetailControlsStrings.ksRedoSet, m_fieldName));
                    DummyGenericMSA dummyMSA = new DummyGenericMSA();
                    dummyMSA.MsaType = sense.GetDesiredMsaType();
                    dummyMSA.MainPOS = hvoSel;
                    MoStemMsa stemMsa = sense.MorphoSyntaxAnalysisRA as MoStemMsa;
                    if (stemMsa != null)
                    {
                        dummyMSA.FromPartsOfSpeech = stemMsa.FromPartsOfSpeechRC;
                    }
                    sense.DummyMSA = dummyMSA;
                    didChange      = true;
                }
                else if (sense.MorphoSyntaxAnalysisRAHvo != hvoSel)
                {
                    ContainingDataTree.DoNotRefresh = true;
                    m_cache.BeginUndoTask(
                        String.Format(DetailControlsStrings.ksUndoSet, m_fieldName),
                        String.Format(DetailControlsStrings.ksRedoSet, m_fieldName));
                    sense.MorphoSyntaxAnalysisRAHvo = hvoSel;
                    didChange = true;
                }
                if (didChange)
                {
                    m_cache.EndUndoTask();
                }
                if (!ContainingDataTree.RefreshListNeeded)
                {
                    m_MSAPopupTreeManager.LoadPopupTree(sense.MorphoSyntaxAnalysisRAHvo);
                    // Don't refresh the datatree unless the popup has actually been loaded.
                    // It could be setting the selection in the process of loading!  See LT-9191.
                    if (m_MSAPopupTreeManager.IsTreeLoaded)
                    {
                        ContainingDataTree.RefreshList(false);
                    }
                }
            }
            finally
            {
                m_handlingMessage = false;
                // We still can't refresh the data at this point without causing a crash due to
                // a pending Windows message.  See LT-9713 and LT-9714.
                if (ContainingDataTree.DoNotRefresh != fOldDoNotRefresh)
                {
                    Mediator.BroadcastMessage("DelayedRefreshList", fOldDoNotRefresh);
                }
            }
        }
コード例 #17
0
 protected void RefreshTree(object sender, EventArgs args)
 {
     CheckDisposed();
     ContainingDataTree.RefreshList(false);
 }
コード例 #18
0
ファイル: SummarySlice.cs プロジェクト: vkarthim/FieldWorks
        /// <summary>
        /// Implement the "Demote..." command.
        /// </summary>
        public bool OnDemoteSubitemInVector(object argument)
        {
            CheckDisposed();

            if (this.Object == null)
            {
                return(false);
            }
            IRnGenericRec rec = this.Object as IRnGenericRec;

            if (rec == null)
            {
                return(false);                          // shouldn't get here
            }
            IRnGenericRec newOwner = null;

            if (Object.Owner is IRnGenericRec)
            {
                IRnGenericRec recOwner = Object.Owner as IRnGenericRec;
                if (recOwner.SubRecordsOS.Count == 2)
                {
                    if (Object.OwnOrd == 0)
                    {
                        newOwner = recOwner.SubRecordsOS[1];
                    }
                    else
                    {
                        newOwner = recOwner.SubRecordsOS[0];
                    }
                }
                else
                {
                    List <IRnGenericRec> owners = new List <IRnGenericRec>();
                    foreach (var recT in recOwner.SubRecordsOS)
                    {
                        if (recT != rec)
                        {
                            owners.Add(recT);
                        }
                    }
                    newOwner = ContainingDataTree.ChooseNewOwner(owners.ToArray(),
                                                                 Resources.DetailControlsStrings.ksChooseOwnerOfDemotedSubrecord);
                }
            }
            else
            {
                return(false);
            }
            if (newOwner == null)
            {
                return(true);
            }
            if (newOwner == rec)
            {
                throw new Exception("RnGenericRec cannot own itself!");
            }

            UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(Resources.DetailControlsStrings.ksUndoDemote,
                                                            Resources.DetailControlsStrings.ksRedoDemote, Cache.ActionHandlerAccessor, () =>
            {
                newOwner.SubRecordsOS.Insert(0, rec);
            });
            return(true);
        }
コード例 #19
0
        private void m_MSAPopupTreeManager_AfterSelect(object sender, TreeViewEventArgs e)
        {
            // unless we get a mouse click or simulated mouse click (e.g. by ENTER or TAB),
            // do not treat as an actual selection.
            if (m_handlingMessage || e.Action != TreeViewAction.ByMouse)
            {
                return;
            }
            HvoTreeNode htn = e.Node as HvoTreeNode;

            if (htn == null)
            {
                return;
            }

            // Don't try changing values on a deleted object!  See LT-8656 and LT-9119.
            if (!m_obj.IsValidObject)
            {
                return;
            }

            int hvoSel = htn.Hvo;

            // if hvoSel is negative, then MSAPopupTreeManager's AfterSelect has handled it,
            // except possibly for refresh.
            if (hvoSel < 0)
            {
                ContainingDataTree.RefreshList(false);
                return;
            }
            var sense = m_obj as ILexSense;
            // Setting sense.DummyMSA can cause the DataTree to want to refresh.  Don't
            // let this happen until after we're through!  See LT-9713 and LT-9714.
            bool fOldDoNotRefresh = ContainingDataTree.DoNotRefresh;

            try
            {
                m_handlingMessage = true;
                if (hvoSel > 0)
                {
                    ICmObject obj = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(hvoSel);
                    if (obj.ClassID == PartOfSpeechTags.kClassId)
                    {
                        ContainingDataTree.DoNotRefresh = true;
                        var sandoxMSA = new SandboxGenericMSA();
                        sandoxMSA.MsaType = sense.GetDesiredMsaType();
                        sandoxMSA.MainPOS = obj as IPartOfSpeech;
                        var stemMsa = sense.MorphoSyntaxAnalysisRA as IMoStemMsa;
                        if (stemMsa != null)
                        {
                            sandoxMSA.FromPartsOfSpeech = stemMsa.FromPartsOfSpeechRC;
                        }
                        UndoableUnitOfWorkHelper.Do(String.Format(DetailControlsStrings.ksUndoSet, m_fieldName),
                                                    String.Format(DetailControlsStrings.ksRedoSet, m_fieldName), sense, () =>
                        {
                            sense.SandboxMSA = sandoxMSA;
                        });
                    }
                    else if (sense.MorphoSyntaxAnalysisRA != obj)
                    {
                        ContainingDataTree.DoNotRefresh = true;
                        UndoableUnitOfWorkHelper.Do(String.Format(DetailControlsStrings.ksUndoSet, m_fieldName),
                                                    String.Format(DetailControlsStrings.ksRedoSet, m_fieldName), sense, () =>
                        {
                            sense.MorphoSyntaxAnalysisRA = obj as IMoMorphSynAnalysis;
                        });
                    }
                }
            }
            finally
            {
                m_handlingMessage = false;
                // We still can't refresh the data at this point without causing a crash due to
                // a pending Windows message.  See LT-9713 and LT-9714.
                if (ContainingDataTree.DoNotRefresh != fOldDoNotRefresh)
                {
                    Mediator.BroadcastMessage("DelayedRefreshList", fOldDoNotRefresh);
                }
            }
        }