private void OnFileNameChanged(object sender, EventArgs e)
        {
            ExcelSelected = false;
            if (excelPathVM.FileNameIsValid)
            {
                string path = excelPathVM.FileName;

                if (File.Exists(path))
                {
                    FileStream fs = null;
                    try
                    {
                        fs = File.Open(path, FileMode.Open, FileAccess.Read);
                    }
                    catch (System.IO.IOException ex)
                    {
                        AccessException(ex);
                    }
                    if (fs != null)
                    {
                        IExcelDataReader reader = null;
                        switch (Path.GetExtension(path))
                        {
                        case ".xls":
                            reader = ExcelReaderFactory.CreateBinaryReader(fs);
                            break;

                        case ".xlsx":
                            reader = ExcelReaderFactory.CreateOpenXmlReader(fs);
                            break;
                        }
                        if (reader != null)
                        {
                            DataSet result = reader.AsDataSet();
                            reader.Close();

                            Layouts.Clear();
                            foreach (DataTable table in result.Tables)
                            {
                                Layouts.Add(table);
                            }
                            ExcelSelected = true;
                        }
                    }
                }
            }

            OnPropertyChanged("ExcelSelected");
        }
        internal void InitializeLayouts()
        {
            Logger.Info("Loading window layouts.");

            Layouts.Clear();

            try
            {
                // Load factory presets.
                string applicationFolder = EditorHelper.GetUserSettingsFolder(ConfigurationUserLevel.None);
                string layoutsFolder     = Path.Combine(applicationFolder, LayoutsFolder, PresetsFolder);
                Layouts.AddRange(Directory.EnumerateFiles(layoutsFolder, LayoutPattern)
                                 .Select(Path.GetFileNameWithoutExtension)
                                 .Select(name => new WindowLayout(name, true)));
            }
            catch (Exception exception)
            {
                Logger.Warn(exception, "Failed to load factory presets.");
            }

            try
            {
                // Load user presets.
                string applicationFolder = EditorHelper.GetUserSettingsFolder(ConfigurationUserLevel.PerUserRoamingAndLocal);
                string layoutsFolder     = Path.Combine(applicationFolder, LayoutsFolder, PresetsFolder);
                Layouts.AddRange(Directory.EnumerateFiles(layoutsFolder, LayoutPattern)
                                 .Select(Path.GetFileNameWithoutExtension)
                                 .Select(name => new WindowLayout(name, false)));
            }
            catch (Exception exception)
            {
                Logger.Warn(exception, "Failed to load user presets.");
            }

            // Add a dummy entry, if no presets are available.
            if (Layouts.Count == 0)
            {
                Layouts.Add(new WindowLayout(DefaultLayout, true));
            }

            // The window layout will be loaded in OnEditorActivated().
            ActiveLayout = null;
        }
 private void UninitializeLayouts()
 {
     Layouts.Clear();
     ActiveLayout = null;
     UpdateWindowLayoutItem();
 }