/// ------------------------------------------------------------------------------------ private void LoadToolbarAndContextMenus() { if (App.DesignMode) { return; } if (_tmAdapter != null) { _tmAdapter.Dispose(); } _tmAdapter = AdapterHelper.CreateTMAdapter(); if (_tmAdapter != null) { var defs = new[] { FileLocator.GetFileDistributedWithApplication(App.ConfigFolderName, "CVChartsTMDefinition.xml") }; _tmAdapter.Initialize(this, App.MsgMediator, App.ApplicationRegKeyPath, defs); _tmAdapter.AllowUpdates = true; } // Give the chart Phone search toolbar button a default image. var childItemProps = _tmAdapter.GetItemProperties("tbbChartPhoneSearchAnywhere"); var parentItemProps = _tmAdapter.GetItemProperties("tbbChartPhoneSearch"); if (parentItemProps != null && childItemProps != null) { parentItemProps.Image = childItemProps.Image; parentItemProps.Visible = true; parentItemProps.Update = true; _tmAdapter.SetItemProperties("tbbChartPhoneSearch", parentItemProps); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="EmptyScripture"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public EmptyScripture(ITMAdapter adapter, FdoCache fdoCache, IHelpTopicProvider helpTopicProvider) { InitializeComponent(); m_helpTopicProvider = helpTopicProvider; if (adapter == null || adapter.MessageMediator == null) btnBook.Enabled = false; else { m_tmAdapter = adapter; // Save the adapter's message mediator so it can be restored when the // dialog closes. m_savMsgMediator = adapter.MessageMediator; // Create a new mediator for this dialog and set // the adapter's mediator to it. Mediator mediator = new Mediator(); mediator.AddColleague(this); m_tmAdapter.MessageMediator = mediator; } string projectName = fdoCache.ProjectId.Name; lblTopLabel.Text = string.Format(lblTopLabel.Text,projectName); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public void Dispose() { m_form = null; m_adapter = null; m_menuStrip = null; m_statusStrip = null; if (m_statusLbl != null) { m_statusLbl.Dispose(); m_statusLbl = null; } if (m_filterButton != null) { m_filterButton.Dispose(); m_filterButton = null; } if (m_separator != null) { m_separator.Dispose(); m_separator = null; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Tells the side bar adapter to setup it's menus so they show up on the application's /// view menu. This method should be called after all the tabs and tab items have been /// created. /// </summary> /// <param name="menuAdapter">Menu adapter used by the application.</param> /// <param name="insertBeforeItem">Name of the menu item before which the sidebar /// menus will be added.</param> /// ------------------------------------------------------------------------------------ public void SetupViewMenuForSideBarTabs(ITMAdapter adapter, string insertBeforeItem) { Debug.Assert(adapter != null); adapter.MessageMediator.AddColleague(this); foreach (SideBarTab tab in m_navPane.Items) { // Add the menu for the view tab. TMItemProperties props = tab.MenuItemProperties; props.Message = "SideBarViewTabMenuHandler"; adapter.AddMenuItem(props, null, insertBeforeItem); // Add menus for the view tab items. foreach (TMItemProperties itemProps in tab.SubMenuItemProperties) { itemProps.Text = itemProps.Text.Replace(Environment.NewLine, " "); itemProps.Message = "SideBarViewTabItemMenuHandler"; adapter.AddMenuItem(itemProps, tab.MenuItemProperties.Name, null); } // Add the menu item for the view tab's configure menu. SBTabProperties tabProps = tab.Properties; props = new TMItemProperties(); props.Name = tab.Name + "Config"; props.Text = tabProps.ConfigureMenuText; props.Message = tabProps.ConfigureMessage; props.BeginGroup = true; props.Tag = tabProps; adapter.AddMenuItem(props, tab.MenuItemProperties.Name, null); } }
/// ------------------------------------------------------------------------------------ public SearchResultView(Type owningViewType, ITMAdapter tmAdapter) { InitializeComponent(); base.DoubleBuffered = true; base.Dock = DockStyle.Fill; _owningViewType = owningViewType; _tmAdapter = tmAdapter; Disposed += SearchResultView_Disposed; }
/// ------------------------------------------------------------------------------------ protected override void OnFormClosing(FormClosingEventArgs e) { App.MsgMediator.RemoveColleague(this); Visible = false; App.UnloadDefaultMenu(m_mainMenuAdapter); m_mainMenuAdapter.Dispose(); m_mainMenuAdapter = null; Controls.Remove(m_view); base.OnFormClosing(e); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a TMBarProperties object. /// </summary> /// ------------------------------------------------------------------------------------ public TMBarProperties(string name, string text, bool enabled, bool visible, Control parentCtrl, ITMAdapter adapter) { Name = name; Text = text; Enabled = enabled; Visible = visible; ParentControl = parentCtrl; Adapter = adapter; Update = false; }
/// ------------------------------------------------------------------------------------ public CVChartGrid(ITMAdapter tmAdapter) : this() { if (tmAdapter != null) { tmAdapter.SetContextMenuForControl(this, "cmnuCharChartGrid"); if (ContextMenuStrip != null) { ContextMenuStrip.Opening += ((sender, args) => m_phoneInfoPopup.Enabled = false); ContextMenuStrip.Closed += ((sender, args) => m_phoneInfoPopup.Enabled = true); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <returns>An instance of a menu adapter.</returns> /// ------------------------------------------------------------------------------------ public static ITMAdapter CreateTMAdapter() { if (MiscUtils.RunningTests || !LoadUIAdapterAssembly()) { return(null); } ITMAdapter tmAdapter = (ITMAdapter)m_uiAdapterAssembly.CreateInstance( "SIL.FieldWorks.Common.UIAdapters.TMAdapter"); Debug.Assert(tmAdapter != null, "Could not create a toolbar/menu adapter."); return(tmAdapter); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected bool OnMainViewOpened(object args) { try { if (args is PaMainWnd) { m_mainWnd = args as PaMainWnd; m_adapter = PaApp.TMAdapter; m_adapter.AddCommandItem("CmdSendFeedback", "SendFeedback", Properties.Resources.kstidFeedbackMenuText, null, null, null, null, null, Keys.None, null, Properties.Resources.kimidSendFeedback); m_feedbackItemProps = new TMItemProperties(); m_feedbackItemProps.BeginGroup = true; m_feedbackItemProps.CommandId = "CmdSendFeedback"; m_feedbackItemProps.Name = "mnuSendFeedback"; m_feedbackItemProps.Text = null; m_adapter.AddMenuItem(m_feedbackItemProps, "mnuHelp", "mnuHelpAbout"); // Get the number of times PA has been launched. int launchCount = PaApp.SettingsHandler.GetIntSettingsValue( "feedbackaddon", "launchcount", 0); // Increase the launch count by one and save it. PaApp.SettingsHandler.SaveSettingsValue( "feedbackaddon", "launchcount", ++launchCount); // If we've reached the tenth time PA has been run, then show // the user the dialog requesting feedback. if (launchCount == 10) { using (RequestDlg dlg = new RequestDlg()) { if (dlg.ShowDialog(m_mainWnd) == DialogResult.Yes) { OnSendFeedback(null); } } } } } catch { } return(false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public FilterGUIComponent(Form frm) { m_form = frm; if (frm is PaMainWnd) { m_adapter = PaApp.TMAdapter; } else if (frm is UndockedViewWnd) { m_adapter = ReflectionHelper.GetField(frm, "m_mainMenuAdapter") as ITMAdapter; } SetupFilterToolbarButton(); SetupFilterStatusBarLabel(); SetupFilterMenu(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Tells the side bar adapter to setup it's menus so they show up on the application's /// view menu. This method should be called after all the tabs and tab items have been /// created. /// </summary> /// <param name="menuAdapter">Menu adapter used by the application.</param> /// <param name="insertBeforeItem">Name of the menu item before which the sidebar /// menus will be added.</param> /// ------------------------------------------------------------------------------------ public void SetupViewMenuForSideBarTabs(ITMAdapter adapter, string insertBeforeItem) { TMAdapter silAdapter = adapter as TMAdapter; foreach (SBTabProperties tab in m_tabProps) { ToolStripMenuItem viewTab = new ToolStripMenuItem(); viewTab.Text = tab.Text; viewTab.Enabled = tab.Enabled; foreach (SBTabItemProperties item in m_tabItemProps) { if (item.OwningTabName == tab.Name) { ToolStripMenuItem menuItem = new ToolStripMenuItem(); // just one space if any version of newline is present menuItem.Text = item.Text.Replace("\r\n", " ").Replace('\r', ' ').Replace('\n', ' '); menuItem.Image = this.m_smallItemImages.Images[item.ImageIndex]; menuItem.Tag = item; //menuItem.Image = this.m_smallItemImages[]; viewTab.DropDown.Items.Add(menuItem); menuItem.Click += SideBarItemOnMenuClick; } } if (tab.ConfigureMenuVisible && !String.IsNullOrEmpty(tab.ConfigureMessage) && !String.IsNullOrEmpty(tab.ConfigureMenuText)) { var menuItem = new ToolStripMenuItem(); menuItem.Text = tab.ConfigureMenuText; menuItem.Tag = tab; menuItem.Click += new EventHandler(ConfigureItem_Click); viewTab.DropDown.Items.Add(new ToolStripSeparator()); viewTab.DropDown.Items.Add(menuItem); } viewTab.DropDownOpened += new EventHandler(TabMenu_DropDownOpened); silAdapter.InsertMenuItem(viewTab, insertBeforeItem); } adapter.MessageMediator.AddColleague(this); }
/// ------------------------------------------------------------------------------------ public UndockedViewWnd(Control view) : this() { if (view != null) { Name = view.GetType().Name; } try { Properties.Settings.Default[Name] = App.InitializeForm(this, Properties.Settings.Default[Name] as FormSettings); } catch { StartPosition = FormStartPosition.CenterScreen; } m_mainMenuAdapter = App.LoadDefaultMenu(this); m_mainMenuAdapter.AllowUpdates = false; Controls.Add(view); view.BringToFront(); m_view = view; Opacity = 0; sblblMain.Text = sblblProgress.Text = string.Empty; sblblProgress.Font = FontHelper.MakeFont(FontHelper.UIFont, 9, FontStyle.Bold); sblblProgress.Visible = false; sbProgress.Visible = false; sblblPercent.Visible = false; MinimumSize = App.MinimumViewWindowSize; sblblFilter.Paint += HandleFilterStatusStripLabelPaint; if (App.Project != null) { OnFilterChanged(App.Project.CurrentFilter); } App.MsgMediator.AddColleague(this); }
/// ------------------------------------------------------------------------------------ private void LoadToolbar() { if (m_tmAdapter != null) { m_tmAdapter.Dispose(); } m_tmAdapter = AdapterHelper.CreateTMAdapter(); if (WordListGrid != null) { WordListGrid.TMAdapter = m_tmAdapter; } if (m_tmAdapter != null) { m_tmAdapter.LoadControlContainerItem += m_tmAdapter_LoadControlContainerItem; var defs = new[] { FileLocator.GetFileDistributedWithApplication(App.ConfigFolderName, "DataCorpusTMDefinition.xml") }; m_tmAdapter.Initialize(this, App.MsgMediator, App.ApplicationRegKeyPath, defs); m_tmAdapter.AllowUpdates = true; } }
void UpdateItemProps(ITMAdapter tmAdapter, string menuName, bool nonSpellingError, object tag) { TMItemProperties itemProps = tmAdapter.GetItemProperties(menuName); if (itemProps != null) { if (nonSpellingError) { itemProps.Tag = null; // disable } else { itemProps.Tag = tag; } itemProps.Update = true; tmAdapter.SetItemProperties(menuName, itemProps); } }
private List<string> MakeSpellCheckMenuOptions(Point mousePos, RootSite rootsite, ITMAdapter tmAdapter, string menuName, string addToDictMenuName, string changeMultipleMenuName, string insertBeforeMenuName) { int hvoObj, tag, wsAlt, wsText; string word; ISpellEngine dict; bool nonSpellingError; ICollection<SpellCorrectMenuItem> suggestions = SpellCheckHelper.GetSuggestions(mousePos, rootsite, out hvoObj, out tag, out wsAlt, out wsText, out word, out dict, out nonSpellingError); IVwRootBox rootb = rootsite.RootBox; // These two menu items are disabled for non-spelling errors. In addition, for addToDict, we need // to set the tag to an AddToDictMenuItem which can actually do the work. UpdateItemProps(tmAdapter, addToDictMenuName, nonSpellingError, new AddToDictMenuItem(dict, word, rootb, hvoObj, tag, wsAlt, wsText, RootSiteStrings.ksAddToDictionary, Cache)); // any non-null value of tag will indicate the item should be enabled, tested in TeMainWnd.UpdateSpellingMenus. UpdateItemProps(tmAdapter, changeMultipleMenuName, nonSpellingError, "ok to change"); if (suggestions == null) return null; // Make the menu options. List<string> menuItemNames = new List<string>(); TMItemProperties itemProps; if (suggestions.Count == 0) { itemProps = new TMItemProperties(); itemProps.Name = "noSpellingSuggestion"; itemProps.Text = RootSiteStrings.ksNoSuggestions; itemProps.Enabled = false; menuItemNames.Add(itemProps.Name); tmAdapter.AddContextMenuItem(itemProps, menuName, insertBeforeMenuName); } int cSuggestions = 0; string additionalSuggestionsMenuName = "additionalSpellSuggestion"; foreach (SpellCorrectMenuItem scmi in suggestions) { itemProps = new TMItemProperties(); itemProps.Name = "spellSuggestion" + scmi.Text; itemProps.Text = scmi.Text; itemProps.Message = "SpellingSuggestionChosen"; itemProps.CommandId = "CmdSpellingSuggestionChosen"; itemProps.Tag = scmi; itemProps.Font = (wsText == 0) ? null : GetFontForNormalStyle(wsText, rootb.Stylesheet, rootb.DataAccess.WritingSystemFactory); if (cSuggestions++ == kMaxSpellingSuggestionsInRootMenu) { TMItemProperties tmpItemProps = new TMItemProperties(); tmpItemProps.Name = additionalSuggestionsMenuName; tmpItemProps.Text = RootSiteStrings.ksAdditionalSuggestions; menuItemNames.Add(tmpItemProps.Name); tmAdapter.AddContextMenuItem(tmpItemProps, menuName, insertBeforeMenuName); insertBeforeMenuName = null; } if (insertBeforeMenuName != null) { menuItemNames.Add(itemProps.Name); tmAdapter.AddContextMenuItem(itemProps, menuName, insertBeforeMenuName); } else { tmAdapter.AddContextMenuItem(itemProps, menuName, additionalSuggestionsMenuName, null); } } return menuItemNames; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the specified context menu for the specified rootsite at the specified /// mouse position. This will also determine whether or not to include the spelling /// correction options. /// </summary> /// ------------------------------------------------------------------------------------ public void ShowContextMenu(Point mousePos, ITMAdapter tmAdapter, RootSite rootsite, string contextMenuName, string addToDictMenuName, string insertBeforeMenuName, string changeMultipleMenuName, bool fShowSpellingOptions) { CheckDisposed(); m_spellCheckStatus = SpellCheckStatus.Disabled; List<string> menuItemNames = null; if (fShowSpellingOptions) { Debug.Assert(rootsite.RootBox == Callbacks.EditedRootBox); menuItemNames = MakeSpellCheckMenuOptions(mousePos, rootsite, tmAdapter, contextMenuName, addToDictMenuName, insertBeforeMenuName, changeMultipleMenuName); m_spellCheckStatus = (menuItemNames == null ? SpellCheckStatus.WordInDictionary : SpellCheckStatus.Enabled); } Point pt = rootsite.PointToScreen(mousePos); tmAdapter.PopupMenu(contextMenuName, pt.X, pt.Y, menuItemNames); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:EditorialChecksControl"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="app">The app.</param> /// <param name="bookFilter">The book filter.</param> /// <param name="sCaption">The caption to use when this control is displayed as a /// floating window</param> /// <param name="sProject">The name of the current project</param> /// <param name="tmAdapter">TMAdapter for the main window</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public EditorialChecksControl(FdoCache cache, IApp app, FilteredScrBooks bookFilter, string sCaption, string sProject, ITMAdapter tmAdapter, IHelpTopicProvider helpTopicProvider) : base(sCaption, sProject) { InitializeComponent(); lblCheckName.Text = string.Empty; m_dxButtonGap = m_btnApplyFilter.Left - m_btnRunChecks.Right; m_dyButtonGap = pnlButtons.Padding.Top; m_buttonPanelHeight1 = pnlButtons.Height; m_buttonPanelHeight2 = m_buttonPanelHeight1 + m_btnRunChecks.Height + m_dyButtonGap; m_buttonPanelHeight3 = m_buttonPanelHeight2 + m_btnRunChecks.Height + m_dyButtonGap; m_helpTopicProvider = helpTopicProvider; m_app = app; // It's important to subscribe to this event after the previous three // heights are saved. Therefore, this event should not be subscribed // to in designer (i.e. InitializeComponent()). This fixes TE-6653. pnlButtons.ClientSizeChanged += pnlButtons_ClientSizeChanged; m_cache = cache; m_chkDataSource = new ScrChecksDataSource(cache, FwDirectoryFinder.TeStylesPath, FwDirectoryFinder.LegacyWordformingCharOverridesFile); m_bookFilter = bookFilter; m_bookFilter.FilterChanged += OnBookFilterChanged; CreateCheckingToolbar(tmAdapter); m_nodeTip = new ToolTip(); m_ComboBox.HideDropDownWhenComboTextChanges = false; // Set the minimum allowable with for the // control will be based on the widest button. int minWidth = m_btnRunChecks.Width; minWidth = Math.Max(minWidth, m_btnApplyFilter.Width); MinimumSize = new Size(Math.Max(minWidth, m_btnHelp.Width), MinimumSize.Height); if (tmAdapter != null) { if (tmAdapter.MessageMediator != null) tmAdapter.MessageMediator.AddColleague(this); tmAdapter.SetContextMenuForControl(this, "cmnuEditorialChecksTree"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="EditorialChecksControl"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="bookFilter">The book filter.</param> /// <param name="sCaption">The caption to use when this control is displayed as a /// floating window</param> /// <param name="sProject">The name of the current project</param> /// <param name="tmAdapter">TMAdapter for the main window</param> /// ------------------------------------------------------------------------------------ public EditorialChecksControl(FdoCache cache, FilteredScrBooks bookFilter, string sCaption, string sProject, ITMAdapter tmAdapter) : base(sCaption, sProject) { InitializeComponent(); lblCheckName.Text = string.Empty; m_dxButtonGap = m_btnApplyFilter.Left - m_btnRunChecks.Right; m_dyButtonGap = pnlButtons.Padding.Top; m_buttonPanelHeight1 = pnlButtons.Height; m_buttonPanelHeight2 = m_buttonPanelHeight1 + m_btnRunChecks.Height + m_dyButtonGap; m_buttonPanelHeight3 = m_buttonPanelHeight2 + m_btnRunChecks.Height + m_dyButtonGap; // It's important to subscribe to this event after the previous three // heights are saved. Therefore, this event should not be subscribed // to in designer (i.e. InitializeComponent()). This fixes TE-6653. pnlButtons.ClientSizeChanged += pnlButtons_ClientSizeChanged; m_cache = cache; m_chkDataSource = new ScrChecksDataSource(cache); m_bookFilter = bookFilter; m_bookFilter.CheckFilteredBooks(); m_bookFilter.FilterChanged += OnBookFilterChanged; Content = pnlOuter; CreateCheckingToolbar(tmAdapter); m_nodeTip = new ToolTip(); m_ComboBox.HideDropDownWhenComboTextChanges = false; // Set the minimum allowable with for the // control will be based on the widest button. int minWidth = m_btnRunChecks.Width; minWidth = Math.Max(minWidth, m_btnApplyFilter.Width); MinimumSize = new Size(Math.Max(minWidth, m_btnHelp.Width), MinimumSize.Height); m_chkHelpIds = new Dictionary<Guid, string>(); m_chkHelpIds[StandardCheckIds.kguidCharacters] = "khtpScrChecksCharacters"; m_chkHelpIds[StandardCheckIds.kguidChapterVerse] = "khtpScrChecksChapterVerse"; m_chkHelpIds[StandardCheckIds.kguidMixedCapitalization] = "khtpScrChecksMixedCapitalization"; m_chkHelpIds[StandardCheckIds.kguidRepeatedWords] = "khtpScrChecksRepeatedWords"; m_chkHelpIds[StandardCheckIds.kguidMatchedPairs] = "khtpScrChecksMatchingPunctPairs"; m_chkHelpIds[StandardCheckIds.kguidPunctuation] = "khtpScrChecksPunctuationPatterns"; m_chkHelpIds[StandardCheckIds.kguidQuotations] = "khtpScrChecksQuotationMarks"; m_chkHelpIds[StandardCheckIds.kguidCapitalization] = "khtpScrChecksCapitalization"; if (tmAdapter != null) { if (tmAdapter.MessageMediator != null) tmAdapter.MessageMediator.AddColleague(this); tmAdapter.SetContextMenuForControl(this, "cmnuEditorialChecksTree"); } }
public void SetupViewMenuForSideBarTabs(ITMAdapter adapter, string insertBeforeItem) { TMAdapter silAdapter = adapter as TMAdapter; foreach (SBTabProperties tab in m_tabProps) { ToolStripMenuItem viewTab = new ToolStripMenuItem(); viewTab.Text = tab.Text; viewTab.Enabled = tab.Enabled; foreach (SBTabItemProperties item in m_tabItemProps) { if (item.OwningTabName == tab.Name) { ToolStripMenuItem menuItem = new ToolStripMenuItem(); // just one space if any version of newline is present menuItem.Text = item.Text.Replace("\r\n", " ").Replace('\r', ' ').Replace('\n', ' '); menuItem.Image = this.m_smallItemImages.Images[item.ImageIndex]; menuItem.Tag = item; //menuItem.Image = this.m_smallItemImages[]; viewTab.DropDown.Items.Add(menuItem); menuItem.Click += SideBarItemOnMenuClick; } } if (tab.ConfigureMenuVisible && !String.IsNullOrEmpty(tab.ConfigureMessage) && !String.IsNullOrEmpty(tab.ConfigureMenuText)) { var menuItem = new ToolStripMenuItem(); menuItem.Text = tab.ConfigureMenuText; menuItem.Tag = tab; menuItem.Click += new EventHandler(ConfigureItem_Click); viewTab.DropDown.Items.Add(new ToolStripSeparator()); viewTab.DropDown.Items.Add(menuItem); } viewTab.DropDownOpened += new EventHandler(TabMenu_DropDownOpened); silAdapter.InsertMenuItem(viewTab, insertBeforeItem); } adapter.MessageMediator.AddColleague(this); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Tells the side bar adapter to setup it's menus so they show up on the application's /// view menu. This method should be called after all the tabs and tab items have been /// created. /// </summary> /// <param name="menuAdapter">Menu adapter used by the application.</param> /// <param name="insertBeforeItem">Name of the menu item before which the sidebar /// menus will be added.</param> /// ------------------------------------------------------------------------------------ public void SetupViewMenuForSideBarTabs(ITMAdapter adapter, string insertBeforeItem) { Debug.Assert(adapter != null); adapter.MessageMediator.AddColleague(this); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Tells the side bar adapter to setup it's menus so they show up on the application's /// view menu. This method should be called after all the tabs and tab items have been /// created. /// </summary> /// <param name="menuAdapter">Menu adapter used by the application.</param> /// <param name="insertBeforeItem">Name of the menu item before which the sidebar /// menus will be added.</param> /// ------------------------------------------------------------------------------------ public void SetupViewMenuForSideBarTabs(ITMAdapter adapter, string insertBeforeItem) { TMAdapter dnbAdapter = adapter as TMAdapter; if (dnbAdapter == null || dnbAdapter.m_dnbMngr == null) { // Use this block when the menu adapter isn't one or our DNB ones defined in // this assembly. TODO: Need to call AddItem for each subitem in each tab's menu. foreach (SideBarTab tab in m_navPane.Items) adapter.AddMenuItem(tab.MenuItemProperties, null, insertBeforeItem); } // When the menu adapter is one of a type from our assembly, then use it's DNB // manager instead of the one instantiated in SetupSideBarsContextMenu. Add the // side bar's context menu to the DNB manager and set it to popup for as the // side bar's default context menu. m_dnbMngr = dnbAdapter.m_dnbMngr; m_dnbMngr.ContextMenus.Add(m_contextMenu); m_dnbMngr.SetContextMenuEx(m_navPane, "sbcontextmenu"); // Insert our tab's menus before the specified item. foreach (SideBarTab tab in m_navPane.Items) { dnbAdapter.InsertMenuItem(tab.Menu, insertBeforeItem, false); tab.Menu.Visible = true; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void CreateCheckingToolbar(ITMAdapter tmAdapter) { if (tmAdapter == null) return; m_tmAdapter = tmAdapter; m_sepShowOnlyAtTop = new ToolStripSeparator(); m_ToolStrip.Items.Insert(0, m_sepShowOnlyAtTop); AddToolStripButton(tmAdapter.GetItemProperties("mnuStatusEditAnnotation"), "ScrChecksEditAnnotation"); m_tbbEditAnnotations = m_ToolStrip.Items[0] as ToolStripButton; m_ToolStrip.Items.Insert(0, new ToolStripSeparator()); AddToolStripButton(tmAdapter.GetItemProperties("mnuStatusInconsistency"), "ScrChecksInconsistency"); m_tbbInconsistencies = m_ToolStrip.Items[0] as ToolStripButton; s_dontIgnoreImage = TeResourceHelper.UnignoredInconsistency; AddToolStripButton(tmAdapter.GetItemProperties("mnuStatusIgnoredWAnnotation"), "ScrChecksIgnoredWAnnotation"); m_tbbIgnoreWAnnotation = m_ToolStrip.Items[0] as ToolStripButton; AddToolStripButton(tmAdapter.GetItemProperties("mnuStatusIgnored"), "ScrChecksIgnored"); m_tbbIgnore = m_ToolStrip.Items[0] as ToolStripButton; s_ignoreImage = TeResourceHelper.IgnoredInconsistency; OnCheckErrorsListReferenceChanged(null, CheckingError.Empty); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Clean up any resources being used. /// </summary> /// ------------------------------------------------------------------------------------ protected override void Dispose(bool disposing) { Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + ". ******************"); // Must not be run more than once. if (IsDisposed || m_beingDisposed || Disposing) return; m_beingDisposed = true; if (disposing) { foreach (Control ctrl in m_rgClientViews.Values) { // Dispose of any views that aren't in the form currently. if (ctrl.Parent == null) ctrl.Dispose(); } if (m_mediator != null) { m_mediator.ProcessMessages = false; m_mediator.RemoveColleague(this); } if (m_cboZoomPercent != null) m_cboZoomPercent.Dispose(); if (m_paraStylesComboBox != null) m_paraStylesComboBox.Dispose(); if (m_charStylesComboBox != null) m_charStylesComboBox.Dispose(); if (m_writingSystemSelector != null) m_writingSystemSelector.Dispose(); if (m_progressHandler != null) m_progressHandler.Dispose(); if (m_writingSystemSelector != null) m_writingSystemSelector.Dispose(); if (m_UndoRedoDropDown != null) m_UndoRedoDropDown.Dispose(); if (components != null) components.Dispose(); // no need to explicitly call Dispose on m_persistence - it's part of // components collection and gets disposed there. if (m_rgClientViews != null) m_rgClientViews.Clear(); if (m_tmAdapter != null) { m_tmAdapter.LoadControlContainerItem -= LoadCustomToolBarControls; m_tmAdapter.InitializeComboItem -= InitializeToolBarCombos; m_tmAdapter.Dispose(); } if (m_cache != null) m_cache.ProjectNameChanged -= ProjectNameChanged; if (m_app != null) { // The removing of the window from the app's collection needs to happen later, after // this main window is already disposed of. This is needed for side-effects // that require a running message loop (such as closing the TE notes view // which would normally happen at this call without a running message loop) m_app.FwManager.ExecuteAsync(m_app.RemoveWindow, this); } } m_cboZoomPercent = null; m_paraStylesComboBox = null; m_charStylesComboBox = null; m_writingSystemSelector = null; m_delegate = null; m_tmAdapter = null; m_UndoRedoDropDown = null; m_writingSystemSelector = null; m_StyleSheet = null; m_selectedView = null; m_rgClientViews = null; #if !__MonoCS__ base.Dispose(disposing); #else try { base.Dispose(disposing); } catch (System.ArgumentOutOfRangeException) { // TODO-Linux: examine ToolStrip disposal in UIAdapter // is ToolStrip (from UIAdapter?) being Disposed multiple times? } #endif if (disposing) { if (m_viewHelper != null) m_viewHelper.Dispose(); if (m_mediator != null) m_mediator.Dispose(); } m_cache = null; m_viewHelper = null; m_mediator = null; m_app = null; m_beingDisposed = false; }
protected virtual void CreateMenusAndToolBars() { m_tmAdapter = AdapterHelper.CreateTMAdapter(); // This will always be null when running tests. Otherwise, it will only be null if // The UIAdapter.dll couldn't be found... or null for some other reason. :o) if (m_tmAdapter == null) { // Do this for the sake of the tests. InitializeToolBarCombos("tbbParaStylesCombo", new ComboBox()); InitializeToolBarCombos("tbbCharStylesCombo", new ComboBox()); InitializeToolBarCombos("tbbZoom", new ComboBox()); return; } // Use this to deliver controls to control container toolbar items. m_tmAdapter.LoadControlContainerItem += LoadCustomToolBarControls; // Use this to initialize combo box items. m_tmAdapter.InitializeComboItem += InitializeToolBarCombos; string sMenuToolBarDefinition = Path.Combine(FwDirectoryFinder.CodeDirectory, "FwTMDefinition.xml"); m_tmAdapter.Initialize(this, AdapterContentControl, m_mediator, m_app.ProjectSpecificSettingsKey.ToString(), new string[] { sMenuToolBarDefinition, GetAppSpecificMenuToolBarDefinition() }); InitializeContextMenus(sMenuToolBarDefinition, GetAppSpecificMenuToolBarDefinition()); m_tmAdapter.AllowUpdates = true; m_mediator.AddColleague(this); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct the toolbars /// </summary> /// ------------------------------------------------------------------------------------ private void CreateMenuAndToolbars() { Debug.Assert(m_tmAdapter == null); m_tmAdapter = AdapterHelper.CreateTMAdapter(); // This will always be null when running tests. Otherwise, it will only be null if // The UIAdapter.dll couldn't be found... or null for some other reason. :o) if (m_tmAdapter == null) return; // Use this to initialize combo box items. m_tmAdapter.InitializeComboItem += new InitializeComboItemHandler(InitializeToolBarCombos); string[] def = new string[] {Common.Utils.DirectoryFinder.FWCodeDirectory + @"\Translation Editor\Configuration\DiffViewTMDefinition.xml"}; m_tmAdapter.AllowUpdates = true; m_tmAdapter.Initialize(this, m_msgMediator, def); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged /// resources; <c>false</c> to release only unmanaged resources. /// </param> /// ----------------------------------------------------------------------------------- protected override void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); // Must not be run more than once. if (IsDisposed) return; if (disposing) { if (m_messageFilterInstalled) { Application.RemoveMessageFilter(this); m_messageFilterInstalled = false; } // We don't want to call Controls.Clear() here, because that causes the controls // to change size (and fire the events for it...). It causes CreateMenuAndToolbars() // to be called, so we end up with two toolbar adapters, but we dispose only one, // so eventually it tries to access the already disposed mediator. //Controls.Clear(); // No, since m_bookMerger owns it. // if (m_differences != null) // m_differences.Dispose(); if (m_viewHelper != null) m_viewHelper.Dispose(); if (m_msgMediator != null) { m_msgMediator.RemoveColleague(this); // m_msgMediator gets disposed from calling components.Dispose() below } if (m_tmAdapter != null) { m_tmAdapter.InitializeComboItem -= InitializeToolBarCombos; m_tmAdapter.Dispose(); } ZoomFactorDraft.Dispose(); ZoomFactorFootnote.Dispose(); if(components != null) { components.Dispose(); } } // Deal with unmanaged stuff here. m_viewHelper = null; m_tmAdapter = null; m_differences = null; // Just null it, since m_bookMerger owns it and will dispose it. m_msgMediator = null; m_bookMerger = null; // Client gave it, so it has to dispose it. m_cache = null; m_scr = null; m_stylesheet = null; base.Dispose(disposing); }