Exemple #1
0
        private void AfterUpdate(NameAndCount[] collectionDocumentsCount)
        {
            // update documents count

            var nameToCount = collectionDocumentsCount.OrderByDescending(count => count.Count).ToDictionary(i => i.Name, i => i.Count);
            var collections = Collections.OrderByDescending(model => model.Count).ToList();

            Collections = new BindableCollection <CollectionModel>(model => model.Name);
            foreach (var collectionModel in collections)
            {
                Collections.Add(collectionModel);
            }

            foreach (var collectionModel in Collections)
            {
                collectionModel.Count = nameToCount[collectionModel.Name];
            }

            if (initialSelectedDatabaseName != null &&
                (SelectedCollection.Value == null || SelectedCollection.Value.Name != initialSelectedDatabaseName || Collections.Contains(SelectedCollection.Value) == false))
            {
                SelectedCollection.Value = Collections.FirstOrDefault(x => x.Name == initialSelectedDatabaseName);
            }

            if (SelectedCollection.Value == null)
            {
                SelectedCollection.Value = Collections.FirstOrDefault();
            }

            OnPropertyChanged(() => Collections);
        }
 public ChooseServerDialogViewModel(BindableCollection <ServerItemModel> servers)
 {
     this.servers   = servers;
     DisplayName    = "Choose default server:";
     SelectedServer = servers.FirstOrDefault(x => x.IsChecked);
     if (SelectedServer == null)
     {
         SelectedServer = servers.FirstOrDefault();
     }
 }
 public ChooseServerDialogViewModel(BindableCollection<ServerItemModel> servers)
 {
     this.servers = servers;
     this.DisplayName = "Choose default server:";
     this.SelectedServer = servers.FirstOrDefault(x => x.IsChecked);
     if (this.SelectedServer == null)
     {
         this.SelectedServer = servers.FirstOrDefault();
     }
 }
Exemple #4
0
        protected override void LoadState()
        {
            Forename      = (string)TombstoningContainer.GetValue(TombstoningVariables.ClientEditForename);
            Surname       = (string)TombstoningContainer.GetValue(TombstoningVariables.ClientEditSurname);
            Birthdate     = (DateTime?)TombstoningContainer.GetValue(TombstoningVariables.ClientEditBirthdate);
            Longitude     = (double?)TombstoningContainer.GetValue(TombstoningVariables.ClientEditLongitude);
            Latitude      = (double?)TombstoningContainer.GetValue(TombstoningVariables.ClientEditLatitude);
            IsActive      = (bool)TombstoningContainer.GetValue(TombstoningVariables.ClientEditIsActive);
            lastPhotoName = (string)TombstoningContainer.GetValue(TombstoningVariables.ClientEditLastPhotoName);
            Photo         = ImageConverter.ConvertToImage((byte[])TombstoningContainer.GetValue(TombstoningVariables.ClientEditPhoto));

            using (IDataContextWrapper dataContext = _dataContextLocator())
            {
                Group noneGroup = new Group()
                {
                    Id = -1, GroupName = "None"
                };
                GroupsList = new BindableCollection <Group>(dataContext.Table <Group>().OrderBy(g => g.GroupName).ToList());
                GroupsList.Insert(0, noneGroup);

                long id = (long)TombstoningContainer.GetValue(TombstoningVariables.ClientEditGroupId);
                Group = GroupsList.FirstOrDefault(x => x.Id == id) ?? noneGroup;
            }
            PhotoChooserTask photoChooserTask = new PhotoChooserTask();

            photoChooserTask.Completed += getPhotoComplete;
        }
        public EndoscopyViewModel(IEventAggregator events, int sessionId)
        {
            DisplayName = "Nội soi";
            if (App.Current != null)
            {
                _esClinicContext = App.Current.EsClinicContext;
            }
            _events = events;
            _sessionId = sessionId;
          
            Photos = new BindableCollection<TmpPhoto>();

            IsEnabledScopy = true;
            NotifyOfPropertyChange(() => IsEnabledScopy);

            EsTypes = new BindableCollection<EndoscopyType>();
            var esTypes = _esClinicContext.EndoscopyTypes.ToList();
            
            foreach (var esType in esTypes)
            {
                EsTypes.Add(esType);
            }

            Cameras = new BindableCollection<Camera>();
            foreach (var camera in CameraService.AvailableCameras)
            {
                Cameras.Add(camera);
            }

            _selectedCamera = Cameras.FirstOrDefault();
        }
