Exemple #1
0
        void ShowCore(Guid?guid, Window owner)
        {
            currentContextVM = new ContextVM {
                TreeViewNodeTextElementProvider = treeViewNodeTextElementProvider,
            };

            var allVMs = CreateSettingsPages();

            Debug.Assert(allVMs.Any(a => a.Page.Guid == rootGuid));
            var rootVM = CreateRootVM(allVMs);

            if (rootVM.Children.Count == 0)
            {
                return;
            }

            currentContextVM.TreeView = CreateTreeView(rootVM);

            if (guid == null)
            {
                guid = lastSelectedGuid;
            }
            var selectedItem = (guid != null ? allVMs.FirstOrDefault(a => a.Page.Guid == guid.Value) : null) ?? rootVM.Children.FirstOrDefault();

            if (selectedItem != null)
            {
                currentContextVM.TreeView.SelectItems(new[] { selectedItem });
            }

            var dlg = new AppSettingsDlg();

            dlg.treeViewContentPresenter.Content = currentContextVM.TreeView.UIObject;
            dlg.Owner = owner ?? appWindow.MainWindow;
            bool saveSettings = dlg.ShowDialog() == true;

            lastSelectedGuid = (currentContextVM.TreeView.SelectedItem as AppSettingsPageVM)?.Page.Guid;
            Debug.Assert(lastSelectedGuid != null);

            var appRefreshSettings = new AppRefreshSettings();

            foreach (var vm in allVMs)
            {
                vm.Page.OnClosed(saveSettings, appRefreshSettings);
            }
            if (saveSettings)
            {
                foreach (var listener in appSettingsModifiedListeners)
                {
                    listener.Value.OnSettingsModified(appRefreshSettings);
                }
            }
        }
Exemple #2
0
 public AppSettingsPageVM(IAppSettingsPage page, ContextVM context)
 {
     if (page == null)
     {
         throw new ArgumentNullException(nameof(page));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     Page         = page;
     Children     = new List <AppSettingsPageVM>();
     this.context = context;
 }
 public ShowAppSettingsDialog(IClassificationFormatMap classificationFormatMap, ITextElementProvider textElementProvider, ITreeViewService treeViewService, ITreeViewNodeTextElementProvider treeViewNodeTextElementProvider, Lazy <IAppSettingsPageContainer, IAppSettingsPageContainerMetadata>[] appSettingsPageContainers, Lazy <IAppSettingsPageProvider>[] appSettingsPageProviders, Lazy <IAppSettingsModifiedListener, IAppSettingsModifiedListenerMetadata>[] appSettingsModifiedListeners)
 {
     this.classificationFormatMap      = classificationFormatMap;
     this.textElementProvider          = textElementProvider;
     this.treeViewService              = treeViewService;
     this.appSettingsPageContainers    = appSettingsPageContainers;
     this.appSettingsPageProviders     = appSettingsPageProviders;
     this.appSettingsModifiedListeners = appSettingsModifiedListeners;
     currentContextVM = new ContextVM {
         TreeViewNodeTextElementProvider = treeViewNodeTextElementProvider,
         SearchMatcher = new SearchMatcher(),
     };
     currentContextVM.SearchMatcher.SetSearchText(SearchText);
     converterVersion = ContentConverterProperties.DefaultContentConverterVersion + 1;
 }
Exemple #4
0
 void Show2(Guid?guid, Window owner)
 {
     Debug.Assert(!showingDialog);
     if (showingDialog)
     {
         return;
     }
     try {
         showingDialog = true;
         ShowCore(guid, owner);
     }
     finally {
         currentContextVM?.TreeView?.Dispose();
         currentContextVM = null;
         showingDialog    = false;
     }
 }
        static AppSettingsPageVM TryCreate(object obj, IAppSettingsPageContainerMetadata md, ContextVM context)
        {
            Guid?guid = md.Guid == null ? null : TryParseGuid(md.Guid);

            Debug.Assert(guid != null, "Invalid GUID");
            if (guid == null)
            {
                return(null);
            }

            Guid?parentGuid = md.ParentGuid == null ? rootGuid : TryParseGuid(md.ParentGuid);

            Debug.Assert(parentGuid != null, "Invalid Parent GUID");
            if (parentGuid == null)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(md.Title))
            {
                return(null);
            }

            var title = ResourceHelper.GetString(obj, md.Title);
            var icon  = ImageReferenceHelper.GetImageReference(obj, md.Icon) ?? ImageReference.None;

            return(new AppSettingsPageVM(new AppSettingsPageContainer(title, md.Order, guid.Value, parentGuid.Value, icon), context));
        }