コード例 #1
0
ファイル: SimpleMatchDlg.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:SimpleMatchDlg"/> class.
		/// </summary>
		/// <param name="wsf">The WSF.</param>
		/// <param name="ws">The ws.</param>
		/// <param name="ss">The ss.</param>
		/// ------------------------------------------------------------------------------------
		public SimpleMatchDlg(ILgWritingSystemFactory wsf, int ws, IVwStylesheet ss)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			// We do this outside the designer-controlled code because it does funny things
			// to FwTextBoxes, owing to the need for a writing system factory, and some
			// properties it should not persist but I can't persuade it not to.
			this.m_textBox = new FwTextBox();
			this.m_textBox.WritingSystemFactory = wsf; // set ASAP.
			this.m_textBox.WritingSystemCode = ws;
			this.m_textBox.StyleSheet = ss; // before setting text, otherwise it gets confused about height needed.
			this.m_textBox.Location = new System.Drawing.Point(8, 24);
			this.m_textBox.Name = "m_textBox";
			this.m_textBox.Size = new System.Drawing.Size(450, 32);
			this.m_textBox.TabIndex = 0;
			this.m_textBox.Text = "";
			this.Controls.Add(this.m_textBox);

			regexContextMenu = new RegexHelperMenu(m_textBox, FwApp.App);

			m_ivwpattern = VwPatternClass.Create();

			helpProvider = new System.Windows.Forms.HelpProvider();
			helpProvider.HelpNamespace = FwApp.App.HelpFile;
			helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
			helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
		}
コード例 #2
0
ファイル: SimpleMatchDlg.cs プロジェクト: sillsdev/WorldPad
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:SimpleMatchDlg"/> class.
        /// </summary>
        /// <param name="wsf">The WSF.</param>
        /// <param name="ws">The ws.</param>
        /// <param name="ss">The ss.</param>
        /// ------------------------------------------------------------------------------------
        public SimpleMatchDlg(ILgWritingSystemFactory wsf, int ws, IVwStylesheet ss)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // We do this outside the designer-controlled code because it does funny things
            // to FwTextBoxes, owing to the need for a writing system factory, and some
            // properties it should not persist but I can't persuade it not to.
            this.m_textBox = new FwTextBox();
            this.m_textBox.WritingSystemFactory = wsf;  // set ASAP.
            this.m_textBox.WritingSystemCode    = ws;
            this.m_textBox.StyleSheet           = ss;   // before setting text, otherwise it gets confused about height needed.
            this.m_textBox.Location             = new System.Drawing.Point(8, 24);
            this.m_textBox.Name     = "m_textBox";
            this.m_textBox.Size     = new System.Drawing.Size(450, 32);
            this.m_textBox.TabIndex = 0;
            this.m_textBox.Text     = "";
            this.Controls.Add(this.m_textBox);

            regexContextMenu = new RegexHelperMenu(m_textBox, FwApp.App);

            m_ivwpattern = VwPatternClass.Create();

            helpProvider = new System.Windows.Forms.HelpProvider();
            helpProvider.HelpNamespace = FwApp.App.HelpFile;
            helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
            helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
        }
コード例 #3
0
        public override void TestSetup()
        {
            base.TestSetup();

            m_vc       = new StVc();
            m_vc.Cache = Cache;

            m_pattern = VwPatternClass.Create();

            m_pattern.Pattern = TsStringUtils.MakeString("a", Cache.DefaultVernWs);
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;

            IScrBook genesis = AddBookWithTwoSections(1, "Genesis");

            m_section = genesis.SectionsOS[0];
            // Add paragraphs (because we use an StVc in the test we add them all to the same section)
            m_para1 = AddParaToMockedSectionContent(m_section,
                                                    ScrStyleNames.NormalParagraph);
            AddRunToMockedPara(m_para1,
                               "This is some text so that we can test the find functionality.", null);
            m_para2 = AddParaToMockedSectionContent(m_section,
                                                    ScrStyleNames.NormalParagraph);
            AddRunToMockedPara(m_para2,
                               "Some more text so that we can test the find and replace functionality.", null);
            m_para3 = AddParaToMockedSectionContent(
                m_section, ScrStyleNames.NormalParagraph);
            AddRunToMockedPara(m_para3,
                               "This purugruph doesn't contuin the first letter of the ulphubet.", null);
        }
コード例 #4
0
		public ConcordanceControl()
		{
			InitializeComponent();

			m_vwPattern = VwPatternClass.Create();
			this.helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
			this.helpProvider.SetShowHelp(this, true);
			m_tbSearchText.SuppressEnter = true;
		}
コード例 #5
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:FindCollectorEnv"/> class.
 /// </summary>
 /// <param name="vc">The view constructor.</param>
 /// <param name="sda">Date access to get prop values etc.</param>
 /// <param name="hvoRoot">The root object to display.</param>
 /// <param name="frag">The fragment.</param>
 /// <param name="vwPattern">The find/replace pattern.</param>
 /// <param name="searchKiller">Used to interrupt a find/replace</param>
 /// <remarks>If the base environment is not null, it is used for various things,
 /// such as obtaining 'outer object' information.</remarks>
 /// ------------------------------------------------------------------------------------
 public FindCollectorEnv(IVwViewConstructor vc, ISilDataAccess sda,
                         int hvoRoot, int frag, IVwPattern vwPattern, IVwSearchKiller searchKiller)
     : base(null, sda, hvoRoot)
 {
     m_vc             = vc;
     m_frag           = frag;
     m_Pattern        = vwPattern;
     m_searchKiller   = searchKiller;
     m_textSourceInit = VwMappedTxtSrcClass.Create();
 }