Exemple #6
0
        public ShellViewModel()
        {
            Installations        = new BindableCollection <InstallationViewModel>(FindInstallations());
            SelectedInstallation = Installations.FirstOrDefault();

            SelectInstallationCommand = new RelayCommand <InstallationViewModel>(x => SelectedInstallation = x);
        }
Exemple #7
0
        public void SetCurrentDatabase(UrlParser urlParser)
        {
            var databaseName = urlParser.GetQueryParam("database");

            if (databaseName == null)
            {
                return;
            }
            if (SelectedDatabase.Value != null && SelectedDatabase.Value.Name == databaseName)
            {
                return;
            }
            var database = Databases.FirstOrDefault(x => x.Name == databaseName);

            if (database != null)
            {
                SelectedDatabase.Value = database;
            }
            else
            {
                var databaseModel = new DatabaseModel(databaseName, documentStore.AsyncDatabaseCommands.ForDatabase(databaseName));
                Databases.Add(databaseModel);
                SelectedDatabase.Value = databaseModel;
            }
        }
 bool isInTheList(BindableCollection <ObjectModel> list, ObjectModel obj)
 {
     return(list.FirstOrDefault(x => x.bucketName == obj.bucketName &&
                                x.key == obj.key &&
                                x.displayName == obj.displayName &&
                                x.localPath == obj.localPath) != null);
 }
Exemple #9
0
        public EndoscopyViewModel(IEventAggregator events, int sessionId)
        {
            DisplayName = "Nội soi";
            if (App.Current != null)
            {
                _esClinicContext = App.Current.EsClinicContext;
            }
            _events    = events;
            _sessionId = sessionId;

            Photos = new BindableCollection <TmpPhoto>();

            IsEnabledScopy = true;
            NotifyOfPropertyChange(() => IsEnabledScopy);

            EsTypes = new BindableCollection <EndoscopyType>();
            var esTypes = _esClinicContext.EndoscopyTypes.ToList();

            foreach (var esType in esTypes)
            {
                EsTypes.Add(esType);
            }

            Cameras = new BindableCollection <Camera>();
            foreach (var camera in CameraService.AvailableCameras)
            {
                Cameras.Add(camera);
            }

            _selectedCamera = Cameras.FirstOrDefault();
        }
        public void SetCurrentDatabase(UrlParser urlParser)
        {
            var databaseName = urlParser.GetQueryParam("database");

            if (databaseName == null)
            {
                SelectedDatabase.Value = defaultDatabase[0];
                return;
            }
            if (SelectedDatabase.Value != null && SelectedDatabase.Value.Name == databaseName)
            {
                return;
            }
            var database = Databases.FirstOrDefault(x => x.Name == databaseName);

            if (database != null)
            {
                SelectedDatabase.Value = database;
                return;
            }
            singleTenant = urlParser.GetQueryParam("api-key") != null;
            var databaseModel = new DatabaseModel(databaseName, documentStore);

            Databases.Add(databaseModel);
            SelectedDatabase.Value = databaseModel;
        }
Exemple #11
0
        public ToolboxViewModel()
        {
            DisplayName = "Tools";

            // assign tools to their categories
            var tools      = IoC.GetAll <IEditorTool>();
            var categories = new BindableCollection <ToolCategoryModel>();

            foreach (var tool in tools)
            {
                var matchingCat = categories.FirstOrDefault(cat => cat.Name == tool.ToolCategory);

                if (matchingCat == null)
                {
                    matchingCat      = new ToolCategoryModel();
                    matchingCat.Name = tool.ToolCategory;
                    categories.Add(matchingCat);
                }

                var toolViewModel = new ToolModel(tool);
                matchingCat.Children.Add(toolViewModel);
            }

            Categories = categories;
        }
