当前位置: 首页>>代码示例>>C#>>正文


C# OpenFileDialog.DismissPopUp方法代码示例

本文整理汇总了C#中System.Windows.Forms.OpenFileDialog.DismissPopUp方法的典型用法代码示例。如果您正苦于以下问题:C# OpenFileDialog.DismissPopUp方法的具体用法?C# OpenFileDialog.DismissPopUp怎么用?C# OpenFileDialog.DismissPopUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.OpenFileDialog的用法示例。


在下文中一共展示了OpenFileDialog.DismissPopUp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestDragDrop

        public void TestDragDrop()
        {
            Trace.WriteLine("TestDragDrop==========================================================");
            var w = this.LaunchNotepad();

            Rectangle treeBounds = this.TreeView.Bounds;

            Trace.WriteLine("OpenFileDialog");
            w.InvokeAsyncMenuItem("openToolStripMenuItem");
            Window openDialog = w.WaitForPopup();
            Trace.WriteLine("Opening '" + TestDir + "UnitTests'");
            openDialog.SendKeystrokes(TestDir + "UnitTests{ENTER}");
            Sleep(1000);

            // Drag/drop from open file dialog into xml notepad client area.
            OpenFileDialog dialogWrapper = new OpenFileDialog(openDialog);

            Point drop = GetDropSpot(openDialog, treeBounds);
            Trace.WriteLine("Drop spot = " + drop.ToString());

            AutomationWrapper item = dialogWrapper.GetFileItem("test1.xml");

            if (item == null)
            {
                // try finding the item using the keyboard.
                throw new Exception("File item not found");
            }

            Rectangle ibounds = item.Bounds;
            Point iloc = new Point(ibounds.Left + 10, ibounds.Top + 10);
            Trace.WriteLine("Dragging from " + iloc.ToString());
            Mouse.MouseDragDrop(iloc, drop, 5, MouseButtons.Left);
            Sleep(1000);
            dialogWrapper.DismissPopUp("{ESC}");

            // need bigger window to test drag/drop
            w.SetWindowSize(800, 600);

            w.InvokeMenuItem("collapseAllToolStripMenuItem");
            w.InvokeMenuItem("expandAllToolStripMenuItem");

            // Test mouse wheel
            AutomationWrapper tree = this.TreeView;
            CheckProperties(tree);

            w.SendKeystrokes("{HOME}");
            Cursor.Position = tree.Bounds.Center();
            Sleep(500); // wait for focus to kick in before sending mouse events.
            Mouse.MouseWheel(-120 * 15); // first one doesn't get thru for some reason!
            Sleep(500);
            Mouse.MouseWheel(120 * 15);
            Sleep(500);

            // Test navigation keys
            w.SendKeystrokes("{HOME}");
            CheckNodeValue("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            w.SendKeystrokes("{END}");
            CheckNodeValue("<!--last comment-->");
            w.SendKeystrokes("{PGUP}{PGDN}{UP}{UP}");
            CheckNodeValue("Name");

            // Get AutomationWrapper to selected node in the tree.
            AutomationWrapper ntv = this.NodeTextView;
            CheckProperties(ntv);
            // mouse down in node text view
            AutomationWrapper node = ntv.GetSelectedChild();
            node = node.Parent.NextSibling; // Office node.
            CheckNodeName(node, "Office");
            Rectangle bounds = node.Bounds;
            Mouse.MouseClick(bounds.Center(), MouseButtons.Left);

            // test edit of node value using AccessibilityObject
            string office = "35/1682";
            node.Value = office;

            // for some odd reason the paste expands the element.
            Sleep(300);
            CheckNodeValue(office);  // confirm via copy operation

            node = tree.GetSelectedChild();
            if (node == null) {
                throw new ApplicationException("Selected node not found");
            }
            CheckProperties(node);
            CheckNodeName(node, "Office");
            node.AddToSelection();

            // test edit of node name using accessibility.
            this.SetNodeName(node, "MyOffice");
            CheckNodeValue("MyOffice");  // confirm via copy operation

            // Test that "right arrow" moves over to the nodeTextView.
            w.SendKeystrokes("{RIGHT}{DOWN}{RIGHT}");
            CheckNodeValue("35/1682");  // confirm via copy operation

            Undo(); // make sure we can undo node name change!
            Undo(); // make sure we can undo node value change (while #text is expanded)!
            this.TreeView.SetFocus();
            CheckNodeValue("Office");

//.........这里部分代码省略.........
开发者ID:dbremner,项目名称:xmlnotepad,代码行数:101,代码来源:UnitTest1.cs

示例2: TestSchemaDialog

        public void TestSchemaDialog()
        {
            Trace.WriteLine("TestSchemaDialog==========================================================");
            var w = LaunchNotepad();

            Sleep(1000);
            Trace.WriteLine("Open Schema Dialog");
            Window schemaDialog = w.OpenDialog("schemasToolStripMenuItem", "FormSchemas");
            schemaDialog.InvokeMenuItem("clearToolStripMenuItem");

            Trace.WriteLine("Add schema via file dialog");
            var button = schemaDialog.FindDescendant("Browse Row 0");
            button.Invoke(); // bring up file open dialog
            Sleep(1000);

            Window fileDialog = schemaDialog.WaitForPopup();
            OpenFileDialog fd = new OpenFileDialog(fileDialog);
            string schema = TestDir + "UnitTests\\emp.xsd";
            fd.FileName = schema;
            fd.DismissPopUp("{ENTER}");

            schemaDialog.SendKeystrokes("^{HOME}+ "); // select first row
            Sleep(300); // just so we can watch it happen
            schemaDialog.SendKeystrokes("^c"); // copy
            string text = Clipboard.GetText();
            if (!text.ToLowerInvariant().Contains("emp.xsd")) {
                throw new ApplicationException("Did not find 'test2.xsd' on the clipboard!");
            }
            Trace.WriteLine("Close schema dialog");
            schemaDialog.DismissPopUp("%O"); // hot key for OK button.

            Trace.WriteLine("Close Microsoft XML Notepad and reload it to ensure schema cache was persisted");
            CloseApp();
            w = LaunchNotepad();

            Sleep(1000);
            schemaDialog = w.OpenDialog("schemasToolStripMenuItem", "FormSchemas");
            Sleep(500);
            w.SendKeystrokes("^{HOME}+ "); // select first row

            Trace.WriteLine("Cut");
            schemaDialog.SendKeystrokes("^x"); // cut
            text = Clipboard.GetText();
            if (!text.ToLowerInvariant().Contains("emp.xsd")) {
                throw new ApplicationException("Did not find 'test2.xsd' on the clipboard!");
            }
            Sleep(300);
            Trace.WriteLine("Paste");
            schemaDialog.SendKeystrokes("^v"); // paste
            Sleep(300);

            Trace.WriteLine("Edit of filename cell.");
            schemaDialog.SendKeystrokes("^{HOME}{RIGHT}{RIGHT}" + schema + "{ENTER}");
            Trace.WriteLine("Undo");
            schemaDialog.SendKeystrokes("^z"); // undo
            Sleep(300);
            Trace.WriteLine("Redo");
            schemaDialog.SendKeystrokes("^y"); // redo
            Sleep(300);
            Trace.WriteLine("Delete");
            schemaDialog.SendKeystrokes("^{HOME}+ {DELETE}"); // delete first row
            Sleep(300);
            Trace.WriteLine("Undo");
            schemaDialog.SendKeystrokes("^z"); // undo
            Sleep(300);
            Trace.WriteLine("Redo");
            schemaDialog.SendKeystrokes("^y"); // redo
            Sleep(300);
            Trace.WriteLine("Undo");
            schemaDialog.SendKeystrokes("^z"); // undo
            Sleep(300);

            Trace.WriteLine("Make sure we commit with some rows to update schema cache!");
            schemaDialog.DismissPopUp("%O"); // hot key for OK button.

            Trace.WriteLine("Now add a duplicate target namespcace.");
            schemaDialog = w.OpenDialog("schemasToolStripMenuItem", "FormSchemas");
            Sleep(500);

            Trace.WriteLine("Add emp2.xsd via paste");
            schema = TestDir + "UnitTests\\emp2.xsd";
            schemaDialog.SendKeystrokes("{DOWN}{RIGHT}{RIGHT}^ "); // select first row
            Clipboard.SetText(schema);
            schemaDialog.SendKeystrokes("^v");
            schemaDialog.SendKeystrokes("^c"); // copy
            text = Clipboard.GetText();
            if (!text.ToLowerInvariant().Contains("emp2.xsd")) {
                throw new ApplicationException("Did not find 'test2.xsd' on the clipboard!");
            }

            Trace.WriteLine("Add duplicate schema via file dialog ");
            Sleep(1000);
            schemaDialog.InvokeAsyncMenuItem("addSchemasToolStripMenuItem");

            fileDialog = schemaDialog.WaitForPopup();
            fd = new OpenFileDialog(fileDialog);
            schema = TestDir + "UnitTests\\emp.xsd";
            fd.FileName = schema;
            fd.DismissPopUp("{ENTER}");

//.........这里部分代码省略.........
开发者ID:dbremner,项目名称:xmlnotepad,代码行数:101,代码来源:UnitTest1.cs


注:本文中的System.Windows.Forms.OpenFileDialog.DismissPopUp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。