Exemplo n.º 1
0
 internal void LoadScenario(string filename)
 {
     try
     {
         if (System.IO.Path.GetExtension(filename).ToLower() == ".scnx")
         {
             ScenarioControl newScenarioControl = new ScenarioControl();
             TestScenario    loadedScenario     = TestScenario.Load(filename);
             newScenarioControl.FillTree(loadedScenario);
             tabbedDocumentControl.Items.Add(System.IO.Path.GetFileNameWithoutExtension(filename), newScenarioControl);
             tabbedDocumentControl.SelectedControl = tabbedDocumentControl.Items[tabbedDocumentControl.Items.Count - 1];
         }
         else if (System.IO.Path.GetExtension(filename).ToLower() == ".qlog")
         {
             LogViewerControl logViewerControl = new LogViewerControl();
             logViewerControl.Filename = filename;
             tabbedDocumentControl.Items.Add("Log - " + System.IO.Path.GetFileNameWithoutExtension(filename), logViewerControl);
             tabbedDocumentControl.SelectedControl = tabbedDocumentControl.Items[tabbedDocumentControl.Items.Count - 1];
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Could not load '" + filename + "'\n" + ex.Message, "Error While Loading");
     }
 }
Exemplo n.º 2
0
        public void TestCtor()
        {
            var source =
                new SingleDataSourceViewModel(
                    new SingleDataSource(_logFileFactory, _scheduler, new DataSource("Foobar")
            {
                Id = DataSourceId.CreateNew()
            }),
                    _actionCenter.Object);

            source.LevelsFilter = LevelFlags.All;

            var control = new LogViewerControl
            {
                DataSource = source
            };

            control.ShowOther.Should().BeTrue();
            control.ShowTrace.Should().BeTrue();
            control.ShowDebug.Should().BeTrue();
            control.ShowInfo.Should().BeTrue();
            control.ShowWarning.Should().BeTrue();
            control.ShowError.Should().BeTrue();
            control.ShowFatal.Should().BeTrue();
        }
Exemplo n.º 3
0
        internal void openToolStripButton_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = openFileDialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                foreach (string filename in openFileDialog.FileNames)
                {
                    try
                    {
                        if (System.IO.Path.GetExtension(filename).ToLower() == ".scnx")
                        {
                            ScenarioControl newScenarioControl = new ScenarioControl();
                            TestScenario    loadedScenario     = TestScenario.Load(filename);
                            newScenarioControl.FillTree(loadedScenario);
                            tabbedDocumentControl.Items.Add(System.IO.Path.GetFileNameWithoutExtension(filename), newScenarioControl);
                            tabbedDocumentControl.SelectedControl = tabbedDocumentControl.Items[tabbedDocumentControl.Items.Count - 1];
                        }
                        else if (System.IO.Path.GetExtension(filename).ToLower() == ".qlog")
                        {
                            LogViewerControl logViewerControl = new LogViewerControl();
                            logViewerControl.Filename = filename;
                            tabbedDocumentControl.Items.Add("Log - " + System.IO.Path.GetFileNameWithoutExtension(filename), logViewerControl);
                            tabbedDocumentControl.SelectedControl = tabbedDocumentControl.Items[tabbedDocumentControl.Items.Count - 1];
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Could not load '" + filename + "'\n" + ex.Message, "Error While Loading");
                    }
                }
            }
        }
Exemplo n.º 4
0
        private string GetLog()
        {
            LogViewerControl.CopyToClipboard();

            var dataObject = Clipboard.GetDataObject();

            if (dataObject == null)
            {
                return(string.Empty);
            }

            return(dataObject.GetData(DataFormats.Text).ToString());
        }
Exemplo n.º 5
0
        protected override void OnLogResultArrived(string logFile)
        {
            if (control != null)
            {
                if (control.InvokeRequired)
                {
                    control.Invoke(new LogResultArrivedCallback(OnLogResultArrived), logFile);
                }
                else if (System.IO.File.Exists(logFile))
                {
                    string title = string.Empty;
                    if (control.currentPlayingScenarioControl != null)
                    {
                        title = "Log - " + control.currentPlayingScenarioControl.TestScenario.RootTestCase.Name;
                    }
                    else
                    {
                        title = "Log - " + System.IO.Path.GetFileNameWithoutExtension(logFile);
                    }

                    foreach (Control c in control.dockManager.tabbedScenarioControl.tabbedDocumentControl.Items)
                    {
                        LogViewerControl lvc = c as LogViewerControl;
                        if (lvc != null)
                        {
                            if (string.Compare(title, control.dockManager.tabbedScenarioControl.tabbedDocumentControl.ItemTitles[lvc]) == 0)
                            {
                                lvc.Filename = logFile;
                                if (Properties.Settings.Default.ShowLogAfter)
                                {
                                    control.dockManager.tabbedScenarioControl.tabbedDocumentControl.SelectedControl = lvc;
                                }

                                return;
                            }
                        }
                    }
                    LogViewerControl logViewerControl = new LogViewerControl();
                    logViewerControl.Filename = logFile;
                    control.dockManager.tabbedScenarioControl.tabbedDocumentControl.Items.Add(title, logViewerControl);
                    if (Properties.Settings.Default.ShowLogAfter)
                    {
                        control.dockManager.tabbedScenarioControl.tabbedDocumentControl.SelectedControl = logViewerControl;
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="parameters">Parameters.</param>
        public LogViewerDocument(Project project, LogListener parameters)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            Project = project;
            View    = new LogViewerControl();
            View.SelectedLogChanged += View_SelectedLogChanged;
            _logNodeManager          = new TreeViewNodeManager(View.LogContentData);
            Parameters = parameters;
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            _settings   = new Mock <IApplicationSettings>();
            _dataSource =
                CreateViewModel(
                    new FileDataSource(_logSourceFactory, _scheduler, new DataSource("Foobar")
            {
                Id = DataSourceId.CreateNew()
            }));
            _control = new LogViewerControl
            {
                DataSource = _dataSource,
                Width      = 1024,
                Height     = 768
            };

            DispatcherExtensions.ExecuteAllEvents();
        }
Exemplo n.º 8
0
 internal void CloseItem(object sender, EventArgs e)
 {
     try
     {
         ScenarioControl currentScenarioControl = tabbedDocumentControl.SelectedControl as ScenarioControl;
         if (currentScenarioControl != null)
         {
             tabbedDocumentControl.Items.Remove(currentScenarioControl);
         }
         else
         {
             LogViewerControl currentLogViewControl = tabbedDocumentControl.SelectedControl as LogViewerControl;
             if (currentLogViewControl != null)
             {
                 tabbedDocumentControl.Items.Remove(currentLogViewControl);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Could not close!\n" + ex.Message, "Error While Closing");
     }
 }
Exemplo n.º 9
0
 private void CopyToClipboard()
 {
     LogViewerControl.CopyToClipboard();
 }
Exemplo n.º 10
0
 public void Clear()
 {
     LogViewerControl.Clear();
 }
Exemplo n.º 11
0
 private void ClearLog_OnClick(object sender, RoutedEventArgs e)
 {
     LogViewerControl.Clear();
 }