コード例 #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:FindReplaceCollectorEnvBase"/> class.
		/// </summary>
		/// <param name="vc">The view constructor.</param>
		/// <param name="sda">Date access to get prop values etc.</param>
		/// <param name="hvoRoot">The root object to display.</param>
		/// <param name="frag">The fragment.</param>
		/// <param name="vwPattern">The find/replace pattern.</param>
		/// <param name="searchKiller">Used to interrupt a find/replace</param>
		/// <remarks>If the base environment is not null, it is used for various things,
		/// such as obtaining 'outer object' information.</remarks>
		/// ------------------------------------------------------------------------------------
		public FindReplaceCollectorEnvBase(IVwViewConstructor vc, ISilDataAccess sda,
			int hvoRoot, int frag, IVwPattern vwPattern, IVwSearchKiller searchKiller)
			: base(null, sda, hvoRoot)
		{
			m_vc = vc;
			m_frag = frag;
			m_Pattern = vwPattern;
			m_searchKiller = searchKiller;
			m_textSourceInit = VwMappedTxtSrcClass.Create();
		}
コード例 #7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes for replace all: creates a view constructor to be used with replace all
        /// as well as initial settings for the pattern.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void InitializeForReplaceAll()
        {
            m_vc       = new TeStVc(TeStVc.LayoutViewTarget.targetDraft, 0);
            m_vc.Cache = Cache;

            m_pattern    = VwPatternClass.Create();
            m_strFactory = TsStrFactoryClass.Create();

            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
        }
コード例 #8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes for replace all: creates a view constructor to be used with replace all
		/// as well as initial settings for the pattern.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void InitializeForReplaceAll()
		{
			// REVIEW: do we need to create m_vc? We don't seem to use it anywhere.
			m_vc = new TeStVc(TeStVc.LayoutViewTarget.targetDraft, 0);
			m_vc.Cache = Cache;

			m_pattern = VwPatternClass.Create();
			m_strFactory = TsStrFactoryClass.Create();

			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;
		}
コード例 #9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <remarks>This method is called after each test</remarks>
        /// ------------------------------------------------------------------------------------
        public override void TestTearDown()
        {
            m_vc      = null;
            m_section = null;
            m_para1   = null;
            m_para2   = null;
            m_para3   = null;
            if (Marshal.IsComObject(m_pattern))
            {
                Marshal.ReleaseComObject(m_pattern);
            }
            m_pattern = null;

            base.TestTearDown();
        }
コード例 #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes for replace all: creates a view constructor to be used with replace all
        /// as well as initial settings for the pattern.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void InitializeForReplaceAll()
        {
            // REVIEW: do we need to create m_vc? We don't seem to use it anywhere.
            m_vc       = new TeStVc(TeStVc.LayoutViewTarget.targetDraft, 0);
            m_vc.Cache = Cache;

            m_pattern    = VwPatternClass.Create();
            m_strFactory = TsStrFactoryClass.Create();

            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
        }
コード例 #11
0
		public ConcordanceControl()
		{
			InitializeComponent();

			m_regexContextMenu = new RegexHelperMenu(m_tbSearchText, FwApp.App);
			m_vwPattern = VwPatternClass.Create();

			if (FwApp.App != null)
				this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
			this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
			this.helpProvider.SetShowHelp(this, true);
			if (FwApp.App != null)
			{
				helpProvider.SetHelpKeyword(this, "khtpSpecConcordanceCrit");
				m_btnHelp.Enabled = true;
			}
		}
コード例 #12
0
        public override void Initialize()
        {
            CheckDisposed();
            base.Initialize();

            m_vc       = new StVc();
            m_vc.Cache = Cache;

            m_pattern    = VwPatternClass.Create();
            m_strFactory = TsStrFactoryClass.Create();

            m_pattern.Pattern = m_strFactory.MakeString("a", Cache.DefaultVernWs);
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
        }
コード例 #13
0
        public override void Exit()
        {
            CheckDisposed();

            m_vc.Dispose();
            m_vc      = null;
            m_section = null;
            m_para1   = null;
            m_para2   = null;
            m_para3   = null;
            if (Marshal.IsComObject(m_pattern))
            {
                Marshal.ReleaseComObject(m_pattern);
            }
            m_pattern = null;
            if (Marshal.IsComObject(m_strFactory))
            {
                Marshal.ReleaseComObject(m_strFactory);
            }
            m_strFactory = null;

            base.Exit();
        }
コード例 #14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Change the main window which owns this dialog. Since this dialog attempts to stay
		/// alive as long as the app is alive (or, as long as there is a main window open),
		/// the app should call this to re-assign an owner any time the existing owner is
		/// closing.
		/// </summary>
		/// <param name="rootSite">view</param>
		/// <param name="newOwner">The main window that owns the rootsite</param>
		/// <param name="findPattern">The find/replace pattern of the new owner. TODO Review (Hasso) 2015.08: unused</param>
		/// <param name="wsEdit">writing system for the find and replace edit boxes TODO Review (Hasso) 2015.08: unused</param>
		/// ------------------------------------------------------------------------------------
		public void SetOwner(IVwRootSite rootSite, Form newOwner, IVwPattern findPattern, int wsEdit)
		{
			CheckDisposed();

			m_vwRootsite = rootSite;
			if (m_vwRootsite != null && rootSite.RootBox != null)
				fweditFindText.StyleSheet = fweditReplaceText.StyleSheet = rootSite.RootBox.Stylesheet;

			if (newOwner != null && Owner != newOwner)
			{
				Owner = newOwner;
				m_vwSelectionForPattern = null;
				m_findEnvironment = null;
			}
		}
