private FwLink Pop(LinkedList <FwLink> stack) { FwLink lnk = stack.Last.Value; stack.RemoveLast(); return(lnk); }
/// <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", FwLink.Create(toolName, Guid.Empty, cache.ServerName, cache.DatabaseName), false); }
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { m_link = FwLink.Create("phonologicalFeaturesAdvancedEdit", m_cache.LangProject.PhFeatureSystemOA.Guid, m_cache.ServerName, m_cache.DatabaseName); m_btnCancel.PerformClick(); DialogResult = DialogResult.Ignore; }
private void Push(LinkedList <FwLink> stack, FwLink context) { stack.AddLast(context); while (stack.Count > kmaxDepth) { stack.RemoveFirst(); } }
public virtual bool OnMappingJumpToPhoneme(object args) { CheckDisposed(); int hvo = RuleFormulaControl.CurrentHvo; IMoInsertPhones mapping = new MoInsertPhones(m_cache, hvo); Mediator.PostMessage("FollowLink", FwLink.Create("phonemeEdit", m_cache.GetGuidFromId(mapping.ContentRS[0].Hvo), m_cache.ServerName, m_cache.DatabaseName)); return(true); }
public virtual bool OnContextJumpToPhoneme(object args) { CheckDisposed(); int hvo = RuleFormulaControl.CurrentContextHvo; IPhSimpleContextSeg ctxt = new PhSimpleContextSeg(m_cache, hvo); Mediator.PostMessage("FollowLink", FwLink.Create("phonemeEdit", m_cache.GetGuidFromId(ctxt.FeatureStructureRAHvo), m_cache.ServerName, m_cache.DatabaseName)); return(true); }
public bool OnMappingJumpToNaturalClass(object args) { CheckDisposed(); int hvo = RuleFormulaControl.CurrentHvo; IMoModifyFromInput mapping = new MoModifyFromInput(m_cache, hvo); Mediator.PostMessage("FollowLink", FwLink.Create("naturalClassedit", m_cache.GetGuidFromId(mapping.ModificationRAHvo), m_cache.ServerName, m_cache.DatabaseName)); return(true); }
public bool OnViewIncorrectWords(object argument) { FwLink link = FwLink.Create("Language Explorer", "Analyses", ActiveWordform(Cache), Cache.ServerName, Cache.DatabaseName); List <Property> additionalProps = link.PropertyTableEntries; additionalProps.Add(new Property("SuspendLoadListUntilOnChangeFilter", link.ToolName)); additionalProps.Add(new Property("LinkSetupInfo", "TeCorrectSpelling")); m_mediator.PostMessage("FollowLink", link); return(true); }
/// <summary> /// /// </summary> /// <returns></returns> public bool OnFollowLink(object lnk) { CheckDisposed(); m_fFollowingLink = true; m_cBackStackOrig = m_backStack.Count; m_lnkActive = lnk as FwLink; bool b = FollowActiveLink(); return(b); }
/// <summary> /// /// </summary> /// <returns></returns> public bool OnHistoryForward(object unused) { CheckDisposed(); if (m_forwardStack.Count > 0) { m_fUsingHistory = true; m_lnkActive = Pop(m_forwardStack); FollowActiveLink(); } return(true); }
/// <summary> /// /// </summary> /// <returns></returns> public bool OnAddContextToHistory(object _link) { CheckDisposed(); //Debug.WriteLineIf(RuntimeSwitches.linkListenerSwitch.TraceInfo, "OnAddContextToHistory(" + m_currentContext + ")", RuntimeSwitches.linkListenerSwitch.DisplayName); FwLink lnk = (FwLink)_link; if (lnk.EssentiallyEquals(m_currentContext)) { //Debug.WriteLineIf(RuntimeSwitches.linkListenerSwitch.TraceInfo, " Link equals current context.", RuntimeSwitches.linkListenerSwitch.DisplayName); return(true); } if (m_currentContext != null && //not where we just came from via a "Back" call ((m_forwardStack.Count == 0) || (m_currentContext != m_forwardStack.Last.Value))) { //Debug.WriteLineIf(RuntimeSwitches.linkListenerSwitch.TraceInfo, " Pushing current to back: " + m_currentContext, RuntimeSwitches.linkListenerSwitch.DisplayName); Push(m_backStack, m_currentContext); } // Try to omit intermediate targets which are added to the stack when switching // tools. This doesn't work in OnFollowLink() because the behavior of following // the link is not synchronous even when SendMessage is used at the first two // levels of handling. if (m_fFollowingLink && lnk.EssentiallyEquals(m_lnkActive)) { int howManyAdded = m_backStack.Count - m_cBackStackOrig; for ( ; howManyAdded > 1; --howManyAdded) { m_backStack.RemoveLast(); } m_fFollowingLink = false; m_cBackStackOrig = 0; m_lnkActive = null; } // The forward stack should be cleared by jump operations that are NOT spawned by // a Back or Forward (ie, history) operation. This is the standard behavior in // browsers, for example (as far as I know). if (m_fUsingHistory) { if (lnk.EssentiallyEquals(m_lnkActive)) { m_fUsingHistory = false; m_lnkActive = null; } } else { m_forwardStack.Clear(); } m_currentContext = lnk; return(true); }
public void HandleIncomingLink(FwLink link) { CheckDisposed(); FwXWindow fwxwnd = null; string server = link.Server.Replace(".", Environment.MachineName); // = FwLink.RestoreServerFromURL(link.Server).Replace(".", Environment.MachineName); Debug.Assert(server != null && server != String.Empty); string database = link.Database; Debug.Assert(database != null && database != String.Empty); string key = MakeKey(server, database); if (!m_caches.ContainsKey(key)) { // Add command line info. Dictionary <string, List <String> > oldTable = m_commandLineArgs; // Save original args. m_commandLineArgs = new Dictionary <string, List <String> >(); List <String> list = new List <String>(); list.Add(server); m_commandLineArgs.Add("c", list); list = new List <String>(); list.Add(database); m_commandLineArgs.Add("db", list); list = new List <String>(); list.Add(link.ToString()); m_commandLineArgs.Add("link", list); Form frm = ActiveForm; fwxwnd = (FwXWindow)NewMainWindow(null, false); AdjustNewWindowPosition(fwxwnd, frm); m_commandLineArgs = oldTable; // Restore oringinal args. } else { FdoCache cache = m_caches[key]; // Get window that uses the given DB. foreach (FwXWindow wnd in m_rgMainWindows) { if (wnd.Cache == cache) { fwxwnd = wnd; break; } } } fwxwnd.Mediator.SendMessage("FollowLink", link); bool topmost = fwxwnd.TopMost; fwxwnd.TopMost = true; fwxwnd.TopMost = topmost; fwxwnd.Activate(); }
/// <summary> /// Called by reflection to implement the command. /// </summary> /// <param name="argument"></param> /// <returns></returns> public bool OnEditSpellingStatus(object argument) { // Without checking both the SpellingStatus and (virtual) FullConcordanceCount // fields for the ActiveWordform(Cache) result, it's too likely that the user // will get a puzzling "Target not found" message popping up. See LT-8717. FwLink link = FwLink.Create("Language Explorer", "toolBulkEditWordforms", Guid.Empty, Cache.ServerName, Cache.DatabaseName); List <Property> additionalProps = link.PropertyTableEntries; additionalProps.Add(new Property("SuspendLoadListUntilOnChangeFilter", link.ToolName)); additionalProps.Add(new Property("LinkSetupInfo", "TeReviewUndecidedSpelling")); m_mediator.PostMessage("FollowLink", link); return(true); }
public void OnIncomingLink(FwLink link) { CheckDisposed(); if (m_rgMainWindows.Count == 0) { return; } FwXWindow wnd = m_rgMainWindows[0] as FwXWindow; Debug.Assert(wnd != null); wnd.Invoke(wnd.IncomingLinkHandler, new Object[] { link }); }
/// <summary> /// /// </summary> /// <returns></returns> public bool OnTestFollowLink(object unused) { CheckDisposed(); FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache"); int[] hvos = cache.LangProject.LexDbOA.EntriesOC.HvoArray; m_mediator.SendMessage("FollowLink", FwLink.Create("lexiconEdit", cache.GetGuidFromId(hvos[hvos.Length - 1]) /*the last one*/, cache.ServerName, cache.DatabaseName)); return(true); }
/// <summary> /// create and register a URL describing the current context, for use in going backwards and forwards /// </summary> protected virtual void UpdateContextHistory() { //are we the dominant pane? The thinking here is that if our clerk is controlling the record tree bar, then we are. if (Clerk.IsControllingTheRecordTreeBar) { //add our current state to the history system string toolName = m_mediator.PropertyTable.GetStringProperty("currentContentControl", ""); int hvo = -1; if (Clerk.CurrentObject != null) { hvo = Clerk.CurrentObject.Hvo; } FdoCache cache = Cache; m_mediator.SendMessage("AddContextToHistory", FwLink.Create(toolName, cache.GetGuidFromId(hvo), cache.ServerName, cache.DatabaseName), false); } }
/// <summary> /// /// </summary> /// <returns></returns> public bool OnHistoryBack(object unused) { CheckDisposed(); if (m_backStack.Count > 0) { if (m_currentContext != null) { Push(m_forwardStack, m_currentContext); } m_fUsingHistory = true; m_lnkActive = Pop(m_backStack); FollowActiveLink(); } return(true); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Link,Name")] FwLink fwLink) { if (id != fwLink.Id) { return(NotFound()); } if (ModelState.IsValid) { if (_context.FwLink.Any(p => p.Id != fwLink.Id && p.Link == fwLink.Link)) { ModelState.AddModelError("Link", "链接已存在"); return(View(fwLink)); } if (_context.FwLink.Any(p => p.Id != fwLink.Id && p.Name == fwLink.Name)) { ModelState.AddModelError("Name", "链接名称已存在"); return(View(fwLink)); } var item = _context.FwLink.FirstOrDefault(p => p.Id == fwLink.Id); try { item.Link = fwLink.Link; item.Name = fwLink.Name; item.EditTime = DateTime.Now; _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FwLinkExists(fwLink.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(List))); } return(View(fwLink)); }
internal int DisplayChooser(string fieldName, string linkText, string toolName, string guiControl, Set <int> candidates) { int hvo = 0; ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates); using (SimpleListChooser chooser = new SimpleListChooser(m_persistenceProvider, labels, fieldName)) { chooser.Cache = m_cache; chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOAHvo; chooser.AddLink(linkText, SimpleListChooser.LinkType.kGotoLink, FwLink.Create(toolName, m_cache.GetGuidFromId(chooser.TextParamHvo), m_cache.ServerName, m_cache.DatabaseName)); chooser.ReplaceTreeView(m_mediator, guiControl); if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.RegRuleFormulaControl) { chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-RegRuleFormulaControl"); } else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl) { chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-MetaRuleFormulaControl"); } else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl) { chooser.SetHelpTopic("khtpChoose-LexiconEdit-PhonFeats-AffixRuleFormulaControl"); } DialogResult res = chooser.ShowDialog(); if (res != DialogResult.Cancel) { chooser.HandleAnyJump(); if (chooser.ChosenOne != null) { hvo = chooser.ChosenOne.Hvo; } } } return(hvo); }
protected override void ShowRecord() { RecordClerk clerk = Clerk; // See if it is showing the same record, as before. if (m_currentObject != null && clerk.CurrentObject != null && m_currentIndex == clerk.CurrentIndex && m_currentObject.Hvo == clerk.CurrentObject.Hvo) { SetInfoBarText(); return; } // See if the main owning object has changed. if (clerk.OwningObject.Hvo != m_hvoOwner) { m_hvoOwner = clerk.OwningObject.Hvo; m_mainView.ResetRoot(m_hvoOwner); } m_currentObject = clerk.CurrentObject; m_currentIndex = clerk.CurrentIndex; //add our current state to the history system string toolName = m_mediator.PropertyTable.GetStringProperty( "currentContentControl", ""); int hvo = -1; if (clerk.CurrentObject != null) { hvo = clerk.CurrentObject.Hvo; } FdoCache cache = Cache; m_mediator.SendMessage("AddContextToHistory", FwLink.Create(toolName, cache.GetGuidFromId(hvo), cache.ServerName, cache.DatabaseName), false); SelectAndScrollToCurrentRecord(); base.ShowRecord(); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_mediator != null) { m_mediator.RemoveColleague(this); m_mediator.PropertyTable.SetProperty("LinkListener", null, false); m_mediator.PropertyTable.SetPropertyPersistence("LinkListener", false); } if (m_backStack != null) { m_backStack.Clear(); } if (m_forwardStack != null) { m_forwardStack.Clear(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_mediator = null; m_currentContext = null; m_backStack = null; m_forwardStack = null; m_isDisposed = true; }
public async Task <IActionResult> Create([Bind("Id,Link,Name")] FwLink fwLink) { if (ModelState.IsValid) { if (_context.FwLink.Any(p => p.Id != fwLink.Id && p.Link == fwLink.Link)) { ModelState.AddModelError("Link", "链接已存在"); return(View(fwLink)); } if (_context.FwLink.Any(p => p.Id != fwLink.Id && p.Name == fwLink.Name)) { ModelState.AddModelError("Name", "链接名称已存在"); return(View(fwLink)); } fwLink.User = _context.Users.Find(_userId); fwLink.CreateTime = DateTime.Now; fwLink.EditTime = fwLink.CreateTime; _context.Add(fwLink); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(List))); } return(View(fwLink)); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="LinkListener"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public LinkListener() { m_backStack = new LinkedList <FwLink>(); m_forwardStack = new LinkedList <FwLink>(); m_currentContext = null; }