Exemple #12
0
        public void Handle(DatabaseRegistrationMessage message)
        {
            switch (message.Action)
            {
            case DatabaseRegistrationActions.Updated:
            case DatabaseRegistrationActions.Removed:
                var existing = _databases.FirstOrDefault(
                    x => x.Id == message.Id);

                if (existing != null)
                {
                    _databases.Remove(existing);
                }

                break;
            }

            switch (message.Action)
            {
            case DatabaseRegistrationActions.Added:
            case DatabaseRegistrationActions.Updated:
                _databases.Add(Map(message.Registration));
                break;
            }
        }
Exemple #13
0
        public void SearchClient(ActionExecutionContext context, string phrase)
        {
            var keyArgs = context.EventArgs as KeyEventArgs;

            if (keyArgs != null && keyArgs.Key == Key.Enter)
            {
                _currentSearchClientPhrase = phrase;
                Task.Run(() =>
                {
                    if (phrase != _currentSearchClientPhrase)
                    {
                        return;
                    }

                    if (String.IsNullOrEmpty(phrase))
                    {
                        int id         = SelectedClient != null ? SelectedClient.Id : -1;
                        Clients        = new BindableCollection <Client>(AllClients);
                        SelectedClient = Clients.FirstOrDefault(c => c.Id == id);
                    }
                    else
                    {
                        Clients = new BindableCollection <Client>(AllClients.Where(c => c.FullName.ContainsAny(phrase)));
                    }
                });
            }
        }
Exemple #14
0
        public void SetCurrentDatabase(UrlParser urlParser)
        {
            var databaseName = urlParser.GetQueryParam("database");

            if (databaseName == null)
            {
                defaultDatabase = new[] { new DatabaseModel(DefaultDatabaseName, documentStore.AsyncDatabaseCommands) };
                Databases.Set(defaultDatabase);
                SelectedDatabase.Value = defaultDatabase[0];
                return;
            }
            if (SelectedDatabase.Value != null && SelectedDatabase.Value.Name == databaseName)
            {
                return;
            }
            var database = Databases.FirstOrDefault(x => x.Name == databaseName);

            if (database != null)
            {
                SelectedDatabase.Value = database;
                return;
            }
            singleTenant = urlParser.GetQueryParam("api-key") != null;
            var databaseCommands = databaseName.Equals("default", StringComparison.OrdinalIgnoreCase)
                                                ? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
                                                : documentStore.AsyncDatabaseCommands.ForDatabase(databaseName);
            var databaseModel = new DatabaseModel(databaseName, databaseCommands);

            Databases.Add(databaseModel);
            SelectedDatabase.Value = databaseModel;
        }
Exemple #15
0
		public DatabaseModel(string name, DocumentStore documentStore)
		{
			this.name = name;
			this.documentStore = documentStore;

			Tasks = new BindableCollection<TaskModel>(x => x.Name)
			{
				new ImportTask(),
				new ExportTask(),
				new StartBackupTask(),
				new IndexingTask(),
				new SampleDataTask()
			};

			SelectedTask = new Observable<TaskModel> { Value = Tasks.FirstOrDefault() };
			Statistics = new Observable<DatabaseStatistics>();
			Status = new Observable<string>
			{
				Value = "Offline"
			};

			asyncDatabaseCommands = name.Equals(Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase)
											? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
											: documentStore.AsyncDatabaseCommands.ForDatabase(name);

		    DocumentChanges.Select(c => Unit.Default).Merge(IndexChanges.Select(c => Unit.Default))
		        .SampleResponsive(TimeSpan.FromSeconds(2))
		        .Subscribe(_ => RefreshStatistics(), exception => ApplicationModel.Current.Server.Value.IsConnected.Value = false);

			RefreshStatistics();
		}