コード例 #15
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:FindReplaceCollectorEnvBase"/> class.
 /// </summary>
 /// <param name="vc">The view constructor.</param>
 /// <param name="sda">Date access to get prop values etc.</param>
 /// <param name="hvoRoot">The root object to display.</param>
 /// <param name="frag">The fragment.</param>
 /// <param name="vwPattern">The find/replace pattern.</param>
 /// <param name="searchKiller">Used to interrupt a find/replace</param>
 /// <remarks>If the base environment is not null, it is used for various things,
 /// such as obtaining 'outer object' information.</remarks>
 /// ------------------------------------------------------------------------------------
 public ReplaceAllCollectorEnv(IVwViewConstructor vc, ISilDataAccess sda,
                               int hvoRoot, int frag, IVwPattern vwPattern, IVwSearchKiller searchKiller)
     : base(vc, sda, hvoRoot, frag, vwPattern, searchKiller)
 {
     m_ReadOnlyStack.Push(m_fReadOnly);
 }
コード例 #16
0
ファイル: RecordFilter.cs プロジェクト: bbriggs/FieldWorks
		// After setting the Pattern (TsString) of the VwPattern, once we have a cache, we can figure out the locale
		// and sort rules to use based on the WS of the pattern string.
		public static void SetupPatternCollating(IVwPattern pattern, FdoCache cache)
		{
			pattern.IcuLocale = cache.ServiceLocator.WritingSystemFactory.GetStrFromWs(pattern.Pattern.get_WritingSystem(0));
			var wsManager = cache.ServiceLocator.WritingSystemManager.Get(pattern.IcuLocale);
			// Enhance JohnT: we would like to be able to make it use the defined collating rules for the
			// other sort types, but don't currently know how.
			if (wsManager != null)
			{
				if (wsManager.SortUsing == WritingSystemDefinition.SortRulesType.CustomICU)
					pattern.IcuCollatingRules = wsManager.SortRules;
				else if (wsManager.SortUsing == WritingSystemDefinition.SortRulesType.CustomSimple)
					pattern.IcuCollatingRules = SimpleRulesCollator.ConvertToIcuRules(wsManager.SortRules);
				else if (wsManager.SortUsing == WritingSystemDefinition.SortRulesType.OtherLanguage)
					pattern.IcuCollatingRules = "#" + wsManager.SortRules;
			}
		}
