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


C# WindowsAppFriend.Type方法代码示例

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


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

示例1: TestInitialize

 public void TestInitialize()
 {
     app = new WindowsAppFriend(Process.Start("Target.exe"));
     WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
     dynamic main = app.Type<Application>().Current.MainWindow;
     dataGrid = new WPFDataGrid(app.Type<WPFDataGridTest>().InitDataGrid(main._grid));
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:7,代码来源:WPFDataGridTest.cs.cs

示例2: WinForms

        public void WinForms()
        {
            var app = new WindowsAppFriend(Process.Start("WinForms.exe"));
            var mainForm = app.Type().System.Windows.Forms.Application.OpenForms[0];

            //WinFormsの場合は変数名で取りましょう。
            var _buttonX = new FormsButton(mainForm._buttonX);
            _buttonX.EmulateClick();

            //ポップアップメニューも変数からとる
            var _toolStripMenuItemA = new FormsToolStripItem(mainForm._toolStripMenuItemA);
            _toolStripMenuItemA.EmulateClick();

            //とは言え、取れないときも
            //そんなときは工夫する
            WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
            var button名無し = new FormsButton(app.Type().Tips.ChildControl.Get名無し(mainForm));
            button名無し.EmulateClick();

            //メニューアイテムも上位ライブラリ使えばインデックスとかテキストから取れたり
            var menu = new FormsToolStrip(mainForm._contextMenuStrip);
            var b = menu.FindItem("B");
            b.EmulateClick();

            Process.GetProcessById(app.ProcessId).Kill();
        }
开发者ID:Ishikawa-Tatsuya,项目名称:AsiyanAutomationAlliance,代码行数:26,代码来源:ChildControl.cs

示例3: TestInitialize

 public void TestInitialize()
 {
     _app = new WindowsAppFriend(Process.Start("Target.exe"));
     WindowsAppExpander.LoadAssembly(_app, GetType().Assembly);
     dynamic main = _app.Type<Application>().Current.MainWindow;
     _ctrl = _app.Type<WPFListViewTest>().Init(main._grid);
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:7,代码来源:WPFListViewTest.cs

示例4: ResetConnection

 void ResetConnection()
 {
     int id = _app.ProcessId;
     _app.Dispose();
     _app = new WindowsAppFriend(Process.GetProcessById(id));
     dynamic main = _app.Type<Application>().Current.MainWindow;
     _ctrl = _app.Type<WPFListViewTest>().Init(main._grid);
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:8,代码来源:WPFListViewTest.cs

示例5: TestInitialize

 public void TestInitialize() {
     app = new WindowsAppFriend(Process.Start("Target.exe"));
     WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
     win = app.Type(typeof(Application)).Current.MainWindow;
     dynamic grid = win._grid;
     control = app.Type<WPFContextMenuTestControl>()();
     grid.Children.Add(control);
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:8,代码来源:WPFContextMenuTest.cs

示例6: TestInitialize

 public void TestInitialize()
 {
     app = new WindowsAppFriend(Process.Start("Target.exe"));
     dynamic win = app.Type<Application>().Current.MainWindow;
     dynamic grid = win._grid;
     target = app.Type<ListBox>()();
     grid.Children.Add(target);
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:8,代码来源:WPFControlBaseTest.cs

示例7: TestInitialize

 public void TestInitialize()
 {
     _app = new WindowsAppFriend(Process.Start("Target.exe"));
     WindowsAppExpander.LoadAssembly(_app, GetType().Assembly);
     dynamic main = _app.Type<Application>().Current.MainWindow;
     dynamic checkBox = _app.Type<CheckBox>()();
     main._grid.Children.Add(checkBox);
     _toggle = new WPFToggleButton(checkBox);
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:9,代码来源:WPFToggleButtonTest.cs

示例8: Test

        public void Test()
        {
            //アタッチ
            WindowsAppFriend app = new WindowsAppFriend(vsProcess);

            //DLLインジェクション
            WindowsAppExpander.LoadAssembly(app, GetType().Assembly);

            //Microsoft.VisualStudio.Shell.Package.GetGlobalServiceの呼び出し
            var dteType = app.Type(GetType()).DTEType;
            AppVar obj = app.Type().Microsoft.VisualStudio.Shell.Package.GetGlobalService(dteType);

            //注目!
            //インターフェイスでプロキシが作成できる!
            var dte = obj.Pin<DTE2>();
            var solution = dte.Solution;

            //ソリューション作成
            solution.Create(SolutionDir, "Test.sln");
            string solutionPath = Path.Combine(SolutionDir, "Test.sln");
            solution.SaveAs(solutionPath);

            //プロジェクト追加
            solution.AddFromTemplate(
                @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1041\WPFApplication\csWPFApplication.vstemplate",
                Path.Combine(SolutionDir, "WPF"), "WPF", true);

            //保存
            solution.SaveAs(solutionPath);

            //閉じる
            solution.Close();

            //再度開く
            solution.Open(solutionPath);

            //クリーン→ビルド
            solution.SolutionBuild.Clean(true);
            solution.SolutionBuild.Build(true);

            //デバッグ
            solution.SolutionBuild.Debug();

            //デバッグ対象プロセスを操作
            var debProcess = System.Diagnostics.Process.GetProcessById(dte.Debugger.DebuggedProcesses.Item(1).ProcessID);
            using (var debApp = new WindowsAppFriend(debProcess))
            {
                debApp.Type().System.Windows.Application.Current.MainWindow.Close(new Async());
            }

            //編集モードに戻るまで待つ
            while (dte.Debugger.CurrentMode != dbgDebugMode.dbgDesignMode)
            {
                System.Threading.Thread.Sleep(10);
            }
        }
开发者ID:Ishikawa-Tatsuya,项目名称:Sample_VS_DTE,代码行数:56,代码来源:Demo.cs

示例9: TestInitialize

 public void TestInitialize() {
     app = new WindowsAppFriend(Process.Start("Target.exe"));
     WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
     dynamic win = app.Type(typeof(Application)).Current.MainWindow;
     dynamic grid = win._grid;
     dynamic target = app.Type<ListBox>()();
     grid.Children.Add(target);
     target.ItemsSource = Enumerable.Range(0, 100).Select(i => "value " + i).ToArray();
     listBox = new WPFListBox(target);
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:10,代码来源:WPFListBoxTest.cs

示例10: TestInitialize

 public void TestInitialize()
 {
     app = new WindowsAppFriend(Process.Start("Target.exe"));
     WindowsAppExpander.LoadAssembly(app, GetType().Assembly);
     dynamic win = app.Type(typeof(Application)).Current.MainWindow;
     dynamic grid = win._grid;
     dynamic target = app.Type<Expander>()();
     grid.Children.Add(target);
     expander = new WPFExpander(target);
     window = new WindowControl(win);
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:11,代码来源:WPFExpanderTest.cs

示例11: SetUp

        public void SetUp()
        {
            _app = new WindowsAppFriend(Process.Start("Target.exe"));
            _mainWindow = WindowControl.FromZTop(_app);

            dynamic win = _app.Type<Application>().Current.MainWindow;
            dynamic grid = win._grid;
            _target = _app.Type<ProgressBar>()();
            grid.Children.Add(_target);

            WindowsAppExpander.LoadAssemblyFromFile(_app, GetType().Assembly.Location);
        }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:12,代码来源:WPFProgressBarTest.cs

示例12: WinForms

        public void WinForms()
        {
            var app = new WindowsAppFriend(Process.Start("WinForms.exe"));

            //System.Windows.Forms.Application.OpenForms
            var form = app.Type().System.Windows.Forms.Application.OpenForms[0];
            form.Text = "取れたよ";

            //複数個開いている場合
            {
                var form2 = app.Type().System.Windows.Forms.Form();
                form2.Text = "2";
                form2.Show();
            }

            //実はforeachできます。
            //Linqは無理ですけどね。
            foreach (var f in app.Type().System.Windows.Forms.Application.OpenForms)
            {
                string title = f.Text;
                if (title == "2")
                {
                    f.Text = "これも取れた";
                    break;
                }
            }

            //WindowControlの検索関数を使ってみる
            var main = WindowControl.IdentifyFromTypeFullName(app, "WinForms.MainForm");
            main.Dynamic().Text = "ほらね。";

            var second = WindowControl.IdentifyFromWindowText(app, "これも取れた");
            second.Dynamic().Text = "バッチリ。";

            //WaitFor
            //取れるまで待つ
            Task.Factory.StartNew(() =>
            {
                Thread.Sleep(10000);
                var form3 = app.Type().System.Windows.Forms.Form();
                form3.Text = "3";
                form3.Show();
            });
            var third = WindowControl.WaitForIdentifyFromWindowText(app, "3");

            //Get
            //複数あった場合、複数とれる
            var many = WindowControl.GetFromTypeFullName(app, "System.Windows.Forms.Form");
            Assert.AreEqual(2, many.Length);

            Process.GetProcessById(app.ProcessId).Kill();
        }
开发者ID:Ishikawa-Tatsuya,项目名称:AsiyanAutomationAlliance,代码行数:52,代码来源:TopLevelWindow.cs

示例13: WinForms

        public void WinForms()
        {
            var app = new WindowsAppFriend(Process.Start("WinForms.exe"));
            var form = app.Type().System.Windows.Forms.Application.OpenForms[0];
            WindowsAppExpander.LoadAssembly(app, GetType().Assembly);

            var _grid = form._grid;
            _grid.CurrentCell = _grid[0, 0];
            app.Type(GetType()).Edit(_grid, "abc");

            var wrap = new FormsDataGridView(_grid);
            wrap.EmulateChangeCellText(0, 1, "xyz");

            Process.GetProcessById(app.ProcessId).Kill();
        }
开发者ID:Ishikawa-Tatsuya,项目名称:AsiyanAutomationAlliance,代码行数:15,代码来源:弱いコントロール.cs

示例14: Wpf

        public void Wpf()
        {
            var app = new WindowsAppFriend(Process.Start("Wpf.exe"));
            AppVar window = app.Type().System.Windows.Application.Current.MainWindow;
            var logicalTree = window.LogicalTree();
            var buttonModal = new WPFButtonBase(logicalTree.ByBinding("CommandModal").Single());
            var buttonModeless = new WPFButtonBase(logicalTree.ByBinding("CommandModeless").Single());

            //モーダレスは通常はそのままでOK
            buttonModeless.EmulateClick();
            var next = app.Type().System.Windows.Application.Current.Windows[1];
            next.Title = "aaa";

            //でもたまに変なことしているやつがいれば注意
            //まあ、こっち使った方が無難
            var nextW = WindowControl.WaitForIdentifyFromWindowText(app, "aaa");
            nextW.Dynamic().Close();

            //モーダルは要注意
            var current = new WindowControl(window);

            {
                var a = new Async();
                buttonModal.EmulateClick(a);
                var modal = current.WaitForNextModal();
                modal.Dynamic().Close();
                a.WaitForCompletion();
            }

            //連続で出るやつはもっと注意
            var buttonModalSequential = new WPFButtonBase(logicalTree.ByBinding("CommandModalSequential").Single());
            {
                var a = new Async();
                buttonModalSequential.EmulateClick(a);

                var modal1 = current.WaitForNextModal();
                modal1.Dynamic().Close();
                modal1.WaitForDestroy();

                var modal2 = current.WaitForNextModal();
                modal2.Dynamic().Close();
                modal2.WaitForDestroy();

                a.WaitForCompletion();
            }

            Process.GetProcessById(app.ProcessId).Kill();
        }
开发者ID:Ishikawa-Tatsuya,项目名称:AsiyanAutomationAlliance,代码行数:48,代码来源:画面遷移.cs

示例15: WPF

        public void WPF()
        {
            var app = new WindowsAppFriend(Process.Start("Wpf.exe"));
            var window = app.Type().System.Windows.Application.Current.MainWindow;

            //ガタガタ言わずにx:Name使えばいいじゃん。
            var _textBox = new WPFTextBox(window._textBox);
            _textBox.EmulateChangeText("x:Name最高!");

            //嫌って言う人いるから頑張ったよ。
            AppVar windowAppVar = window;
            var logicalTree = windowAppVar.LogicalTree();
            var textBox = new WPFTextBox(logicalTree.ByBinding("Memo").ByType<System.Windows.Controls.TextBox>().Single());
            var textBlock = new WPFTextBlock(logicalTree.ByBinding("Memo").ByType<System.Windows.Controls.TextBlock>().Single());
            var buttonModal = new WPFButtonBase(logicalTree.ByBinding("CommandModal").Single());
            var buttonModalSequential = new WPFButtonBase(logicalTree.ByBinding("CommandModalSequential").Single());
            var buttonModeless = new WPFButtonBase(logicalTree.ByBinding("CommandModeless").Single());
            var listBox = new WPFListBox(logicalTree.ByBinding("Persons").Single());

            //VisualTreeにしか現れない要素は気を付けて
            var item = listBox.GetItem(20);
            var itemText = new WPFTextBlock(item.VisualTree().ByBinding("Name").Single());

            //これでもダメな場合は工夫してね!

            Process.GetProcessById(app.ProcessId).Kill();
        }
开发者ID:Ishikawa-Tatsuya,项目名称:AsiyanAutomationAlliance,代码行数:27,代码来源:ChildControl.cs


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