public MainWindow(IKernel ioc) { this.Logger = ioc.Get <ILog>(); Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; //if (!Directory.Exists(ConfigurationManager.AppSettings["graphvizPath"])) //{ // var error = string.Format("Could not find the given GraphViz directory: '{0}'", ConfigurationManager.AppSettings["graphvizPath"]); // this.Logger.Fatal(error); // var messageError = string.Format("{0}.{1}{2} Check the path on this config file: '{3}.conf'", error, Environment.NewLine, Environment.NewLine, Assembly.GetEntryAssembly().Location); // MessageBox.Show(messageError, "Fatal Error", MessageBoxButton.OK, MessageBoxImage.Error); // Application.Current.Shutdown(); //} //GraphVizPathSelector graphVizPathSelectorUserControl = null; if (string.IsNullOrWhiteSpace(Properties.Settings.Default.graphvizPath) || !Directory.Exists(Properties.Settings.Default.graphvizPath)) { this.ShowGraphVizPathSelector(); } else { try { GraphVizHelper.TryGraphvizPath(Properties.Settings.Default.graphvizPath); } catch (Exception) { this.ShowGraphVizPathSelector(); } } if (this.GraphVizPathSelectorUserControl != null && ((GraphVizPathSelectorViewModel)this.GraphVizPathSelectorUserControl.DataContext).CloseApplication) { Application.Current.Shutdown(); } this.DataContext = new MainWindowViewModel(ioc); this.InitializeComponent(); }
private void ExecuteSetPath(object obj) { using (var fbd = new FolderBrowserDialog()) { fbd.ShowNewFolderButton = false; DialogResult result = fbd.ShowDialog(); if (result == DialogResult.OK && Directory.Exists(fbd.SelectedPath)) { try { GraphVizHelper.TryGraphvizPath(fbd.SelectedPath); this.GraphVizPath = fbd.SelectedPath; ((Window)obj).Close(); } catch (Exception) { this.ErrorMessage = string.Format(@"The path '{0}' is not a valid Graphviz path. Remember to select the 'bin' directory (i.g. 'C:\Program Files (x86)\Graphviz2.38\bin')", fbd.SelectedPath); } } } }