Exemple #16
0
        public void ToggleViewed(Episode e)
        {
            e.HasBeenViewed = !e.HasBeenViewed;

            if (e.HasBeenViewed)
            {
                for (var i = 0; i < backlog.Count; i++)
                {
                    if (backlog[i].Episode != e)
                    {
                        continue;
                    }
                    backlog.RemoveAt(i);
                    break;
                }
            }
            else
            {
                var show   = shows.FirstOrDefault(w => w.Name == e.ShowName);
                var season = show.Seasons.FirstOrDefault(w => w.SeasonNumber == e.SeasonNumber);

                backlog.Add(new BacklogItem {
                    Show = show, Episode = e, Season = season
                });
            }
        }
Exemple #17
0
        public DatabaseModel(string name, DocumentStore documentStore)
        {
            this.name          = name;
            this.documentStore = documentStore;

            Tasks = new BindableCollection <TaskModel>(x => x.Name)
            {
                new ImportTask(),
                new ExportTask(),
                new StartBackupTask(),
                new IndexingTask(),
                new SampleDataTask()
            };

            SelectedTask = new Observable <TaskModel> {
                Value = Tasks.FirstOrDefault()
            };
            Statistics = new Observable <DatabaseStatistics>();
            Status     = new Observable <string>
            {
                Value = "Offline"
            };

            asyncDatabaseCommands = name.Equals(Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase)
                                                                                        ? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
                                                                                        : documentStore.AsyncDatabaseCommands.ForDatabase(name);

            DocumentChanges.Select(c => Unit.Default).Merge(IndexChanges.Select(c => Unit.Default))
            .SampleResponsive(TimeSpan.FromSeconds(2))
            .Subscribe(_ => RefreshStatistics(), exception => ApplicationModel.Current.Server.Value.IsConnected.Value = false);

            RefreshStatistics();
        }
Exemple #18
0
        private void Init()
        {
            SourceFields = new BindableCollection <string>
            {
                "_id",
                "Name",
                "Age",
                "IsEnable",
            };

            TargetFields = new BindableCollection <string>
            {
                "_id",
                "Name",
                "IsEnable",
            };

            var mappingSet = new BindableCollection <DocumentToDocumentMap>();

            // Fill from source
            foreach (var sourceField in SourceFields)
            {
                var documentMap = new DocumentToDocumentMap
                {
                    SourceKey        = sourceField,
                    SourceIsReadonly = true
                };

                mappingSet.Add(documentMap);
            }

            // Fill from target
            foreach (var targetField in TargetFields)
            {
                var documentMap = mappingSet.FirstOrDefault(p => p.SourceKey.Equals(targetField, StringComparison.OrdinalIgnoreCase));
                if (documentMap != null)
                {
                    documentMap.TargetKey = targetField;
                }
                else
                {
                    documentMap = new DocumentToDocumentMap
                    {
                        TargetKey = targetField
                    };
                    mappingSet.Add(documentMap);
                }
            }

            foreach (var documentMap in mappingSet)
            {
                if (documentMap.SourceKey != null && documentMap.TargetKey != null)
                {
                    documentMap.Active = true;
                }
            }

            MappingSet = mappingSet;
        }
Exemple #19
0
        public override void LoadModelParameters(string parameters)
        {
            var urlParser = new UrlParser(parameters);

            ExecutionElapsedTime.Value = TimeSpan.Zero;
            GroupByField.Value         = "";
            ValueCalculations.Clear();

            UpdateAvailableIndexes();

            var newIndexName = urlParser.Path.Trim('/');

            if (string.IsNullOrEmpty(newIndexName))
            {
                if (AvailableIndexes.Any())
                {
                    NavigateToIndexReport(AvailableIndexes.FirstOrDefault());
                    return;
                }
            }

            IndexName = newIndexName;

            DatabaseCommands.GetIndexAsync(IndexName)
            .ContinueOnUIThread(task =>
            {
                if (task.IsFaulted || task.Result == null)
                {
                    if (AvailableIndexes.Any())
                    {
                        NavigateToIndexReport(AvailableIndexes.FirstOrDefault());
                    }
                    else
                    {
                        NavigateToIndexesList();
                    }

                    return;
                }

                var fields = task.Result.Fields;

                IndexFields.Match(fields);
                QueryIndexAutoComplete = new QueryIndexAutoComplete(fields, IndexName, FilterDoc);
            }).Catch();
        }
