Exemple #1
0
        private void LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string            path    = (string)(sender as Control).Tag;
            LogFileViewerForm logForm = new LogFileViewerForm();

            logForm.Show();
            AppContext.Instance.Register(logForm);
            logForm.OpenFile(path);
        }
        public LogFileViewerForm()
        {
            InitializeComponent();

            newViewerToolStripMenuItem.Click += new EventHandler((sender, args) =>
            {
                LogFileViewerForm newForm = new LogFileViewerForm();
                AppContext.Instance.Register(newForm);
                newForm.Show();
            });

            openToolStripMenuItem.Click += new EventHandler((sender, args) => OpenFile());
            exitToolStripMenuItem.Click += new EventHandler((sender, args) => Close());
            infoToolStripMenuItem.Click += new EventHandler((sender, args) => new AboutDialog().ShowDialog(this));
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (args.Length == 0)
            {
                MainForm mainForm = new MainForm();
                mainForm.Show();
                AppContext.Instance.Register(mainForm);
            }
            else
            {
                LogFileViewerForm logForm = new LogFileViewerForm();
                logForm.Show();
                AppContext.Instance.Register(logForm);
                logForm.OpenFile(args[0]);
            }

            Application.Run(AppContext.Instance);
        }
Exemple #4
0
        public MainForm()
        {
            InitializeComponent();

            // Event handler for the start button
            startButton.Click += new EventHandler((object sender, EventArgs args) => StartTest());

            // Remove empty file group rows when possible. The RowLeave event would be better, but
            // it does not permit concurrent modification of the grid.
            fileGroupGrid.Leave += new EventHandler((object sender, EventArgs args) =>
            {
                for (int i = 0; i < fileGroupGrid.RowCount - 1; i++)
                {
                    DataGridViewRow row = fileGroupGrid.Rows[i];
                    if (WinForms.RowIsEmpty(row))
                    {
                        fileGroupGrid.Rows.RemoveAt(i--);
                    }
                }
            });

            // Disable sorting in the file group table
            foreach (DataGridViewColumn column in fileGroupGrid.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            // Add default file groups
            fileGroupGrid.Rows.Add("1000", "256K");
            fileGroupGrid.Rows.Add("100", "2M");
            fileGroupGrid.Rows.Add("10", "400M");

            // Add verification modes
            IDictionary <VerificationMode, string> vModes = new Dictionary <VerificationMode, string>()
            {
                { VerificationMode.NONE, "Nein" },
                { VerificationMode.SIMPLE, "Einfach" },
                { VerificationMode.BOTH, "Doppelt" }
            };

            verifyModeComboBox.DataSource            = new BindingSource(vModes, null);
            verifyModeComboBox.SelectedIndexChanged += new EventHandler(UpdateVerificationModeDescription);
            verifyModeComboBox.SelectedIndex         = 1;
            verifyModeComboBox.DisplayMember         = "Value";
            verifyModeComboBox.ValueMember           = "Key";

            // Enable browsing
            targetDirInput.Browse   += new EventHandler(BrowseForTargetDirectory);
            testFileDirInput.Browse += new EventHandler(BrowseForTargetDirectory);
            logDirInput.Browse      += new EventHandler(BrowseForTargetDirectory);

            // We will use a single instance of the connection dialog to preserve its state
            connectionDialog = new ConnectionDialog();
            nasConnToolStripMenuItem.Click += new EventHandler((sender, args) => ShowConnectionDialog());

            logFileToolStripMenuItem.Click += new EventHandler((sender, args) =>
            {
                LogFileViewerForm logViewer = new LogFileViewerForm();
                AppContext.Instance.Register(logViewer);
                logViewer.Show();
                logViewer.OpenFile();
            });

            infoToolStripMenuItem.Click += new EventHandler((sender, args) => new AboutDialog().ShowDialog(this));

            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Interval = 60000;
            timer.Tick    += new EventHandler((sender, args) => logBox.Log("Heartbeat"));
            timer.Start();
        }
Exemple #5
0
        public void RebuildView(IList <LogFile.Entry> entries, IList <Performance.Group> groups)
        {
            LogFileViewerForm viewer = (LogFileViewerForm)FindForm();

            flowPanel.Controls.Clear();

            foreach (Performance.Group group in groups)
            {
                LogFileSummaryBoxControl box = new LogFileSummaryBoxControl();

                box.Title   = group.FileCount + " x " + Units.FormatSize(group.FileSize);
                box.Details = Units.FormatRate(group.TransmissionRate(true, true));

                box.SetLink("Details", () =>
                {
                    viewer.FileTree.SelectGroup(group);
                    viewer.ShowFileTree();
                });

                if (flowPanel.Controls.Count % 2 == 0)
                {
                    box.BackColor = Color.LightGreen;
                }
                else
                {
                    box.BackColor = Color.LightBlue;
                }

                flowPanel.Controls.Add(box);
            }

            List <LogFile.Entry> generatedFiles;

            generatedFiles = new List <LogFile.Entry>();
            List <LogFile.Entry> verifyOkay, verifyFailed;

            verifyOkay   = new List <LogFile.Entry>();
            verifyFailed = new List <LogFile.Entry>();

            foreach (LogFile.Entry entry in entries)
            {
                if (entry.Tag == LogFile.Tag.VERIFY_OKAY)
                {
                    verifyOkay.Add((LogFile.VerifyFileEntry)entry);
                }
                else if (entry.Tag == LogFile.Tag.VERIFY_FAIL)
                {
                    verifyFailed.Add((LogFile.VerifyFileEntry)entry);
                }
                else if (entry.Tag == LogFile.Tag.GENERATE_FILE_DONE)
                {
                    generatedFiles.Add((LogFile.GenerateFileEntry)entry);
                }
            }

            if (verifyOkay.Count > 0)
            {
                LogFileSummaryBoxControl box = new LogFileSummaryBoxControl();
                box.Title     = verifyOkay.Count + " Datei(en) verifiziert";
                box.Details   = "Der Inhalt von " + verifyOkay.Count + " Datei(en) wurde erfolgreich verifiziert.";
                box.BackColor = Color.LightGreen;

                box.SetLink("Log-Einträge", () =>
                {
                    LogFileViewerForm form = (LogFileViewerForm)FindForm();
                    form.ShowEvents();
                    form.LogFileEvents.ClearSelection();
                    form.LogFileEvents.SelectEvents(verifyOkay);
                });

                flowPanel.Controls.Add(box);
            }

            if (verifyFailed.Count > 0)
            {
                LogFileSummaryBoxControl box = new LogFileSummaryBoxControl();
                box.Title     = verifyFailed.Count + " Datei(en) fehlerhaft";
                box.Details   = "Der Inhalt von " + verifyFailed.Count + " Datei(en) ist fehlerhaft.";
                box.BackColor = Color.Tomato;

                box.SetLink("Log-Einträge", () =>
                {
                    LogFileViewerForm form = (LogFileViewerForm)FindForm();
                    form.ShowEvents();
                    form.LogFileEvents.ClearSelection();
                    form.LogFileEvents.SelectEvents(verifyFailed);
                });

                flowPanel.Controls.Add(box);
            }

            if (generatedFiles.Count > 0)
            {
                LogFileSummaryBoxControl box = new LogFileSummaryBoxControl();
                box.Title     = generatedFiles.Count + " Datei(en) erzeugt";
                box.Details   = generatedFiles.Count + " Datei(en) wurde(n) erfolgreich erzeugt.";
                box.BackColor = Color.LightGreen;

                box.SetLink("Log-Einträge", () =>
                {
                    LogFileViewerForm form = (LogFileViewerForm)FindForm();
                    form.ShowEvents();
                    form.LogFileEvents.ClearSelection();
                    form.LogFileEvents.SelectEvents(generatedFiles);
                });

                flowPanel.Controls.Add(box);
            }
        }