コード例 #17
0
ファイル: FwApp.cs プロジェクト: sillsdev/FieldWorks
		/// <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)
		{
			System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			// Must not be run more than once.
			if (IsDisposed || BeingDisposed)
				return;
			BeingDisposed = true;

			if (disposing)
			{
			UpdateAppRuntimeCounter();

				Logger.WriteEvent("Disposing app: " + GetType().Name);
				RegistrySettings.FirstTimeAppHasBeenRun = false;

				// Dispose managed resources here.
				List<IFwMainWnd> mainWnds = new List<IFwMainWnd>(m_rgMainWindows); // Use another array, since m_rgMainWindows may change.
				m_rgMainWindows.Clear(); // In fact, just clear the main array, so the windows won't have to worry so much.
				foreach (IFwMainWnd mainWnd in mainWnds)
				{
					if (mainWnd is Form)
					{
						Form wnd = (Form)mainWnd;
						wnd.Closing -= OnClosingWindow;
						wnd.Closed -= OnWindowClosed;
						wnd.Activated -= fwMainWindow_Activated;
						wnd.HandleDestroyed -= fwMainWindow_HandleDestroyed;
						wnd.Dispose();
					}
					else if (mainWnd is IDisposable)
						((IDisposable)mainWnd).Dispose();
				}
				if (m_findReplaceDlg != null)
					m_findReplaceDlg.Dispose();
#if DEBUG
				if (m_debugProcs != null)
					m_debugProcs.Dispose();
#endif

				ResourceHelper.ShutdownHelper();

				if (m_registrySettings != null)
					m_registrySettings.Dispose();

				Application.EnterThreadModal -= Application_EnterThreadModal;
				Application.LeaveThreadModal -= Application_LeaveThreadModal;

				Application.RemoveMessageFilter(this);
				PictureHolder.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_rgMainWindows = null;
			m_activeMainWindow = null;
			m_registrySettings = null;
			m_findPattern = null;
			m_findReplaceDlg = null;
			m_suppressedCacheInfo = null;
			m_refreshView = null;
			PictureHolder = null;
#if DEBUG
			m_debugProcs = null;
#endif
			IsDisposed = true;
			BeingDisposed = false;
		}
コード例 #18
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the initial values for the dialog controls, prior to displaying the dialog.
		/// This method should be called after creating, but prior to calling DoModeless. This
		/// overload is meant to be called from unmanaged code.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="ode"></param>
		/// <param name="oleDbAccess"></param>
		/// <param name="rootSite">view</param>
		/// <param name="hwnd">The window handle of the main window that owns the rootsite
		/// </param>
		/// <param name="findPattern">The find/replace pattern.</param>
		/// <remarks>ENHANCE JohnT: it may need more arguments, for example, the name of the
		/// kind of object we can restrict the search to, a list of fields.</remarks>
		/// ------------------------------------------------------------------------------------
		public void SetOwner(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess,
			IVwRootSite rootSite, IntPtr hwnd, IVwPattern findPattern)
		{
			CheckDisposed();

			SetOwner(new FdoCache(ode, mdc, oleDbAccess), rootSite, hwnd, findPattern);
		}
コード例 #19
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Change the main window which owns this dialog. Since this dialog attempts to stay
		/// alive as long as the app is alive (or, as long as there is a main window open),
		/// the app should call this to re-assign an owner any time the existing owner is
		/// closing.
		/// </summary>
		/// <param name="cache">The cache belonging to the view.</param>
		/// <param name="rootSite">view</param>
		/// <param name="hwnd">The window handle of the main window that owns the rootsite
		/// </param>
		/// <param name="findPattern">The find/replace pattern of the new owner.</param>
		/// <param name="wsEdit">writing system for the find and replace edit boxes</param>
		/// ------------------------------------------------------------------------------------
		public void SetOwner(FdoCache cache, IVwRootSite rootSite, IntPtr hwnd,
			IVwPattern findPattern, int wsEdit)
		{
			CheckDisposed();

			m_vwRootsite = rootSite;
			if (m_vwRootsite != null && rootSite.RootBox != null)
				fweditFindText.StyleSheet = fweditReplaceText.StyleSheet = rootSite.RootBox.Stylesheet;

			bool fChangingCache = (m_cache != cache);
			m_cache = cache;
			if (m_cache != null && fChangingCache)
			{
				ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor;
				fweditFindText.WritingSystemFactory = fweditReplaceText.WritingSystemFactory = wsf;
				ITsStrFactory strFact = TsStrFactoryClass.Create();
				FindText = strFact.MakeString(string.Empty, m_cache.DefaultVernWs);
				ReplaceText = strFact.MakeString(string.Empty, m_cache.DefaultVernWs);
				// Make sure each of the edit boxes has a reasonable writing system assigned.
				// (See LT-5130 for what can happen otherwise.)
				// The default verncular is not always reasonable enough.
				fweditFindText.WritingSystemCode = wsEdit;	// m_cache.DefaultVernWs;
				fweditReplaceText.WritingSystemCode = wsEdit; // m_cache.DefaultVernWs;
				FindText = EnsureValidWs(wsEdit, findPattern.Pattern);
				ReplaceText = EnsureValidWs(wsEdit, findPattern.ReplaceWith);
				SetCheckboxStates(findPattern);
				m_vwPattern = findPattern;
			}
			Control newOwner = Form.FromHandle(hwnd);
			if (newOwner != null && Owner != newOwner && newOwner is Form)
			{
				Owner = (Form)newOwner;
				m_vwselPattern = null;
				m_findEnvironment = null;
			}
		}
コード例 #20
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Set the initial values for the dialog controls, assuming that the find and replace
		/// edit boxes use the default vernacular writing system.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="vwPattern"></param>
		/// <param name="rootSite"></param>
		/// <param name="fReplace"></param>
		/// <param name="fOverlays"></param>
		/// <param name="sUserWs"></param>
		/// <param name="hwnd"></param>
		/// <param name="tool"></param>
		/// <param name="helpTopicProvider"></param>
		/// <returns></returns>
		public bool SetDialogValues(FdoCache cache, IVwPattern vwPattern, IVwRootSite rootSite,
			bool fReplace, bool fOverlays, string sUserWs, IntPtr hwnd, IFwTool tool,
			IHelpTopicProvider helpTopicProvider)
		{
			return SetDialogValues(cache, vwPattern, rootSite, fReplace, fOverlays, sUserWs,
				hwnd, tool, helpTopicProvider, cache.DefaultVernWs);
		}
コード例 #21
0
ファイル: BulkEditBar.cs プロジェクト: sillsdev/FieldWorks
		public ReplaceWithMethod(FdoCache cache, ISilDataAccessManaged sda, FieldReadWriter accessor, XmlNode spec, IVwPattern pattern, ITsString replacement)
			: base(cache, sda, accessor, spec)
		{
			m_pattern = pattern;
			m_replacement = replacement;
			m_pattern.ReplaceWith = m_replacement;
			m_textSourceInit = VwStringTextSourceClass.Create();
			m_ts = m_textSourceInit as IVwTextSource;
		}
コード例 #22
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the initial values for the dialog controls, prior to displaying the dialog.
		/// This method should be called after creating, but prior to calling DoModeless. This
		/// overload is meant to be called from unmanaged code.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="ode"></param>
		/// <param name="oleDbAccess"></param>
		/// <param name="vwPattern">Find/replace values</param>
		/// <param name="rootSite">view</param>
		/// <param name="fReplace"><c>true</c> to initially display replace dialog page</param>
		/// <param name="fOverlays">ignored for now</param>
		/// <param name="sUserWs">UI writing system</param>
		/// <param name="hwnd">The window handle of the main window that owns the rootsite
		/// </param>
		/// <param name="tool">The app (needed to be able to disable all main windows)</param>
		/// <param name="helpTopicProvider">help topic provider allows the dialog box class
		/// to specify the appropriate help topic path for this dialog
		/// </param>
		/// <param name="wsEdit">writing system for the find and replace edit boxes</param>
		/// <returns>true if the dialog was initialized properly, otherwise false.
		/// False indicates some problem and the find/replace dialog should not be
		/// shown at this time.</returns>
		/// <remarks>ENHANCE JohnT: it may need more arguments, for example, the name of the
		/// kind of object we can restrict the search to, a list of fields.</remarks>
		/// ------------------------------------------------------------------------------------
		public bool SetDialogValues(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess,
			IVwPattern vwPattern, IVwRootSite rootSite, bool fReplace, bool fOverlays,
			string sUserWs, IntPtr hwnd, IFwTool tool, IHelpTopicProvider helpTopicProvider,
			int wsEdit)
		{
			CheckDisposed();

			m_cacheMadeLocally = true;
			return SetDialogValues(new FdoCache(ode, mdc, oleDbAccess), vwPattern, rootSite,
				fReplace, fOverlays, sUserWs, hwnd, tool, helpTopicProvider, wsEdit);
		}
コード例 #23
0
ファイル: RecordFilter.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// normal constructor
		/// </summary>
		/// <param name="pattern"></param>
		public SimpleStringMatcher(IVwPattern pattern)
		{
			m_pattern = pattern;
			Init();
		}
コード例 #24
0
ファイル: RecordFilter.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// normal constructor
		/// </summary>
		/// <param name="pattern"></param>
		public AnywhereMatcher(IVwPattern pattern) : base(pattern) {}
コード例 #25
0
ファイル: RecordFilter.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// normal constructor
		/// </summary>
		/// <param name="pattern"></param>
		public BeginMatcher(IVwPattern pattern) : base(pattern) {}
コード例 #26
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// use this interface to deserialize settings to new pattern
		/// </summary>
		public VwPatternSerializableSettings()
		{
			// create a new mattern to capture deserialized settings.
			m_pattern = VwPatternClass.Create();
			m_fNewlyCreated = true;
		}
コード例 #27
0
ファイル: BtDraftViewTests.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes for replace all: creates a view constructor to be used with replace all
		/// as well as initial settings for the pattern.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void InitializeForReplaceAll()
		{
			m_vc = new TeStVc(TeStVc.LayoutViewTarget.targetDraft, 0);
			m_vc.Cache = Cache;

			m_pattern = VwPatternClass.Create();
			m_strFactory = TsStrFactoryClass.Create();

			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;
		}
コード例 #28
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the initial values for the dialog controls, prior to displaying the dialog.
		/// This method should be called after creating, but prior to calling DoModeless. This
		/// overload is meant to be called from managed code.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="vwPattern">Find/replace values</param>
		/// <param name="rootSite">view</param>
		/// <param name="fReplace"><c>true</c> to initially display replace dialog page</param>
		/// <param name="fOverlays">ignored for now</param>
		/// <param name="sUserWs">UI writing system</param>
		/// <param name="hwnd">The window handle of the main window that owns the rootsite
		/// </param>
		/// <param name="tool">The app (needed to be able to disable all main windows)</param>
		/// <param name="helpTopicProvider">help topic provider allows the dialog box class
		/// to specify the appropriate help topic path for this dialog
		/// </param>
		/// <param name="wsEdit">writing system for the find and replace edit boxes</param>
		/// <remarks>ENHANCE JohnT: it may need more arguments, for example, the name of the
		/// kind of object we can restrict the search to, a list of fields.</remarks>
		/// <returns>true if the dialog was initialized properly, otherwise false.
		/// False indicates some problem and the find/replace dialog should not be
		/// shown at this time.</returns>
		/// ------------------------------------------------------------------------------------
		public bool SetDialogValues(FdoCache cache, IVwPattern vwPattern, IVwRootSite rootSite,
			bool fReplace, bool fOverlays, string sUserWs, IntPtr hwnd, IFwTool tool,
			IHelpTopicProvider helpTopicProvider, int wsEdit)
		{
			CheckDisposed();

			if (!SetDialogValues(cache, vwPattern, rootSite, fReplace, fOverlays, sUserWs, hwnd, helpTopicProvider, wsEdit))
				return false;

			m_tool = tool;

			// get the current selection text to fill in the find pattern.
			IVwSelection sel = rootSite.RootBox.Selection;
			if (sel == null)
			{
				// Set the TSS of the edit box to an empty string if it isn't set.
				if (FindText == null)
				{
					FindText = TsStrFactoryClass.Create().MakeString(
						string.Empty, cache.DefaultVernWs);
				}
			}
			else
			{
				// Get the selected text as the initial contents of the find box. Make a new TS String without
				// any character style so the character style from the selection will not be used. Also, if the
				// selection ends with a paragraph end sequence (CR/LF) then remove it.
				ITsString tssSel;
				bool fGotItAll;
				sel.GetFirstParaString(out tssSel, " ", out fGotItAll);
				if (tssSel == null)
				{
					// Not able to get ITsString from selection (e.g. if it is a picture)...
					SetFormatLabels();
					return true;
				}
				ITsStrBldr bldr = tssSel.GetBldr();
				bldr.SetStrPropValue(0, bldr.Length, (int)FwTextPropType.ktptNamedStyle, null);
				RemoveEndOfPara(bldr);
				// Set the TSS of the edit box if there is any text to set, or if there is no
				// TSS for the box, or if there is no text in the find box AND the selection is not a user prompt.
				// If the current selection is an IP AND we have a previous find text, we want to use that
				// instead of the current selection (TE-5127 and TE-5126).
				int nVar; //dummy for out params
				if (bldr.Length == 0 && vwPattern != null && vwPattern.Pattern != null)
				{
					FindText = vwPattern.Pattern;
				}
				else if ((bldr.Length != 0 || FindText == null || FindText.Length == 0)
					&& tssSel.get_Properties(0).GetIntPropValues(SimpleRootSite.ktptUserPrompt, out nVar) != 1)
				{
					FindText = bldr.GetString();
				}
				if (FindText != null)
				{
					// Set the replace text box properties to be the same as the find text box.
					// The best we can do is take the properties of the first run which should
					// be fine for most cases.
					ITsTextProps props = FindText.get_Properties(0);
					ITsStrBldr replaceBldr = TsStrBldrClass.Create();
					replaceBldr.Replace(0, 0, "", props);
					ReplaceText = replaceBldr.GetString();
				}
			}

			SetFormatLabels();
			return true;
		}
コード例 #29
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// use this interface to serialize the given pattern
		/// </summary>
		/// <param name="pattern"></param>
		public VwPatternSerializableSettings(IVwPattern pattern)
		{
			m_pattern = pattern;
		}
コード例 #30
0
ファイル: RecordFilter.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// normal constructor
		/// </summary>
		/// <param name="pattern"></param>
		public ExactMatcher(IVwPattern pattern) : base(pattern) {}
コード例 #31
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the initial values for the dialog controls, prior to displaying the dialog.
		/// This private overload takes all possible arguments, and is called in various ways
		/// by the others.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="vwPattern">Find/replace values</param>
		/// <param name="rootSite">view (may be null!)</param>
		/// <param name="fReplace"><c>true</c> to initially display replace dialog page</param>
		/// <param name="fOverlays">ignored for now</param>
		/// <param name="sUserWs">UI writing system</param>
		/// <param name="hwnd">The window handle of the main window that owns the rootsite
		/// </param>
		/// <param name="helpTopicProvider">help topic provider allows the dialog box class
		/// to specify the appropriate help topic path for this dialog
		/// </param>
		/// <param name="wsEdit">writing sytem for the find and replace edit boxes</param>
		/// <remarks>ENHANCE JohnT: it may need more arguments, for example, the name of the
		/// kind of object we can restrict the search to, a list of fields.</remarks>
		/// <returns>true if the dialog was initialized properly, otherwise false.
		/// False indicates some problem and the find/replace dialog should not be
		/// shown at this time.</returns>
		/// ------------------------------------------------------------------------------------
		private bool SetDialogValues(FdoCache cache, IVwPattern vwPattern, IVwRootSite rootSite,
			bool fReplace, bool fOverlays, string sUserWs, IntPtr hwnd,
			IHelpTopicProvider helpTopicProvider, int wsEdit)
		{
			fweditFindText.controlID = "Find";
			fweditReplaceText.controlID = "Replace";
			// save the pattern and put the text into the find edit box.
			if (vwPattern == null)
				throw new ArgumentNullException("vwPattern");
			m_vwPattern = vwPattern;

			m_helpTopicProvider = helpTopicProvider;

			SetOwner(cache, rootSite, hwnd, vwPattern, wsEdit);
			tabControls.SelectedTab = fReplace ? tabReplace : tabFind;
			tabControls_SelectedIndexChanged(null, new EventArgs());

			if (m_helpTopicProvider != null) // Will be null when running tests
			{
				this.helpProvider.HelpNamespace = DirectoryFinder.FWCodeDirectory +
					m_helpTopicProvider.GetHelpString("UserHelpFile", 0);
			}

			SetCheckboxStates(vwPattern);

			regexContextMenuFind = new RegexHelperMenu(fweditFindText, m_helpTopicProvider);
			regexContextMenuReplace = new RegexHelperMenu(fweditReplaceText, m_helpTopicProvider, false);

			// The Regex context menus need to be turned off in TE due to a UI freeze
			if (Application.ProductName != "Language Explorer")
			{
				btnRegexMenuFind.Visible = btnRegexMenuFind.Enabled = false;
				btnRegexMenuReplace.Visible = btnRegexMenuReplace.Enabled = false;

				// Now grow the text fields to fill the empty space
				fweditFindText.Width = fweditReplaceText.Width = 472;
			}

			// everything seems ok to proceed with find/replace
			return true;
		}
コード例 #32
0
ファイル: RecordFilter.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// normal constructor
		/// </summary>
		/// <param name="pattern"></param>
		public EndMatcher(IVwPattern pattern) : base(pattern) {}
コード例 #33
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the checkbox states.
		/// </summary>
		/// <param name="vwPattern">The vw pattern.</param>
		/// ------------------------------------------------------------------------------------
		private void SetCheckboxStates(IVwPattern vwPattern)
		{
			// Set initial checkbox states
			chkMatchWS.Checked = vwPattern.MatchOldWritingSystem;
			chkMatchDiacritics.Checked = vwPattern.MatchDiacritics;
			chkMatchCase.Checked = vwPattern.MatchCase;
			chkMatchWholeWord.Checked = vwPattern.MatchWholeWord;
			if (chkUseRegularExpressions.Enabled)
				chkUseRegularExpressions.Checked = vwPattern.UseRegularExpressions;
		}
コード例 #34
0
ファイル: RecordFilter.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// normal constructor
		/// </summary>
		/// <param name="pattern"></param>
		public RegExpMatcher(IVwPattern pattern) : base(pattern)
		{
			Init();
		}
コード例 #35
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Set initial values, assuming default vernacular writing system for the find
		/// and replace edit boxes.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="vwPattern"></param>
		/// <param name="stylesheet"></param>
		/// <param name="hwnd"></param>
		/// <param name="helpTopicProvider"></param>
		/// <returns></returns>
		public bool SetDialogValues(FdoCache cache, IVwPattern vwPattern,
			IVwStylesheet stylesheet, IntPtr hwnd, IHelpTopicProvider helpTopicProvider)
		{
			return SetDialogValues(cache, vwPattern, stylesheet, hwnd, helpTopicProvider,
				cache.DefaultVernWs);
		}
コード例 #36
0
ファイル: RecordFilter.cs プロジェクト: sillsdev/WorldPad
		private void Init()
		{
			m_textSourceInit = VwStringTextSourceClass.Create();
			m_ts = m_textSourceInit as IVwTextSource;

			if(m_pattern == null)
				m_pattern = VwPatternClass.Create();
		}
コード例 #37
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the initial values for the dialog controls, prior to displaying the dialog.
		/// This method should be called after creating, but prior to calling DoModal. This
		/// overload is meant to be called from the Setup button of the Find/Replace tab
		/// of the Bulk Edit bar. Instead of having a root site and controls that allow the
		/// find/replace to be actually done, it just serves to edit the pattern.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="vwPattern">Find/replace values</param>
		/// <param name="stylesheet">to use in text boxes</param>
		/// <param name="hwnd">The window handle of the main window that owns the rootsite
		/// </param>
		/// <param name="helpTopicProvider">help topic provider allows the dialog box class
		/// to specify the appropriate help topic path for this dialog
		/// </param>
		/// <param name="wsEdit">writing system used in the find/replace text boxes</param>
		/// <remarks>ENHANCE JohnT: it may need more arguments, for example, the name of the
		/// kind of object we can restrict the search to, a list of fields.</remarks>
		/// <returns>true if the dialog was initialized properly, otherwise false.
		/// False indicates some problem and the find/replace dialog should not be
		/// shown at this time.</returns>
		/// ------------------------------------------------------------------------------------
		public bool SetDialogValues(FdoCache cache, IVwPattern vwPattern,
			IVwStylesheet stylesheet, IntPtr hwnd, IHelpTopicProvider helpTopicProvider,
			int wsEdit)
		{
			CheckDisposed();

			// Must set the stylesheet for the FwEdit boxes before calling SetDialogValues since
			// that call can reset the text in those boxes.
			fweditFindText.StyleSheet = fweditReplaceText.StyleSheet = stylesheet;

			// For now pass a null writing system string since it isn't used at all.
			if (!SetDialogValues(cache, vwPattern, null, true, false, null, hwnd, helpTopicProvider, wsEdit))
				return false;

			FindText = vwPattern.Pattern;
			// Reconfigure the dialog for this special purpose. The Find/Replace buttons go away,
			// we have an OK button which is the default.
			btnReplace.Hide();
			btnFindNext.Hide();
			btnReplaceAll.Hide();
			m_okButton.Show();
			m_inGetSpecs = true; // disables showing Replace buttons
			//m_inReplace = true; // disables switch to Find tab.
			tabControls.TabPages.Remove(tabFind);
			this.AcceptButton = m_okButton;
			return true;
		}
コード例 #38
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ReverseFindCollectorEnv"/> class.
 /// </summary>
 /// <param name="vc">The view constructor.</param>
 /// <param name="sda">Date access to get prop values etc.</param>
 /// <param name="hvoRoot">The root object to display.</param>
 /// <param name="frag">The fragment.</param>
 /// <param name="vwPattern">The find/replace pattern.</param>
 /// <param name="searchKiller">Used to interrupt a find/replace</param>
 /// <remarks>If the base environment is not null, it is used for various things,
 /// such as obtaining 'outer object' information.</remarks>
 /// ------------------------------------------------------------------------------------
 public ReverseFindCollectorEnv(IVwViewConstructor vc, ISilDataAccess sda,
                                int hvoRoot, int frag, IVwPattern vwPattern, IVwSearchKiller searchKiller)
     : base(vc, sda, hvoRoot, frag, vwPattern, searchKiller)
 {
 }
コード例 #39
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// -----------------------------------------------------------------------------------
		/// <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)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			m_lastTextBoxInFocus = null;

			if (disposing)
			{
				if (components != null)
					components.Dispose();
				if (m_cacheMadeLocally && m_cache != null)
					m_cache.Dispose();
				//if (m_helpTopicProvider != null && (m_helpTopicProvider is IDisposable)) // No, since the client provides it.
				//	(m_helpTopicProvider as IDisposable).Dispose();
				if (m_htNamedWS != null)
					m_htNamedWS.Clear();
				if (m_messageFilterInstalled)
				{
					Application.RemoveMessageFilter(this);
					m_messageFilterInstalled = false;
				}
			}
			m_htNamedWS = null;
			m_helpTopicProvider = null;
			m_searchKiller = null;
			m_prevSearchText = null;
			m_vwRootsite = null;
			m_vwPattern = null;
			m_cache = null;

			base.Dispose(disposing);
		}