Exemple #20
0
        public RegionViewModel()
        {
            Warehouses = new BindableCollection <Warehouse>(new CompanyEntities().Warehouse.ToList());
            WarehouseSelectedRegion = Warehouses.FirstOrDefault();

            Employees = new BindableCollection <Employee>(new CompanyEntities().Employee.Where(e => e.Position.position1.Equals("Kurier") && e.isActive && e.idWarehouse == WarehouseSelectedRegion.id).ToList());
            EmployeeSelectedRegion = Employees.FirstOrDefault();
        }
Exemple #21
0
        public ParcelAddViewModel()
        {
            ParcelType         = new BindableCollection <TypeOfParcel>(CompanyEntities.TypeOfParcel.ToList());
            ParcelTypeSelected = ParcelType.FirstOrDefault();

            ParcelSendMethod         = new BindableCollection <MethodOfSend>(CompanyEntities.MethodOfSend.ToList());
            ParcelSendMethodSelected = ParcelSendMethod.FirstOrDefault();
        }
Exemple #22
0
 /// <summary>
 ///     Handles the message.
 /// </summary>
 /// <param name="message">The message.</param>
 public void Handle(GameResultUpdated message)
 {
     Execute.OnUIThread(
         () =>
     {
         using (PauseNotify.For(this))
         {
             var hasGame = gameResults.FirstOrDefault(x => x.Id == message.GameResultId);
             if (hasGame != null)
             {
                 var newgame = gameRepository.FirstOrDefault(x => x.Id == message.GameResultId);
                 hasGame.MapFrom(newgame);
                 RefreshStats();
             }
         }
     });
 }
 public CalendarViewModel(ICalendarRepository calendarRepository, IWindowManager windowManager)
 {
     _calendarRepository = calendarRepository;
     _windowManager      = windowManager;
     _fullEntrieList     = _calendarRepository.GetCalendarEntries().ToList();
     CalendarEntries.AddRange(_fullEntrieList);
     SelectedEntrie = _calendarEntries.FirstOrDefault();
 }
 public SeasonsEditingViewModel(Season season)
 {
     CurrentSeason     = season;
     Episodes          = new BindableCollection <Episode>(season.Episodes);
     SelectedEpisode   = Episodes.FirstOrDefault();
     SeasonDescription = season.Description;
     NotifyOfPropertyChange(() => CanSelectEpisode);
 }
Exemple #25
0
 private void AlterMapCollection(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         foreach (var newItem in e.NewItems.OfType <DomainModelService.Map>())
         {
             CreateMapViewModel(newItem);
         }
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         foreach (var oldItem in e.OldItems.OfType <DomainModelService.Map>())
         {
             m_Maps.Remove(m_Maps.Single(m => m.Model == oldItem));
         }
     }
     SelectedMap = m_Maps.FirstOrDefault();
 }
Exemple #26
0
 private void LoadMaps()
 {
     foreach (var map in m_Repository.Maps)
     {
         CreateMapViewModel(map);
     }
     NotifyOfPropertyChange(() => Maps);
     SelectedMap = m_Maps.FirstOrDefault();
 }
Exemple #27
0
        public static void EnableAll(this BindableCollection <ITraceWatcher> traceWatchers)
        {
            var activeTrace = traceWatchers.FirstOrDefault(t => t.IsChecked);

            foreach (var tw in traceWatchers)
            {
                tw.IsEnabled = activeTrace == null || activeTrace.FilterForCurrentSession == tw.FilterForCurrentSession;
            }
        }
        public GenericPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
        {
            LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
            OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);

            SelectedLayerAnimation =
                LayerAnimations.FirstOrDefault(l => l.Name == editorVm.ProposedLayer.LayerAnimation?.Name) ??
                LayerAnimations.First(l => l.Name == "None");
        }
        public GenericPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
        {
            LayerAnimations   = new BindableCollection <ILayerAnimation>(editorVm.LayerAnimations);
            OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);

            SelectedLayerAnimation =
                LayerAnimations.FirstOrDefault(l => l.Name == editorVm.ProposedLayer.LayerAnimation?.Name) ??
                LayerAnimations.First(l => l.Name == "None");
        }
