示例#1
0
        // Deletes a single log file or a directory (NYI)
        private void LogBTNDelete_Click(object sender, EventArgs e)
        {
            FileTreeNode fn = (FileTreeNode)logFilesTreeView.SelectedNode;

            DialogResult dr = MessageBox.Show("Do you really want to delete " + fn.Text + "?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (dr == DialogResult.No)
            {
                return;
            }


            if (fn.IsFile)
            {
                FileInfo fi = new FileInfo(fn.Path);

                if (fi.Exists)
                {
                    fi.Delete();
                }
            }
            else
            {
                DirectoryInfo di = new DirectoryInfo(fn.Path);

                if (di.Exists)
                {
                    di.Delete(true);
                }
            }

            logFilesTreeView.Nodes.Remove(logFilesTreeView.SelectedNode);
        }
        public override void OnSetActive()
        {
            if (!first)
            {
                return;
            }

            ToggleControls(false);

            // Figure out where our logs are
            DirectoryInfo LogDir = new DirectoryInfo(Environment.CurrentDirectory + "\\logs");

            // Store the time so we can show an example of the timestamp
            Time = DateTime.Now;
            timestampExampleTextLabel.Text = Time.ToString(timestampFormatTextbox.Text);

            if (LogDir.Exists)
            {
                // Get the network subdirectories
                DirectoryInfo[] LogSubDirs = LogDir.GetDirectories();

                if (LogSubDirs.Length != 0)
                {
                    // For each network, add channel logs and private messages
                    foreach (DirectoryInfo di in LogSubDirs)
                    {
                        FileTreeNode dirNode = new FileTreeNode(false, di.Name + '\\', di.FullName);

                        // Get the channel/pmsg logs
                        FileInfo[] SubFiles = di.GetFiles();

                        foreach (FileInfo file in SubFiles)
                        {
                            FileTreeNode fileNode = new FileTreeNode(true, file.Name, file.FullName);

                            dirNode.Nodes.Add(fileNode);
                        }

                        // Add network node to list
                        logFilesTreeView.Nodes.Add(dirNode);
                    }
                }
                else // Found no network subdirs
                {
                    logFilesTreeView.Nodes.Add(new FileTreeNode(true, "No logs found"));
                }
            }
            else // Found no logs directory
            {
                logFilesTreeView.Nodes.Add(new FileTreeNode(true, "Log directory doesn't exist."));
            }
            first = false;
        }
示例#3
0
        // Updates the controls depending on whether or not a file is selected or not
        private void LogTVLogfiles_AfterSelect(object sender, TreeViewEventArgs e)
        {
            FileTreeNode fn = (FileTreeNode)e.Node;

            if (!fn.IsDummy && fn.IsFile)
            {
                ToggleControls(true);
            }
            else
            {
                ToggleControls(false);
            }
        }
示例#4
0
        public override void OnSetActive()
        {
            if (!first) return;

            ToggleControls(false);

            // Figure out where our logs are
            DirectoryInfo LogDir = new DirectoryInfo(Environment.CurrentDirectory + "\\logs");

            // Store the time so we can show an example of the timestamp
            Time = DateTime.Now;
            timestampExampleTextLabel.Text = Time.ToString(timestampFormatTextbox.Text);

            if (LogDir.Exists)
            {
                // Get the network subdirectories
                DirectoryInfo[] LogSubDirs = LogDir.GetDirectories();

                if (LogSubDirs.Length != 0)
                {
                    // For each network, add channel logs and private messages
                    foreach (DirectoryInfo di in LogSubDirs)
                    {
                        FileTreeNode dirNode = new FileTreeNode(false, di.Name + '\\', di.FullName);

                        // Get the channel/pmsg logs
                        FileInfo[] SubFiles = di.GetFiles();

                        foreach (FileInfo file in SubFiles)
                        {
                            FileTreeNode fileNode = new FileTreeNode(true, file.Name, file.FullName);

                            dirNode.Nodes.Add(fileNode);
                        }

                        // Add network node to list
                        logFilesTreeView.Nodes.Add(dirNode);
                    }
                }
                else // Found no network subdirs
                {
                    logFilesTreeView.Nodes.Add(new FileTreeNode(true, "No logs found"));
                }
            }
            else // Found no logs directory
            {
                logFilesTreeView.Nodes.Add(new FileTreeNode(true, "Log directory doesn't exist."));
            }
            first = false;
        }