コード例 #40
0
ファイル: TestPersistence.cs プロジェクト: sillsdev/WorldPad
        public void PersistMatchersEtc()
        {
            // BaseMatcher is abstract
            // IntMatcher is abstract
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(5, 23);

            rangeIntMatch.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            ITsString tssLabel = m_cache.MakeAnalysisTss("label1");

            rangeIntMatch.Label = tssLabel;
            OwnIntPropFinder    ownIntFinder   = new OwnIntPropFinder(m_sda, 551);
            FilterBarCellFilter rangeIntFilter = new FilterBarCellFilter(ownIntFinder, rangeIntMatch);
            AndFilter           andFilter      = new AndFilter();

            andFilter.Add(rangeIntFilter);

            ITsStrFactory tsf       = TsStrFactoryClass.Create();
            int           ws        = m_cache.DefaultAnalWs;
            IVwPattern    m_pattern = VwPatternClass.Create();

            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;

            andFilter.Add(new FilterBarCellFilter(ownIntFinder, new NotEqualIntMatcher(77)));

            OwnMlPropFinder mlPropFinder = new OwnMlPropFinder(m_cache.MainCacheAccessor, 788, 23);

            m_pattern.Pattern = tsf.MakeString("hello", ws);
            andFilter.Add(new FilterBarCellFilter(mlPropFinder, new ExactMatcher(m_pattern)));

            OwnMonoPropFinder monoPropFinder = new OwnMonoPropFinder(m_cache.MainCacheAccessor, 954);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("goodbye", ws);
            andFilter.Add(new FilterBarCellFilter(monoPropFinder, new BeginMatcher(m_pattern)));

            OneIndirectMlPropFinder oneIndMlPropFinder =
                new OneIndirectMlPropFinder(m_cache.MainCacheAccessor, 221, 222, 27);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("exit", ws);
            andFilter.Add(new FilterBarCellFilter(oneIndMlPropFinder, new EndMatcher(m_pattern)));

            MultiIndirectMlPropFinder mimlPropFinder = new MultiIndirectMlPropFinder(
                m_cache.MainCacheAccessor, new int[] { 444, 555 }, 666, 87);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("whatever", ws);
            andFilter.Add(new FilterBarCellFilter(mimlPropFinder, new AnywhereMatcher(m_pattern)));

            OneIndirectAtomMlPropFinder oneIndAtomFinder =
                new OneIndirectAtomMlPropFinder(m_cache.MainCacheAccessor, 543, 345, 43);

            andFilter.Add(new FilterBarCellFilter(oneIndAtomFinder, new BlankMatcher()));

            andFilter.Add(new FilterBarCellFilter(oneIndAtomFinder, new NonBlankMatcher()));

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("pattern", ws);
            andFilter.Add(new FilterBarCellFilter(oneIndAtomFinder,
                                                  new InvertMatcher(new RegExpMatcher(m_pattern))));

            andFilter.Add(new NullFilter());

            XmlDocument docPaf = new XmlDocument();

            docPaf.LoadXml("<root targetClasses=\"LexEntry, LexSense\"></root>");
            ProblemAnnotationFilter paf = new ProblemAnnotationFilter();

            paf.Init(m_cache, docPaf.DocumentElement);
            andFilter.Add(paf);

            // Save and restore!
            string xml = DynamicLoader.PersistObject(andFilter, "filter");

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            // And check all the pieces...
            AndFilter andFilterOut =
                DynamicLoader.RestoreObject(doc.DocumentElement) as AndFilter;

            andFilterOut.Cache = m_cache;

            Assert.IsNotNull(andFilterOut);

            FilterBarCellFilter rangeIntFilterOut =
                andFilterOut.Filters[0] as FilterBarCellFilter;                 // todo

            Assert.IsNotNull(rangeIntFilterOut);

            OwnIntPropFinder ownIntFinderOut = rangeIntFilterOut.Finder as OwnIntPropFinder;

            Assert.IsNotNull(ownIntFinderOut);
            Assert.AreEqual(551, ownIntFinderOut.Flid);

            RangeIntMatcher rangeIntMatchOut = rangeIntFilterOut.Matcher as RangeIntMatcher;

            Assert.IsNotNull(rangeIntMatchOut);
            Assert.AreEqual(5, rangeIntMatchOut.Min);
            Assert.AreEqual(23, rangeIntMatchOut.Max);
            Assert.IsTrue(tssLabel.Equals(rangeIntMatchOut.Label));

            NotEqualIntMatcher notEqualMatchOut = GetMatcher(andFilter, 1) as NotEqualIntMatcher;

            Assert.IsNotNull(notEqualMatchOut);
            Assert.AreEqual(77, notEqualMatchOut.NotEqualValue);

            ExactMatcher exactMatchOut = GetMatcher(andFilter, 2) as ExactMatcher;

            Assert.IsNotNull(exactMatchOut);
            Assert.AreEqual("hello", exactMatchOut.Pattern.Pattern.Text);

            BeginMatcher beginMatchOut = GetMatcher(andFilter, 3) as BeginMatcher;

            Assert.IsNotNull(beginMatchOut);
            Assert.AreEqual("goodbye", beginMatchOut.Pattern.Pattern.Text);

            EndMatcher endMatchOut = GetMatcher(andFilter, 4) as EndMatcher;

            Assert.IsNotNull(endMatchOut);
            Assert.AreEqual("exit", endMatchOut.Pattern.Pattern.Text);

            AnywhereMatcher anywhereMatchOut = GetMatcher(andFilter, 5) as AnywhereMatcher;

            Assert.IsNotNull(anywhereMatchOut);
            Assert.AreEqual("whatever", anywhereMatchOut.Pattern.Pattern.Text);

            BlankMatcher blankMatchOut = GetMatcher(andFilter, 6) as BlankMatcher;

            Assert.IsNotNull(blankMatchOut);

            NonBlankMatcher nonBlankMatchOut = GetMatcher(andFilter, 7) as NonBlankMatcher;

            Assert.IsNotNull(nonBlankMatchOut);

            InvertMatcher invertMatchOut = GetMatcher(andFilter, 8) as InvertMatcher;

            Assert.IsNotNull(invertMatchOut);

            OwnMlPropFinder mlPropFinderOut = GetFinder(andFilter, 2) as OwnMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, mlPropFinderOut.DataAccess);
            Assert.AreEqual(788, mlPropFinderOut.Flid);
            Assert.AreEqual(23, mlPropFinderOut.Ws);

            OwnMonoPropFinder monoPropFinderOut = GetFinder(andFilter, 3) as OwnMonoPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, monoPropFinderOut.DataAccess);
            Assert.AreEqual(954, monoPropFinderOut.Flid);

            OneIndirectMlPropFinder oneIndMlPropFinderOut =
                GetFinder(andFilter, 4) as OneIndirectMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, oneIndMlPropFinderOut.DataAccess);
            Assert.AreEqual(221, oneIndMlPropFinderOut.FlidVec);
            Assert.AreEqual(222, oneIndMlPropFinderOut.FlidString);
            Assert.AreEqual(27, oneIndMlPropFinderOut.Ws);

            MultiIndirectMlPropFinder mimlPropFinderOut =
                GetFinder(andFilter, 5) as MultiIndirectMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, mimlPropFinderOut.DataAccess);
            Assert.AreEqual(444, mimlPropFinderOut.VecFlids[0]);
            Assert.AreEqual(555, mimlPropFinderOut.VecFlids[1]);
            Assert.AreEqual(666, mimlPropFinderOut.FlidString);
            Assert.AreEqual(87, mimlPropFinderOut.Ws);

            OneIndirectAtomMlPropFinder oneIndAtomFinderOut =
                GetFinder(andFilter, 6) as OneIndirectAtomMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, oneIndAtomFinderOut.DataAccess);
            Assert.AreEqual(543, oneIndAtomFinderOut.FlidAtom);
            Assert.AreEqual(345, oneIndAtomFinderOut.FlidString);
            Assert.AreEqual(43, oneIndAtomFinderOut.Ws);

            // 7, 8 are duplicates

            NullFilter nullFilterOut = andFilter.Filters[9] as NullFilter;

            Assert.IsNotNull(nullFilterOut);

            ProblemAnnotationFilter pafOut = andFilter.Filters[10] as ProblemAnnotationFilter;

            Assert.IsNotNull(pafOut);
            Assert.AreEqual(5002, pafOut.ClassIds[0]);
            Assert.AreEqual(5016, pafOut.ClassIds[1]);
        }
コード例 #41
0
ファイル: FwFindReplaceDlg.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Change the main window which owns this dialog. Since this dialog attempts to stay
		/// alive as long as the app is alive (or, as long as there is a main window open),
		/// the app should call this to re-assign an owner any time the existing owner is
		/// closing.  This assumes that the find and replace edit boxes use the default
		/// vernacular writing system.
		/// </summary>
		public void SetOwner(FdoCache cache, IVwRootSite rootSite, IntPtr hwnd,
			IVwPattern findPattern)
		{
			SetOwner(cache, rootSite, hwnd, findPattern, cache.DefaultVernWs);
		}