Beispiel #1
0
        /// <summary>
        /// Receives the broadcast message "PropertyChanged"
        /// </summary>
        public override void OnPropertyChanged(string name)
        {
            var wsBefore = 0;

            // We want to know below whether a base class changed the ws or not.
            if (name == "WritingSystemHvo")
            {
                if (RootObject != null && m_rootb != null && m_rootb.Selection.IsValid)
                {
                    wsBefore = SelectionHelper.GetWsOfEntireSelection(m_rootb.Selection);
                }
            }

            base.OnPropertyChanged(name);
            bool newVal;             // used in two cases below

            switch (name)
            {
            case "WritingSystemHvo":
                if (RootObject != null && m_rootb != null && m_rootb.Selection.IsValid)
                {
                    int hvo, tag, ws, ichMin, ichLim;
                    ws = SelectionHelper.GetWsOfEntireSelection(m_rootb.Selection);
                    if (ws != wsBefore)                             // writing system changed!
                    {
                        if (GetSelectedWordPos(m_rootb.Selection, out hvo, out tag, out ws, out ichMin, out ichLim))
                        {
                            if (tag != StTxtParaTags.kflidContents)
                            {
                                return;
                            }

                            var para = m_fdoCache.ServiceLocator.GetInstance <IStTxtParaRepository>().GetObject(hvo);
                            // force this paragraph to recognize it might need reparsing.
                            SetParaToReparse(para);
                        }
                    }
                }
                break;

            case "ShowInvisibleSpaces":
                newVal = ShowInvisibleSpaces;
                if (newVal != m_showSpaceDa.ShowSpaces)
                {
                    m_showSpaceDa.ShowSpaces = newVal;
                    var saveSelection = SelectionHelper.Create(this);
                    m_rootb.Reconstruct();
                    saveSelection.SetSelection(true);
                }
                if (!newVal && ClickInvisibleSpace)
                {
                    TurnOffClickInvisibleSpace();
                }
                break;

            case "ClickInvisibleSpace":
                newVal = ClickInvisibleSpace;
                if (newVal == m_fClickInsertsZws)
                {
                    return;
                }
                m_fClickInsertsZws = newVal;
                if (newVal && !ShowInvisibleSpaces)
                {
                    TurnOnShowInvisibleSpaces();
                }
                break;

            default:
                break;
            }
        }