예제 #1
0
        private void sysWatcher_Created(object sender, FileSystemEventArgs e)
        {
            if (!File.Exists(e.FullPath)) {
                return;
            }

            if (!_extensionList.Any(s => e.FullPath.Contains(s))) {
                return;
            }

            if (_ignoreList.Any(s => e.FullPath.Contains(s))) {
                return;
            }

            try {
                App.Current.Dispatcher.Invoke(delegate {
                    if (File.Exists(e.FullPath)) {

                        if (_warningSound) {
                            GeneralSettings.PlaySound();
                        }

                        var fileInfo = new FileInfo(e.FullPath);
                        var wFunc = new WarningItem(e.FullPath, e.Name, AppSettings.SizeSuffix(fileInfo.Length),
                            fileInfo.CreationTime.ToString("g"), fileInfo.Extension, "Datei", new Uri("/Images/inWatch.File.png", UriKind.RelativeOrAbsolute));

                        AddToWarningList(Path.GetDirectoryName(e.FullPath),
                            DateTime.Now.ToString("g"), fileInfo.Extension, e.FullPath, fileInfo.Name,
                            AppSettings.SizeSuffix(fileInfo.Length), new Uri("/Images/inWatch.File.png", UriKind.RelativeOrAbsolute));
                        lblActiveWarningsCount.Content = lstWarning.Items.Count;

                        if (_warningPopUp && !_autoScan) {
                            var wWin = new WarningWin();
                            wWin.init(wFunc);
                            wWin.ShowDialog();
                        }
                        else if(!_warningPopUp && _autoScan) {

                            var scannedFile = new ScannedFileItem(e.FullPath, e.Name, fileInfo.CreationTime.ToString("g"), AppSettings.SizeSuffix(fileInfo.Length));
                            Scan.scanFile(e.FullPath, scannedFile);
                        }
                        else if (_warningPopUp) {
                            var wWin = new WarningWin();
                            wWin.init(wFunc);
                            wWin.ShowDialog();
                        }
                    }
                });
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "syswatcher_Created()");
            }
        }
예제 #2
0
        public void init(WarningItem _item)
        {
            if(_item != null) {

                Title = "Mögliche Bedrohung!";
                Foreground = Brushes.Red;

                _fileName = _item.DirName;
                _name = _item.FileName;
                _creationDate = _item.CreationDate;
                _fileSize = _item.FileSize;

                _warning.Add(new WarningItem {
                    DirName = _item.DirName,
                    FileName = "Dateiname: " + _item.FileName,
                    CreationDate = "Erstellt: " + _item.CreationDate,
                    Extension = "Typ: " + _item.Extension,
                    FileSize = "Größe: " + _item.FileSize
                });
                lstWarningItem.ItemsSource = _warning;
            }
        }
예제 #3
0
        private void StartWatch_EventArrived(object sender, EventArrivedEventArgs e)
        {
            var procName = e.NewEvent.Properties["ProcessName"].Value.ToString();

            if (!_procList.Any(s => procName.Contains(s))) {
                return;
            }
            else {

                if (_warningSound) {
                    GeneralSettings.PlaySound();
                }

                var procID = e.NewEvent.Properties["ProcessID"].Value.ToString();
                var uri = new Uri("/Images/inWatch.Prozess.png", UriKind.RelativeOrAbsolute);
                _warningList.Add(new WarningItem {
                    FileName = procName,
                    DirName = procID,
                    CreationDate = "Prozess Gestartet",
                    StatusImage = uri
                });

                var wFunc = new WarningItem(procName, procID, "Process", uri);
                var wWin = new WarningWin();
                wWin.init(wFunc);
                wWin.ShowDialog();
            }
        }