public void ShowPane(IPane pane) { if (pane == null) { throw new ArgumentNullException(nameof(pane)); } var wnd = new PaneWindow { Pane = pane }; DockSite.DocumentWindows.Add(wnd); wnd.Activate(); }
public void LoadLayout() { try { if (File.Exists(_layoutFile)) { CultureInfo.InvariantCulture.DoInCulture(() => LayoutSerializer.LoadFromFile(_layoutFile, MainWindow.DockSite)); } if (_settings == null) { return; } var navBar = _settings.GetValue <SettingsStorage>("navBar"); MainWindow.CurrentSources.SelectedIndex = navBar.GetValue <int>("SelectedSource"); MainWindow.CurrentConverters.SelectedIndex = navBar.GetValue <int>("SelectedConverter"); var panes = _settings.GetValue <IEnumerable <SettingsStorage> >("panes").ToArray(); var wnds = MainWindow.DockSite.DocumentWindows.OfType <PaneWindow>().ToArray(); // почему-то после загрузки разметки устанавливается в MainWindow wnds.ForEach(w => w.DataContext = null); var len = wnds.Length.Min(panes.Length); PaneWindow activeWnd = null; for (var i = 0; i < len; i++) { try { var wnd = wnds[i]; wnd.Pane = panes[i].LoadEntire <IPane>(); if (wnd.Pane.IsValid) { if (panes[i].GetValue <bool>("isActive")) { activeWnd = wnd; } } else { wnd.Pane = null; } } catch (Exception ex) { ex.LogError(); } } wnds.Where(w => w.Pane == null).ForEach(w => w.Close()); if (activeWnd != null) { activeWnd.Activate(); } DriveCache.Instance.NewDriveCreated += s => { lock (_timerSync) _needToSave = true; }; DatabaseConnectionCache.Instance.NewConnectionCreated += c => { lock (_timerSync) _needToSave = true; }; } catch (Exception ex) { ex.LogError(); } }