コード例 #1
0
ファイル: ProfilingTests.cs プロジェクト: lioaphy/nodejstools
        private static string SavePerfFile(string saveDirectory, VisualStudioApp app, IntPtr? dialog = null) {
            string destName;
            using (var saveDialog = new SaveDialog(app, AutomationElement.FromHandle(dialog ?? app.WaitForDialog()))) {
                var originalDestName = Path.Combine(saveDirectory, Path.GetFileName(saveDialog.FileName));
                destName = originalDestName;

                while (File.Exists(destName)) {
                    destName = string.Format("{0} {1}{2}",
                        Path.GetFileNameWithoutExtension(originalDestName),
                        Guid.NewGuid(),
                        Path.GetExtension(originalDestName)
                    );
                }

                saveDialog.FileName = destName;
                saveDialog.Save();
            }
            return destName;
        }
コード例 #2
0
ファイル: VisualStudioApp.cs プロジェクト: yepeiwen/PTVS
 public SaveDialog SaveAs()
 {
     return(SaveDialog.FromDte(this));
 }
コード例 #3
0
ファイル: ProfilingTests.cs プロジェクト: wenh123/PTVS
        private IPythonProfileSession LaunchSession(
            PythonVisualStudioApp app,
            Func<IPythonProfileSession> creator
        ) {
            // Ensure the performance window has been opened, which will make
            // the app clean up all sessions when it is disposed.
            app.OpenPythonPerformance();

            IPythonProfileSession session = null;
            var task = Task.Factory.StartNew(() => {
                session = creator();
                // Must fault the task to abort the wait
                throw new Exception();
            });
            var dialog = app.WaitForDialog(task);
            if (dialog != IntPtr.Zero) {
                using (var saveDialog = new SaveDialog(app, AutomationElement.FromHandle(dialog))) {

                    var originalDestName = Path.Combine(SaveDirectory, Path.GetFileName(saveDialog.FileName));
                    var destName = originalDestName;

                    while (File.Exists(destName)) {
                        destName = string.Format("{0} {1}{2}",
                            Path.GetFileNameWithoutExtension(originalDestName),
                            Guid.NewGuid(),
                            Path.GetExtension(originalDestName)
                        );
                    }

                    saveDialog.FileName = destName;
                    saveDialog.Save();
                    try {
                        task.Wait(TimeSpan.FromSeconds(5.0));
                        Assert.Fail("Task did not fault");
                    } catch (AggregateException) {
                    }
                }
            } else {
                // Ensure the exception is observed
                var ex = task.Exception;
            }
            Assert.IsNotNull(session, "Session was not correctly initialized");
            return session;
        }