예제 #1
0
        //private FindDialog FindDlg = new FindDialog();
        //private ReplaceDialog ReplaceDlg=new ReplaceDialog();

        /// <summary>
        /// 查找对话框
        /// </summary>
        public void ShowFindDlg()
        {
            FindDialog FindDlg = new FindDialog();

            FindDlg.richTextBox1  = this;
            FindDlg.textBox1.Text = this.SelectedText;
            FindDlg.StartPosition = FormStartPosition.CenterParent;
            FindDlg.ShowDialog();
        }
예제 #2
0
 //private FindDialog FindDlg = new FindDialog();
 //private ReplaceDialog ReplaceDlg=new ReplaceDialog();
 /// <summary>
 /// 查找对话框
 /// </summary>
 public void ShowFindDlg()
 {
     FindDialog FindDlg = new FindDialog();
     FindDlg.richTextBox1 = this;
     FindDlg.textBox1.Text = this.SelectedText;
     FindDlg.StartPosition = FormStartPosition.CenterParent;
     FindDlg.ShowDialog();
 }
예제 #3
0
        public void TestDialogs()
        {
            // ensure we get this warning dialog.
            ResetFormatLongLines();

            // ensure we get a horizontal scroll bar on the supply.xml file.
            SetTreeViewWidth(290);

            Trace.WriteLine("TestDialogs==========================================================");
            var w = LaunchNotepad();

            // About...
            Trace.WriteLine("About...");
            w.InvokeAsyncMenuItem("aboutXMLNotepadToolStripMenuItem");
            Window popup = w.WaitForPopup();
            popup.DismissPopUp("{ENTER}");

            // hide/show status bar
            Trace.WriteLine("hide/show status bar...");
            w.InvokeAsyncMenuItem("statusBarToolStripMenuItem");
            Sleep(500);
            w.InvokeAsyncMenuItem("statusBarToolStripMenuItem");
            Sleep(500);

            // open bad file.
            Trace.WriteLine("open bad file");
            w.InvokeAsyncMenuItem("openToolStripMenuItem");
            popup = w.WaitForPopup();
            popup.SendKeystrokes(TestDir + "UnitTests\\bad.xml{ENTER}");
            popup = w.WaitForPopup();
            popup.SendKeystrokes("%Y");
            popup = w.WaitForPopup();
            popup.DismissPopUp("%{F4}");

            // Test OpenFileDialog
            Trace.WriteLine("OpenFileDialog");
            w.InvokeAsyncMenuItem("openToolStripMenuItem");
            popup = w.WaitForPopup();
            popup.SendKeystrokes(TestDir + "UnitTests\\supply.xml");
            popup.DismissPopUp("{ENTER}");

            Trace.WriteLine("Test long line wrap message.");
            w.InvokeAsyncMenuItem("findToolStripMenuItem");
            popup = w.WaitForPopup();
            FindDialog fd = new FindDialog(popup);
            fd.UseRegex = false;
            fd.UseXPath = false;
            fd.UseWholeWord = false;
            fd.FindString = "FinalDeliverable";
            popup.SendKeystrokes("{ENTER}");
            popup.DismissPopUp("{ESC}");

            Trace.WriteLine("Test horizontal scroll bar");
            AutomationWrapper hscroll = XmlTreeView.FindChild("HScrollBar");
            Rectangle sbBounds = hscroll.Bounds;
            Sleep(1000);
            Mouse.MouseClick(new Point(sbBounds.Left + 5, sbBounds.Top + 5), MouseButtons.Left);
            Sleep(500);

            this.TreeView.SetFocus();
            w.SendKeystrokes("{TAB}{ENTER}");
            popup = w.WaitForPopup();
            popup.DismissPopUp("{ENTER}");
            w.SendKeystrokes("{ENTER}");

            Trace.WriteLine("View source");
            w.InvokeAsyncMenuItem("sourceToolStripMenuItem");
            popup = w.WaitForPopup(); // file has changed, do you want to save it?
            popup.SendKeystrokes("%N");
            popup = w.WaitForPopup(); // wait for Notepad.exe.
            popup.DismissPopUp("%{F4}");

            // Show help
            Trace.WriteLine("Show help...");
            Trace.WriteLine(Directory.GetCurrentDirectory());
            Trace.WriteLine(Application.StartupPath);
            w.SendKeystrokes("{F1}");
            popup = w.WaitForPopup();
            popup.DismissPopUp("%{F4}");

            // Test reload - discard changes
            Trace.WriteLine("Reload- discard changes");
            w.InvokeAsyncMenuItem("reloadToolStripMenuItem");
            popup = w.WaitForPopup();
            popup.DismissPopUp("{ENTER}");

            // Save As...
            Trace.WriteLine("Save As...");
            string outFile = TestDir + "UnitTests\\out.xml";
            WipeFile(outFile);
            w.InvokeAsyncMenuItem("saveAsToolStripMenuItem");
            popup = w.WaitForPopup();
            popup.SendKeystrokes("out.xml");
            popup.DismissPopUp("{ENTER}");

            // Check save read only
            Trace.WriteLine("Check save read only.");
            File.SetAttributes(outFile, File.GetAttributes(outFile) | FileAttributes.ReadOnly);
            w.InvokeAsyncMenuItem("saveToolStripMenuItem");
            popup = w.WaitForPopup();
            popup.DismissPopUp("%Y");
            Sleep(2000); // let file system settle down...

            // Test "reload" message box.
            Trace.WriteLine("File has changed on disk, do you want to reload?");
            File.SetLastWriteTime(outFile, DateTime.Now);
            Sleep(2000); // now takes 2 seconds for this to show up.

            popup = w.WaitForPopup();
            popup.DismissPopUp("%Y"); // reload!

            // Window/NewWindow!
            Trace.WriteLine("Window/NewWindow");
            w.InvokeAsyncMenuItem("newWindowToolStripMenuItem");
            popup = w.WaitForPopup();
            popup.DismissPopUp("%{F4}"); // close second window!

            if (!Window.GetForegroundWindowText().StartsWith("XML Notepad")) {
                w.Activate(); // alt-f4 sometimes sends focus to another window (namely, the VS process running this test!)
                Sleep(500);
            }
            Sleep(1000);

            // Test SaveIfDirty
            Trace.WriteLine("make simple edit");
            FocusTreeView();
            w.SendKeystrokes("{END}{DELETE}");// make simple edit

            Trace.WriteLine("Test error dialog when user tries to enter element with no name");
            w.InvokeMenuItem("repeatToolStripMenuItem");
            w.SendKeystrokes("{ENTER}");
            popup = w.WaitForPopup();
            popup.DismissPopUp("%N");

            Trace.WriteLine("Test error dialog when user tries to enter name with spaces");
            w.SendKeystrokes("     {ENTER}");
            popup = w.WaitForPopup();
            Trace.WriteLine("This time accept the empty name");
            popup.DismissPopUp("%Y");

            Trace.WriteLine("Test error dialog when user enter an invalid name");
            w.SendKeystrokes("{ENTER}{+}{+}{+}{ENTER}");
            popup = w.WaitForPopup();
            popup.DismissPopUp("{ENTER}");
            w.SendKeystrokes("{ESC}");
            Undo();

            // Save changes on exit?
            Trace.WriteLine("Save changes on exit - cancel");
            w.InvokeAsyncMenuItem("exitToolStripMenuItem");
            popup = w.WaitForPopup();
            popup.DismissPopUp("{ESC}"); // make sure we can cancel exit!
            Sleep(1000);

            // Save changes on 'new'?
            Trace.WriteLine("Save changes on 'new' - cancel");
            w.InvokeAsyncMenuItem("newToolStripMenuItem");
            popup = w.WaitForPopup();
            popup.DismissPopUp("{ESC}"); // make sure we can cancel 'new'!
            Sleep(1000);

            Trace.WriteLine("Save changes on 'exit' - yes!");
            CheckNodeName("Header");
            w.InvokeAsyncMenuItem("exitToolStripMenuItem");
            popup = w.WaitForPopup();

            // save the changes!
            popup.SendKeystrokes("%Y");
        }