本文整理汇总了C#中XCore.Mediator.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Mediator.SendMessage方法的具体用法?C# Mediator.SendMessage怎么用?C# Mediator.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XCore.Mediator
的用法示例。
在下文中一共展示了Mediator.SendMessage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReversalIndexHvo
/// <summary>
/// Get the current reversal index hvo. If there is none, create a new reversal index
/// since there must not be any. This fixes LT-6653.
/// </summary>
/// <param name="mediator"></param>
/// <returns></returns>
internal static int GetReversalIndexHvo(Mediator mediator)
{
string sHvo = (string)mediator.PropertyTable.GetValue("ReversalIndexHvo");
if (String.IsNullOrEmpty(sHvo))
{
mediator.SendMessage("InsertReversalIndex_FORCE", null);
sHvo = (string)mediator.PropertyTable.GetValue("ReversalIndexHvo");
}
int rih = int.Parse(sHvo);
return rih;
}
示例2: CreateNewUiObject
/// <summary>
/// Handle the context menu for inserting a POS.
/// </summary>
/// <param name="mediator"></param>
/// <param name="classId"></param>
/// <param name="hvoOwner"></param>
/// <param name="flid"></param>
/// <param name="insertionPosition"></param>
/// <returns></returns>
public new static PartOfSpeechUi CreateNewUiObject(Mediator mediator, int classId, int hvoOwner, int flid, int insertionPosition)
{
PartOfSpeechUi posUi = null;
using (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
{
FdoCache cache = (FdoCache)mediator.PropertyTable.GetValue("cache");
Debug.Assert(cache != null);
var newOwner = cache.ServiceLocator.GetInstance<IPartOfSpeechRepository>().GetObject(hvoOwner);
dlg.SetDlginfo(newOwner.OwningList, mediator, true, newOwner);
switch (dlg.ShowDialog((Form)mediator.PropertyTable.GetValue("window")))
{
case DialogResult.OK: // Fall through.
case DialogResult.Yes:
posUi = new PartOfSpeechUi(dlg.SelectedPOS);
mediator.SendMessage("JumpToRecord", dlg.SelectedPOS.Hvo);
break;
}
}
return posUi;
}
示例3: Init
public void Init(Mediator mediator, XmlNode configurationParameters)
{
CheckDisposed();
this.mediator = mediator; //allows the Cache property to function
string name = XmlUtils.GetAttributeValue(configurationParameters, "clerk");
var clerk = RecordClerk.FindClerk(mediator, name);
m_clerk = (clerk == null || clerk is TemporaryRecordClerk) ?
(InterlinearTextsRecordClerk)RecordClerkFactory.CreateClerk(mediator, configurationParameters, true) :
(InterlinearTextsRecordClerk)clerk;
// There's no record bar for it to control, but it should control the staus bar (e.g., it should update if we change
// the set of selected texts).
m_clerk.ActivateUI(true);
_areaName = XmlUtils.GetOptionalAttributeValue(configurationParameters, "area", "unknown");
RebuildStatisticsTable();
//add ourselves so that we can receive messages (related to the text selection currently misnamed AddTexts)
mediator.AddColleague(this);
//add our current state to the history system
string toolName = mediator.PropertyTable.GetStringProperty("currentContentControl", "");
mediator.SendMessage("AddContextToHistory", new FwLinkArgs(toolName, Guid.Empty), false);
}
示例4: CreateNewUiObject
/// <summary>
/// Handle the context menu for inserting an FsFeatDefn.
/// </summary>
/// <param name="mediator"></param>
/// <param name="classId"></param>
/// <param name="hvoOwner"></param>
/// <param name="flid"></param>
/// <param name="insertionPosition"></param>
/// <returns></returns>
public new static FsFeatDefnUi CreateNewUiObject(Mediator mediator, uint classId, int hvoOwner, int flid, int insertionPosition)
{
FsFeatDefnUi ffdUi = null;
string className = "FsClosedFeature";
if (classId == FDO.Cellar.FsComplexFeature.kClassId)
className = "FsComplexFeature";
using (MasterInflectionFeatureListDlg dlg = new MasterInflectionFeatureListDlg(className))
{
FdoCache cache = (FdoCache)mediator.PropertyTable.GetValue("cache");
Debug.Assert(cache != null);
dlg.SetDlginfo(cache.LangProject.MsFeatureSystemOA, mediator, true);
switch (dlg.ShowDialog((Form)mediator.PropertyTable.GetValue("window")))
{
case DialogResult.OK: // Fall through.
case DialogResult.Yes:
ffdUi = new FsFeatDefnUi(dlg.SelectedFeatDefn);
mediator.SendMessage("JumpToRecord", dlg.SelectedFeatDefn.Hvo);
break;
}
}
return ffdUi;
}
示例5: Window
public Window()
{
InitializeComponent();
m_mainPaneText = new Label();
m_mainPaneText.Text = "No item was yet clicked.";
m_mainPaneText.Dock = DockStyle.Right;
string[] iconLabels = { "iconName" };
var imagelist = new ImageList();
var itemIcon = new Bitmap(32, 32);
for(int x = 0; x < itemIcon.Width; ++x)
for (int y = 0; y < itemIcon.Height; ++y)
itemIcon.SetPixel(x, y, Color.Blue);
imagelist.Images.Add(itemIcon);
m_smallImages.AddList(imagelist, iconLabels);
m_largeImages.AddList(imagelist, iconLabels);
m_mediator = new Mediator();
m_mediator.StringTbl = new SIL.Utils.StringTable("../../DistFiles/Language Explorer/Configuration");
m_sidebarAdapter = new SidebarAdapter();
m_sidebar = m_sidebarAdapter.Init(this, m_smallImages, m_largeImages, m_mediator);
m_sidebarChoiceGroupCollection = new MyChoiceGroupCollection(m_mediator, m_sidebarAdapter, null);
m_sidebarChoiceGroupCollection.Init();
this.Controls.Add(m_sidebar);
this.Controls.Add(m_mainPaneText);
m_sidebarAdapter.FinishInit();
((IUIAdapter)m_sidebarAdapter).OnIdle();
m_mediator.SendMessage("Idle", null);
m_mediator.AddColleague(new MyCoreColleague(m_mainPaneText));
}
示例6: Prioritize
public void Prioritize()
{
using (Mediator mediator = new Mediator())
{
mediator.AddColleague(new LowColleague());
mediator.AddColleague(new HighColleague());
mediator.AddColleague(new MedColleague());
ArrayList testList = new ArrayList();
ArrayList expectedResult = new ArrayList() {"High", "Medium", "Low"};
mediator.SendMessage("AddTestItem", testList);
CollectionAssert.AreEqual(testList, expectedResult, "Mediator message Prioritization is broken.");
}
}
示例7: CoreDoIt
/// <summary>
/// Core of the DoIt method, may be called with or without progress dialog.
/// </summary>
private void CoreDoIt(ProgressDialogWorkingOn progress, Mediator mediator)
{
var specialMdc = m_specialSda.MetaDataCache;
int flidOccurrences = specialMdc.GetFieldId2(WfiWordformTags.kClassId, "Occurrences", false);
using (UndoableUnitOfWorkHelper uuow = new UndoableUnitOfWorkHelper(m_cache.ActionHandlerAccessor,
String.Format(MEStrings.ksUndoChangeSpelling, m_oldSpelling, NewSpelling),
String.Format(MEStrings.ksRedoChangeSpelling, m_oldSpelling, NewSpelling)))
{
IWfiWordform wfOld = FindOrCreateWordform(m_oldSpelling, m_vernWs);
var originalOccurencesInTexts = wfOld.OccurrencesInTexts.ToList(); // At all levels.
IWfiWordform wfNew = FindOrCreateWordform(NewSpelling, m_vernWs);
SetOldOccurrencesOfWordforms(flidOccurrences, wfOld, wfNew);
UpdateProgress(progress);
// It's important to do this BEFORE we update the changed paragraphs. As we update the analysis to point
// at the new wordform and update the text, it may happen that AnalysisAdjuster sees the only occurrence
// of the (new) wordform go away, if the text is being changed to an other-case form. If we haven't set
// the spelling status first, the wordform may get deleted before we ever record its spelling status.
// This way, having a known spelling status will prevent the deletion.
SetSpellingStatus(wfNew);
ComputeParaChanges(true, progress);
if (progress != null)
progress.WorkingOnText = MEStrings.ksDealingAnalyses;
UpdateProgress(progress);
// Compute new occurrence lists, save and cache
SetNewOccurrencesOfWordforms(progress);
UpdateProgress(progress);
// Deal with analyses.
if (wfOld.IsValidObject && CopyAnalyses)
{
// Note: "originalOccurencesInTexts" may have fewer segments, after the call, as they can be removed.
CopyAnalysesToNewWordform(originalOccurencesInTexts, wfOld, wfNew);
}
UpdateProgress(progress);
if (AllChanged)
{
SpellingHelper.SetSpellingStatus(m_oldSpelling, m_vernWs,
m_cache.LanguageWritingSystemFactoryAccessor, false);
if (wfOld.IsValidObject)
{
ProcessAnalysesAndLexEntries(progress, wfOld, wfNew);
}
UpdateProgress(progress);
}
// Only mess with shifting if it was only a case diff in wf, but no changes were made in paragraphs.
// Regular spelling changes will trigger re-tokenization of para, otherwise
if (PreserveCase)
{
// Move pointers in segments to new WF, if the segment references the original WF.
foreach (var segment in originalOccurencesInTexts)
{
if (!m_changedParas.ContainsKey(segment.Owner.Hvo))
continue; // Skip shifting it for items that were not checked
var wfIdx = segment.AnalysesRS.IndexOf(wfOld);
while (wfIdx > -1)
{
segment.AnalysesRS.RemoveAt(wfIdx);
segment.AnalysesRS.Insert(wfIdx, wfNew);
wfIdx = segment.AnalysesRS.IndexOf(wfOld);
}
}
}
// The timing of this is rather crucial. During the work above, we may (if this is invoked from a
// wordform concordance) detect that the current occurrence is no longer valid (since we change the spelling
// and that wordform no longer occurs in that position). This leads to reloading the list and broadcasting
// a RecordNavigation message, as we switch the selection to the first item. However, before we reload the
// list, we need to process ItemDataModified, because that figures out what the new list items are. If
// it doesn't happen before we reload the list, we will put a bunch of invalid occurrences back into it.
// Things to downhill from there as we try to select an invalid one.
// OTOH, we can't figure out the new item data for the wordforms until the work above updates the occurrences!
// The right solution is to wait until we have updated the instances, then send ItemDataModified
// to update the ConcDecorator state, then close the UOW which triggers other PropChanged effects.
// We have to use SendMessage so the ConcDecorator gets that updated before the Clerk using it
// tries to re-read the list.
if (wfOld.CanDelete)
{
wfOld.Delete();
}
else
{
mediator.SendMessage("ItemDataModified", wfOld);
}
mediator.SendMessage("ItemDataModified", wfNew);
uuow.RollBack = false;
}
}
示例8: Init
/// <summary>
/// Initialize.
/// </summary>
/// <param name="mediator"></param>
/// <param name="configurationParameters"></param>
public void Init(Mediator mediator, XmlNode configurationParameters)
{
CheckDisposed();
m_mediator = mediator;
m_previousShowTreeBarValue = m_mediator.PropertyTable.GetBoolProperty("ShowRecordList", true);
m_mediator.PropertyTable.SetProperty("ShowRecordList", false);
m_configurationParameters = configurationParameters;
mediator.AddColleague(this);
m_mediator.PropertyTable.SetProperty("StatusPanelRecordNumber", "");
m_mediator.PropertyTable.SetPropertyPersistence("StatusPanelRecordNumber", false);
#if notnow
m_htmlControl.Browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(Browser_DocumentCompleted);
#endif
SetStrings();
ReadParameters();
DetermineNumberOfPrompts();
DetermineNumberOfTransforms();
SetAlsoSaveInfo();
ReadRegistry();
ShowSketch();
//add our current state to the history system
string toolName = m_mediator.PropertyTable.GetStringProperty("currentContentControl","");
FdoCache cache = Cache;
m_mediator.SendMessage("AddContextToHistory", new FwLinkArgs(toolName, Guid.Empty), false);
}
示例9: QueryDisplayProperties
/// <summary>
///
/// </summary>
/// <param name="group">This provides more context for colleagues to know whether to add a command to a menu.
/// colleagues who want to support short-cut keys should be able to handle <c>null</c>, apart from a context menu group.</param>
/// <param name="mediator"></param>
/// <param name="command"></param>
/// <param name="defaultVisible"></param>
/// <param name="label"></param>
/// <returns></returns>
private static UIItemDisplayProperties QueryDisplayProperties(ChoiceGroup group, Mediator mediator, Command command, bool defaultVisible, string label)
{
// Let the default be that it is enabled if we know that it has
//at least one potential receiver, based on the method signatures of the
//current set of colleagues.
//If one of those colleagues thinks that it should be disabled at the moment,
//then it needs to implement the corresponding Display method
//and disable it from there.
bool hasReceiver = mediator.HasReceiver(command.MessageString);
UIItemDisplayProperties display = new UIItemDisplayProperties(group, label, hasReceiver, command.IconName, defaultVisible);
//OK, this is a little non-obvious
//first we allow anyone who knows about this specific command to influence how it is displayed
//why was it this way? m_mediator.SendMessage("Display"+this.m_idOfCorrespondingCommand, CommandObject, ref display);
mediator.SendMessage("Display" + command.Id, command, ref display);
//but then, we also allow anyone who knows about this specific message that would be sent
//to control how it is displayed. What's the difference?
//Well, it is not uncommon for a single message, e.g. "InsertRecord", to be associated with
//multiple commands, e.g. "CmdInsertPersonRecord", "CmdInsertCompanyRecord".
//And in this case, there may not be any actual code which knows about one of these commands,
//instead the code may be written to just listen for the "InsertRecord" message and then act
//upon its arguments which, in this example, would cause it to either insert a person or a company.
mediator.SendMessage("Display" + command.MessageString, command, ref display);
return display;
}
示例10: GetReversalIndexGuid
/// <summary>
/// Get the current reversal index guid. If there is none, create a new reversal index
/// since there must not be any. This fixes LT-6653.
/// </summary>
/// <param name="mediator"></param>
/// <returns></returns>
internal static Guid GetReversalIndexGuid(Mediator mediator)
{
var riGuid = ReversalIndexEntryUi.GetObjectGuidIfValid(mediator, "ReversalIndexGuid");
if (riGuid.Equals(Guid.Empty))
{
try
{
mediator.SendMessage("InsertReversalIndex_FORCE", null);
riGuid = ReversalIndexEntryUi.GetObjectGuidIfValid(mediator, "ReversalIndexGuid");
}
catch
{
return Guid.Empty;
}
}
return riGuid;
}