Exemple #30
0
        private void OnConnectionsRemoveEventHandler(Connection connection)
        {
            var toBeRemoved = _connections.FirstOrDefault(b => b.Id == connection.Id);

            if (toBeRemoved != null)
            {
                Connections.Remove(toBeRemoved);
            }
        }
Exemple #31
0
 public WarehouseViewModel()
 {
     companyEntities = new CompanyEntities();
     Warehouse       = new BindableCollection <Warehouse>(companyEntities.Warehouse.ToList());
     Warehouse.Insert(0, new Warehouse()
     {
         code = "Wybierz magazyn"
     });
     WarehouseSelected = Warehouse.FirstOrDefault(w => w.id == Properties.Settings.Default.Warehouse);
 }
        public async void Search(Guid selection)
        {
            using (Busy.GetTicket())
            {
                var items = await UnitOfWork.Search.Simple(SearchText);

                Items = new BindableCollection <StaffingResourceListItem>(items);
                CurrentStaffingResource = Items.FirstOrDefault(r => r.Id == selection) ?? Items.FirstOrDefault();
            }
        }
Exemple #33
0
        private void OnConnectorRemoveAtEventHandler(int pos, Connector connector)
        {
            var toBeRemoved = _symbolVms.FirstOrDefault(b => b.Id == connector.Id);

            if (toBeRemoved != null)
            {
                //Connectors.Remove(toBeRemoved);
                SymbolVms.Remove(toBeRemoved);
            }
        }
Exemple #34
0
        public ShellViewModel(IEnumerable <IAppWidget> widgets, IEventAggregator eventAgg, IWindowManager windowMgr, NowPlayingViewModel nowPlaying, NavigationBarViewModel navBar)
        {
            this.eventAgg   = eventAgg;
            this.nowPlaying = nowPlaying;
            this.navBar     = navBar;
            this.windowMgr  = windowMgr;

            eventAgg.Subscribe(this);
            Widgets = new BindableCollection <IAppWidget>(widgets.OrderBy(x => x.Name));
            ActivateWidget(Widgets.FirstOrDefault(a => a.Name == "Library"));
        }
Exemple #35
0
		public DatabaseModel(string name, IAsyncDatabaseCommands asyncDatabaseCommands)
		{
			Name = name;
			this.asyncDatabaseCommands = asyncDatabaseCommands;

			Tasks = new BindableCollection<TaskModel>(x => x.Name)
			{
				new ImportTask(asyncDatabaseCommands),
				new ExportTask(asyncDatabaseCommands)
			};
			SelectedTask = new Observable<TaskModel> {Value = Tasks.FirstOrDefault()};
			Statistics = new Observable<DatabaseStatistics>();
		}
Exemple #36
0
		public DatabaseModel(string name, DocumentStore documentStore)
		{
			this.name = name;

			Tasks = new BindableCollection<TaskModel>(x => x.Name)
			{
				new ImportTask(),
				new ExportTask(),
				new StartBackupTask(),
			};
			SelectedTask = new Observable<TaskModel> {Value = Tasks.FirstOrDefault()};
			Statistics = new Observable<DatabaseStatistics>();

			asyncDatabaseCommands = name.Equals(DefaultDatabaseName, StringComparison.OrdinalIgnoreCase)
			                             	? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
			                             	: documentStore.AsyncDatabaseCommands.ForDatabase(name);
		}
