private void _menuItemsSelect_Click(object sender, RoutedEventArgs e) { try { if (Filepath != null) { if (File.Exists(Filepath) || Directory.Exists(Filepath)) { OpeningService.FilesOrFolders(Filepath); return; } } if (Filepath == null || !_metaGrf.FileTable.ContainsFile(Filepath)) { ErrorHandler.HandleException("File path not found."); } else { OpeningService.FilesOrFolders(_metaGrf.FindTkPath(Filepath).FilePath); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
private void _menuItemsSelectInExplorer_Click(object sender, RoutedEventArgs e) { try { if (_itemsResources.SelectedItem != null) { TkPathView rme = (TkPathView)_itemsResources.SelectedItem; OpeningService.FilesOrFolders(new string[] { rme.Path.FilePath }); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
private void _miSelect_Click(object sender, RoutedEventArgs e) { BackupView view = _listView.SelectedItem as BackupView; if (view != null) { if (Directory.Exists(view.DbPath)) { OpeningService.FilesOrFolders(view.DbPath); } else { ErrorHandler.HandleException("Directory not found " + view.DbPath + "."); } } }
public static void SInit <TKey>(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { settings.Style = "TabItemStyledLess"; settings.ContextMenu = new ContextMenu(); var menuItem = new MenuItem { Header = "Select '" + settings.DbData.Filename.Replace("_", "__") + "' in explorer", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("arrowdown.png") } }; menuItem.Click += delegate { if (settings.DbData != null) { try { string path = AllLoaders.DetectPath(settings.DbData); if (path != null) { OpeningService.FilesOrFolders(path); } else { ErrorHandler.HandleException("File not found."); } } catch (Exception err) { ErrorHandler.HandleException(err); } } else { ErrorHandler.HandleException("File not found."); } }; settings.ContextMenu.Items.Add(menuItem); settings.Loaded += _loaded; if (tab == null || gdb == null) { return; } if (gdb.AttributeList.Attributes.Any(p => p.IsSkippable)) { foreach (var attributeIntern in gdb.AttributeList.Attributes.Where(p => p.IsSkippable)) { var attribute = attributeIntern; var menuItemSkippable = new MenuItem { Header = attribute.DisplayName + " [" + attribute.AttributeName + ", " + attribute.Index + "]", Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage("add.png") } }; menuItemSkippable.IsEnabled = false; menuItemSkippable.Click += delegate { gdb.Attached["EntireRewrite"] = true; gdb.Attached[attribute.DisplayName] = gdb.Attached[attribute.DisplayName] != null && !(bool)gdb.Attached[attribute.DisplayName]; gdb.To <TKey>().TabGenerator.OnTabVisualUpdate(tab, settings, gdb); }; settings.ContextMenu.Items.Add(menuItemSkippable); } gdb.Attached.CollectionChanged += delegate { int index = 2; foreach (var attributeIntern in gdb.AttributeList.Attributes.Where(p => p.IsSkippable)) { var attribute = attributeIntern; int index1 = index; settings.ContextMenu.Dispatch(delegate { var menuItemSkippable = (MenuItem)settings.ContextMenu.Items[index1]; menuItemSkippable.IsEnabled = true; bool isSet = gdb.Attached[attribute.DisplayName] == null || (bool)gdb.Attached[attribute.DisplayName]; menuItemSkippable.Icon = new Image { Source = (BitmapSource)ApplicationManager.PreloadResourceImage(isSet ? "delete.png" : "add.png") }; }); index++; } }; } }