protected override void Enable () { ItemsAvailableEventArgs eventArgs = new ItemsAvailableEventArgs (); lock(remminaItemList) { String remminaconfdir = Path.Combine (Environment.GetEnvironmentVariable ("HOME"), ".remmina"); FileSystemWatcher watcher = new FileSystemWatcher (remminaconfdir, "*.*"); watcher.Renamed += new RenamedEventHandler (FileCreated); watcher.Deleted += new FileSystemEventHandler (FileDeleted); watcher.EnableRaisingEvents = true; IEnumerable<String> allfiles = Directory.GetFiles (remminaconfdir).Where (file => file.EndsWith (".remmina")); foreach (String remminaprefpath in allfiles) { Console.WriteLine (remminaprefpath); String itemname = ParseRemminaItem (remminaprefpath); if (itemname == null) return; remminaItemList [itemname] = new RemminaItem(itemname, remminaprefpath); } eventArgs.newItems = remminaItemList.Values; } RaiseItemsAvailable (eventArgs); }
private void FileCreated(object sender, RenamedEventArgs args) { Console.WriteLine ("add new item {0}", args.FullPath); if(!Connected) return; String remminapref = args.FullPath; String itemname = ParseRemminaItem (remminapref); if (remminaItemList.ContainsKey (itemname)) return; RemminaItem item = new RemminaItem (itemname, remminapref); RaiseItemsAvailable (new ItemsAvailableEventArgs () { newItems = new Item[]{item}}); }