예제 #1
0
        private ObjectStoreModel SelectObjectStore(IList <ObjectStoreModel> objectStores)
        {
            ObjectStoreModel objectStore = null;

            if (objectStores.Count == 1)
            {
                objectStore = objectStores.First();
            }
            else if (objectStores.Count > 1)
            {
                objectStore = Execution.ExecuteOnUiThread(() =>
                {
                    var window             = new ProfileSelectionView();
                    var selectionViewModel = new ProfileSelectionViewModel();

                    selectionViewModel.Items.Reset(objectStores);
                    window.DataContext = selectionViewModel;

                    var result = window.ShowDialog();
                    if (result == null || result == false)
                    {
                        Shutdown(0);
                    }

                    return(selectionViewModel.Selection.SelectedItem);
                });
            }

            return(objectStore);
        }
예제 #2
0
        private void LoadObjectStore(
            [NotNull] IDataProvider dataProvider,
            [NotNull] IIconResolver iconResolver,
            [NotNull] ObjectStoreModel objectStore)
        {
            if (dataProvider == null)
            {
                throw new ArgumentNullException(nameof(dataProvider));
            }

            if (iconResolver == null)
            {
                throw new ArgumentNullException(nameof(iconResolver));
            }

            if (objectStore == null)
            {
                throw new ArgumentNullException(nameof(objectStore));
            }

            var profile = objectStore as ProfileModel;

            if (profile != null)
            {
                var basePreset = profile.BasedOn;
                if (basePreset != null)
                {
                    basePreset.Load(dataProvider);
                    if (basePreset.IconStore != null)
                    {
                        iconResolver.AddExternalDataSource(basePreset.IconStore);
                    }
                }

                if (profile.IconStore != null)
                {
                    iconResolver.AddExternalDataSource(profile.IconStore);
                }

                profile.Load(dataProvider);
            }
            else
            {
                if (objectStore.IconStore != null)
                {
                    iconResolver.AddExternalDataSource(objectStore.IconStore);
                }

                objectStore.Load(dataProvider);
            }
        }