/// <summary> /// This is the one (and should be only) handler for the user Refresh command. /// Refresh wants to first clean up the cache, then give things like Clerks a /// chance to reload stuff (calling the old OnRefresh methods), then give /// windows a chance to redisplay themselves. /// </summary> public void OnMasterRefresh(object sender) { // TODO: This is no longer called by the Mediator, since this class // is no longer an xcore colleague. But, it can't be removed either, // since it is used by another method on this clsss. :-( CheckDisposed(); // Susanna asked that refresh affect only the currently active project, which is // what the string and List variables below attempt to handle. See LT-6444. FwXWindow activeWnd = ActiveForm as FwXWindow; List<FwXWindow> rgxw = new List<FwXWindow>(); foreach (IFwMainWnd wnd in MainWindows) { FwXWindow xwnd = wnd as FwXWindow; if (xwnd != null) { xwnd.PrepareToRefresh(); rgxw.Add(xwnd); } } if (activeWnd != null) rgxw.Remove(activeWnd); foreach (FwXWindow xwnd in rgxw) { xwnd.FinishRefresh(); xwnd.Refresh(); } // LT-3963: active window changes as a result of a refresh. // Make sure focus doesn't switch to another FLEx application / window also // make sure the application focus isn't lost all together. // ALSO, after doing a refresh with just a single application / window, // the application would loose focus and you'd have to click into it to // get that back, this will reset that too. if (activeWnd != null) { // Refresh it last, so its saved settings get restored. activeWnd.FinishRefresh(); activeWnd.Refresh(); activeWnd.Activate(); } }
/// <summary> /// Overridden to set the new values selected from the chooser dialog. /// </summary> /// <param name="rghvosChosen"></param> public override void SetItems(List<int> rghvosChosen) { CheckDisposed(); m_phoneEnvRefView.Commit(); // null indicates that we cancelled out of the chooser dialog -- we shouldn't get // here with that value, but just in case... if (rghvosChosen == null) return; int h1 = m_phoneEnvRefView.RootBox.Height; // First, we need a list of hvos added and a list of hvos deleted. int citemsOld = m_cache.GetVectorSize(m_obj.Hvo, m_flid); List<int> rghvosNew = new List<int>(rghvosChosen); List<int> rghvosDel = new List<int>(citemsOld); if (citemsOld > 0) { int[] hvosOld = m_cache.GetVectorProperty(m_obj.Hvo, m_flid, false); Debug.Assert(citemsOld == hvosOld.Length); for (int i = 0; i < citemsOld; ++i) { if (rghvosNew.Contains(hvosOld[i])) rghvosNew.Remove(hvosOld[i]); else rghvosDel.Add(hvosOld[i]); } } // Add all the new environments. using (new UndoRedoTaskHelper(m_cache, String.Format(DetailControlsStrings.ksUndoSet, m_fieldName), String.Format(DetailControlsStrings.ksRedoSet, m_fieldName))) { for (int i = 0; i < rghvosNew.Count; ++i) { int hvo = (int)rghvosNew[i]; m_phoneEnvRefView.AddNewItem(hvo); if (m_flid == (int)MoAffixAllomorph.MoAffixAllomorphTags.kflidPosition) { ((MoAffixAllomorph)m_obj).PositionRS.Append(hvo); } else { if (m_obj is MoAffixAllomorph) ((MoAffixAllomorph)m_obj).PhoneEnvRC.Add(hvo); else ((MoStemAllomorph)m_obj).PhoneEnvRC.Add(hvo); } } for (int i = 0; i < rghvosDel.Count; ++i) { int hvo = (int)rghvosDel[i]; m_phoneEnvRefView.RemoveItem(hvo); if (m_flid == (int)MoAffixAllomorph.MoAffixAllomorphTags.kflidPosition) { ((MoAffixAllomorph)m_obj).PositionRS.Remove(hvo); } else { if (m_obj is MoAffixAllomorph) ((MoAffixAllomorph)m_obj).PhoneEnvRC.Remove(hvo); else ((MoStemAllomorph)m_obj).PhoneEnvRC.Remove(hvo); } } } int h2 = m_phoneEnvRefView.RootBox.Height; if (h1 != h2 && ViewSizeChanged != null) { ViewSizeChanged(this, new FwViewSizeEventArgs(h2, m_phoneEnvRefView.RootBox.Width)); } }
protected virtual void ComputeValue(List<ICmObject> chosenObjs, int hvoItem, out List<ICmObject> oldVals, out List<ICmObject> newVal) { int hvoReal; // Check whether we can actually compute values for this item. If not, // just return a pair of empty lists. (See LT-11016 and LT-11357.) if (!CanActuallyComputeValuesFor(hvoItem, out hvoReal)) { oldVals = new List<ICmObject>(); newVal = oldVals; return; } oldVals = GetOldVals(hvoReal); newVal = chosenObjs; if (m_fRemove) { newVal = oldVals; // by default no change in remove mode. if (oldVals.Count > 0) { var newValues = new List<ICmObject>(oldVals); foreach (ICmObject obj in chosenObjs) { if (newValues.Contains(obj)) newValues.Remove(obj); } newVal = newValues; } } else if (!m_fReplace && oldVals.Count != 0) { // Need to handle as append. if (Atomic) newVal = oldVals; // can't append to non-empty atomic value else { var newValues = new List<ICmObject>(oldVals); foreach (ICmObject obj in chosenObjs) { if (!newValues.Contains(obj)) newValues.Add(obj); } newVal = newValues; } } }
public virtual void OnMasterRefresh(object sender) { CheckDisposed(); // Susanna asked that refresh affect only the currently active project, which is // what the string and List variables below attempt to handle. See LT-6444. FwXWindow activeWnd = ActiveForm as FwXWindow; FdoCache activeCache = null; if (activeWnd != null) activeCache = activeWnd.Cache; List<FwXWindow> rgxw = new List<FwXWindow>(); foreach (IFwMainWnd wnd in m_app.MainWindows) { FwXWindow xwnd = wnd as FwXWindow; if (xwnd != null) { if (activeCache == null || xwnd.Cache == activeCache) { xwnd.PrepareToRefresh(); rgxw.Add(xwnd); } } } if (activeWnd != null) rgxw.Remove(activeWnd); foreach (FwXWindow xwnd in rgxw) { xwnd.FinishRefresh(); xwnd.Refresh(); } // LT-3963: active window changes as a result of a refresh. // Make sure focus doesn't switch to another FLEx application / window also // make sure the application focus isn't lost all together. // ALSO, after doing a refresh with just a single application / window, // the application would loose focus and you'd have to click into it to // get that back, this will reset that too. if (activeWnd != null) { // Refresh it last, so its saved settings get restored. activeWnd.FinishRefresh(); activeWnd.Refresh(); activeWnd.Activate(); } }
public void ModifyOverlay(bool fApplyTag, IVwOverlay pvo, int itag) { CheckDisposed(); if (m_rootb == null) return; Debug.WriteLine("WARNING: RootSite.ModifyOverlay() isn't tested yet"); int hvo; uint clrFore; uint clrBack; uint clrUnder; int unt; bool fHidden; string uid; using (ArrayPtr arrayPtr = MarshalEx.StringToNative((int)VwConst1.kcchGuidRepLength + 1, true)) { pvo.GetDbTagInfo(itag, out hvo, out clrFore, out clrBack, out clrUnder, out unt, out fHidden, arrayPtr); uid = MarshalEx.NativeToString(arrayPtr, (int)VwConst1.kcchGuidRepLength, false); } IVwSelection vwsel; ITsTextProps[] vttp; IVwPropertyStore[] vvps; if (EditingHelper.GetCharacterProps(out vwsel, out vttp, out vvps)) { int cttp = vttp.Length; for (int ittp = 0; ittp < cttp; ittp++) { string strGuid = vttp[ittp].GetStrPropValue( (int)FwTextPropType.ktptTags); // REVIEW (EberhardB): I'm not sure if this works int cGuids = strGuid.Length / Marshal.SizeOf(typeof(Guid)); List<string> guids = new List<string>(); for (int i = 0; i < cGuids; i++) guids.Add(strGuid.Substring(i, Marshal.SizeOf(typeof(Guid)))); if (fApplyTag) { // Add the tag if it does not exist if (guids.BinarySearch(uid) >= 0) { // The tag has already been applied to the textprop, so it doesn't // need to be modified. vttp[ittp] = null; continue; } else { // We need to add the tag to the textprop. guids.Add(uid); guids.Sort(); } } else { // Remove the tag from the textprop. guids.Remove(uid); } ITsPropsBldr tpb = vttp[ittp].GetBldr(); tpb.SetStrPropValue((int)FwTextPropType.ktptTags, guids.ToString()); vttp[ittp] = tpb.GetTextProps(); } vwsel.SetSelectionProps(cttp, vttp); /* * ENHANCE (EberhardB): Implement this if we need it. It probably should be * implemented in a derived class (view class for DataNotebook?) // Update the RnGenericRec_PhraseTags table as necessary. // (Yes, this is special case code!) AfDbInfo * pdbi = NULL; AfMainWnd * pamw = m_pwndSubclass->MainWindow(); if (pamw) { AfMdiMainWnd * pammw = dynamic_cast<AfMdiMainWnd *>(pamw); AfLpInfo * plpi = NULL; if (pammw) { plpi = pammw->GetLpInfo(); if (plpi) pdbi = plpi->GetDbInfo(); } } if (pdbi) { int clevEnd; int clevAnchor; HVO hvoEnd; HVO hvoAnchor; PropTag tagEnd; PropTag tagAnchor; int ihvo; int cpropPrev; IVwPropertyStorePtr qvps; CheckHr(qvwsel->CLevels(true, &clevEnd)); Assert(clevEnd >= 1); CheckHr(qvwsel->CLevels(false, &clevAnchor)); Assert(clevAnchor >= 1); CheckHr(qvwsel->PropInfo(true, clevEnd - 1, &hvoEnd, &tagEnd, &ihvo, &cpropPrev, &qvps)); CheckHr(qvwsel->PropInfo(false, clevAnchor - 1, &hvoAnchor, &tagAnchor, &ihvo, &cpropPrev, &qvps)); IOleDbEncapPtr qode; pdbi->GetDbAccess(&qode); DbStringCrawler::UpdatePhraseTagsTable(kflidRnGenericRec_PhraseTags, fApplyTag, qode, hvo, hvoEnd, hvoAnchor); } */ } if (FindForm() == Form.ActiveForm) Focus(); }
private void ComputeValue(int[] chosenHvos, int hvoItem, out int[] oldVals, out int[] newVal) { oldVals = m_cache.GetVectorProperty(hvoItem, m_flid, true); newVal = chosenHvos; if (m_fRemove) { newVal = oldVals; // by default no change in remove mode. if (oldVals.Length > 0) { List<int> newValues = new List<int>(oldVals); foreach (int hvo in chosenHvos) { if (newValues.Contains(hvo)) newValues.Remove(hvo); } newVal = newValues.ToArray(); } } else if (!m_fReplace && oldVals.Length != 0) { // Need to handle as append. List<int> newValues = new List<int>(oldVals); foreach (int hvo in chosenHvos) { if (!newValues.Contains(hvo)) newValues.Add(hvo); } newVal = newValues.ToArray(); } }
/// <summary> /// get the end offsets for potential morphs based upon whitespace delimiters /// </summary> /// <param name="sourceString"></param> /// <returns></returns> private static List<int> IchLimOfMorphs(string sourceString, bool fBaseWordIsPhrase) { List<int> whiteSpaceOffsets = WhiteSpaceOffsets(sourceString); List<int> morphEndOffsets = new List<int>(whiteSpaceOffsets); int prevOffset = -1; int cOffsets = whiteSpaceOffsets.Count; foreach (int offset in whiteSpaceOffsets) { // we always want to remove spaces following a previous space // or if we're in a a phrase, always remove the last offset, since // it cannot be followed by a second one. if (prevOffset != -1 && offset == prevOffset + 1 || fBaseWordIsPhrase && offset == whiteSpaceOffsets[whiteSpaceOffsets.Count - 1]) { morphEndOffsets.Remove(offset); } if (fBaseWordIsPhrase) { // for a phrase, we always want to remove previous offsets // that are not followed by a space offset if (prevOffset != -1 && prevOffset != offset - 1) { morphEndOffsets.Remove(prevOffset); } } prevOffset = offset; } // finally add the end of the sourcestring to the offsets. morphEndOffsets.Add(sourceString.Length); return morphEndOffsets; }
private void BuildDummiesToConvertList(List<int> queue, List<int> dummiesToConvert) { ICmObject realObj = null; // Add only up to the max allowed. foreach (int item in queue.ToArray()) { if (dummiesToConvert.Count == kMaxDummiesToConvertAtOnce) break; // only add unique and things that haven't already been converted. if (!dummiesToConvert.Contains(item)) { if (m_dummyToRealDict.TryGetValue(item, out realObj) && realObj != null) { // we've already converted this, so remove it from our queue queue.Remove(item); continue; } dummiesToConvert.Add(item); } } }