private void button_Add_Click(object sender, EventArgs e) { if (textBox_FileMask.Text.Trim().Length == 0) { MessageBoxHelper.PrepToCenterMessageBoxOnForm(this); MessageBox.Show("The file name mask can't be empty.", "Add file entry", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FileAccessRight fileAccessRight = new FileAccessRight(); fileAccessRight.FileNameMask = textBox_FileMask.Text; fileAccessRight.AccessFlag = uint.Parse(textBox_AccessFlag.Text); if (0 == fileAccessRight.AccessFlag) { fileAccessRight.AccessFlag = (uint)FilterAPI.AccessFlag.LEAST_ACCESS_FLAG; } processFileAccessRightsList.Remove(fileAccessRight.FileNameMask); processFileAccessRightsList.Add(fileAccessRight.FileNameMask, fileAccessRight); InitListView(); }
private void listView_ProcessFileAccessRights_SelectedIndexChanged(object sender, EventArgs e) { if (listView_ProcessFileAccessRights.SelectedItems.Count > 0) { currentFileAccessRight = (FileAccessRight)listView_ProcessFileAccessRights.SelectedItems[0].Tag; textBox_FileMask.Text = currentFileAccessRight.FileNameMask; textBox_AccessFlag.Text = currentFileAccessRight.AccessFlag.ToString(); SetCheckBoxValue(); } }
private void button_Delete_Click(object sender, EventArgs e) { if (listView_ProcessFileAccessRights.SelectedItems.Count == 0) { MessageBoxHelper.PrepToCenterMessageBoxOnForm(this); MessageBox.Show("There are no item selected.", "Delete entry", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FileAccessRight processFileAccessRight = (FileAccessRight)listView_ProcessFileAccessRights.SelectedItems[0].Tag; processFileAccessRightsList.Remove(processFileAccessRight.FileNameMask); InitListView(); }
public ProcessFileAccessRights(ProcessFilterRule filterRule) { InitializeComponent(); StartPosition = FormStartPosition.CenterParent; currentFilterRule = filterRule; string processFileAccessRights = filterRule.FileAccessRights; string[] accessRightList = processFileAccessRights.ToLower().Split(new char[] { ';' }); if (accessRightList.Length > 0) { foreach (string processFileAccessRightStr in accessRightList) { if (processFileAccessRightStr.Trim().Length > 0) { string fileMask = processFileAccessRightStr.Substring(0, processFileAccessRightStr.IndexOf('!')); uint accessFlag = uint.Parse(processFileAccessRightStr.Substring(processFileAccessRightStr.IndexOf('!') + 1)); if (!processFileAccessRightsList.ContainsKey(fileMask)) { FileAccessRight fileAccessRight = new FileAccessRight(); fileAccessRight.FileNameMask = fileMask; fileAccessRight.AccessFlag = accessFlag; processFileAccessRightsList.Add(fileMask, fileAccessRight); currentFileAccessRight = fileAccessRight; } textBox_FileMask.Text = fileMask; textBox_AccessFlag.Text = accessFlag.ToString(); } } } groupBox_ProcessRights.Text = "The file access rights for processes which match " + filterRule.ProcessNameFilterMask; InitListView(); SetCheckBoxValue(); }