protected override void OnDrop(DragEventArgs e) { base.OnDrop(e); if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var newApps = new List <IApplication>(); try { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (var file in files) { switch (Path.GetExtension(file).ToLower()) { case ".gsa": var apps = FileManager.LoadObject <List <IApplication> >(file, false, true); if (apps != null) { newApps.AddRange(apps); } break; case ".exe": Dispatcher.InvokeAsync(() => lstIgnoredApplications.SelectedItem = ApplicationManager.Instance.AddApplication(new IgnoredApp() { IsEnabled = true }, file), DispatcherPriority.Input); break; case ".lnk": WshShell shell = new WshShell(); IWshShortcut link = (IWshShortcut)shell.CreateShortcut(file); if (Path.GetExtension(link.TargetPath).ToLower() == ".exe") { Dispatcher.InvokeAsync(() => lstIgnoredApplications.SelectedItem = ApplicationManager.Instance.AddApplication(new IgnoredApp() { IsEnabled = true }, link.TargetPath), DispatcherPriority.Input); } break; } } } catch (Exception exception) { Common.UIHelper.GetParentWindow(this).ShowModalMessageExternal(exception.GetType().Name, exception.Message); } if (newApps.Count != 0) { Dispatcher.InvokeAsync(() => { ExportImportDialog exportImportDialog = new ExportImportDialog(false, true, newApps, GestureSign.Common.Gestures.GestureManager.Instance.Gestures); exportImportDialog.ShowDialog(); }, System.Windows.Threading.DispatcherPriority.Background); } } e.Handled = true; }
private void ImportActionMenuItem_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog ofdApplications = new Microsoft.Win32.OpenFileDialog() { Filter = LocalizationProvider.Instance.GetTextValue("Action.ApplicationFile") + "|*.gsa", Title = LocalizationProvider.Instance.GetTextValue("Common.Import"), CheckFileExists = true }; if (ofdApplications.ShowDialog().Value) { var newApps = FileManager.LoadObject <List <IApplication> >(ofdApplications.FileName, false, true); if (newApps != null) { ExportImportDialog exportImportDialog = new ExportImportDialog(false, false, newApps, GestureSign.Common.Gestures.GestureManager.Instance.Gestures); exportImportDialog.ShowDialog(); } } }
private void ExportActionMenuItem_Click(object sender, RoutedEventArgs e) { ExportImportDialog exportImportDialog = new ExportImportDialog(true, false, ApplicationManager.Instance.Applications, GestureSign.Common.Gestures.GestureManager.Instance.Gestures); exportImportDialog.ShowDialog(); }
protected override void OnDrop(DragEventArgs e) { base.OnDrop(e); if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var newApps = new List <IApplication>(); var newGestures = GestureManager.Instance.Gestures.ToList(); try { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (var file in files) { switch (Path.GetExtension(file).ToLower()) { case GestureSign.Common.Constants.ActionExtension: var apps = FileManager.LoadObject <List <IApplication> >(file, false, true); if (apps != null) { newApps.AddRange(apps); } break; case ".exe": lstAvailableApplication.SelectedItem = ApplicationManager.Instance.AddApplication(new UserApp(), file); break; case ".lnk": WshShell shell = new WshShell(); IWshShortcut link = (IWshShortcut)shell.CreateShortcut(file); if (Path.GetExtension(link.TargetPath).ToLower() == ".exe") { lstAvailableApplication.SelectedItem = ApplicationManager.Instance.AddApplication(new UserApp(), link.TargetPath); } break; case GestureSign.Common.Constants.ArchivesExtension: { IEnumerable <IApplication> applications; IEnumerable <IGesture> gestures; Archive.LoadFromArchive(file, out applications, out gestures); if (applications != null) { newApps.AddRange(applications); } if (gestures != null) { foreach (var gesture in gestures) { if (newGestures.Find(g => g.Name == gesture.Name) == null) { newGestures.Add(gesture); } } } break; } } } } catch (Exception exception) { UIHelper.GetParentWindow(this).ShowModalMessageExternal(exception.GetType().Name, exception.Message); } if (newApps.Count != 0) { Dispatcher.InvokeAsync(() => { ExportImportDialog exportImportDialog = new ExportImportDialog(false, false, newApps, newGestures); exportImportDialog.ShowDialog(); }, DispatcherPriority.Background); } } e.Handled = true; }