コード例 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the Writiing System selector combo box
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void UpdateWritingSystemSelectorForSelection(IVwRootBox rootbox)
        {
            ComboBox box = WritingSystemSelector;

            if (box == null || rootbox == null)
            {
                return;
            }
            int hvoWs = SelectionHelper.GetFirstWsOfSelection(rootbox.Selection);

            if (hvoWs == 0)
            {
                box.SelectedIndex = -1;
                return;
            }
            IWritingSystem ws = Cache.ServiceLocator.WritingSystemManager.Get(hvoWs);

            box.SelectedIndex = box.FindString(ws.DisplayLabel);
        }
コード例 #2
0
        /// <summary>
        /// Sets the value of a control.
        /// Note: write operations need to occur in the context of a UndoableUnitOfWorkHelper (for Undo/Redo purposes).
        /// This requires fdoCache...so perhaps an edit control needs to be in RootSite.dll rather than SimpleRootSite.
        /// </summary>
        /// <param name="value"></param>
        /// <exception cref="T:System.InvalidOperationException">
        /// If locale-specific information is passed to a control in an incorrect format such as an incorrectly formatted date.
        /// </exception>
        /// <exception cref="T:System.ArgumentException">
        /// If a new value cannot be converted from a string to a format the control recognizes.
        /// </exception>
        /// <exception cref="T:System.Windows.Automation.ElementNotEnabledException">
        /// When an attempt is made to manipulate a control that is not enabled.
        /// </exception>
        public void SetValue(string value)
        {
            // install the range selection for this text box
            // past a string over the selection
            if (!Focused())
            {
                SetFocus();                 //installs range selection.
            }
            // get the writing system at the anchor
            int       ws  = SelectionHelper.GetFirstWsOfSelection(m_rootb.Selection);
            ITsString tss = TsStringUtils.MakeTss(value, ws);

            m_site.Invoke(() => m_site.EditingHelper.PasteCore(tss));
            // NOTE: PasteCore leaves the rootbox selection in a cursor state
            // at the end of the pasted seleciton. So
            // now we need to readjust the Selection with the new end offset.
            var shEditRange = SelectionHelper.Create(Selection, m_site);

            shEditRange.SetIch(SelectionHelper.SelLimitType.Anchor, 0);
            shEditRange.SetIch(SelectionHelper.SelLimitType.End, tss.Length);
            Selection = shEditRange.SetSelection(m_site, false, false);
            ComputeScreenBoundingRectangle();
        }
コード例 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the Writiing System selector combo box
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void UpdateWritingSystemSelectorForSelection(IVwRootBox rootbox)
        {
            ComboBox box = WritingSystemSelector;

            if (box == null || rootbox == null)
            {
                return;
            }
            int hvoWs = SelectionHelper.GetFirstWsOfSelection(rootbox.Selection);

            if (hvoWs == 0)
            {
                box.SelectedIndex = -1;
                return;
            }
            LgWritingSystem lgws = new LgWritingSystem(Cache, hvoWs);

            if (lgws == null)
            {
                box.SelectedIndex = -1;
                return;
            }
            box.SelectedIndex = box.FindString(lgws.ShortName);
        }