Exemple #37
0
		public DatabaseModel(string name, DocumentStore documentStore)
		{
			this.name = name;
			this.documentStore = documentStore;

			Tasks = new BindableCollection<TaskModel>(x => x.Name)
			{
				new ImportTask(),
				new ExportTask(),
				new StartBackupTask(),
				new IndexingTask(),
				new SampleDataTask(),
                new CsvImportTask()
			};

			if (name == null || name == Constants.SystemDatabase)
				Tasks.Insert(3, new StartRestoreTask());

			SelectedTask = new Observable<TaskModel> { Value = Tasks.FirstOrDefault() };
			Statistics = new Observable<DatabaseStatistics>();
			Status = new Observable<string>
			{
				Value = "Offline"
			};
			OnPropertyChanged(() => StatusImage);

			asyncDatabaseCommands = name.Equals(Constants.SystemDatabase, StringComparison.OrdinalIgnoreCase)
			                             	? documentStore.AsyncDatabaseCommands.ForDefaultDatabase()
			                             	: documentStore.AsyncDatabaseCommands.ForDatabase(name);

		    DocumentChanges.Select(c => Unit.Default).Merge(IndexChanges.Select(c => Unit.Default))
		        .SampleResponsive(TimeSpan.FromSeconds(2))
		        .Subscribe(_ => RefreshStatistics());

			databaseChanges.ConnectionStatusChanged += (sender, args) =>
			{
				ApplicationModel.Current.Server.Value.SetConnected(((IDatabaseChanges)sender).Connected);
				UpdateStatus();
			};

			RefreshStatistics();
		}
 public void RefreshDevices()
 {
     VideoDevices = new BindableCollection<string>(DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice).Select((device) => device.Name));
     InputName = VideoDevices.FirstOrDefault();
 }
        private void SetupControls()
        {
            var dataModelProps = _layerEditorViewModel.DataModelProps;
            Name = _property + ":";

            // Populate target combobox
            Targets = new BindableCollection<GeneralHelpers.PropertyCollection>
            {
                new GeneralHelpers.PropertyCollection {Display = "None"}
            };
            Targets.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));

            // Populate sources combobox
            Sources = new BindableCollection<GeneralHelpers.PropertyCollection>();
            Sources.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));

            // Preselect according to the model
            SelectedTarget = dataModelProps.FirstOrDefault(p => p.Path == Proposed.GameProperty);
            SelectedSource = dataModelProps.FirstOrDefault(p => p.Path == Proposed.PercentageProperty);
            LayerPropertyType = Proposed.LayerPropertyType;

            // Populate the extra options combobox
            switch (_property)
            {
                case "Width":
                    LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
                    {
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.LeftToRight,
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.RightToLeft
                    };
                    break;
                case "Height":
                    LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
                    {
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Downwards,
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Upwards
                    };
                    break;
                case "Opacity":
                    LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
                    {
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Increase,
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Decrease
                    };
                    break;
            }

            UserSourceIsVisible = LayerPropertyType == LayerPropertyType.PercentageOf;
            SourcesIsVisible = LayerPropertyType == LayerPropertyType.PercentageOfProperty;

            // Set up a default for SelectedTarget if it was null
            if (SelectedTarget.Display == null)
                SelectedTarget = Targets.FirstOrDefault();
            // Set up a default for the extra option if it fell outside the range
            if (!LayerPropertyOptions.Contains(Proposed.LayerPropertyOptions))
                Proposed.LayerPropertyOptions = LayerPropertyOptions.FirstOrDefault();
        }
Exemple #40
0
		private void AfterUpdate(NameAndCount[] collectionDocumentsCount)
		{
            // update documents count

		    var nameToCount = collectionDocumentsCount.OrderByDescending(count => count.Count).ToDictionary(i => i.Name, i => i.Count);
		    var collections = Collections.OrderByDescending(model => model.Count).ToList();
            Collections = new BindableCollection<CollectionModel>(model => model.Name);
		    foreach (var collectionModel in collections)
		    {
		        Collections.Add(collectionModel);
		    }
		    
		    foreach (var collectionModel in Collections)
		    {
		        collectionModel.Count = nameToCount[collectionModel.Name];
		    }

			if (initialSelectedDatabaseName != null &&
				(SelectedCollection.Value == null || SelectedCollection.Value.Name != initialSelectedDatabaseName || Collections.Contains(SelectedCollection.Value) == false))
			{
				SelectedCollection.Value = Collections.FirstOrDefault(x => x.Name == initialSelectedDatabaseName);
			}

			if (SelectedCollection.Value == null)
				SelectedCollection.Value = Collections.FirstOrDefault();

            OnPropertyChanged(() => Collections);
		}